summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorYan2007-10-25 21:49:25 +0200
committerChris Mason2008-09-25 17:03:57 +0200
commit134d45120164141c0847daf5222aaec77e04724a (patch)
tree096a7b7853281b28bd6059cf610f38a8ec65f07a /fs/btrfs/inode.c
parentbtrfs_inode_by_name return random value. (diff)
downloadkernel-qcow2-linux-134d45120164141c0847daf5222aaec77e04724a.tar.gz
kernel-qcow2-linux-134d45120164141c0847daf5222aaec77e04724a.tar.xz
kernel-qcow2-linux-134d45120164141c0847daf5222aaec77e04724a.zip
Fix ENOTEMPTY check in btrfs_rmdir
The ENOTEMPTY check in btrfs_rmdir isn't reliable. It's possible that the backward search finds . or .. at first, then some other directory entry. In that case, btrfs_rmdir delete . or .. improperly. The patch also fixes a fs_mutex unlock issue in btrfs_rmdir. -- Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b74a831fab19..7e4b2c1b4a56 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -448,6 +448,9 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
char *goodnames = "..";
unsigned long nr;
+ if (inode->i_size > BTRFS_EMPTY_DIR_SIZE)
+ return -ENOTEMPTY;
+
path = btrfs_alloc_path();
BUG_ON(!path);
mutex_lock(&root->fs_info->fs_mutex);
@@ -501,9 +504,9 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
out:
btrfs_release_path(root, path);
btrfs_free_path(path);
- mutex_unlock(&root->fs_info->fs_mutex);
nr = trans->blocks_used;
ret = btrfs_end_transaction(trans, root);
+ mutex_unlock(&root->fs_info->fs_mutex);
btrfs_btree_balance_dirty(root, nr);
if (ret && !err)
err = ret;