From b5a6d4bd97800dd00849677c2ace4417dd914ccc Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Tue, 29 Jan 2013 23:56:25 -0800 Subject: fuse-bridge: fix some breakages from lock migration patch - do not attempt lock migration if no locks were ever acquired on an fd. - fix fd_lk_ctx_t ref leak during fd migration - remove spurious fd_unref() (probably added to compensate for the fd_ref leak in syncop_open_cbk) - remove @newfdptr out-param which makes fd ref management really tricky (and currently refs were unmanaged for the out-param). Instead acquire ref and unref within lock migration function. Change-Id: I4cc9c451f0df4c051612bd1fa7bef11e801570e4 BUG: 808400 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/4453 Tested-by: Gluster Build System Reviewed-by: Raghavendra Bhat --- xlators/mount/fuse/src/fuse-bridge.c | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'xlators/mount') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 65df6713..25545b78 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -3710,8 +3710,7 @@ out: int fuse_migrate_fd_open (xlator_t *this, fd_t *basefd, fd_t *oldfd, - xlator_t *old_subvol, xlator_t *new_subvol, - fd_t **newfdptr) + xlator_t *old_subvol, xlator_t *new_subvol) { loc_t loc = {0, }; fd_t *newfd = NULL, *old_activefd = NULL; @@ -3765,6 +3764,9 @@ fuse_migrate_fd_open (xlator_t *this, fd_t *basefd, fd_t *oldfd, goto out; } + if (newfd->lk_ctx) + fd_lk_ctx_unref (newfd->lk_ctx); + newfd->lk_ctx = fd_lk_ctx_ref (oldfd->lk_ctx); newfd_ctx = fuse_fd_ctx_check_n_create (this, newfd); @@ -3810,10 +3812,6 @@ fuse_migrate_fd_open (xlator_t *this, fd_t *basefd, fd_t *oldfd, old_subvol->name, old_subvol->graph->id, new_subvol->name, new_subvol->graph->id); - if (newfdptr != NULL) { - *newfdptr = newfd; - } - ret = 0; out: @@ -3823,12 +3821,27 @@ out: } int -fuse_migrate_locks (xlator_t *this, fd_t *oldfd, fd_t *newfd, +fuse_migrate_locks (xlator_t *this, fd_t *basefd, fd_t *oldfd, xlator_t *old_subvol, xlator_t *new_subvol) { int ret = -1; dict_t *lockinfo = NULL; void *ptr = NULL; + fd_t *newfd = NULL; + fuse_fd_ctx_t *basefd_ctx = NULL; + + + if (!oldfd->lk_ctx || fd_lk_ctx_empty (oldfd->lk_ctx)) + return 0; + + basefd_ctx = fuse_fd_ctx_get (this, basefd); + GF_VALIDATE_OR_GOTO ("glusterfs-fuse", basefd_ctx, out); + + LOCK (&basefd->lock); + { + newfd = fd_ref (basefd_ctx->activefd); + } + UNLOCK (&basefd->lock); ret = syncop_fgetxattr (old_subvol, oldfd, &lockinfo, GF_XATTR_LOCKINFO_KEY); @@ -3869,6 +3882,9 @@ fuse_migrate_locks (xlator_t *this, fd_t *oldfd, fd_t *newfd, } out: + if (newfd) + fd_unref (newfd); + if (lockinfo != NULL) { dict_unref (lockinfo); } @@ -3884,7 +3900,7 @@ fuse_migrate_fd (xlator_t *this, fd_t *basefd, xlator_t *old_subvol, int ret = -1; char create_in_progress = 0; fuse_fd_ctx_t *basefd_ctx = NULL; - fd_t *oldfd = NULL, *newfdptr = NULL; + fd_t *oldfd = NULL; basefd_ctx = fuse_fd_ctx_get (this, basefd); GF_VALIDATE_OR_GOTO ("glusterfs-fuse", basefd_ctx, out); @@ -3945,7 +3961,7 @@ fuse_migrate_fd (xlator_t *this, fd_t *basefd, xlator_t *old_subvol, } ret = fuse_migrate_fd_open (this, basefd, oldfd, old_subvol, - new_subvol, &newfdptr); + new_subvol); if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "open corresponding to " "basefd (ptr:%p inode-gfid:%s) in new graph failed " @@ -3956,15 +3972,15 @@ fuse_migrate_fd (xlator_t *this, fd_t *basefd, xlator_t *old_subvol, goto out; } - ret = fuse_migrate_locks (this, oldfd, newfdptr, old_subvol, + ret = fuse_migrate_locks (this, basefd, oldfd, old_subvol, new_subvol); if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "migrating locks from old-subvolume (%s-%d) to " "new-subvolume (%s-%d) failed (inode-gfid:%s oldfd:%p " - "newfd:%p)", old_subvol->name, old_subvol->graph->id, + "basefd:%p)", old_subvol->name, old_subvol->graph->id, new_subvol->name, new_subvol->graph->id, - uuid_utoa (basefd->inode->gfid), oldfd, newfdptr); + uuid_utoa (basefd->inode->gfid), oldfd, basefd); } out: -- cgit