diff options
author | Josef Bacik <josef@redhat.com> | 2010-11-20 04:48:00 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-11-21 22:26:09 -0500 |
commit | 6a912213046ecb6511fdf35531a0c7de3de963c9 (patch) | |
tree | b745a07d0ad5c5bedf68c55739200093f9d96c1b /fs/btrfs/inode.c | |
parent | 76195853903ca613ba722203db9b747d70478fc7 (diff) |
Btrfs: use dget_parent where we can UPDATED
There are lots of places where we do dentry->d_parent->d_inode without holding
the dentry->d_lock. This could cause problems with rename. So instead we need
to use dget_parent() and hold the reference to the parent as long as we are
going to use it's inode and then dput it at the end.
Signed-off-by: Josef Bacik <josef@redhat.com>
Cc: raven@themaw.net
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index fc22f556aa24..c0faf47d0cd9 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -4811,10 +4811,12 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, | |||
4811 | if (err) { | 4811 | if (err) { |
4812 | drop_inode = 1; | 4812 | drop_inode = 1; |
4813 | } else { | 4813 | } else { |
4814 | struct dentry *parent = dget_parent(dentry); | ||
4814 | btrfs_update_inode_block_group(trans, dir); | 4815 | btrfs_update_inode_block_group(trans, dir); |
4815 | err = btrfs_update_inode(trans, root, inode); | 4816 | err = btrfs_update_inode(trans, root, inode); |
4816 | BUG_ON(err); | 4817 | BUG_ON(err); |
4817 | btrfs_log_new_name(trans, inode, NULL, dentry->d_parent); | 4818 | btrfs_log_new_name(trans, inode, NULL, parent); |
4819 | dput(parent); | ||
4818 | } | 4820 | } |
4819 | 4821 | ||
4820 | nr = trans->blocks_used; | 4822 | nr = trans->blocks_used; |
@@ -6768,8 +6770,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
6768 | BUG_ON(ret); | 6770 | BUG_ON(ret); |
6769 | 6771 | ||
6770 | if (old_inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) { | 6772 | if (old_inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) { |
6771 | btrfs_log_new_name(trans, old_inode, old_dir, | 6773 | struct dentry *parent = dget_parent(new_dentry); |
6772 | new_dentry->d_parent); | 6774 | btrfs_log_new_name(trans, old_inode, old_dir, parent); |
6775 | dput(parent); | ||
6773 | btrfs_end_log_trans(root); | 6776 | btrfs_end_log_trans(root); |
6774 | } | 6777 | } |
6775 | out_fail: | 6778 | out_fail: |