Hard link across subvolumes
Hi,
In Btrfs, a hard link across subvolumes should be prohibited, but not prohibited yet. (It may be convenient if possible, I think.) If we make a hard link like this, filesystem may abort or after umount/mount, contents of file may be swapped to contents of other file(with same i-node number in same tree as 'from' file).
About this, I found Christian Parpart's patch posted last year, and this patch seems to work well.
http://www.spinics.net/lists/linux-btrfs/msg00749.html
But this patch is not merged yet.
Some work(to check more, to change error code or to simply test) shuould be done for this?
Signature · 1 line
taruisi
PATCH 1/1 Deny sys_link across subvolumes.
From: Christian Parpart <[email protected]>
I rebased Christian Parpart's patch to deny hard link across subvolumes. Original patch modifies also btrfs_rename, but I excluded it because we can move across subvolumes now and it make no problem.
-----------------
Hard link across subvolumes should not allowed in Btrfs. btrfs_link checks root of 'to' directory is same as root of 'from' file. If not same, btrfs_link returns -EPERM.
--- fs/btrfs/inode.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
fs/btrfs/inode.c +4 -0
@@ -4284,6 +4284,10 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,if (inode->i_nlink ==0 )return -ENOENT ; +/* do not allow sys_link's with other subvols of the same device */ +if (root->objectid !=BTRFS_I (inode)->root->objectid) +return -EPERM ; +/* * 1 item for inode ref * 2 items for dir items
-- 1.6.5 --
taruisi
Re: [PATCH] Deny sys_link across subvolumes.
Quoted 7 lines · TARUISI Hiroaki
From: Christian Parpart <[email protected]>
I rebased Christian Parpart's patch to deny hard link across subvolumes. Original patch modifies also
btrfs_rename, but I excluded it because we can move across subvolumes now and it make no problem.
Thanks for sending this in again.
Actually, we still can't rename across subvolumes, but we do support renaming subvolumes. Do you have some time to add more checks to rename as well?
-chris
Re: [PATCH] Deny sys_link across subvolumes.
Quoted 14 lines · Chris Mason
Quoted 6 lines · TARUISI Hiroaki
From: Christian Parpart <[email protected]>
I rebased Christian Parpart's patch to deny hard link across subvolumes. Original patch modifies also
btrfs_rename, but I excluded it because we can move across subvolumes now and it make no problem.Thanks for sending this in again.
Actually, we still can't rename across subvolumes, but we do support renaming subvolumes. Do you have some time to add more checks to rename as well?
Quoted 5 lines
-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Thank you for your reply.
I tried moving file/directory/subvolume across subvolumes, and found it worked. In source code of btrfs_rename, it's already checked if 'from' directory and 'to' directory are under a same root or not except a root object. If not matched, btrfs_rename returns with -EXDEV but it seems mv command treats it properly. Even if in no-check case (root object case), I tried but found no serious problem.
I wonder renaming subvolumes across subvolumes does not completely work yet in some points I cannot found, or btrfs_rename works without returning -EXDEV.
Could you tell me how should we check when renaming subvolumes?
Regards,
taruisi
Re: [PATCH] Deny sys_link across subvolumes.
In reply to Chris MasonQuoted 9 lines · On Thu, Nov 12, 2009 at 11:00 PM, Chris Mason <[email protected]> = wrote:
Quoted 7 lines · TARUISI Hiroaki
From: Christian Parpart <[email protected]>
I rebased Christian Parpart's patch to deny hard link across subvolumes. Original patch modifies also
btrfs_rename, but I excluded it because we can move across subvolumes now and it make no problem.
Quoted 4 lines
Thanks for sending this in again.
Actually, we still can't rename across subvolumes, but we do support renaming subvolumes. =A0Do you have some time to add more checks to r=
ename
Quoted 2 lines
as well?
Just a note, btrfs_name already has check it.
Yan, Zheng
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html