diff options
author | Niels de Vos <ndevos@redhat.com> | 2012-09-03 12:49:21 +0200 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-09-06 18:32:26 -0700 |
commit | c13823bd16b26bc471d3efb15f63b76fbfdf0309 (patch) | |
tree | 0195ee6b28ba6732bc579b5aa09624f0f2f38042 /xlators | |
parent | baddf332d589d29d9bcb18d11dcbb875650e4298 (diff) |
mount/fuse: add mount-option "enable-ino32" for the native client
By default the GlusterFS-native client uses 64-bit inodes. Some 32-bit
applications can not handle these correctly. Introduce a client-side
mount option "enable-ino32" which causes the FUSE-client to squash the
64-bit inodes into a 32-bit value.
Change-Id: I3296d16528bfb50457b9675f6b8701234ed82ff0
BUG: 850352
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/3885
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 16 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.h | 4 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-helpers.c | 46 | ||||
-rwxr-xr-x | xlators/mount/fuse/utils/mount.glusterfs.in | 13 |
4 files changed, 49 insertions, 30 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 65a479aed8b..726e500e9e4 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -306,7 +306,7 @@ fuse_entry_cbk (call_frame_t *frame, void *cookie, xlator_t *this, state->loc.path, buf->ia_ino); buf->ia_blksize = this->ctx->page_size; - gf_fuse_stat2attr (buf, &feo.attr); + gf_fuse_stat2attr (buf, &feo.attr, priv->enable_ino32); if (!buf->ia_ino) { gf_log ("glusterfs-fuse", GF_LOG_WARNING, @@ -513,7 +513,7 @@ fuse_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, prebuf->ia_ino); postbuf->ia_blksize = this->ctx->page_size; - gf_fuse_stat2attr (postbuf, &fao.attr); + gf_fuse_stat2attr (postbuf, &fao.attr, priv->enable_ino32); fao.attr_valid = calc_timeout_sec (priv->attribute_timeout); fao.attr_valid_nsec = @@ -565,7 +565,7 @@ fuse_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, buf->ia_ino); buf->ia_blksize = this->ctx->page_size; - gf_fuse_stat2attr (buf, &fao.attr); + gf_fuse_stat2attr (buf, &fao.attr, priv->enable_ino32); fao.attr_valid = calc_timeout_sec (priv->attribute_timeout); fao.attr_valid_nsec = @@ -847,7 +847,7 @@ fuse_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, statpost->ia_ino); statpost->ia_blksize = this->ctx->page_size; - gf_fuse_stat2attr (statpost, &fao.attr); + gf_fuse_stat2attr (statpost, &fao.attr, priv->enable_ino32); fao.attr_valid = calc_timeout_sec (priv->attribute_timeout); fao.attr_valid_nsec = @@ -1767,7 +1767,7 @@ fuse_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, state->loc.path, fd, buf->ia_ino); buf->ia_blksize = this->ctx->page_size; - gf_fuse_stat2attr (buf, &feo.attr); + gf_fuse_stat2attr (buf, &feo.attr, priv->enable_ino32); linked_inode = inode_link (inode, state->loc.parent, state->loc.name, buf); @@ -4622,6 +4622,8 @@ init (xlator_t *this_xl) GF_OPTION_INIT ("read-only", priv->read_only, bool, cleanup_exit); + GF_OPTION_INIT ("enable-ino32", priv->enable_ino32, bool, cleanup_exit); + priv->fuse_dump_fd = -1; ret = dict_get_str (options, "dump-fuse", &value_string); if (ret == 0) { @@ -4868,6 +4870,10 @@ struct volume_options options[] = { .type = GF_OPTION_TYPE_BOOL, .default_value = "false" }, + { .key = {"enable-ino32"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "false" + }, { .key = {"background-qlen"}, .type = GF_OPTION_TYPE_INT, .default_value = "64", diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h index 63ec5d2ef1e..3f45f064463 100644 --- a/xlators/mount/fuse/src/fuse-bridge.h +++ b/xlators/mount/fuse/src/fuse-bridge.h @@ -104,6 +104,7 @@ struct fuse_private { gf_boolean_t read_only; gf_boolean_t fopen_keep_cache; int32_t gid_cache_timeout; + gf_boolean_t enable_ino32; fdtable_t *fdtable; gid_cache_t gid_cache; @@ -413,7 +414,8 @@ fuse_loc_fill (loc_t *loc, fuse_state_t *state, ino_t ino, call_frame_t *get_call_frame_for_req (fuse_state_t *state); 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); +void gf_fuse_stat2attr (struct iatt *st, struct fuse_attr *fa, + 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 d97cb16154e..b990cffe4c7 100644 --- a/xlators/mount/fuse/src/fuse-helpers.c +++ b/xlators/mount/fuse/src/fuse-helpers.c @@ -430,33 +430,39 @@ fail: return ret; } +/* Use the same logic as the Linux NFS-client */ +#define GF_FUSE_SQUASH_INO(ino) ((uint32_t) ino) ^ (ino >> 32) /* courtesy of folly */ void -gf_fuse_stat2attr (struct iatt *st, struct fuse_attr *fa) +gf_fuse_stat2attr (struct iatt *st, struct fuse_attr *fa, gf_boolean_t enable_ino32) { - fa->ino = st->ia_ino; - fa->size = st->ia_size; - fa->blocks = st->ia_blocks; - fa->atime = st->ia_atime; - fa->mtime = st->ia_mtime; - fa->ctime = st->ia_ctime; - fa->atimensec = st->ia_atime_nsec; - fa->mtimensec = st->ia_mtime_nsec; - fa->ctimensec = st->ia_ctime_nsec; - fa->mode = st_mode_from_ia (st->ia_prot, st->ia_type); - fa->nlink = st->ia_nlink; - fa->uid = st->ia_uid; - fa->gid = st->ia_gid; - fa->rdev = makedev (ia_major (st->ia_rdev), - ia_minor (st->ia_rdev)); + if (enable_ino32) + fa->ino = GF_FUSE_SQUASH_INO(st->ia_ino); + else + fa->ino = st->ia_ino; + + fa->size = st->ia_size; + fa->blocks = st->ia_blocks; + fa->atime = st->ia_atime; + fa->mtime = st->ia_mtime; + fa->ctime = st->ia_ctime; + fa->atimensec = st->ia_atime_nsec; + fa->mtimensec = st->ia_mtime_nsec; + fa->ctimensec = st->ia_ctime_nsec; + fa->mode = st_mode_from_ia (st->ia_prot, st->ia_type); + fa->nlink = st->ia_nlink; + fa->uid = st->ia_uid; + fa->gid = st->ia_gid; + fa->rdev = makedev (ia_major (st->ia_rdev), + ia_minor (st->ia_rdev)); #if FUSE_KERNEL_MINOR_VERSION >= 9 - fa->blksize = st->ia_blksize; + fa->blksize = st->ia_blksize; #endif #ifdef GF_DARWIN_HOST_OS - fa->crtime = (uint64_t)-1; - fa->crtimensec = (uint32_t)-1; - fa->flags = 0; + fa->crtime = (uint64_t)-1; + fa->crtimensec = (uint32_t)-1; + fa->flags = 0; #endif } diff --git a/xlators/mount/fuse/utils/mount.glusterfs.in b/xlators/mount/fuse/utils/mount.glusterfs.in index cb0f65b8e93..9b9c0f81b6f 100755 --- a/xlators/mount/fuse/utils/mount.glusterfs.in +++ b/xlators/mount/fuse/utils/mount.glusterfs.in @@ -104,6 +104,10 @@ start_glusterfs () cmd_line=$(echo "$cmd_line --selinux"); fi + if [ -n "$enable_ino32" ]; then + cmd_line=$(echo "$cmd_line --enable-ino32"); + fi + if [ -n "$worm" ]; then cmd_line=$(echo "$cmd_line --worm"); fi @@ -313,11 +317,12 @@ main () for pair in $(echo "$opt" | tr "," " "); do # Handle options without values. case "$pair" in - "ro") read_only=1 ;; - "acl") acl=1 ;; - "selinux") selinux=1 ;; - "worm") worm=1 ;; + "ro") read_only=1 ;; + "acl") acl=1 ;; + "selinux") selinux=1 ;; + "worm") worm=1 ;; "fopen-keep-cache") fopen_keep_cache=1 ;; + "enable-ino32") enable_ino32=1 ;; # "mount -t glusterfs" sends this, but it's useless. "rw") ;; # these ones are interpreted during system initialization |