From fbb9ad5030abf058ce75af1890b7ec1be77d22f9 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 3 Sep 2012 13:34:22 +0200 Subject: 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: I7544010a27b7eb2d3b9fadb84ed934e4e7dff21e BUG: 850352 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/3886 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- glusterfsd/src/glusterfsd.c | 17 +++++++++++ glusterfsd/src/glusterfsd.h | 1 + libglusterfs/src/glusterfs.h | 1 + xlators/mount/fuse/src/fuse-bridge.c | 17 ++++++++--- xlators/mount/fuse/src/fuse-bridge.h | 4 ++- xlators/mount/fuse/src/fuse-helpers.c | 47 +++++++++++++++++------------ xlators/mount/fuse/utils/mount.glusterfs.in | 13 +++++--- 7 files changed, 70 insertions(+), 30 deletions(-) diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index ebd12bf0b..5130bcf34 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -154,6 +154,9 @@ static struct argp_option gf_options[] = { "Mount the filesystem with POSIX ACL support"}, {"selinux", ARGP_SELINUX_KEY, 0, 0, "Enable SELinux label (extened attributes) support on inodes"}, + {"enable-ino32", ARGP_INODE32_KEY, "BOOL", OPTION_ARG_OPTIONAL, + "Use 32-bit inodes when mounting to workaround broken applications" + "that don't support 64-bit inodes"}, {"worm", ARGP_WORM_KEY, 0, 0, "Mount the filesystem in 'worm' mode"}, {"mac-compat", ARGP_MAC_COMPAT_KEY, "BOOL", OPTION_ARG_OPTIONAL, @@ -359,6 +362,15 @@ create_fuse_mount (glusterfs_ctx_t *ctx) } } + if (cmd_args->enable_ino32) { + ret = dict_set_static_ptr (master->options, "enable-ino32", "on"); + if (ret < 0) { + gf_log ("glusterfsd", GF_LOG_ERROR, + "failed to set 'on' for key enable-ino32"); + goto err; + } + } + if (cmd_args->read_only) { ret = dict_set_static_ptr (master->options, "read-only", "on"); if (ret < 0) { @@ -579,6 +591,10 @@ parse_opts (int key, char *arg, struct argp_state *state) cmd_args->selinux = 1; break; + case ARGP_INODE32_KEY: + cmd_args->enable_ino32 = 1; + break; + case ARGP_WORM_KEY: cmd_args->worm = 1; break; @@ -1106,6 +1122,7 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) cmd_args->log_level = DEFAULT_LOG_LEVEL; cmd_args->mac_compat = GF_OPTION_DISABLE; + cmd_args->enable_ino32 = GF_OPTION_DISABLE; #ifdef GF_DARWIN_HOST_OS /* On Darwin machines, O_APPEND is not handled, * which may corrupt the data diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h index 8ec121954..d576121ce 100644 --- a/glusterfsd/src/glusterfsd.h +++ b/glusterfsd/src/glusterfsd.h @@ -87,6 +87,7 @@ enum argp_option_keys { ARGP_USER_MAP_ROOT_KEY = 156, ARGP_MEM_ACCOUNTING_KEY = 157, ARGP_SELINUX_KEY = 158, + ARGP_INODE32_KEY = 159, }; struct _gfd_vol_top_priv_t { diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 8d6abdb04..035bb7c0e 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -297,6 +297,7 @@ struct _cmd_args { int read_only; int acl; int selinux; + int enable_ino32; int worm; int mac_compat; struct list_head xlator_options; /* list of xlator_option_t */ diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 51e644269..ed24c7382 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -246,7 +246,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, @@ -437,7 +437,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 = @@ -489,7 +489,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 = @@ -761,7 +761,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 = @@ -1673,7 +1673,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); @@ -4515,6 +4515,13 @@ init (xlator_t *this_xl) GF_ASSERT (ret == 0); } + priv->enable_ino32 = 0; + ret = dict_get_str (options, "enable-ino32", &value_string); + if (ret == 0) { + ret = gf_string2boolean (value_string, &priv->enable_ino32); + GF_ASSERT (ret == 0); + } + priv->fuse_dump_fd = -1; ret = dict_get_str (options, "dump-fuse", &value_string); if (ret == 0) { diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h index eb43e6686..4811ad120 100644 --- a/xlators/mount/fuse/src/fuse-bridge.h +++ b/xlators/mount/fuse/src/fuse-bridge.h @@ -109,6 +109,7 @@ struct fuse_private { gf_boolean_t acl; gf_boolean_t selinux; gf_boolean_t read_only; + gf_boolean_t enable_ino32; fdtable_t *fdtable; /* For fuse-reverse-validation */ @@ -342,7 +343,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 feec23998..e0a63e4c3 100644 --- a/xlators/mount/fuse/src/fuse-helpers.c +++ b/xlators/mount/fuse/src/fuse-helpers.c @@ -403,32 +403,39 @@ fail: } +/* 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 381a61bd9..0ed0af882 100755 --- a/xlators/mount/fuse/utils/mount.glusterfs.in +++ b/xlators/mount/fuse/utils/mount.glusterfs.in @@ -83,6 +83,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 @@ -278,10 +282,11 @@ 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 ;; + "enable-ino32") enable_ino32=1 ;; # "mount -t glusterfs" sends this, but it's useless. "rw") ;; *) -- cgit