diff options
author | Raghavendra Bhat <raghavendrabhat@gluster.com> | 2012-04-24 18:40:00 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-04-24 13:08:24 -0700 |
commit | 2a59514236630756dc996e08b50f539ccc2d3ff0 (patch) | |
tree | 65bfc088c7ecd14d304283b544884c510829efdf /xlators/mount | |
parent | 1fc54cf7c5e2a88cf8f59d98f6e0eb7df485ae80 (diff) |
mount/fuse: unref the fds after they have been migrated to the new graph
In fuse upon graph changes fds were being migrated to the new graph.
It was done by taking all the fds from the fdtable in a structure and then
migrating each fd in the structure to the new graph. But after the fds
are migrated the structure which had the fds within it (that is refed fds)
was being freed without unrefing the fds, thus leading to a fd leak.
Change-Id: I7b25220a48954384a004373d378cee11c6109f7e
BUG: 811552
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/3222
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mount')
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 9a2d60b9b4c..0b9ee176588 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -3666,32 +3666,48 @@ fuse_handle_opened_fds (xlator_t *this, xlator_t *old_subvol, if (fdentries != NULL) { for (i = 0; i < count; i++) { fd = fdentries[i].fd; - if (fd != NULL) { - ret = fuse_migrate_fd (this, fd, old_subvol, + if (fd == NULL) + continue; + + ret = fuse_migrate_fd (this, fd, old_subvol, new_subvol); - if (ret < 0) { - if (ret == -1) { - fdctx = fuse_fd_ctx_check_n_create (fd, this); - if (fdctx != NULL) { - fdctx->migration_failed = 1; - } - } else { - /* nameless lookup has failed, - * it can be identified using - * fd->inode->table->xl - * != active_subvol. so, do - * nothing - */ - } - } else { - fdctx = fuse_fd_ctx_get (this, fd); + if (ret < 0) { + if (ret == -1) { + fdctx = fuse_fd_ctx_check_n_create (fd, + this); if (fdctx != NULL) { - fdctx->migration_failed = 0; + fdctx->migration_failed = 1; + gf_log_callingfn ("glusterfs-" + "fuse", + GF_LOG_ERROR, + "fd migration" + " for the fd " + "(%p), with" + "context (%p)" + " failed", fd, + fdctx); } + } else { + /* nameless lookup has failed, + * it can be identified using + * fd->inode->table->xl + * != active_subvol. so, do + * nothing + */ + } + } else { + fdctx = fuse_fd_ctx_get (this, fd); + if (fdctx != NULL) { + fdctx->migration_failed = 0; } } } + for (i = 0; i < count ; i++) { + fd = fdentries[i].fd; + if (fd) + fd_unref (fd); + } GF_FREE (fdentries); } |