Btrfs: use right root when checking for hash collision
PATCH 1/1 Btrfs: use right root when checking for hash collision
btrfs_rename was using the root of the old dir instead of the root of the new dir when checking for a hash collision, so if you tried to move a file into a subvol it would freak out because it would see the file you are trying to move in its current root. This fixes the bug where this would fail
btrfs subvol create test1
btrfs subvol create test2
mv test1 test2.
Thanks to Chris Murphy for catching this,
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -7993,7 +7993,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,/* check for collisions, even if the name isn't there */ - ret =btrfs_check_dir_item_collision (root, new_dir->i_ino, + ret =btrfs_check_dir_item_collision (dest, new_dir->i_ino, new_dentry->d_name.name, new_dentry->d_name.len);
Signature · 1 line
1.8.3.1
Quoted 5 lines · Josef Bacik
btrfs_renamewas using the root of the old dir instead of the root of the new dir when checking for a hash collision, so if you tried to move a file into a subvol it would freak out because it would see the file you are trying to move in its current root. This fixes the bug where this would fail
Quoted 8 lines
btrfs subvol create test1
btrfs subvol create test2
mv test1 test2.Thanks to Chris Murphy for catching this,
Reported-by Chris Murphy <[email protected]>Signed-off-by Josef Bacik <[email protected]>
Looks right to me.
Quoted 22 lines · Josef Bacik
btrfs_renamewas using the root of the old dir instead of the root of the new dir when checking for a hash collision, so if you tried to move a file into a subvol it would freak out because it would see the file you are trying to move in its current root. This fixes the bug where this would failbtrfs subvol create test1
btrfs subvol create test2
mv test1 test2.Thanks to Chris Murphy for catching this,
Reported-by Chris Murphy <[email protected]>Signed-off-by Josef Bacik <[email protected]>--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/inode.c +0
-0
fs/btrfs/inode.c static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, · line 7998
Quoted 7 lines
fs/btrfs/inode.c +1
-1@@ -7993,7 +7993,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,/* check for collisions, even if the name isn't there */ - ret =btrfs_check_dir_item_collision (root, new_dir->i_ino, + ret =btrfs_check_dir_item_collision (dest, new_dir->i_ino, new_dentry->d_name.name, new_dentry->d_name.len);
Looks correct.
I claim that better variable names would have had avoided this bug. The code uses old_dir / new_dir, old_entry / new_entry, old_inode / new_inode - so, while you're at it: How about changing the variables to old_root / new_root instead of keeping root / dest?
- Jan