summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/common-utils.c14
-rw-r--r--libglusterfs/src/common-utils.h6
-rw-r--r--xlators/cluster/ec/src/ec-combine.c15
-rw-r--r--xlators/features/gfid-access/src/gfid-access.c9
-rw-r--r--xlators/features/snapview-server/src/snapview-server-helpers.c10
-rw-r--r--xlators/meta/src/meta-helpers.c15
-rw-r--r--xlators/performance/md-cache/src/md-cache.c16
-rw-r--r--xlators/storage/posix/src/posix-helpers.c10
8 files changed, 24 insertions, 71 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index b9062c159c7..b2d5a279dc8 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -4538,3 +4538,17 @@ is_virtual_xattr (const char *k)
return ret;
}
+
+ino_t
+gfid_to_ino (uuid_t gfid)
+{
+ ino_t ino = 0;
+ int32_t i;
+
+ for (i = 8; i < 16; i++) {
+ ino <<= 8;
+ ino += (uint8_t)gfid[i];
+ }
+
+ return ino;
+}
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index e2b3f3ea032..d7277e6e834 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -652,6 +652,12 @@ gf_time_fmt (char *dst, size_t sz_dst, time_t utime, unsigned int fmt)
return dst;
}
+/* This function helps us use gfid (unique identity) to generate inode's unique
+ * number in glusterfs.
+ */
+ino_t
+gfid_to_ino (uuid_t gfid);
+
int
mkdir_p (char *path, mode_t mode, gf_boolean_t allow_symlinks);
/*
diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c
index 2566cc0d0cf..379d703bf35 100644
--- a/xlators/cluster/ec/src/ec-combine.c
+++ b/xlators/cluster/ec/src/ec-combine.c
@@ -108,21 +108,6 @@ void ec_iatt_time_merge(uint32_t * dst_sec, uint32_t * dst_nsec,
}
static
-uint64_t
-gfid_to_ino(uuid_t gfid)
-{
- uint64_t ino = 0;
- int32_t i;
-
- for (i = 8; i < 16; i++) {
- ino <<= 8;
- ino += (uint8_t)gfid[i];
- }
-
- return ino;
-}
-
-static
gf_boolean_t
ec_iatt_is_trusted(ec_fop_data_t *fop, struct iatt *iatt)
{
diff --git a/xlators/features/gfid-access/src/gfid-access.c b/xlators/features/gfid-access/src/gfid-access.c
index a2b1a2c6793..7d75b09bae0 100644
--- a/xlators/features/gfid-access/src/gfid-access.c
+++ b/xlators/features/gfid-access/src/gfid-access.c
@@ -655,10 +655,7 @@ ga_virtual_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, inode_t *inode,
struct iatt *buf, dict_t *xdata, struct iatt *postparent)
{
- int j = 0;
- int i = 0;
int ret = 0;
- uint64_t temp_ino = 0;
inode_t *cbk_inode = NULL;
inode_t *true_inode = NULL;
uuid_t random_gfid = {0,};
@@ -727,11 +724,7 @@ ga_virtual_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
gf_uuid_copy (buf->ia_gfid, random_gfid);
- for (i = 15; i > (15 - 8); i--) {
- temp_ino += (uint64_t)(buf->ia_gfid[i]) << j;
- j += 8;
- }
- buf->ia_ino = temp_ino;
+ buf->ia_ino = gfid_to_ino (buf->ia_gfid);
unwind:
/* Lookup on non-existing gfid returns ESTALE.
diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c
index dd2e891a849..5bf41c2317b 100644
--- a/xlators/features/snapview-server/src/snapview-server-helpers.c
+++ b/xlators/features/snapview-server/src/snapview-server-helpers.c
@@ -347,9 +347,6 @@ svs_uuid_generate (uuid_t gfid, char *snapname, uuid_t origin_gfid)
void
svs_fill_ino_from_gfid (struct iatt *buf)
{
- uint64_t temp_ino = 0;
- int j = 0;
- int i = 0;
xlator_t *this = NULL;
this = THIS;
@@ -362,11 +359,8 @@ svs_fill_ino_from_gfid (struct iatt *buf)
buf->ia_ino = -1;
goto out;
}
- for (i = 15; i > (15 - 8); i--) {
- temp_ino += (uint64_t)(buf->ia_gfid[i]) << j;
- j += 8;
- }
- buf->ia_ino = temp_ino;
+
+ buf->ia_ino = gfid_to_ino (buf->ia_gfid);
out:
return;
}
diff --git a/xlators/meta/src/meta-helpers.c b/xlators/meta/src/meta-helpers.c
index d01fcb3c679..e681af59bf7 100644
--- a/xlators/meta/src/meta-helpers.c
+++ b/xlators/meta/src/meta-helpers.c
@@ -185,21 +185,6 @@ meta_direct_io_mode (dict_t *xdata, call_frame_t *frame)
}
-static uint64_t
-gfid_to_ino (uuid_t gfid)
-{
- uint64_t ino = 0;
- int i = 0, j = 0;
-
- for (i = 15; i > (15 - 8); i--) {
- ino += (uint64_t)(gfid[i]) << j;
- j += 8;
- }
-
- return ino;
-}
-
-
static void
meta_uuid_copy (uuid_t dst, uuid_t src)
{
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
index 1ad9e8ebda1..0a4d3c78ead 100644
--- a/xlators/performance/md-cache/src/md-cache.c
+++ b/xlators/performance/md-cache/src/md-cache.c
@@ -99,22 +99,6 @@ static struct mdc_key {
}
};
-
-static uint64_t
-gfid_to_ino (uuid_t gfid)
-{
- uint64_t ino = 0;
- int i = 0, j = 0;
-
- for (i = 15; i > (15 - 8); i--) {
- ino += (uint64_t)(gfid[i]) << j;
- j += 8;
- }
-
- return ino;
-}
-
-
struct mdc_local;
typedef struct mdc_local mdc_local_t;
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index d6209521206..8ad674e063f 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -527,20 +527,12 @@ posix_fill_gfid_fd (xlator_t *this, int fd, struct iatt *iatt)
void
posix_fill_ino_from_gfid (xlator_t *this, struct iatt *buf)
{
- uint64_t temp_ino = 0;
- int j = 0;
- int i = 0;
-
/* consider least significant 8 bytes of value out of gfid */
if (gf_uuid_is_null (buf->ia_gfid)) {
buf->ia_ino = -1;
goto out;
}
- for (i = 15; i > (15 - 8); i--) {
- temp_ino += (uint64_t)(buf->ia_gfid[i]) << j;
- j += 8;
- }
- buf->ia_ino = temp_ino;
+ buf->ia_ino = gfid_to_ino (buf->ia_gfid);
out:
return;
}