From 147b20c4a485ddb4b31b1811be4bf90610c91f7f Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Tue, 7 Dec 2010 05:36:54 +0000 Subject: nfs: cleanup inode_ref/inode_unref to fix inode leaks and extra unrefs Signed-off-by: Anand V. Avati Signed-off-by: Anand V. Avati BUG: 2195 (Crash in __inode_retire on NFS failover) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2195 --- xlators/nfs/server/src/nfs-inodes.c | 45 ++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'xlators/nfs/server/src/nfs-inodes.c') diff --git a/xlators/nfs/server/src/nfs-inodes.c b/xlators/nfs/server/src/nfs-inodes.c index cd334525d..ddc1a9c0d 100644 --- a/xlators/nfs/server/src/nfs-inodes.c +++ b/xlators/nfs/server/src/nfs-inodes.c @@ -74,11 +74,12 @@ nfs_inode_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { struct nfs_fop_local *nfl = frame->local; fop_create_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; if (op_ret == -1) goto do_not_link; - inode_link (inode, nfl->parent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->parent, nfl->path, buf); do_not_link: /* NFS does not need it, upper layers should not expect the pointer to @@ -90,6 +91,12 @@ do_not_link: if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, fd, inode, buf, preparent, postparent); + + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } + return 0; } @@ -139,11 +146,12 @@ nfs_inode_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { struct nfs_fop_local *nfl = frame->local; fop_mkdir_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; if (op_ret == -1) goto do_not_link; - inode_link (inode, nfl->parent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->parent, nfl->path, buf); do_not_link: inodes_nfl_to_prog_data (nfl, progcbk, frame); @@ -151,6 +159,11 @@ do_not_link: progcbk (frame, cookie, this, op_ret, op_errno, inode, buf, preparent, postparent); + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } + return 0; } @@ -296,18 +309,25 @@ nfs_inode_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { struct nfs_fop_local *nfl = NULL; fop_link_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; if (op_ret == -1) goto do_not_link; nfl = frame->local; - inode_link (inode, nfl->newparent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->newparent, nfl->path, buf); do_not_link: inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, inode, buf, preparent, postparent); + + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } + return 0; } @@ -349,6 +369,7 @@ nfs_inode_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto do_not_unlink; inode_unlink (nfl->inode, nfl->parent, nfl->path); + inode_forget (nfl->inode, 0); do_not_unlink: inodes_nfl_to_prog_data (nfl, progcbk, frame); @@ -396,6 +417,7 @@ nfs_inode_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto do_not_unlink; inode_unlink (nfl->inode, nfl->parent, nfl->path); + inode_forget (nfl->inode, 0); do_not_unlink: inodes_nfl_to_prog_data (nfl, progcbk, frame); @@ -438,19 +460,26 @@ nfs_inode_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { struct nfs_fop_local *nfl = NULL; fop_mknod_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; nfl = frame->local; if (op_ret == -1) goto do_not_link; - inode_link (inode, nfl->parent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->parent, nfl->path, buf); do_not_link: inodes_nfl_to_prog_data (nfl, progcbk, frame); if (progcbk) progcbk (frame, cookie, this, op_ret, op_errno, inode, buf, preparent, postparent); + + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } + return 0; } @@ -488,12 +517,13 @@ nfs_inode_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, { struct nfs_fop_local *nfl = NULL; fop_symlink_cbk_t progcbk = NULL; + inode_t *linked_inode = NULL; nfl = frame->local; if (op_ret == -1) goto do_not_link; - inode_link (inode, nfl->parent, nfl->path, buf); + linked_inode = inode_link (inode, nfl->parent, nfl->path, buf); do_not_link: inodes_nfl_to_prog_data (nfl, progcbk, frame); @@ -501,6 +531,11 @@ do_not_link: progcbk (frame, cookie, this, op_ret, op_errno, inode, buf, preparent, postparent); + if (linked_inode) { + inode_lookup (linked_inode); + inode_unref (linked_inode); + } + return 0; } -- cgit