diff mbox

[3/3] btrfs: Update the directory link count correctly

Message ID 1264279089-14913-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com (mailing list archive)
State Rejected
Headers show

Commit Message

Aneesh Kumar K.V Jan. 23, 2010, 8:38 p.m. UTC
None
diff mbox

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 9a56b3b..12b9d6e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2703,8 +2703,17 @@  static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
 				 dentry->d_name.name, dentry->d_name.len);
 	if (!err) {
 		btrfs_i_size_write(inode, 0);
-		btrfs_drop_nlink(inode);
+		/*
+		 * Directories have link count 2.
+		 */
+		btrfs_clear_nlink(dentry->d_inode);
 		btrfs_update_inode(trans, root, inode);
+		/*
+		 * If we are removing a directory drop the link count from
+		 * the parent directory
+		 */
+		btrfs_drop_nlink(dir);
+		btrfs_update_inode(trans, root, dir);
 	}
 out:
 	nr = trans->blocks_used;