diff options
author | Raghavendra G <raghavendra@gluster.com> | 2011-06-22 02:43:30 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-17 23:34:48 -0700 |
commit | b53d76e392f0b88a7d135f099fe52ae933050719 (patch) | |
tree | 09e3007021ca991f5fd6aebf661bed85d8db7780 /xlators | |
parent | 1a807fec3992fcff9bfbc410f0a21a5794d04f7a (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')
-rw-r--r-- | xlators/mount/fuse/src/fuse-helpers.c | 7 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-resolve.c | 36 |
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 cd35d719214..6ac6b3092a4 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 b13cb360641..4a450b87646 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: |