diff options
Diffstat (limited to 'xlators/mount/fuse/src/fuse-bridge.c')
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 108 |
1 files changed, 76 insertions, 32 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index fd44c4fb5f5..745617a71c1 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -29,6 +29,7 @@ static void fuse_invalidate_inode(xlator_t *this, uint64_t fuse_ino); * Send an invalidate notification up to fuse to purge the file from local * page cache. */ + static int32_t fuse_invalidate(xlator_t *this, inode_t *inode) { @@ -45,8 +46,8 @@ fuse_invalidate(xlator_t *this, inode_t *inode) return 0; nodeid = inode_to_fuse_nodeid(inode); - gf_log(this->name, GF_LOG_DEBUG, "Invalidate inode id %lu.", nodeid); - fuse_log_eh (this, "Sending invalidate inode id: %lu gfid: %s", nodeid, + gf_log(this->name, GF_LOG_DEBUG, "Invalidate inode id %"GF_PRI_INODE"." , nodeid); + fuse_log_eh (this, "Sending invalidate inode id: %"GF_PRI_INODE" gfid: %s", nodeid, uuid_utoa (inode->gfid)); fuse_invalidate_inode(this, nodeid); @@ -236,6 +237,7 @@ send_fuse_data (xlator_t *this, fuse_in_header_t *finh, void *data, size_t size) send_fuse_data (this, finh, obj, sizeof (*(obj))) +#if FUSE_KERNEL_MINOR_VERSION >= 11 static void fuse_invalidate_entry (xlator_t *this, uint64_t fuse_ino) { @@ -293,6 +295,7 @@ fuse_invalidate_entry (xlator_t *this, uint64_t fuse_ino) if (inode) inode_unref (inode); } +#endif /* * Send an inval inode notification to fuse. This causes an invalidation of the @@ -301,6 +304,7 @@ fuse_invalidate_entry (xlator_t *this, uint64_t fuse_ino) static void fuse_invalidate_inode(xlator_t *this, uint64_t fuse_ino) { +#if FUSE_KERNEL_MINOR_VERSION >= 11 struct fuse_out_header *fouh = NULL; struct fuse_notify_inval_inode_out *fniio = NULL; fuse_private_t *priv = NULL; @@ -346,8 +350,13 @@ fuse_invalidate_inode(xlator_t *this, uint64_t fuse_ino) if (inode) inode_unref (inode); +#else + gf_log ("glusterfs-fuse", GF_LOG_WARNING, + "fuse_invalidate_inode not implemented on OS X due to missing FUSE notification"); +#endif } + int send_fuse_err (xlator_t *this, fuse_in_header_t *finh, int error) { @@ -368,7 +377,7 @@ send_fuse_err (xlator_t *this, fuse_in_header_t *finh, int error) uuid_utoa (inode->gfid)); } else { fuse_log_eh (this, "Sending %s for operation %d on " - "inode %ld", strerror (error), + "inode %" GF_PRI_INODE, strerror (error), finh->opcode, finh->nodeid); } } @@ -624,6 +633,7 @@ fuse_forget (xlator_t *this, fuse_in_header_t *finh, void *msg) GF_FREE (finh); } +#if FUSE_KERNEL_MINOR_VERSION >= 16 static void fuse_batch_forget(xlator_t *this, fuse_in_header_t *finh, void *msg) { @@ -640,9 +650,9 @@ fuse_batch_forget(xlator_t *this, fuse_in_header_t *finh, void *msg) continue; do_forget(this, finh->unique, ffo[i].nodeid, ffo[i].nlookup); } - GF_FREE(finh); } +#endif static int fuse_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -1142,7 +1152,9 @@ fuse_setattr (xlator_t *this, fuse_in_header_t *finh, void *msg) { struct fuse_setattr_in *fsi = msg; +#if FUSE_KERNEL_MINOR_VERSION >= 9 fuse_private_t *priv = NULL; +#endif fuse_state_t *state = NULL; GET_STATE (this, finh, state); @@ -1170,8 +1182,8 @@ fuse_setattr (xlator_t *this, fuse_in_header_t *finh, void *msg) * http://git.kernel.org/?p=linux/kernel/git/torvalds/ * linux-2.6.git;a=commit;h=v2.6.23-5896-gf333211 */ - priv = this->private; #if FUSE_KERNEL_MINOR_VERSION >= 9 + priv = this->private; if (priv->proto_minor >= 9 && fsi->valid & FATTR_LOCKOWNER) state->lk_owner = fsi->lock_owner; #endif @@ -1448,11 +1460,11 @@ fuse_mknod (xlator_t *this, fuse_in_header_t *finh, void *msg) char *name = (char *)(fmi + 1); fuse_state_t *state = NULL; +#if FUSE_KERNEL_MINOR_VERSION >= 12 fuse_private_t *priv = NULL; - int32_t ret = -1; + int32_t ret = -1; priv = this->private; -#if FUSE_KERNEL_MINOR_VERSION >= 12 if (priv->proto_minor < 12) name = (char *)msg + FUSE_COMPAT_MKNOD_IN_SIZE; #endif @@ -1466,8 +1478,8 @@ fuse_mknod (xlator_t *this, fuse_in_header_t *finh, void *msg) state->mode = fmi->mode; state->rdev = fmi->rdev; - priv = this->private; #if FUSE_KERNEL_MINOR_VERSION >=12 + priv = this->private; FUSE_ENTRY_CREATE(this, priv, finh, state, fmi, "MKNOD"); #endif @@ -1515,10 +1527,12 @@ fuse_mkdir (xlator_t *this, fuse_in_header_t *finh, void *msg) { struct fuse_mkdir_in *fmi = msg; char *name = (char *)(fmi + 1); +#if FUSE_KERNEL_MINOR_VERSION >=12 fuse_private_t *priv = NULL; + int32_t ret = -1; +#endif fuse_state_t *state; - int32_t ret = -1; GET_STATE (this, finh, state); @@ -1528,8 +1542,8 @@ fuse_mkdir (xlator_t *this, fuse_in_header_t *finh, void *msg) state->mode = fmi->mode; - priv = this->private; #if FUSE_KERNEL_MINOR_VERSION >=12 + priv = this->private; FUSE_ENTRY_CREATE(this, priv, finh, state, fmi, "MKDIR"); #endif @@ -2004,17 +2018,17 @@ fuse_create (xlator_t *this, fuse_in_header_t *finh, void *msg) { #if FUSE_KERNEL_MINOR_VERSION >= 12 struct fuse_create_in *fci = msg; + fuse_private_t *priv = NULL; + int32_t ret = -1; #else struct fuse_open_in *fci = msg; #endif char *name = (char *)(fci + 1); - fuse_private_t *priv = NULL; fuse_state_t *state = NULL; - int32_t ret = -1; - priv = this->private; #if FUSE_KERNEL_MINOR_VERSION >= 12 + priv = this->private; if (priv->proto_minor < 12) name = (char *)((struct fuse_open_in *)msg + 1); #endif @@ -2028,8 +2042,8 @@ fuse_create (xlator_t *this, fuse_in_header_t *finh, void *msg) state->mode = fci->mode; state->flags = fci->flags; - priv = this->private; #if FUSE_KERNEL_MINOR_VERSION >=12 + priv = this->private; FUSE_ENTRY_CREATE(this, priv, finh, state, fci, "CREATE"); #endif fuse_resolve_and_resume (state, fuse_create_resume); @@ -2167,7 +2181,9 @@ fuse_readv (xlator_t *this, fuse_in_header_t *finh, void *msg) { struct fuse_read_in *fri = msg; +#if FUSE_KERNEL_MINOR_VERSION >= 9 fuse_private_t *priv = NULL; +#endif fuse_state_t *state = NULL; fd_t *fd = NULL; @@ -2179,8 +2195,8 @@ fuse_readv (xlator_t *this, fuse_in_header_t *finh, void *msg) fuse_resolve_fd_init (state, &state->resolve, fd); /* See comment by similar code in fuse_settatr */ - priv = this->private; #if FUSE_KERNEL_MINOR_VERSION >= 9 + priv = this->private; if (priv->proto_minor >= 9 && fri->read_flags & FUSE_READ_LOCKOWNER) state->lk_owner = fri->lock_owner; #endif @@ -2188,8 +2204,9 @@ fuse_readv (xlator_t *this, fuse_in_header_t *finh, void *msg) state->size = fri->size; state->off = fri->offset; /* lets ignore 'fri->read_flags', but just consider 'fri->flags' */ +#if FUSE_KERNEL_MINOR_VERSION >= 9 state->io_flags = fri->flags; - +#endif fuse_resolve_and_resume (state, fuse_readv_resume); } @@ -2270,11 +2287,12 @@ fuse_write (xlator_t *this, fuse_in_header_t *finh, void *msg) struct fuse_write_in *fwi = (struct fuse_write_in *) (finh + 1); - fuse_private_t *priv = NULL; fuse_state_t *state = NULL; fd_t *fd = NULL; - +#if FUSE_KERNEL_MINOR_VERSION >= 9 + fuse_private_t *priv = NULL; priv = this->private; +#endif GET_STATE (this, finh, state); fd = FH_TO_FD (fwi->fh); @@ -2283,7 +2301,11 @@ fuse_write (xlator_t *this, fuse_in_header_t *finh, void *msg) state->off = fwi->offset; /* lets ignore 'fwi->write_flags', but just consider 'fwi->flags' */ +#if FUSE_KERNEL_MINOR_VERSION >= 9 state->io_flags = fwi->flags; +#else + state->io_flags = fwi->write_flags; +#endif /* TODO: may need to handle below flag (fwi->write_flags & FUSE_WRITE_CACHE); */ @@ -2292,8 +2314,8 @@ fuse_write (xlator_t *this, fuse_in_header_t *finh, void *msg) fuse_resolve_fd_init (state, &state->resolve, fd); /* See comment by similar code in fuse_settatr */ - priv = this->private; #if FUSE_KERNEL_MINOR_VERSION >= 9 + priv = this->private; if (priv->proto_minor >= 9 && fwi->write_flags & FUSE_WRITE_LOCKOWNER) state->lk_owner = fwi->lock_owner; #endif @@ -2636,7 +2658,7 @@ fuse_readdir (xlator_t *this, fuse_in_header_t *finh, void *msg) fuse_resolve_and_resume (state, fuse_readdir_resume); } - +#if FUSE_KERNEL_MINOR_VERSION >= 20 static int fuse_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, @@ -2751,7 +2773,6 @@ out: } - void fuse_readdirp_resume (fuse_state_t *state) { @@ -2782,7 +2803,9 @@ fuse_readdirp (xlator_t *this, fuse_in_header_t *finh, void *msg) fuse_resolve_and_resume (state, fuse_readdirp_resume); } +#endif +#if FUSE_KERNEL_MINOR_VERSION >= 19 #ifdef FALLOC_FL_KEEP_SIZE static int fuse_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, @@ -2825,7 +2848,7 @@ fuse_fallocate(xlator_t *this, fuse_in_header_t *finh, void *msg) fuse_resolve_and_resume(state, fuse_fallocate_resume); } #endif /* FALLOC_FL_KEEP_SIZE */ - +#endif /* FUSE minor version >= 19 */ static void fuse_releasedir (xlator_t *this, fuse_in_header_t *finh, void *msg) @@ -3097,7 +3120,9 @@ fuse_setxattr (xlator_t *this, fuse_in_header_t *finh, void *msg) gf_log ("fuse", GF_LOG_TRACE, "got request to invalidate %"PRIu64, finh->nodeid); send_fuse_err (this, finh, 0); +#if FUSE_KERNEL_MINOR_VERSION >= 11 fuse_invalidate_entry (this, finh->nodeid); +#endif GF_FREE (finh); return; } @@ -3746,7 +3771,7 @@ fuse_setlk (xlator_t *this, fuse_in_header_t *finh, void *msg) return; } - +#if FUSE_KERNEL_MINOR_VERSION >= 11 static void * notify_kernel_loop (void *data) { @@ -3782,7 +3807,7 @@ notify_kernel_loop (void *data) return NULL; } - +#endif static void fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg) @@ -3791,8 +3816,10 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg) struct fuse_init_out fino = {0,}; fuse_private_t *priv = NULL; int ret = 0; +#if FUSE_KERNEL_MINOR_VERSION >= 9 int pfd[2] = {0,}; pthread_t messenger; +#endif priv = this->private; @@ -3885,16 +3912,17 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg) } if (fini->minor < 9) *priv->msg0_len_p = sizeof(*finh) + FUSE_COMPAT_WRITE_IN_SIZE; -#endif + if (priv->use_readdirp) { if (fini->flags & FUSE_DO_READDIRPLUS) fino.flags |= FUSE_DO_READDIRPLUS; } - +#endif if (priv->fopen_keep_cache == 2) { /* If user did not explicitly set --fopen-keep-cache[=off], then check if kernel support FUSE_AUTO_INVAL_DATA and ... */ +#if FUSE_KERNEL_MINOR_VERSION >= 20 if (fini->flags & FUSE_AUTO_INVAL_DATA) { /* ... enable fopen_keep_cache mode if supported. */ @@ -3903,7 +3931,10 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg) "fopen_keep_cache automatically."); fino.flags |= FUSE_AUTO_INVAL_DATA; priv->fopen_keep_cache = 1; - } else { + } else +#endif + { + gf_log ("glusterfs-fuse", GF_LOG_DEBUG, "No support " "for FUSE_AUTO_INVAL_DATA. Disabling " "fopen_keep_cache."); @@ -3914,20 +3945,24 @@ fuse_init (xlator_t *this, fuse_in_header_t *finh, void *msg) /* If user explicitly set --fopen-keep-cache[=on], then enable FUSE_AUTO_INVAL_DATA if possible. */ +#if FUSE_KERNEL_MINOR_VERSION >= 20 if (fini->flags & FUSE_AUTO_INVAL_DATA) { gf_log ("glusterfs-fuse", GF_LOG_DEBUG, "fopen_keep_cache " "is explicitly set. Enabling FUSE_AUTO_INVAL_DATA"); fino.flags |= FUSE_AUTO_INVAL_DATA; - } else { + } else +#endif + { gf_log ("glusterfs-fuse", GF_LOG_WARNING, "fopen_keep_cache " "is explicitly set. Support for " "FUSE_AUTO_INVAL_DATA is missing"); } } +#if FUSE_KERNEL_MINOR_VERSION >= 22 if (fini->flags & FUSE_ASYNC_DIO) fino.flags |= FUSE_ASYNC_DIO; - +#endif ret = send_fuse_obj (this, finh, &fino); if (ret == 0) gf_log ("glusterfs-fuse", GF_LOG_INFO, @@ -5142,11 +5177,20 @@ static fuse_handler_t *fuse_std_ops[FUSE_OP_HIGH] = { /* [FUSE_IOCTL] */ /* [FUSE_POLL] */ /* [FUSE_NOTIFY_REPLY] */ + +#if FUSE_KERNEL_MINOR_VERSION >= 16 [FUSE_BATCH_FORGET]= fuse_batch_forget, +#endif + +#if FUSE_KERNEL_MINOR_VERSION >= 19 #ifdef FALLOC_FL_KEEP_SIZE [FUSE_FALLOCATE] = fuse_fallocate, #endif /* FALLOC_FL_KEEP_SIZE */ +#endif + +#if FUSE_KERNEL_MINOR_VERSION >= 21 [FUSE_READDIRPLUS] = fuse_readdirp, +#endif }; @@ -5279,13 +5323,13 @@ init (xlator_t *this_xl) goto cleanup_exit; } - GF_OPTION_INIT ("attribute-timeout", priv->attribute_timeout, double, + GF_OPTION_INIT (ZR_ATTR_TIMEOUT_OPT, priv->attribute_timeout, double, cleanup_exit); - GF_OPTION_INIT ("entry-timeout", priv->entry_timeout, double, + GF_OPTION_INIT (ZR_ENTRY_TIMEOUT_OPT, priv->entry_timeout, double, cleanup_exit); - GF_OPTION_INIT ("negative-timeout", priv->negative_timeout, double, + GF_OPTION_INIT (ZR_NEGATIVE_TIMEOUT_OPT, priv->negative_timeout, double, cleanup_exit); GF_OPTION_INIT ("client-pid", priv->client_pid, int32, cleanup_exit); |