summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-10-04 11:17:44 +0300
committerXavi Hernandez <xhernandez@redhat.com>2019-10-14 08:21:52 +0000
commit704961a39ffd019487e36ac6dbd425399cb85cf2 (patch)
treebbdff1293d5cd5602a04d42822f2024d481a3754
parent240eec91c6ab5818c3fa4a9087ba46bbed0e8d2b (diff)
Multiple files: make root gfid a static variable
In many places we use it, compare to it, etc. It could be a static variable, as it really doesn't change. I think it's better than initializing to 0 and then doing gfid[15] = 1 or other tricks. I think there are additional oppportunuties to make more variables static. This is an attempt at an easy one. Change-Id: I7f23a30a94056d8f043645371ab841cbd0f90d19 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
-rw-r--r--xlators/cluster/dht/src/dht-common.c5
-rw-r--r--xlators/cluster/dht/src/dht-helper.c7
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c5
-rw-r--r--xlators/cluster/ec/src/ec-helpers.c2
-rw-r--r--xlators/features/bit-rot/src/stub/bit-rot-stub.c11
-rw-r--r--xlators/features/gfid-access/src/gfid-access.c6
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c4
-rw-r--r--xlators/nfs/server/src/mount3.c10
-rw-r--r--xlators/nfs/server/src/nfs-common.c5
-rw-r--r--xlators/nfs/server/src/nfs-fops.c2
-rw-r--r--xlators/nfs/server/src/nfs3-fh.c6
-rw-r--r--xlators/protocol/server/src/server-common.c30
-rw-r--r--xlators/storage/posix/src/posix-common.c2
-rw-r--r--xlators/storage/posix/src/posix-handle.c2
14 files changed, 24 insertions, 73 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 232685b..b295ce8 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -6395,9 +6395,7 @@ dht_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
int i = -1;
inode_t *inode = NULL;
inode_table_t *itable = NULL;
- uuid_t root_gfid = {
- 0,
- };
+ static uuid_t root_gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
loc_t newloc = {
0,
};
@@ -6423,7 +6421,6 @@ dht_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
}
loc = &local->loc2;
- root_gfid[15] = 1;
inode = inode_find(itable, root_gfid);
if (!inode) {
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index 980a562..9d3e3a3 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -1917,9 +1917,7 @@ dht_heal_path(xlator_t *this, char *path, inode_table_t *itable)
};
char *bname = NULL;
char *save_ptr = NULL;
- uuid_t gfid = {
- 0,
- };
+ static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
char *tmp_path = NULL;
tmp_path = gf_strdup(path);
@@ -1927,9 +1925,6 @@ dht_heal_path(xlator_t *this, char *path, inode_table_t *itable)
goto out;
}
- memset(gfid, 0, 16);
- gfid[15] = 1;
-
gf_uuid_copy(loc.pargfid, gfid);
loc.parent = inode_ref(itable->root);
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 0bf499a..d4e639d 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -2447,15 +2447,12 @@ void
dht_build_root_inode(xlator_t *this, inode_t **inode)
{
inode_table_t *itable = NULL;
- uuid_t root_gfid = {
- 0,
- };
+ static uuid_t root_gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
itable = inode_table_new(0, this);
if (!itable)
return;
- root_gfid[15] = 1;
*inode = inode_find(itable, root_gfid);
}
diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c
index baac001..48f5447 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -476,7 +476,7 @@ out:
int32_t
ec_loc_setup_path(xlator_t *xl, loc_t *loc)
{
- uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
char *name;
int32_t ret = -EINVAL;
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
index de2184d..d9ac009 100644
--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c
+++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
@@ -1817,9 +1817,7 @@ br_stub_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
const char *name, dict_t *xdata)
{
void *cookie = NULL;
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
fop_getxattr_cbk_t cbk = br_stub_getxattr_cbk;
int32_t op_ret = -1;
int32_t op_errno = EINVAL;
@@ -1831,8 +1829,6 @@ br_stub_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
GF_VALIDATE_OR_GOTO(this->name, this->private, unwind);
GF_VALIDATE_OR_GOTO(this->name, loc->inode, unwind);
- rootgfid[15] = 1;
-
if (!name) {
cbk = br_stub_listxattr_cbk;
goto wind;
@@ -1902,16 +1898,13 @@ br_stub_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
const char *name, dict_t *xdata)
{
void *cookie = NULL;
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
fop_fgetxattr_cbk_t cbk = br_stub_getxattr_cbk;
int32_t op_ret = -1;
int32_t op_errno = EINVAL;
br_stub_local_t *local = NULL;
br_stub_private_t *priv = NULL;
- rootgfid[15] = 1;
priv = this->private;
if (!name) {
diff --git a/xlators/features/gfid-access/src/gfid-access.c b/xlators/features/gfid-access/src/gfid-access.c
index ad77767..3fea567 100644
--- a/xlators/features/gfid-access/src/gfid-access.c
+++ b/xlators/features/gfid-access/src/gfid-access.c
@@ -327,10 +327,8 @@ out:
static gf_boolean_t
__is_gfid_access_dir(uuid_t gfid)
{
- uuid_t aux_gfid;
-
- memset(aux_gfid, 0, 16);
- aux_gfid[15] = GF_AUX_GFID;
+ static uuid_t aux_gfid = {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, GF_AUX_GFID};
if (gf_uuid_compare(gfid, aux_gfid) == 0)
return _gf_true;
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index e1bd095..2ed8bbd 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -5220,7 +5220,7 @@ fuse_first_lookup(xlator_t *this)
};
xlator_t *xl = NULL;
dict_t *dict = NULL;
- uuid_t gfid;
+ static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
int ret = -1;
struct iatt iatt = {
0,
@@ -5238,8 +5238,6 @@ fuse_first_lookup(xlator_t *this)
xl = priv->active_subvol;
- memset(gfid, 0, 16);
- gfid[15] = 1;
ret = dict_set_gfuuid(dict, "gfid-req", gfid, true);
if (ret) {
gf_log(xl->name, GF_LOG_ERROR, "failed to set 'gfid-req'");
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index 177046e..3b16bb8 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -920,14 +920,11 @@ mnt3svc_volume_mount(rpcsvc_request_t *req, struct mount3_state *ms,
{
inode_t *exportinode = NULL;
int ret = -EFAULT;
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
if ((!req) || (!exp) || (!ms))
return ret;
- rootgfid[15] = 1;
exportinode = inode_find(exp->vol->itable, rootgfid);
if (!exportinode) {
gf_msg(GF_MNT, GF_LOG_ERROR, ENOENT, NFS_MSG_GET_ROOT_INODE_FAIL,
@@ -1372,9 +1369,7 @@ __mnt3_resolve_subdir(mnt3_resolve_t *mres)
nfs_user_t nfu = {
0,
};
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
if (!mres)
return ret;
@@ -1385,7 +1380,6 @@ __mnt3_resolve_subdir(mnt3_resolve_t *mres)
if (!firstcomp)
goto err;
- rootgfid[15] = 1;
ret = nfs_entry_loc_fill(mres->mstate->nfsx, mres->exp->vol->itable,
rootgfid, firstcomp, &mres->resolveloc,
NFS_RESOLVE_CREATE, NULL);
diff --git a/xlators/nfs/server/src/nfs-common.c b/xlators/nfs/server/src/nfs-common.c
index 5b3ee97..b8f6b6f 100644
--- a/xlators/nfs/server/src/nfs-common.c
+++ b/xlators/nfs/server/src/nfs-common.c
@@ -272,11 +272,8 @@ err:
int
nfs_root_loc_fill(inode_table_t *itable, loc_t *loc)
{
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
- rootgfid[15] = 1;
return nfs_gfid_loc_fill(itable, rootgfid, loc, NFS_RESOLVE_EXIST);
}
diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c
index 896c67c..4d8540c 100644
--- a/xlators/nfs/server/src/nfs-fops.c
+++ b/xlators/nfs/server/src/nfs-fops.c
@@ -327,7 +327,7 @@ nfs_gfid_dict(inode_t *inode)
unsigned char *dyngfid = NULL;
dict_t *dictgfid = NULL;
int ret = -1;
- uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
dyngfid = GF_MALLOC(sizeof(uuid_t), gf_common_mt_char);
if (dyngfid == NULL)
diff --git a/xlators/nfs/server/src/nfs3-fh.c b/xlators/nfs/server/src/nfs3-fh.c
index d0c0a2f..caa3cfa 100644
--- a/xlators/nfs/server/src/nfs3-fh.c
+++ b/xlators/nfs/server/src/nfs3-fh.c
@@ -64,7 +64,7 @@ nfs3_fh_build_indexed_root_fh(xlator_list_t *cl, xlator_t *xl)
struct iatt buf = {
0,
};
- uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
if ((!cl) || (!xl))
return fh;
@@ -85,7 +85,7 @@ nfs3_fh_build_uuid_root_fh(uuid_t volumeid, uuid_t mountid)
struct iatt buf = {
0,
};
- uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
gf_uuid_copy(buf.ia_gfid, root);
nfs3_fh_init(&fh, &buf);
@@ -98,7 +98,7 @@ nfs3_fh_build_uuid_root_fh(uuid_t volumeid, uuid_t mountid)
int
nfs3_fh_is_root_fh(struct nfs3_fh *fh)
{
- uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
if (!fh)
return 0;
diff --git a/xlators/protocol/server/src/server-common.c b/xlators/protocol/server/src/server-common.c
index ce7f264..4bb8404 100644
--- a/xlators/protocol/server/src/server-common.c
+++ b/xlators/protocol/server/src/server-common.c
@@ -21,11 +21,8 @@ server_post_stat(server_state_t *state, gfs3_stat_rsp *rsp, struct iatt *stbuf)
we use inode table which is shared by everyone, but
make sure we send fops only from subdir and below,
we have to alter inode gfid and send it to client */
- uuid_t gfid = {
- 0,
- };
+ static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
- gfid[15] = 1;
stbuf->ia_ino = 1;
gf_uuid_copy(stbuf->ia_gfid, gfid);
}
@@ -182,11 +179,8 @@ server_post_fstat(server_state_t *state, gfs3_fstat_rsp *rsp,
we use inode table which is shared by everyone, but
make sure we send fops only from subdir and below,
we have to alter inode gfid and send it to client */
- uuid_t gfid = {
- 0,
- };
+ static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
- gfid[15] = 1;
stbuf->ia_ino = 1;
gf_uuid_copy(stbuf->ia_gfid, gfid);
}
@@ -454,9 +448,7 @@ server_post_lookup(gfs3_lookup_rsp *rsp, call_frame_t *frame,
{
inode_t *root_inode = NULL;
inode_t *link_inode = NULL;
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
root_inode = frame->root->client->bound_xl->itable->root;
@@ -480,7 +472,6 @@ server_post_lookup(gfs3_lookup_rsp *rsp, call_frame_t *frame,
make sure we send fops only from subdir and below,
we have to alter inode gfid and send it to client */
stbuf->ia_ino = 1;
- rootgfid[15] = 1;
gf_uuid_copy(stbuf->ia_gfid, rootgfid);
if (inode->ia_type == 0)
inode->ia_type = stbuf->ia_type;
@@ -521,11 +512,8 @@ server4_post_common_3iatt(server_state_t *state, gfx_common_3iatt_rsp *rsp,
we use inode table which is shared by everyone, but
make sure we send fops only from subdir and below,
we have to alter inode gfid and send it to client */
- uuid_t gfid = {
- 0,
- };
+ static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
- gfid[15] = 1;
preparent->ia_ino = 1;
postparent->ia_ino = 1;
gf_uuid_copy(preparent->ia_gfid, gfid);
@@ -591,11 +579,8 @@ server4_post_common_iatt(server_state_t *state, gfx_common_iatt_rsp *rsp,
we use inode table which is shared by everyone, but
make sure we send fops only from subdir and below,
we have to alter inode gfid and send it to client */
- uuid_t gfid = {
- 0,
- };
+ static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
- gfid[15] = 1;
stbuf->ia_ino = 1;
gf_uuid_copy(stbuf->ia_gfid, gfid);
}
@@ -802,9 +787,7 @@ server4_post_lookup(gfx_common_2iatt_rsp *rsp, call_frame_t *frame,
{
inode_t *root_inode = NULL;
inode_t *link_inode = NULL;
- uuid_t rootgfid = {
- 0,
- };
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
root_inode = frame->root->client->bound_xl->itable->root;
@@ -828,7 +811,6 @@ server4_post_lookup(gfx_common_2iatt_rsp *rsp, call_frame_t *frame,
make sure we send fops only from subdir and below,
we have to alter inode gfid and send it to client */
stbuf->ia_ino = 1;
- rootgfid[15] = 1;
gf_uuid_copy(stbuf->ia_gfid, rootgfid);
if (inode->ia_type == 0)
inode->ia_type = stbuf->ia_type;
diff --git a/xlators/storage/posix/src/posix-common.c b/xlators/storage/posix/src/posix-common.c
index abe086d..13b70da 100644
--- a/xlators/storage/posix/src/posix-common.c
+++ b/xlators/storage/posix/src/posix-common.c
@@ -576,7 +576,7 @@ posix_init(xlator_t *this)
uuid_t gfid = {
0,
};
- uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
char *guuid = NULL;
int32_t uid = -1;
int32_t gid = -1;
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index 4764c47..f4686a9 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -504,7 +504,7 @@ posix_handle_init(xlator_t *this)
struct stat rootbuf;
struct stat exportbuf;
char *rootstr = NULL;
- uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ static uuid_t gfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
priv = this->private;