diff options
| -rw-r--r-- | rpc/block_svc_routines.c | 12 | ||||
| -rw-r--r-- | rpc/glfs-operations.c | 72 | ||||
| -rw-r--r-- | rpc/glfs-operations.h | 3 | ||||
| -rw-r--r-- | utils/common.h | 4 | ||||
| -rw-r--r-- | utils/utils.h | 2 | 
5 files changed, 76 insertions, 17 deletions
diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c index 7d7080c..ca2fef6 100644 --- a/rpc/block_svc_routines.c +++ b/rpc/block_svc_routines.c @@ -388,9 +388,9 @@ glusterBlockCleanUp(struct glfs *glfs, char *blockname,        LOG("mgmt", GB_LOG_ERROR, "%s volume: %s host: %s",            FAILED_DELETING_FILE, info->volume, "localhost");      } -    ret = glfs_unlink(glfs, blockname); -    if (ret && errno != ENOENT) { -      LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_unlink: failed"); +    ret = glusterBlockDeleteMetaLockFile(glfs, info->volume, blockname); +    if (ret) { +      LOG("mgmt", GB_LOG_ERROR, "%s", "glusterBlockDeleteMetaLockFile: failed");        goto out;      }    } @@ -554,9 +554,9 @@ block_create_1_svc(blockCreate *blk, struct svc_req *rqstp)      goto out;    } -  if (asprintf(&backstore, "%s %s %s %zu %s@%s/%s %s", TARGETCLI_GLFS, +  if (asprintf(&backstore, "%s %s %s %zu %s@%s%s/%s %s", TARGETCLI_GLFS,                 CREATE, blk->block_name, blk->size, blk->volume, -               blk->volfileserver, blk->gbid, blk->gbid) == -1) { +               blk->volfileserver, GB_STOREDIR, blk->gbid, blk->gbid) == -1) {      reply->exit = -1;      goto out;    } @@ -754,7 +754,7 @@ block_list_cli_1_svc(blockListCli *blk, struct svc_req *rqstp)    GB_METALOCK_OR_GOTO(lkfd, blk->volume, ret, out); -  tgmfd = glfs_opendir (glfs, "/block-meta"); +  tgmfd = glfs_opendir (glfs, GB_METADIR);    if (!tgmfd) {      LOG("mgmt", GB_LOG_ERROR, "%s", "glusterBlockVolumeInit failed");      goto out; diff --git a/rpc/glfs-operations.c b/rpc/glfs-operations.c index 0e3787c..4a7e081 100644 --- a/rpc/glfs-operations.c +++ b/rpc/glfs-operations.c @@ -12,9 +12,6 @@  # include "common.h"  # include "glfs-operations.h" -# define  METADIR     "/block-meta" -# define  TXLOCKFILE  "meta.lock" -  struct glfs * @@ -67,9 +64,23 @@ glusterBlockCreateEntry(struct glfs *glfs,                          char *gbid)  {    struct glfs_fd *tgfd; -  int ret = -1; +  int ret; +  ret = glfs_mkdir (glfs, GB_STOREDIR, 0); +  if (ret && errno != EEXIST) { +    LOG("gfapi", GB_LOG_ERROR, "glfs_mkdir(%s) on volume %s failed[%s]", +        GB_STOREDIR, blk->volume, strerror(errno)); +    goto out; +  } + +  ret = glfs_chdir (glfs, GB_STOREDIR); +  if (ret) { +    LOG("gfapi", GB_LOG_ERROR, "glfs_chdir(%s) on volume %s failed[%s]", +        GB_STOREDIR, blk->volume, strerror(errno)); +    goto out; +  } +    tgfd = glfs_creat(glfs, gbid,                      O_WRONLY | O_CREAT | O_EXCL,                      S_IRUSR | S_IWUSR); @@ -103,12 +114,20 @@ glusterBlockDeleteEntry(struct glfs *glfs, char *volume, char *gbid)    int ret; +  ret = glfs_chdir (glfs, GB_STOREDIR); +  if (ret) { +    LOG("gfapi", GB_LOG_ERROR, "glfs_chdir(%s) on volume %s failed[%s]", +        GB_STOREDIR, volume, strerror(errno)); +    goto out; +  } +    ret = glfs_unlink(glfs, gbid);    if (ret) {      LOG("gfapi", GB_LOG_ERROR, "glfs_unlink(%s) on volume %s failed[%s]",          gbid, volume, strerror(errno));    } + out:    return ret;  } @@ -120,24 +139,24 @@ glusterBlockCreateMetaLockFile(struct glfs *glfs, char *volume)    int ret; -  ret = glfs_mkdir (glfs, METADIR, 0); +  ret = glfs_mkdir (glfs, GB_METADIR, 0);    if (ret && errno != EEXIST) {      LOG("gfapi", GB_LOG_ERROR, "glfs_mkdir(%s) on volume %s failed[%s]", -        METADIR, volume, strerror(errno)); +        GB_METADIR, volume, strerror(errno));      goto out;    } -  ret = glfs_chdir (glfs, METADIR); +  ret = glfs_chdir (glfs, GB_METADIR);    if (ret) {      LOG("gfapi", GB_LOG_ERROR, "glfs_chdir(%s) on volume %s failed[%s]", -        METADIR, volume, strerror(errno)); +        GB_METADIR, volume, strerror(errno));      goto out;    } -  lkfd = glfs_creat(glfs, TXLOCKFILE, O_RDWR, S_IRUSR | S_IWUSR); +  lkfd = glfs_creat(glfs, GB_TXLOCKFILE, O_RDWR, S_IRUSR | S_IWUSR);    if (!lkfd) {      LOG("gfapi", GB_LOG_ERROR, "glfs_creat(%s) on volume %s failed[%s]", -        TXLOCKFILE, volume, strerror(errno)); +        GB_TXLOCKFILE, volume, strerror(errno));      goto out;    } @@ -147,6 +166,31 @@ glusterBlockCreateMetaLockFile(struct glfs *glfs, char *volume)    return NULL;  } +int +glusterBlockDeleteMetaLockFile(struct glfs *glfs, +                               char *volume, char *blockname) +{ +  int ret; + + +  ret = glfs_chdir (glfs, GB_METADIR); +  if (ret) { +    LOG("gfapi", GB_LOG_ERROR, "glfs_chdir(%s) on volume %s failed[%s]", +        GB_METADIR, volume, strerror(errno)); +    goto out; +  } + +  ret = glfs_unlink(glfs, blockname); +  if (ret && errno != ENOENT) { +    LOG("gfapi", GB_LOG_ERROR, "glfs_unlink(%s) on volume %s failed[%s]", +        blockname, volume, strerror(errno)); +    goto out; +  } + + out: +  return ret; +} +  void  blockFreeMetaInfo(MetaInfo *info) @@ -232,7 +276,15 @@ blockGetMetaInfo(struct glfs* glfs, char* metafile, MetaInfo *info)    struct glfs_fd *tgmfd;    char line[1024];    char *tmp; +  int ret; + +  ret = glfs_chdir (glfs, GB_METADIR); +  if (ret) { +    LOG("gfapi", GB_LOG_ERROR, "glfs_chdir(%s) on volume %s failed[%s]", +        GB_METADIR, info->volume, strerror(errno)); +    return ret; +  }    tgmfd = glfs_open(glfs, metafile, O_RDONLY);    if (!tgmfd) { diff --git a/rpc/glfs-operations.h b/rpc/glfs-operations.h index a03741e..5d617e6 100644 --- a/rpc/glfs-operations.h +++ b/rpc/glfs-operations.h @@ -53,6 +53,9 @@ struct glfs_fd *  glusterBlockCreateMetaLockFile(struct glfs *glfs, char *volume);  int +glusterBlockDeleteMetaLockFile(struct glfs *glfs, char *volume, char *blockname); + +int  blockGetMetaInfo(struct glfs *glfs, char *metafile, MetaInfo *info);  void diff --git a/utils/common.h b/utils/common.h index 6b0983d..90372ed 100644 --- a/utils/common.h +++ b/utils/common.h @@ -20,6 +20,10 @@  # define  GFAPI_LOG_FILE   "/var/log/gluster-block/gluster-block-gfapi.log"  # define  GFAPI_LOG_LEVEL  7 +# define  GB_METADIR          "/block-meta" +# define  GB_STOREDIR         "/block-store" +# define  GB_TXLOCKFILE       "meta.lock" +  ssize_t glusterBlockCreateParseSize(char *value); diff --git a/utils/utils.h b/utils/utils.h index 2323418..0545219 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -198,7 +198,7 @@ static const char *const gbCmdlineCreateOptLookup[] = {    [GB_CLI_CREATE_VOLSERVER]        = "volserver",    [GB_CLI_CREATE_SIZE]             = "size",    [GB_CLI_CREATE_MULTIPATH]        = "mpath", -  [GB_CLI_CREATE_BACKEND_SERVESRS] = "backend-servers", +  [GB_CLI_CREATE_BACKEND_SERVESRS] = "servers",    [GB_CLI_CREATE_OPT_MAX]   = NULL  | 
