@@ -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;