Skip to content

Commit

Permalink
Btrfs: Fix incorrect inode nlink in btrfs_link()
Browse files Browse the repository at this point in the history
Link count of the inode is not decreased if btrfs_set_inode_index()
fails.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Singed-off-by: Li Zefan <lizf@cn.fujitsu.com>
  • Loading branch information
Miao Xie authored and Li Zefan committed Apr 13, 2011
1 parent b9e03af commit 3153495
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4846,9 +4846,6 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
if (inode->i_nlink == ~0U)
return -EMLINK;

btrfs_inc_nlink(inode);
inode->i_ctime = CURRENT_TIME;

err = btrfs_set_inode_index(dir, &index);
if (err)
goto fail;
Expand All @@ -4864,6 +4861,9 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
goto fail;
}

btrfs_inc_nlink(inode);
inode->i_ctime = CURRENT_TIME;

btrfs_set_trans_block_group(trans, dir);
ihold(inode);

Expand Down

0 comments on commit 3153495

Please sign in to comment.