Skip to content

Commit

Permalink
Fix ENOTEMPTY check in btrfs_rmdir
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yan authored and Chris Mason committed Sep 25, 2008
1 parent 0d9f7f3 commit 134d451
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 134d451

Please sign in to comment.