summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2012-09-18 14:39:51 +0200
committerVijay Bellur <vbellur@redhat.com>2012-11-19 04:03:38 -0500
commit3a500f12bd38f30de2eb60438f8c4d398584f2d2 (patch)
tree2bae9f967875d9e0055fe71f9292334d3f33b9a4
parent2e3b10e3d759583cc7df963ba09eb51f60445c49 (diff)
mount/fuse: readdir() should return 32-bit inodes when 'enable-ino32' is used
From upstream commit 9cc24de746ce0e616fa09120b89aaa9a626f33cb: > The glusterfs mount option 'enable-ino32' does not change the behaviour > of readdir(). fuse_readdir_cbk() uses entry->d_ino directly, and this > was missed in commit c13823bd16b26bc471d3efb15f63b76fbfdf0309. > > By adding the function gf_fuse_fill_dirent(), the fuse_dirent structure > is filled in a similar way as the fuse_attr structure. This helper uses > the same function to squash the 64-bit inode in a 32-bit attribute. > > Change-Id: Ia20e7144613124a58691e7935cb793b6256aef79 > BUG: 850352 > URL: http://lists.nongnu.org/archive/html/gluster-devel/2012-09/msg00051.html > Tested-by: Steve Bakke <sbakke@netzyn.com> > Signed-off-by: Niels de Vos <ndevos@redhat.com> > Reviewed-on: http://review.gluster.org/3955 > Tested-by: Gluster Build System <jenkins@build.gluster.com> > Reviewed-by: Brian Foster <bfoster@redhat.com> > Reviewed-by: Anand Avati <avati@redhat.com> > Signed-off-by: Niels de Vos <ndevos@redhat.com> BUG: 876679 Change-Id: I0d6514fa6d118805b66cb942d94f40bb09045326 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: https://code.engineering.redhat.com/gerrit/1586 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c7
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.h2
-rw-r--r--xlators/mount/fuse/src/fuse-helpers.c16
3 files changed, 21 insertions, 4 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index ab76803fa1d..78f8c0125b0 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -2315,9 +2315,11 @@ fuse_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
char *buf = NULL;
gf_dirent_t *entry = NULL;
struct fuse_dirent *fde = NULL;
+ fuse_private_t *priv = NULL;
state = frame->root->state;
finh = state->finh;
+ priv = state->this->private;
if (op_ret < 0) {
gf_log ("glusterfs-fuse", GF_LOG_WARNING,
@@ -2349,10 +2351,7 @@ fuse_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
size = 0;
list_for_each_entry (entry, &entries->list, list) {
fde = (struct fuse_dirent *)(buf + size);
- fde->ino = entry->d_ino;
- fde->off = entry->d_off;
- fde->namelen = strlen (entry->d_name);
- strncpy (fde->name, entry->d_name, fde->namelen);
+ gf_fuse_fill_dirent (entry, fde, priv->enable_ino32);
size += FUSE_DIRENT_SIZE (fde);
}
diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h
index dab365d59f2..6b0ba54819f 100644
--- a/xlators/mount/fuse/src/fuse-bridge.h
+++ b/xlators/mount/fuse/src/fuse-bridge.h
@@ -345,6 +345,8 @@ fuse_state_t *get_fuse_state (xlator_t *this, fuse_in_header_t *finh);
void free_fuse_state (fuse_state_t *state);
void gf_fuse_stat2attr (struct iatt *st, struct fuse_attr *fa,
gf_boolean_t enable_ino32);
+void gf_fuse_fill_dirent (gf_dirent_t *entry, struct fuse_dirent *fde,
+ gf_boolean_t enable_ino32);
uint64_t inode_to_fuse_nodeid (inode_t *inode);
xlator_t *fuse_active_subvol (xlator_t *fuse);
inode_t *fuse_ino_to_inode (uint64_t ino, xlator_t *fuse);
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c
index b5a46944552..55b60de1cd8 100644
--- a/xlators/mount/fuse/src/fuse-helpers.c
+++ b/xlators/mount/fuse/src/fuse-helpers.c
@@ -438,6 +438,22 @@ gf_fuse_stat2attr (struct iatt *st, struct fuse_attr *fa, gf_boolean_t enable_in
#endif
}
+void
+gf_fuse_fill_dirent (gf_dirent_t *entry, struct fuse_dirent *fde, gf_boolean_t enable_ino32)
+{
+ if (enable_ino32)
+ fde->ino = GF_FUSE_SQUASH_INO(entry->d_ino);
+ else
+ fde->ino = entry->d_ino;
+
+ fde->off = entry->d_off;
+ /* fde->type was added with upstream commit bde1f0b8, not including *
+ * now to prevent a change in behaviour. *
+ * fde->type = entry->d_type; */
+ fde->namelen = strlen (entry->d_name);
+ strncpy (fde->name, entry->d_name, fde->namelen);
+}
+
static int
fuse_do_flip_xattr_ns (char *okey, const char *nns, char **nkey)
{