From 26b9c85861f058a4a8335b28f49410ba061e7c1a Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Thu, 25 Jul 2019 23:36:56 +0300 Subject: glusterd: write voldir once in glusterd-store and don't attempt again. glusterd_store_brickinfos() is calling per each brick the function glusterd_store_brickinfo(). In it, we call: ret = glusterd_store_create_brick_dir(volinfo); However, volinfo is the same for all those bricks - no need to again and again call it (which tries to mkdir that dir). We can do it once above the loops in glusterd_store_brickinfos() While at, combine two similar functions that write additional dirs. Change-Id: I5858cf7783f088ea13a8fa20115118efa816f4cb updates: bz#1193929 Signed-off-by: Yaniv Kaul --- xlators/mgmt/glusterd/src/glusterd-store.c | 45 +++++++++++------------------- 1 file changed, 16 insertions(+), 29 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index ee1c01d39ba..b7246e2dad5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -571,10 +571,6 @@ glusterd_store_brickinfo(glusterd_volinfo_t *volinfo, if (ret) goto out; - ret = glusterd_store_create_brick_dir(volinfo); - if (ret) - goto out; - ret = glusterd_store_create_brick_shandle_on_absence(volinfo, brickinfo); if (ret) goto out; @@ -1046,36 +1042,26 @@ glusterd_store_piddirpath_set(glusterd_volinfo_t *volinfo, char *piddirpath) } static int32_t -glusterd_store_create_volume_dir(glusterd_volinfo_t *volinfo) -{ - int32_t ret = -1; - char voldirpath[PATH_MAX] = { - 0, - }; - - GF_ASSERT(volinfo); - - glusterd_store_voldirpath_set(volinfo, voldirpath); - ret = gf_store_mkdir(voldirpath); - - gf_msg_debug(THIS->name, 0, "Returning with %d", ret); - return ret; -} - -static int32_t -glusterd_store_create_volume_run_dir(glusterd_volinfo_t *volinfo) +glusterd_store_create_volume_dirs(glusterd_volinfo_t *volinfo) { int32_t ret = -1; - char piddirpath[PATH_MAX] = { + char dirpath[PATH_MAX] = { 0, }; GF_ASSERT(volinfo); - glusterd_store_piddirpath_set(volinfo, piddirpath); + glusterd_store_voldirpath_set(volinfo, dirpath); + ret = gf_store_mkdir(dirpath); + if (ret) + goto out; - ret = gf_store_mkdir(piddirpath); + glusterd_store_piddirpath_set(volinfo, dirpath); + ret = gf_store_mkdir(dirpath); + if (ret) + goto out; +out: gf_msg_debug(THIS->name, 0, "Returning with %d", ret); return ret; } @@ -1476,6 +1462,10 @@ glusterd_store_perform_volume_store(glusterd_volinfo_t *volinfo) if (ret) goto out; + ret = glusterd_store_create_brick_dir(volinfo); + if (ret) + goto out; + ret = glusterd_store_brickinfos(volinfo, fd); if (ret) goto out; @@ -1671,11 +1661,8 @@ glusterd_store_volinfo(glusterd_volinfo_t *volinfo, pthread_mutex_lock(&volinfo->store_volinfo_lock); { glusterd_perform_volinfo_version_action(volinfo, ac); - ret = glusterd_store_create_volume_dir(volinfo); - if (ret) - goto unlock; - ret = glusterd_store_create_volume_run_dir(volinfo); + ret = glusterd_store_create_volume_dirs(volinfo); if (ret) goto unlock; -- cgit