diff options
author | Csaba Henk <csaba@gluster.com> | 2009-12-06 14:27:57 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-12-06 12:39:15 -0800 |
commit | 76d6f3fbe993dddd72540f461090803636fa2dc5 (patch) | |
tree | 6f5573d88eb296b153aed466a505d3f3fe3c2c1e | |
parent | 33f3abffe4f0de929d3732a472ad3df766d575b7 (diff) |
fuse-bridge: make use of lock owner data in a protocol adherent way.
No need for pid fallback, for those cases where we use it,
it's always available.
It appears conditionally in read/write/truncate (related to mandatory
locking). There just get it for demonstrative purposes.
Discard it from release, there locking data exists only as a
portability hack, no use of it on Linux.
Signed-off-by: Csaba Henk <csaba@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 336 (Use lock owner field from fuse in locks)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=336
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 857686ad2..db7362ff9 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -222,20 +222,6 @@ get_state (xlator_t *this, fuse_in_header_t *finh) } -void -set_lock_owner (fuse_state_t *state, xlator_t *this, - uint64_t owner, uint64_t pid) -{ - fuse_private_t *priv = NULL; - - priv = this->private; - - if (priv->proto_minor >= 9) - state->lk_owner = owner; - else - state->lk_owner = pid; -} - static call_frame_t * get_call_frame_for_req (fuse_state_t *state) { @@ -998,6 +984,7 @@ fuse_setattr (xlator_t *this, fuse_in_header_t *finh, void *msg) struct stat attr = {0, }; + fuse_private_t *priv = NULL; fuse_state_t *state = NULL; int32_t ret = -1; int32_t valid = 0; @@ -1006,7 +993,22 @@ fuse_setattr (xlator_t *this, fuse_in_header_t *finh, void *msg) ret = fuse_loc_fill (&state->loc, state, finh->nodeid, 0, NULL); - set_lock_owner (state, this, fsi->lock_owner, (uint64_t) finh->pid); + /* + * This is just stub code demonstrating how to retrieve + * lock_owner in setattr, according to the FUSE proto. + * We do not make use of ATM. Its purpose is supporting + * mandatory locking, but getting that right is further + * down the road. Cf. + * + * http://thread.gmane.org/gmane.comp.file-systems.fuse.devel/ + * 4962/focus=4982 + * + * 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 (priv->proto_minor >= 9 && fsi->valid & FATTR_LOCKOWNER) + state->lk_owner = fsi->lock_owner; if ((state->loc.inode == NULL) || (ret < 0)) { @@ -1851,6 +1853,7 @@ fuse_readv (xlator_t *this, fuse_in_header_t *finh, void *msg) { struct fuse_read_in *fri = msg; + fuse_private_t *priv = NULL; fuse_state_t *state = NULL; fd_t *fd = NULL; @@ -1862,7 +1865,10 @@ fuse_readv (xlator_t *this, fuse_in_header_t *finh, void *msg) fd = FH_TO_FD (fri->fh); state->fd = fd; - set_lock_owner (state, this, fri->lock_owner, (uint64_t) finh->pid); + /* See comment by similar code in fuse_settatr */ + priv = this->private; + if (priv->proto_minor >= 9 && fri->read_flags & FUSE_READ_LOCKOWNER) + state->lk_owner = fri->lock_owner; gf_log ("glusterfs-fuse", GF_LOG_TRACE, "%"PRIu64": READ (%p, size=%"PRIu32", offset=%"PRIu64")", @@ -1935,7 +1941,10 @@ fuse_write (xlator_t *this, fuse_in_header_t *finh, void *msg) vector.iov_base = msg; vector.iov_len = fwi->size; - set_lock_owner (state, this, fwi->lock_owner, (uint64_t) finh->pid); + /* See comment by similar code in fuse_settatr */ + priv = this->private; + if (priv->proto_minor >= 9 && fwi->write_flags & FUSE_READ_LOCKOWNER) + state->lk_owner = fwi->lock_owner; gf_log ("glusterfs-fuse", GF_LOG_TRACE, "%"PRIu64": WRITE (%p, size=%"PRIu32", offset=%"PRId64")", @@ -1975,7 +1984,7 @@ fuse_flush (xlator_t *this, fuse_in_header_t *finh, void *msg) if (fd) fd->flush_unique = finh->unique; - set_lock_owner (state, this, ffi->lock_owner, (uint64_t) finh->pid); + state->lk_owner = ffi->lock_owner; gf_log ("glusterfs-fuse", GF_LOG_TRACE, "%"PRIu64": FLUSH %p", finh->unique, fd); @@ -2001,8 +2010,6 @@ fuse_release (xlator_t *this, fuse_in_header_t *finh, void *msg) fd = FH_TO_FD (fri->fh); state->fd = fd; - set_lock_owner (state, this, fri->lock_owner, (uint64_t) finh->pid); - #ifdef GF_LINUX_HOST_OS /* This is an ugly Linux specific hack, relying on subtle * implementation details. @@ -2778,7 +2785,7 @@ fuse_getlk (xlator_t *this, fuse_in_header_t *finh, void *msg) state->fd = fd; convert_fuse_file_lock (&fli->lk, &lock); - set_lock_owner (state, this, fli->owner, (uint64_t) finh->pid); + state->lk_owner = fli->owner; gf_log ("glusterfs-fuse", GF_LOG_TRACE, "%"PRIu64": GETLK %p", finh->unique, fd); @@ -2851,7 +2858,7 @@ fuse_setlk (xlator_t *this, fuse_in_header_t *finh, void *msg) state->fd = fd; convert_fuse_file_lock (&fli->lk, &lock); - set_lock_owner (state, this, fli->owner, (uint64_t) finh->pid); + state->lk_owner = fli->owner; gf_log ("glusterfs-fuse", GF_LOG_TRACE, "%"PRIu64": SETLK%s %p", finh->unique, |