diff options
Diffstat (limited to 'gluster-blockd.c')
-rw-r--r-- | gluster-blockd.c | 301 |
1 files changed, 175 insertions, 126 deletions
diff --git a/gluster-blockd.c b/gluster-blockd.c index 1f75f41..ef27dbd 100644 --- a/gluster-blockd.c +++ b/gluster-blockd.c @@ -62,13 +62,15 @@ glusterBlockCallRPC_1(char *host, void *cobj, if ((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - LOG("mgmt", ERROR, "socket creation failed (%s)", strerror (errno)); + LOG("mgmt", GB_LOG_ERROR, "socket creation failed (%s)", + strerror (errno)); goto out; } server = gethostbyname(host); if (!server) { - LOG("mgmt", ERROR, "gethostbyname failed (%s)", strerror (errno)); + LOG("mgmt", GB_LOG_ERROR, "gethostbyname failed (%s)", + strerror (errno)); goto out; } @@ -79,14 +81,14 @@ glusterBlockCallRPC_1(char *host, void *cobj, sain.sin_port = htons(24006); if (connect(sockfd, (struct sockaddr *) &sain, sizeof(sain)) < 0) { - LOG("mgmt", ERROR, "connect failed (%s)", strerror (errno)); + LOG("mgmt", GB_LOG_ERROR, "connect failed (%s)", strerror (errno)); goto out; } clnt = clnttcp_create ((struct sockaddr_in *) &sain, GLUSTER_BLOCK, GLUSTER_BLOCK_VERS, &sockfd, 0, 0); if (!clnt) { - LOG("mgmt", ERROR, "%s, inet host %s", + LOG("mgmt", GB_LOG_ERROR, "%s, inet host %s", clnt_spcreateerror("client create failed"), host); goto out; } @@ -95,29 +97,35 @@ glusterBlockCallRPC_1(char *host, void *cobj, case CREATE_SRV: reply = block_create_1((blockCreate *)cobj, clnt); if (!reply) { - LOG("mgmt", ERROR, "%s", clnt_sperror(clnt, "block create failed")); + LOG("mgmt", GB_LOG_ERROR, "%s", + clnt_sperror(clnt, "block create failed")); goto out; } break; case DELETE_SRV: reply = block_delete_1((blockDelete *)cobj, clnt); if (!reply) { - LOG("mgmt", ERROR, "%s", clnt_sperror(clnt, "block delete failed")); + LOG("mgmt", GB_LOG_ERROR, "%s", + clnt_sperror(clnt, "block delete failed")); goto out; } break; } - if (GB_STRDUP(*out, reply->out) < 0) + if (GB_STRDUP(*out, reply->out) < 0){ goto out; + } ret = reply->exit; out: - if (!clnt_freeres(clnt, (xdrproc_t)xdr_blockResponse, (char *)reply)) - LOG("mgmt", ERROR, "%s", clnt_sperror(clnt, "clnt_freeres failed")); + if (!clnt_freeres(clnt, (xdrproc_t)xdr_blockResponse, (char *)reply)) { + LOG("mgmt", GB_LOG_ERROR, "%s", + clnt_sperror(clnt, "clnt_freeres failed")); + } - if (clnt) + if (clnt) { clnt_destroy (clnt); + } close(sockfd); @@ -131,13 +139,15 @@ blockServerDefFree(blockServerDefPtr blkServers) size_t i; - if (!blkServers) + if (!blkServers) { return; + } - for (i = 0; i < blkServers->nhosts; i++) + for (i = 0; i < blkServers->nhosts; i++) { GB_FREE(blkServers->hosts[i]); - GB_FREE(blkServers->hosts); - GB_FREE(blkServers); + } + GB_FREE(blkServers->hosts); + GB_FREE(blkServers); } @@ -149,28 +159,33 @@ blockServerParse(char *blkServers) size_t i = 0; - if (GB_ALLOC(list) < 0) + if (GB_ALLOC(list) < 0) { return NULL; + } - if (!blkServers) + if (!blkServers) { blkServers = "localhost"; + } /* count number of servers */ while (*tmp) { - if (*tmp == ',') + if (*tmp == ',') { list->nhosts++; + } tmp++; } list->nhosts++; tmp = blkServers; /* reset addr */ - if (GB_ALLOC_N(list->hosts, list->nhosts) < 0) + if (GB_ALLOC_N(list->hosts, list->nhosts) < 0) { goto fail; + } for (i = 0; tmp != NULL; i++) { - if (GB_STRDUP(list->hosts[i], strsep(&tmp, MSERVER_DELIMITER)) < 0) + if (GB_STRDUP(list->hosts[i], strsep(&tmp, MSERVER_DELIMITER)) < 0) { goto fail; + } } return list; @@ -180,25 +195,29 @@ blockServerParse(char *blkServers) return NULL; } + static void -glusterBlockCreateRemote(struct glfs_fd *tgfd, blockCreate *cobj, - char *addr, char **reply) +glusterBlockCreateRemote(struct glfs_fd *tgmfd, char *volume, + blockCreate *cobj, char *addr, char **reply) { - int ret = -1; + int ret; char *out = NULL; char *tmp = *reply; - METAUPDATE(tgfd, "%s: CONFIGINPROGRESS\n", addr); + GB_METAUPDATE_OR_GOTO(tgmfd, cobj->gbid, volume, ret, out, + "%s: CONFIGINPROGRESS\n", addr); ret = glusterBlockCallRPC_1(addr, cobj, CREATE_SRV, &out); if (ret) { - METAUPDATE(tgfd, "%s: CONFIGFAIL\n", addr); - LOG("mgmt", ERROR, "%s on host: %s", FAILED_CREATE, addr); + GB_METAUPDATE_OR_GOTO(tgmfd, cobj->gbid, volume, ret, out, + "%s: CONFIGFAIL\n", addr); + LOG("mgmt", GB_LOG_ERROR, "%s on host: %s", FAILED_CREATE, addr); goto out; } - METAUPDATE(tgfd, "%s: CONFIGSUCCESS\n", addr); + GB_METAUPDATE_OR_GOTO(tgmfd, cobj->gbid, volume, ret, out, + "%s: CONFIGSUCCESS\n", addr); out: asprintf(reply, "%s%s\n", (tmp==NULL?"":tmp), out); @@ -206,9 +225,10 @@ glusterBlockCreateRemote(struct glfs_fd *tgfd, blockCreate *cobj, GB_FREE(out); } + static int glusterBlockAuditRequest(struct glfs *glfs, - struct glfs_fd *tgfd, + struct glfs_fd *tgmfd, blockCreateCli *blk, blockCreate *cobj, blockServerDefPtr list, @@ -224,20 +244,22 @@ glusterBlockAuditRequest(struct glfs *glfs, MetaInfo *info; - if (GB_ALLOC(info) < 0) + if (GB_ALLOC(info) < 0) { goto out; + } ret = blockGetMetaInfo(glfs, blk->block_name, info); - if (ret) + if (ret) { goto out; + } for (i = 0; i < info->nhosts; i++) { switch (blockMetaStatusEnumParse(info->list[i]->status)) { - case CONFIGSUCCESS: + case GB_CONFIG_SUCCESS: successcnt++; break; - case CONFIGINPROGRESS: - case CONFIGFAIL: + case GB_CONFIG_INPROGRESS: + case GB_CONFIG_FAIL: failcnt++; } } @@ -251,26 +273,27 @@ glusterBlockAuditRequest(struct glfs *glfs, spare = list->nhosts - spent; /* spare after spent */ morereq = blk->mpath - successcnt; /* needed nodes to complete req */ if (spare == 0) { - LOG("mgmt", WARNING, "%s", + LOG("mgmt", GB_LOG_WARNING, "%s", "No Spare nodes: rewining the creation of target"); ret = -1; goto out; } else if (spare < morereq) { - LOG("mgmt", WARNING, "%s", + LOG("mgmt", GB_LOG_WARNING, "%s", "Not enough Spare nodes: rewining the creation of target"); ret = -1; goto out; } else { /* create on spare */ - LOG("mgmt", INFO, "%s", + LOG("mgmt", GB_LOG_INFO, "%s", "trying to serve the mpath from spare machines"); for (i = spent; i < list->nhosts; i++) { - glusterBlockCreateRemote(tgfd, cobj, list->hosts[i], reply); + glusterBlockCreateRemote(tgmfd, info->volume, cobj, + list->hosts[i], reply); } } } - ret = glusterBlockAuditRequest(glfs, tgfd, blk, cobj, list, reply); + ret = glusterBlockAuditRequest(glfs, tgmfd, blk, cobj, list, reply); out: blockFreeMetaInfo(info); @@ -279,23 +302,26 @@ glusterBlockAuditRequest(struct glfs *glfs, static void -glusterBlockDeleteRemote(struct glfs_fd *tgfd, blockDelete *cobj, - char *addr, char **reply) +glusterBlockDeleteRemote(struct glfs_fd *tgmfd, MetaInfo *info, + blockDelete *cobj, char *addr, char **reply) { int ret = -1; char *out = NULL; char *tmp = *reply; - METAUPDATE(tgfd, "%s: CLEANUPINPROGRES\n", addr); + GB_METAUPDATE_OR_GOTO(tgmfd, info->gbid, info->volume, ret, out, + "%s: CLEANUPINPROGRES\n", addr); ret = glusterBlockCallRPC_1(addr, cobj, DELETE_SRV, &out); if (ret) { - METAUPDATE(tgfd, "%s: CLEANUPFAIL\n", addr); - LOG("mgmt", ERROR, "%s on host: %s", + GB_METAUPDATE_OR_GOTO(tgmfd, info->gbid, info->volume, ret, out, + "%s: CLEANUPFAIL\n", addr); + LOG("mgmt", GB_LOG_ERROR, "%s on host: %s", FAILED_GATHERING_INFO, addr); goto out; } - METAUPDATE(tgfd, "%s: CLEANUPSUCCESS\n", addr); + GB_METAUPDATE_OR_GOTO(tgmfd, info->gbid, info->volume, ret, out, + "%s: CLEANUPSUCCESS\n", addr); out: asprintf(reply, "%s%s\n", (tmp==NULL?"":tmp), out); @@ -311,41 +337,43 @@ glusterBlockCleanUp(struct glfs *glfs, char *blockname, int ret = -1; size_t i; static blockDelete cobj; - struct glfs_fd *tgfd = NULL; + struct glfs_fd *tgmfd = NULL; size_t cleanupsuccess = 0; MetaInfo *info; - if (GB_ALLOC(info) < 0) + if (GB_ALLOC(info) < 0) { goto out; + } ret = blockGetMetaInfo(glfs, blockname, info); - if (ret) + if (ret) { goto out; + } strcpy(cobj.block_name, blockname); strcpy(cobj.gbid, info->gbid); - tgfd = glfs_open(glfs, blockname, O_WRONLY|O_APPEND); - if (!tgfd) { - LOG("mgmt", ERROR, "%s", "glfs_open: failed"); + tgmfd = glfs_open(glfs, blockname, O_WRONLY|O_APPEND); + if (!tgmfd) { + LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_open: failed"); goto out; } for (i = 0; i < info->nhosts; i++) { switch (blockMetaStatusEnumParse(info->list[i]->status)) { - case CLEANUPINPROGRES: - case CLEANUPFAIL: - case CONFIGFAIL: - case CONFIGINPROGRESS: - glusterBlockDeleteRemote(tgfd, &cobj, - info->list[i]->addr, reply); + case GB_CLEANUP_INPROGRES: + case GB_CLEANUP_FAIL: + case GB_CONFIG_FAIL: + case GB_CONFIG_INPROGRESS: + glusterBlockDeleteRemote(tgmfd, info, &cobj, + info->list[i]->addr, reply); break; } if (deleteall && - blockMetaStatusEnumParse(info->list[i]->status) == CONFIGSUCCESS) { - glusterBlockDeleteRemote(tgfd, &cobj, - info->list[i]->addr, reply); + blockMetaStatusEnumParse(info->list[i]->status) == GB_CONFIG_SUCCESS) { + glusterBlockDeleteRemote(tgmfd, info, &cobj, + info->list[i]->addr, reply); } } blockFreeMetaInfo(info); @@ -358,18 +386,19 @@ glusterBlockCleanUp(struct glfs *glfs, char *blockname, goto out; for (i = 0; i < info->nhosts; i++) { - if (blockMetaStatusEnumParse(info->list[i]->status) == CLEANUPSUCCESS) + if (blockMetaStatusEnumParse(info->list[i]->status) == GB_CLEANUP_SUCCESS) { cleanupsuccess++; + } } if (cleanupsuccess == info->nhosts) { if (glusterBlockDeleteEntry(info->volume, info->gbid)) { - LOG("mgmt", ERROR, "%s volume: %s host: %s", + 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", ERROR, "%s", "glfs_unlink: failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_unlink: failed"); goto out; } } @@ -377,8 +406,8 @@ glusterBlockCleanUp(struct glfs *glfs, char *blockname, out: blockFreeMetaInfo(info); - if (glfs_close(tgfd) != 0) { - LOG("mgmt", ERROR, "%s", "glfs_close: failed"); + if (glfs_close(tgmfd) != 0) { + LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_close: failed"); } return ret; @@ -397,20 +426,21 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp) static blockResponse *reply; struct glfs *glfs; struct glfs_fd *lkfd = NULL; - struct glfs_fd *tgfd = NULL; + struct glfs_fd *tgmfd = NULL; blockServerDefPtr list = NULL; - if (GB_ALLOC(reply) < 0) + if (GB_ALLOC(reply) < 0) { goto out; + } list = blockServerParse(blk->block_hosts); /* Fail if mpath > list->nhosts */ if (blk->mpath > list->nhosts) { - LOG("mgmt", ERROR, "block multipath request:%d is greater than " - "provided block-hosts:%s", - blk->mpath, blk->block_hosts); + LOG("mgmt", GB_LOG_ERROR, "block multipath request:%d is greater " + "than provided block-hosts:%s", + blk->mpath, blk->block_hosts); asprintf(&reply->out, "multipath req: %d > block-hosts: %s\n", blk->mpath, blk->block_hosts); reply->exit = ENODEV; @@ -419,17 +449,18 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp) glfs = glusterBlockVolumeInit(blk->volume, blk->volfileserver); if (!glfs) { - LOG("mgmt", ERROR, "%s", "glusterBlockVolumeInit failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", "glusterBlockVolumeInit failed"); goto out; } - lkfd = glusterBlockCreateMetaLockFile(glfs); + lkfd = glusterBlockCreateMetaLockFile(glfs, blk->volume); if (!lkfd) { - LOG("mgmt", ERROR, "%s", "glusterBlockCreateMetaLockFile failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", + "glusterBlockCreateMetaLockFile failed"); goto out; } - METALOCK(lkfd); + GB_METALOCK_OR_GOTO(lkfd, blk->volume, ret, out); if (!glfs_access(glfs, blk->block_name, F_OK)) { asprintf(&reply->out, "BLOCK with name: '%s' already EXIST\n", @@ -438,28 +469,31 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp) goto exist; } - tgfd = glfs_creat(glfs, blk->block_name, O_RDWR, S_IRUSR | S_IWUSR); - if (!tgfd) { - LOG("mgmt", ERROR, "%s", "glfs_creat: failed"); + tgmfd = glfs_creat(glfs, blk->block_name, O_RDWR, S_IRUSR | S_IWUSR); + if (!tgmfd) { + LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_creat: failed"); goto out; } uuid_generate(uuid); uuid_unparse(uuid, gbid); - METAUPDATE(tgfd, "VOLUME: %s\n" - "GBID: %s\nSIZE: %zu\nHA: %d\nENTRYCREATE: INPROGRESS\n", - blk->volume, gbid, blk->size, blk->mpath); + GB_METAUPDATE_OR_GOTO(tgmfd, blk->block_name, blk->volume, ret, exist, + "VOLUME: %s\nGBID: %s\nSIZE: %zu\nHA: %d\n" + "ENTRYCREATE: INPROGRESS\n", + blk->volume, gbid, blk->size, blk->mpath); ret = glusterBlockCreateEntry(blk, gbid); if (ret) { - METAUPDATE(tgfd, "ENTRYCREATE: FAIL\n"); - LOG("mgmt", ERROR, "%s volume: %s host: %s", + GB_METAUPDATE_OR_GOTO(tgmfd, blk->block_name, blk->volume, ret, + exist, "ENTRYCREATE: FAIL\n"); + LOG("mgmt", GB_LOG_ERROR, "%s volume: %s host: %s", FAILED_CREATING_FILE, blk->volume, blk->volfileserver); goto out; } - METAUPDATE(tgfd, "ENTRYCREATE: SUCCESS\n"); + GB_METAUPDATE_OR_GOTO(tgmfd, blk->block_name, blk->volume, ret, exist, + "ENTRYCREATE: SUCCESS\n"); strcpy(cobj.volume, blk->volume); strcpy(cobj.volfileserver, blk->volfileserver); @@ -468,14 +502,15 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp) strcpy(cobj.gbid, gbid); for (i = 0; i < blk->mpath; i++) { - glusterBlockCreateRemote(tgfd, &cobj, list->hosts[i], &savereply); + glusterBlockCreateRemote(tgmfd, blk->volume, &cobj, + list->hosts[i], &savereply); } /* Check Point */ - ret = glusterBlockAuditRequest(glfs, tgfd, blk, + ret = glusterBlockAuditRequest(glfs, tgmfd, blk, &cobj, list, &savereply); if (ret) { - LOG("mgmt", ERROR, "%s", + LOG("mgmt", GB_LOG_ERROR, "%s", "even spare nodes have exhausted rewinding"); ret = glusterBlockCleanUp(glfs, blk->block_name, FALSE, &savereply); @@ -484,16 +519,17 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp) out: reply->out = savereply; - if (glfs_close(tgfd) != 0) - LOG("mgmt", ERROR, "%s", "glfs_close: failed"); + if (glfs_close(tgmfd) != 0) + LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_close: failed"); exist: - METAUNLOCK(lkfd); + GB_METAUNLOCK(lkfd, blk->volume, ret); reply->exit = ret; - if (glfs_close(lkfd) != 0) - LOG("mgmt", ERROR, "%s", "glfs_close: failed"); + if (glfs_close(lkfd) != 0) { + LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_close: failed"); + } glfs_fini(glfs); @@ -534,8 +570,9 @@ block_create_1_svc(blockCreate *blk, struct svc_req *rqstp) asprintf(&exec, "%s && %s && %s && %s && %s", backstore, iqn, lun, attr, TARGETCLI_SAVE); - if (GB_ALLOC(reply) < 0) + if (GB_ALLOC(reply) < 0) { goto out; + } if (GB_ALLOC_N(reply->out, 4096) < 0) { GB_FREE(reply); @@ -546,7 +583,7 @@ block_create_1_svc(blockCreate *blk, struct svc_req *rqstp) if (fp != NULL) { size_t newLen = fread(reply->out, sizeof(char), 4096, fp); if (ferror( fp ) != 0) { - LOG("mgmt", ERROR, "Reading command %s output", exec); + LOG("mgmt", GB_LOG_ERROR, "Reading command %s output", exec); } else { reply->out[newLen++] = '\0'; } @@ -574,22 +611,24 @@ block_delete_cli_1_svc(blockDeleteCli *blk, struct svc_req *rqstp) struct glfs_fd *lkfd; - if (GB_ALLOC(reply) < 0) + if (GB_ALLOC(reply) < 0) { return NULL; + } glfs = glusterBlockVolumeInit(blk->volume, "localhost"); if (!glfs) { - LOG("mgmt", ERROR, "%s", "glusterBlockVolumeInit failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", "glusterBlockVolumeInit failed"); goto out; } - lkfd = glusterBlockCreateMetaLockFile(glfs); + lkfd = glusterBlockCreateMetaLockFile(glfs, blk->volume); if (!lkfd) { - LOG("mgmt", ERROR, "%s", "glusterBlockCreateMetaLockFile failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", + "glusterBlockCreateMetaLockFile failed"); goto out; } - METALOCK(lkfd); + GB_METALOCK_OR_GOTO(lkfd, blk->volume, ret, out); if (glfs_access(glfs, blk->block_name, F_OK)) { GB_STRDUP(reply->out, "BLOCK Doesn't EXIST"); @@ -602,12 +641,12 @@ block_delete_cli_1_svc(blockDeleteCli *blk, struct svc_req *rqstp) out: reply->out = savereply; - METAUNLOCK(lkfd); + GB_METAUNLOCK(lkfd, blk->volume, ret); reply->exit = ret; if (glfs_close(lkfd) != 0) - LOG("mgmt", ERROR, "%s", "glfs_close: failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_close: failed"); glfs_fini(glfs); @@ -633,8 +672,9 @@ block_delete_1_svc(blockDelete *blk, struct svc_req *rqstp) asprintf(&exec, "%s && %s && %s", backstore, iqn, TARGETCLI_SAVE); - if (GB_ALLOC(reply) < 0) + if (GB_ALLOC(reply) < 0) { goto out; + } if (GB_ALLOC_N(reply->out, 4096) < 0) { GB_FREE(reply); @@ -645,7 +685,7 @@ block_delete_1_svc(blockDelete *blk, struct svc_req *rqstp) if (fp != NULL) { size_t newLen = fread(reply->out, sizeof(char), 4096, fp); if (ferror( fp ) != 0) { - LOG("mgmt", ERROR, "reading command %s output", exec); + LOG("mgmt", GB_LOG_ERROR, "reading command %s output", exec); } else { reply->out[newLen++] = '\0'; } @@ -667,7 +707,7 @@ block_list_cli_1_svc(blockListCli *blk, struct svc_req *rqstp) blockResponse *reply; struct glfs *glfs; struct glfs_fd *lkfd = NULL; - struct glfs_fd *tgfd = NULL; + struct glfs_fd *tgmfd = NULL; struct dirent *entry; char *tmp = NULL; char *filelist = NULL; @@ -676,25 +716,26 @@ block_list_cli_1_svc(blockListCli *blk, struct svc_req *rqstp) glfs = glusterBlockVolumeInit(blk->volume, "localhost"); if (!glfs) { - LOG("mgmt", ERROR, "%s", "glusterBlockVolumeInit failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", "glusterBlockVolumeInit failed"); goto out; } - lkfd = glusterBlockCreateMetaLockFile(glfs); + lkfd = glusterBlockCreateMetaLockFile(glfs, blk->volume); if (!lkfd) { - LOG("mgmt", ERROR, "%s", "glusterBlockCreateMetaLockFile failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", + "glusterBlockCreateMetaLockFile failed"); goto out; } - METALOCK(lkfd); + GB_METALOCK_OR_GOTO(lkfd, blk->volume, ret, out); - tgfd = glfs_opendir (glfs, "/block-meta"); - if (!tgfd) { - LOG("mgmt", ERROR, "%s", "glusterBlockVolumeInit failed"); + tgmfd = glfs_opendir (glfs, "/block-meta"); + if (!tgmfd) { + LOG("mgmt", GB_LOG_ERROR, "%s", "glusterBlockVolumeInit failed"); goto out; } - while ((entry = glfs_readdir (tgfd))) { + while ((entry = glfs_readdir (tgmfd))) { if (strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..") && strcmp(entry->d_name, "meta.lock")) { @@ -707,19 +748,21 @@ block_list_cli_1_svc(blockListCli *blk, struct svc_req *rqstp) ret = 0; out: - if (GB_ALLOC(reply) < 0) + if (GB_ALLOC(reply) < 0) { return NULL; + } reply->out = filelist? filelist:strdup("*Nil*\n"); - glfs_closedir (tgfd); + glfs_closedir (tgmfd); - METAUNLOCK(lkfd); + GB_METAUNLOCK(lkfd, blk->volume, ret); reply->exit = ret; - if (glfs_close(lkfd) != 0) - LOG("mgmt", ERROR, "%s", "glfs_close: failed"); + if (glfs_close(lkfd) != 0) { + LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_close: failed"); + } glfs_fini(glfs); @@ -742,31 +785,34 @@ block_info_cli_1_svc(blockInfoCli *blk, struct svc_req *rqstp) glfs = glusterBlockVolumeInit(blk->volume, "localhost"); if (!glfs) { - LOG("mgmt", ERROR, "%s", "glusterBlockVolumeInit failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", "glusterBlockVolumeInit failed"); goto out; } - lkfd = glusterBlockCreateMetaLockFile(glfs); + lkfd = glusterBlockCreateMetaLockFile(glfs, blk->volume); if (!lkfd) { - LOG("mgmt", ERROR, "%s", "glusterBlockCreateMetaLockFile failed"); + LOG("mgmt", GB_LOG_ERROR, "%s", + "glusterBlockCreateMetaLockFile failed"); goto out; } - METALOCK(lkfd); + GB_METALOCK_OR_GOTO(lkfd, blk->volume, ret, out); - if (GB_ALLOC(info) < 0) + if (GB_ALLOC(info) < 0) { goto out; + } ret = blockGetMetaInfo(glfs, blk->block_name, info); - if (ret) + if (ret) { goto out; + } asprintf(&tmp, "NAME: %s\nVOLUME: %s\nGBID: %s\nSIZE: %zu\n" "MULTIPATH: %zu\nBLOCK CONFIG NODE(S):", blk->block_name, info->volume, info->gbid, info->size, info->mpath); for (i = 0; i < info->nhosts; i++) { - if (blockMetaStatusEnumParse(info->list[i]->status) == CONFIGSUCCESS) { + if (blockMetaStatusEnumParse(info->list[i]->status) == GB_CONFIG_SUCCESS) { asprintf(&out, "%s %s", (tmp==NULL?"":tmp), info->list[i]->addr); GB_FREE(tmp); tmp = out; @@ -776,20 +822,23 @@ block_info_cli_1_svc(blockInfoCli *blk, struct svc_req *rqstp) ret = 0; out: - if (GB_ALLOC(reply) < 0) + if (GB_ALLOC(reply) < 0) { return NULL; + } - if (!out) + if (!out) { asprintf(&out, "No Block with name %s", blk->block_name); + } reply->out = out; - METAUNLOCK(lkfd); + GB_METAUNLOCK(lkfd, blk->volume, ret); reply->exit = ret; - if (glfs_close(lkfd) != 0) - LOG("mgmt", ERROR, "%s", "glfs_close: failed"); + if (glfs_close(lkfd) != 0) { + LOG("mgmt", GB_LOG_ERROR, "%s", "glfs_close: failed"); + } glfs_fini(glfs); |