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? -- taruisi -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Christian Parpart <trapni@gentoo.org> 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. Signed-off-by: TARUISI Hiroaki <taruishi.hiroak@jp.fujitsu.com> --- fs/btrfs/inode.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 78139ef..c7f66e4 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Nov 12, 2009 at 04:14:26PM +0900, TARUISI Hiroaki wrote:> > From: Christian Parpart <trapni@gentoo.org> > > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Chris Mason wrote:> On Thu, Nov 12, 2009 at 04:14:26PM +0900, TARUISI Hiroaki wrote: >> From: Christian Parpart <trapni@gentoo.org> >> >> 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 > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.htmlThank 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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Nov 12, 2009 at 11:00 PM, Chris Mason <chris.mason@oracle.com> wrote:> On Thu, Nov 12, 2009 at 04:14:26PM +0900, TARUISI Hiroaki wrote: >> >> From: Christian Parpart <trapni@gentoo.org> >> >> 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? >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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html