Btrfs: Fix incorrect inode nlink in btrfs_link()
authorMiao Xie <miaox@cn.fujitsu.com>
Wed, 13 Apr 2011 05:19:21 +0000 (13:19 +0800)
committerLi Zefan <lizf@cn.fujitsu.com>
Wed, 13 Apr 2011 06:25:32 +0000 (14:25 +0800)
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>
fs/btrfs/inode.c

index b9f7f5258343fb23183ce17001cf1cf5bf3a8e3b..a4157cfdd5337a88419577c91b7f9e62729cd2dd 100644 (file)
@@ -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;
@@ -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);