[09/10] btrfs: fix some problem in btrfs_link()
diff mbox

Message ID 4BF4E3BA.8030607@cn.fujitsu.com
State New, archived
Headers show

Commit Message

Miao Xie May 20, 2010, 7:24 a.m. UTC
None

Patch
diff mbox

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1cef510..1392a09 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4418,15 +4418,18 @@  static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
 	if (err)
 		return err;
 
-	btrfs_inc_nlink(inode);
+	trans = btrfs_start_transaction(root, 1);
+	if (!trans) {
+		err = -ENOMEM;
+		goto fail;
+	}
 
 	err = btrfs_set_inode_index(dir, &index);
 	if (err)
 		goto fail;
 
-	trans = btrfs_start_transaction(root, 1);
-
 	btrfs_set_trans_block_group(trans, dir);
+	btrfs_inc_nlink(inode);
 	atomic_inc(&inode->i_count);
 
 	err = btrfs_add_nondir(trans, dentry, inode, 1, index);