summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-05-19 23:31:38 -0700
committerVijay Bellur <vbellur@redhat.com>2013-05-25 11:39:20 -0700
commited11e88b77fe45acd1181728435bb644607a2b22 (patch)
treeb4dbaffba0e7692266d4e8b26d1002dd0345aebc
parent05aaec645a6262d431486eb5ac7cd702646cfcfb (diff)
gfapi: provide stable st_dev in stat structure
Samba depends on st_dev being unique and stable for different filesystems (it uses st_dev+st_ino as key to store metadata of a file). Change-Id: Ia022fabadfb5ef3fc9724c1b1ca86f1a20f98af9 BUG: 953694 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/5045 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
-rw-r--r--api/src/glfs-fops.c16
-rw-r--r--api/src/glfs-internal.h2
-rw-r--r--api/src/glfs.c2
3 files changed, 16 insertions, 4 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 0bea82a04cb..dadaf4b4d10 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -52,6 +52,14 @@ glfs_loc_link (loc_t *loc, struct iatt *iatt)
}
+static void
+glfs_iatt_to_stat (struct glfs *fs, struct iatt *iatt, struct stat *stat)
+{
+ iatt_to_stat (iatt, stat);
+ stat->st_dev = fs->dev_id;
+}
+
+
static int
glfs_loc_unlink (loc_t *loc)
{
@@ -172,7 +180,7 @@ retry:
ESTALE_RETRY (ret, errno, reval, &loc, retry);
if (ret == 0 && stat)
- iatt_to_stat (&iatt, stat);
+ glfs_iatt_to_stat (fs, &iatt, stat);
out:
loc_wipe (&loc);
@@ -203,7 +211,7 @@ retry:
ESTALE_RETRY (ret, errno, reval, &loc, retry);
if (ret == 0 && stat)
- iatt_to_stat (&iatt, stat);
+ glfs_iatt_to_stat (fs, &iatt, stat);
out:
loc_wipe (&loc);
@@ -230,7 +238,7 @@ glfs_fstat (struct glfs_fd *glfd, struct stat *stat)
ret = syncop_fstat (subvol, glfd->fd, &iatt);
if (ret == 0 && stat)
- iatt_to_stat (&iatt, stat);
+ glfs_iatt_to_stat (glfd->fs, &iatt, stat);
out:
return ret;
}
@@ -1705,7 +1713,7 @@ glfs_readdirplus_r (struct glfs_fd *glfd, struct stat *stat, struct dirent *buf,
if (entry) {
gf_dirent_to_dirent (entry, buf);
if (stat)
- iatt_to_stat (&entry->d_stat, stat);
+ glfs_iatt_to_stat (glfd->fs, &entry->d_stat, stat);
}
out:
return ret;
diff --git a/api/src/glfs-internal.h b/api/src/glfs-internal.h
index 7c622637da0..d658ce2ae19 100644
--- a/api/src/glfs-internal.h
+++ b/api/src/glfs-internal.h
@@ -38,6 +38,8 @@ struct glfs {
ssize_t oldvollen;
inode_t *cwd;
+
+ uint32_t dev_id; /* Used to fill st_dev in struct stat */
};
struct glfs_fd {
diff --git a/api/src/glfs.c b/api/src/glfs.c
index ac55628bd55..3962a39da44 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -52,6 +52,7 @@
#include "glfs.h"
#include "glfs-internal.h"
+#include "hashfn.h"
static gf_boolean_t
@@ -577,6 +578,7 @@ glfs_init_common (struct glfs *fs)
if (ret)
return ret;
+ fs->dev_id = gf_dm_hashfn (fs->volname, strlen (fs->volname));
return ret;
}