summaryrefslogtreecommitdiffstats
path: root/xlators/mount
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2011-06-22 02:39:25 +0000
committerAnand Avati <avati@gluster.com>2011-07-17 23:34:56 -0700
commitaf87d7209986692267f80000b389a974b5044a93 (patch)
treedf9f9e0893ee7e1b412c21ea8e0ba1f4daac7bfb /xlators/mount
parentaa2b53171ea8f786052cbe40fee2bb43f081e3e9 (diff)
fuse: fix inode-leaks in fuse_lookup_and_resume codepath.
Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2525 ([glusterfs-3.1.3qa8]: inode leak in rdma) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2525
Diffstat (limited to 'xlators/mount')
-rw-r--r--xlators/mount/fuse/src/fuse-helpers.c7
-rw-r--r--xlators/mount/fuse/src/fuse-resolve.c36
2 files changed, 31 insertions, 12 deletions
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c
index d0dad29a4..e03d15c2b 100644
--- a/xlators/mount/fuse/src/fuse-helpers.c
+++ b/xlators/mount/fuse/src/fuse-helpers.c
@@ -68,14 +68,15 @@ fuse_resolve_wipe (fuse_resolve_t *resolve)
comp = resolve->components;
if (comp) {
-/*
int i = 0;
for (i = 0; comp[i].basename; i++) {
- if (comp[i].inode)
+ if (comp[i].inode) {
inode_unref (comp[i].inode);
+ comp[i].inode = NULL;
+ }
}
-*/
+
GF_FREE ((void *)resolve->components);
}
}
diff --git a/xlators/mount/fuse/src/fuse-resolve.c b/xlators/mount/fuse/src/fuse-resolve.c
index b13cb3606..4a450b876 100644
--- a/xlators/mount/fuse/src/fuse-resolve.c
+++ b/xlators/mount/fuse/src/fuse-resolve.c
@@ -242,15 +242,13 @@ fuse_resolve_deep_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
if (i != 0) {
- inode_ref (inode);
/* no linking for root inode */
link_inode = inode_link (inode, resolve->deep_loc.parent,
resolve->deep_loc.name, buf);
- components[i].inode = inode_ref (link_inode);
+ components[i].inode = link_inode;
link_inode = NULL;
}
- inode_ref (resolve->deep_loc.parent);
- inode_ref (inode);
+
loc_wipe (&resolve->deep_loc);
i++; /* next component */
@@ -296,9 +294,6 @@ fuse_resolve_path_deep (fuse_state_t *state)
/* start from the root */
active_xl = fuse_active_subvol (state->this);
- resolve->deep_loc.inode = inode_ref (active_xl->itable->root);
- resolve->deep_loc.path = gf_strdup ("/");
- resolve->deep_loc.name = "";
for (i = 1; components[i].basename; i++) {
*(components[i].basename - 1) = '/';
@@ -306,7 +301,7 @@ fuse_resolve_path_deep (fuse_state_t *state)
components[i].basename);
if (!inode)
break;
- components[i].inode = inode_ref (inode);
+ components[i].inode = inode;
}
if (!components[i].basename)
@@ -370,8 +365,18 @@ fuse_resolve_path_simple (fuse_state_t *state)
goto out;
}
- if (components[ino_idx].inode)
+ if (components[ino_idx].inode) {
+ if (state->loc_now->inode) {
+ inode_unref (state->loc_now->inode);
+ }
+
state->loc_now->inode = inode_ref (components[ino_idx].inode);
+ }
+
+ if (state->loc_now->parent) {
+ inode_unref (state->loc_now->parent);
+ }
+
state->loc_now->parent = inode_ref (components[par_idx].inode);
ret = 0;
@@ -413,6 +418,10 @@ fuse_resolve_entry_simple (fuse_state_t *state)
}
/* expected @parent was found from the inode cache */
+ if (state->loc_now->parent) {
+ inode_unref (state->loc_now->parent);
+ }
+
state->loc_now->parent = inode_ref (parent);
inode = inode_grep (active_xl->itable, parent, resolve->bname);
@@ -425,6 +434,11 @@ fuse_resolve_entry_simple (fuse_state_t *state)
ret = 0;
+ if (state->loc_now->inode) {
+ inode_unref (state->loc_now->inode);
+ state->loc_now->inode = NULL;
+ }
+
state->loc_now->inode = inode_ref (inode);
out:
@@ -483,6 +497,10 @@ fuse_resolve_inode_simple (fuse_state_t *state)
ret = 0;
+ if (state->loc_now->inode) {
+ inode_unref (state->loc_now->inode);
+ }
+
state->loc_now->inode = inode_ref (inode);
out: