All of lore.kernel.org
 help / color / mirror / Atom feed
* Hard link across subvolumes
@ 2009-10-30  5:30 TARUISI Hiroaki
  2009-11-12  7:14 ` [PATCH] Deny sys_link " TARUISI Hiroaki
  0 siblings, 1 reply; 5+ messages in thread
From: TARUISI Hiroaki @ 2009-10-30  5:30 UTC (permalink / raw)
  To: linux-btrfs; +Cc: chris.mason

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Deny sys_link across subvolumes.
  2009-10-30  5:30 Hard link across subvolumes TARUISI Hiroaki
@ 2009-11-12  7:14 ` TARUISI Hiroaki
  2009-11-12 15:00   ` Chris Mason
  0 siblings, 1 reply; 5+ messages in thread
From: TARUISI Hiroaki @ 2009-11-12  7:14 UTC (permalink / raw)
  To: linux-btrfs; +Cc: chris.mason


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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Deny sys_link across subvolumes.
  2009-11-12  7:14 ` [PATCH] Deny sys_link " TARUISI Hiroaki
@ 2009-11-12 15:00   ` Chris Mason
  2009-11-13  6:17     ` TARUISI Hiroaki
  2009-11-13  9:15     ` Yan, Zheng 
  0 siblings, 2 replies; 5+ messages in thread
From: Chris Mason @ 2009-11-12 15:00 UTC (permalink / raw)
  To: TARUISI Hiroaki; +Cc: linux-btrfs

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Deny sys_link across subvolumes.
  2009-11-12 15:00   ` Chris Mason
@ 2009-11-13  6:17     ` TARUISI Hiroaki
  2009-11-13  9:15     ` Yan, Zheng 
  1 sibling, 0 replies; 5+ messages in thread
From: TARUISI Hiroaki @ 2009-11-13  6:17 UTC (permalink / raw)
  To: chris.mason; +Cc: linux-btrfs

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.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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Deny sys_link across subvolumes.
  2009-11-12 15:00   ` Chris Mason
  2009-11-13  6:17     ` TARUISI Hiroaki
@ 2009-11-13  9:15     ` Yan, Zheng 
  1 sibling, 0 replies; 5+ messages in thread
From: Yan, Zheng  @ 2009-11-13  9:15 UTC (permalink / raw)
  To: Chris Mason, TARUISI Hiroaki, linux-btrfs

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. =A0Do you have some time to add more checks to r=
ename
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-11-13  9:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-30  5:30 Hard link across subvolumes TARUISI Hiroaki
2009-11-12  7:14 ` [PATCH] Deny sys_link " TARUISI Hiroaki
2009-11-12 15:00   ` Chris Mason
2009-11-13  6:17     ` TARUISI Hiroaki
2009-11-13  9:15     ` Yan, Zheng 

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.