From 144a22cd9f547b54a712e0a78cd698edae12dc23 Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Tue, 7 Feb 2017 14:36:58 +0530 Subject: gfapi: unify calls to glfs_init and friends There were two glfs_init(and friends) invocations per op (create & delete). This patch just unifies those calls (since they anyway belong to same volume) Signed-off-by: Prasanna Kumar Kalever --- rpc/block_svc_routines.c | 4 ++-- rpc/glfs-operations.c | 31 +++++++------------------------ rpc/glfs-operations.h | 4 ++-- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c index 91ad630..e2ad31b 100644 --- a/rpc/block_svc_routines.c +++ b/rpc/block_svc_routines.c @@ -376,7 +376,7 @@ glusterBlockCleanUp(struct glfs *glfs, char *blockname, } if (cleanupsuccess == info->nhosts) { - if (glusterBlockDeleteEntry(info->volume, info->gbid)) { + if (glusterBlockDeleteEntry(glfs, info->volume, info->gbid)) { LOG("mgmt", GB_LOG_ERROR, "%s volume: %s host: %s", FAILED_DELETING_FILE, info->volume, "localhost"); } @@ -467,7 +467,7 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp) "ENTRYCREATE: INPROGRESS\n", blk->volume, gbid, blk->size, blk->mpath); - ret = glusterBlockCreateEntry(blk, gbid); + ret = glusterBlockCreateEntry(glfs, blk, gbid); if (ret) { GB_METAUPDATE_OR_GOTO(tgmfd, blk->block_name, blk->volume, ret, exist, "ENTRYCREATE: FAIL\n"); diff --git a/rpc/glfs-operations.c b/rpc/glfs-operations.c index 9712f64..02e656b 100644 --- a/rpc/glfs-operations.c +++ b/rpc/glfs-operations.c @@ -62,23 +62,17 @@ glusterBlockVolumeInit(char *volume, char *volfileserver) int -glusterBlockCreateEntry(blockCreateCli *blk, char *gbid) +glusterBlockCreateEntry(struct glfs *glfs, + blockCreateCli *blk, + char *gbid) { - struct glfs *glfs; struct glfs_fd *tgfd; int ret = -1; - glfs = glusterBlockVolumeInit(blk->volume, blk->volfileserver); - if (!glfs) { - LOG("gfapi", GB_LOG_ERROR, "glusterBlockVolumeInit(%s): failed", - blk->volume); - goto out; - } - tgfd = glfs_creat(glfs, gbid, - O_WRONLY | O_CREAT | O_EXCL, - S_IRUSR | S_IWUSR); + O_WRONLY | O_CREAT | O_EXCL, + S_IRUSR | S_IWUSR); if (!tgfd) { LOG("gfapi", GB_LOG_ERROR, "glfs_creat(%s) on volume %s failed[%s]", gbid, blk->volume, strerror(errno)); @@ -99,34 +93,23 @@ glusterBlockCreateEntry(blockCreateCli *blk, char *gbid) } out: - glfs_fini(glfs); return ret; } int -glusterBlockDeleteEntry(char *volume, char *gbid) +glusterBlockDeleteEntry(struct glfs *glfs, char *volume, char *gbid) { - struct glfs *glfs; - int ret = -1; + int ret; - glfs = glusterBlockVolumeInit(volume, "localhost"); - if (!glfs) { - LOG("gfapi", GB_LOG_ERROR, "glusterBlockVolumeInit(%s): failed", - volume); - 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)); - goto out; } out: - glfs_fini(glfs); return ret; } diff --git a/rpc/glfs-operations.h b/rpc/glfs-operations.h index 8ba12f5..a03741e 100644 --- a/rpc/glfs-operations.h +++ b/rpc/glfs-operations.h @@ -44,10 +44,10 @@ struct glfs * glusterBlockVolumeInit(char *volume, char *volfileserver); int -glusterBlockCreateEntry(blockCreateCli *blk, char *gbid); +glusterBlockCreateEntry(struct glfs *glfs, blockCreateCli *blk, char *gbid); int -glusterBlockDeleteEntry(char *volume, char *gbid); +glusterBlockDeleteEntry(struct glfs *glfs, char *volume, char *gbid); struct glfs_fd * glusterBlockCreateMetaLockFile(struct glfs *glfs, char *volume); -- cgit