summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-06-16 07:48:22 +0000
committerAnand Avati <avati@gluster.com>2011-06-16 23:24:56 -0700
commit4e1ec35ef4f7bbf70c3e08e7c246946551f19e93 (patch)
tree0a932e17c9554a2c31be469c41190a16450b67fe /xlators/storage
parentf04898973f15cfa13fcf39a903786983885352bc (diff)
core: fill 'ia_ino' from 'ia_gfid' in 'storage/posix' to preserve same ino number
take the least significant 64bit from gfid and assign it to 'ia_ino', hence for a given file (or directory), the 'ia_ino' number is always same, and we need not worry about the 'itransform' in 'cluster/*' translators. Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 3042 (inode number should be constant on storage) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3042
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 1ef88df10..524b700f0 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -243,6 +243,21 @@ posix_fill_gfid_fd (xlator_t *this, int fd, struct iatt *iatt)
return ret;
}
+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 */
+ for (i = 15; i > (15 - 8); i--) {
+ temp_ino += buf->ia_gfid[i] << j;
+ j += 8;
+ }
+
+ buf->ia_ino = temp_ino;
+}
int
posix_lstat_with_gfid (xlator_t *this, const char *path, struct iatt *stbuf_p)
@@ -264,6 +279,8 @@ posix_lstat_with_gfid (xlator_t *this, const char *path, struct iatt *stbuf_p)
if (ret)
gf_log_callingfn (this->name, GF_LOG_DEBUG, "failed to get gfid");
+ posix_fill_ino_from_gfid (this, &stbuf);
+
if (stbuf_p)
*stbuf_p = stbuf;
out:
@@ -291,6 +308,8 @@ posix_fstat_with_gfid (xlator_t *this, int fd, struct iatt *stbuf_p)
if (ret)
gf_log_callingfn (this->name, GF_LOG_DEBUG, "failed to get gfid");
+ posix_fill_ino_from_gfid (this, &stbuf);
+
if (stbuf_p)
*stbuf_p = stbuf;
@@ -4116,10 +4135,6 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this,
break;
}
- stbuf.ia_ino = entry->d_ino;
-
- entry->d_ino = stbuf.ia_ino;
-
this_entry = gf_dirent_for_name (entry->d_name);
if (!this_entry) {
@@ -4142,6 +4157,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this,
strcpy (entry_path + real_path_len + 1,
tmp_entry->d_name);
posix_lstat_with_gfid (this, entry_path, &stbuf);
+ tmp_entry->d_ino = stbuf.ia_ino;
tmp_entry->d_stat = stbuf;
}
}