Hello,
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 fix a fs_mutex unlock issue in btrfs_rmdir by the way.
Regards
YZ
--
diff -r 9bf00d0c038f inode.c
--- a/inode.c Fri Oct 19 14:01:21 2007 -0400
+++ b/inode.c Thu Oct 25 19:29:48 2007 +0800
@@ -448,6 +448,9 @@ static int btrfs_rmdir(struct inode *dir
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 @@ out:
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;