From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/3] Btrfs: fix inode leak on failure to setup whiteout inode in rename
Date: Thu, 5 May 2016 02:34:14 +0100 [thread overview]
Message-ID: <1462412056-27878-1-git-send-email-fdmanana@kernel.org> (raw)
From: Filipe Manana <fdmanana@suse.com>
If we failed to fully setup the whiteout inode during a rename operation
with the whiteout flag, we ended up leaking the inode, not decrementing
its link count nor removing all its items from the fs/subvol tree.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/inode.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 09947cb..ab64721 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9612,21 +9612,21 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
ret = btrfs_init_inode_security(trans, inode, dir,
&dentry->d_name);
if (ret)
- return ret;
+ goto out;
ret = btrfs_add_nondir(trans, dir, dentry,
inode, 0, index);
if (ret)
- return ret;
+ goto out;
ret = btrfs_update_inode(trans, root, inode);
- if (ret)
- return ret;
-
+out:
unlock_new_inode(inode);
+ if (ret)
+ inode_dec_link_count(inode);
iput(inode);
- return 0;
+ return ret;
}
static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
--
2.7.0.rc3
next reply other threads:[~2016-05-05 16:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-05 1:34 fdmanana [this message]
2016-05-05 1:34 ` [PATCH 2/3] Btrfs: unpin logs if rename exchange operation fails fdmanana
2016-05-05 1:34 ` [PATCH 3/3] Btrfs: pin logs earlier when doing a rename exchange operation fdmanana
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462412056-27878-1-git-send-email-fdmanana@kernel.org \
--to=fdmanana@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).