* [PATCH] fs/namei.c: Hard link and rename should check same device instead of same mount
@ 2016-03-16 13:05 Jordi Pujol Palomer
2016-03-16 14:25 ` Al Viro
0 siblings, 1 reply; 5+ messages in thread
From: Jordi Pujol Palomer @ 2016-03-16 13:05 UTC (permalink / raw)
To: Linux-Fsdevel
[-- Attachment #1: Type: text/plain, Size: 395 bytes --]
Hello,
Working on a Linux system that bind mounts some
directories, have found frequent errors when moving files between
directories that belong to different mount points but are on the same
device.
The two attached patches solve these problems on a local filesystem.
Maybe we must test it on different configurations.
Thanks,
Jordi Pujol i Palomer
Enginyer Tècnic Industrial
[-- Attachment #2: fs-hard-link-check-same-device-instead-of-same-mount.patch --]
[-- Type: text/x-patch, Size: 503 bytes --]
Signed-off-by: Jordi Pujol Palomer <jordipujolp@gmail.com>
---
Subject: fs: Hard link must check same device instead of same mount
Date: Wed, 16 Mar 2016 09:12:21 +0100
--- linux-4.5.0-a/fs/namei.c
+++ linux-4.5.0-b/fs/namei.c 2016-03-15 22:15:03.275460823 +0100
@@ -4163,7 +4163,7 @@ retry:
goto out;
error = -EXDEV;
- if (old_path.mnt != new_path.mnt)
+ if (old_path.dentry->d_sb->s_dev != new_path.dentry->d_sb->s_dev)
goto out_dput;
error = may_linkat(&old_path);
if (unlikely(error))
[-- Attachment #3: fs-rename-check-same-device-instead-of-same-mount.patch --]
[-- Type: text/x-patch, Size: 452 bytes --]
Signed-off-by: Jordi Pujol Palomer <jordipujolp@gmail.com>
---
Subject: fs: Rename must check same device instead of same mount
Date: Wed, 16 Mar 2016 09:12:21 +0100
--- linux-4.5.0-a/fs/namei.c
+++ linux-4.5.0-b/fs/namei.c 2016-03-15 22:15:03.275460823 +0100
@@ -4424,7 +4424,7 @@ retry:
}
error = -EXDEV;
- if (old_path.mnt != new_path.mnt)
+ if (old_path.dentry->d_sb->s_dev != new_path.dentry->d_sb->s_dev)
goto exit2;
error = -EBUSY;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs/namei.c: Hard link and rename should check same device instead of same mount
2016-03-16 13:05 [PATCH] fs/namei.c: Hard link and rename should check same device instead of same mount Jordi Pujol Palomer
@ 2016-03-16 14:25 ` Al Viro
2016-03-20 18:06 ` Jordi Pujol Palomer
0 siblings, 1 reply; 5+ messages in thread
From: Al Viro @ 2016-03-16 14:25 UTC (permalink / raw)
To: Jordi Pujol Palomer; +Cc: Linux-Fsdevel
On Wed, Mar 16, 2016 at 02:05:14PM +0100, Jordi Pujol Palomer wrote:
> Hello,
>
> Working on a Linux system that bind mounts some
> directories, have found frequent errors when moving files between
> directories that belong to different mount points but are on the same
> device.
> The two attached patches solve these problems on a local filesystem.
> Maybe we must test it on different configurations.
NAK. This is absolutely deliberate; moreover, mount --bind $DIR $DIR
is often used just to set such a boundary.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs/namei.c: Hard link and rename should check same device instead of same mount
2016-03-16 14:25 ` Al Viro
@ 2016-03-20 18:06 ` Jordi Pujol Palomer
2016-03-20 18:22 ` Al Viro
0 siblings, 1 reply; 5+ messages in thread
From: Jordi Pujol Palomer @ 2016-03-20 18:06 UTC (permalink / raw)
To: Al Viro; +Cc: Linux-Fsdevel
El Wed, 16 Mar 2016 14:25:16 +0000
Al Viro <viro@ZenIV.linux.org.uk> escrigué:
> NAK. This is absolutely deliberate; moreover, mount --bind $DIR $DIR
> is often used just to set such a boundary.
It means that the way I have proposed may work also ?
Therefore we can develop a new option for binding to let the superuser
choose what is needed for every mount-bind, example:
mount --bind -o boundary $DIR $DIR
mount --bind -o noboundary $DIR1 $DIR2
and allow remount also,
mount -o remount,boundary $DIR
mount -o remount,noboundary $DIR
That seems feasible,
Jordi Pujol i Palomer
Enginyer Tècnic Industrial
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs/namei.c: Hard link and rename should check same device instead of same mount
2016-03-20 18:06 ` Jordi Pujol Palomer
@ 2016-03-20 18:22 ` Al Viro
2016-03-21 13:35 ` Jordi Pujol Palomer
0 siblings, 1 reply; 5+ messages in thread
From: Al Viro @ 2016-03-20 18:22 UTC (permalink / raw)
To: Jordi Pujol Palomer; +Cc: Linux-Fsdevel
On Sun, Mar 20, 2016 at 07:06:25PM +0100, Jordi Pujol Palomer wrote:
> Therefore we can develop a new option for binding to let the superuser
> choose what is needed for every mount-bind, example:
>
> mount --bind -o boundary $DIR $DIR
>
> mount --bind -o noboundary $DIR1 $DIR2
>
> and allow remount also,
>
> mount -o remount,boundary $DIR
>
> mount -o remount,noboundary $DIR
>
> That seems feasible,
... until you consider the fun of moving subtrees between different mounts.
IMO it's a bloody bad idea; semantics would be hard to define, not to mention
that things that used to be on the same fs might eventually get moved to
different ones, and for those there's obviously no way to do link(2) or
rename(2) at all.
What are you actually trying to achieve? There might be saner ways to do
it...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fs/namei.c: Hard link and rename should check same device instead of same mount
2016-03-20 18:22 ` Al Viro
@ 2016-03-21 13:35 ` Jordi Pujol Palomer
0 siblings, 0 replies; 5+ messages in thread
From: Jordi Pujol Palomer @ 2016-03-21 13:35 UTC (permalink / raw)
To: Al Viro; +Cc: Linux-Fsdevel
[-- Attachment #1: Type: text/plain, Size: 991 bytes --]
El Sun, 20 Mar 2016 18:22:51 +0000
Al Viro <viro@ZenIV.linux.org.uk> escrigué:
> ... until you consider the fun of moving subtrees between different
> mounts. IMO it's a bloody bad idea; semantics would be hard to
> define, not to mention that things that used to be on the same fs
> might eventually get moved to different ones, and for those there's
> obviously no way to do link(2) or rename(2) at all.
>
Well I'm not an expert,
think the boundary option should be only for bind mounts, and will
work only when the filesystem supports it, as usual by now. The
mountpoint can be moved, but the underlying device continues being the
same; but sure it is more complicated, I understand,
> What are you actually trying to achieve? There might be saner ways
> to do it...
Yes, now I see that the all the local bind may be replaced with symbolic
links,
# mount-list > mount-list.txt
Thanks for your attention,
Jordi Pujol i Palomer
Enginyer Tècnic Industrial
[-- Attachment #2: mount-list.txt --]
[-- Type: text/plain, Size: 2931 bytes --]
sysfs /sys sysfs nodev,noexec,nosuid,relatime,rw sysfs 0:17
proc /proc proc nodev,noexec,nosuid,relatime,rw proc 0:5
udev /dev devtmpfs mode=755,nosuid,nr_inodes=978001,relatime,rw,size=3912004k udev 0:6
devpts /dev/pts devpts gid=5,mode=620,noexec,nosuid,ptmxmode=000,relatime,rw devpts 0:14
tmpfs /run tmpfs mode=755,noexec,nosuid,relatime,rw,size=786088k tmpfs 0:18
tmpfs /lnet tmpfs mode=755,relatime,rw,size=7860880k tmpfs 0:19
/dev/sda1 /lnet/image ext2 errors=continue,noacl,noatime,nouser_xattr,ro /dev/sda1 8:1
/lnet/image/LneTLXQT64/00filesystem.squashfs /lnet/00filesystem.squashfs squashfs noatime,ro,loop=/dev/loop0 /dev/loop0 7:0
/lnet/image/LneTLXQT64/10interfaces.squashfs /lnet/10interfaces.squashfs squashfs noatime,ro,loop=/dev/loop1 /dev/loop1 7:1
/dev/sda2 /lnet/cowroot ext4 data=ordered,relatime,rw /dev/sda2 8:2
overlay / overlay lowerdir=/lnet/00filesystem.squashfs:/lnet/10interfaces.squashfs,relatime,rw,upperdir=/lnet/cowroot/LneTLXQTCOW/upper,workdir=/lnet/cowroot/LneTLXQTCOW/work overlay 0:20
tmpfs /tmp tmpfs nodev,nosuid,relatime,rw,size=7860880k,mode=1777 tmpfs 0:21
tmpfs /var/log tmpfs mode=755,nosuid,relatime,rw,size=7860880k tmpfs 0:22
tmpfs /var/tmp tmpfs nodev,nosuid,relatime,rw,size=7860880k,mode=1777 tmpfs 0:23
securityfs /sys/kernel/security securityfs nodev,noexec,nosuid,relatime,rw securityfs 0:16
tmpfs /dev/shm tmpfs nodev,nosuid,rw,mode=1777 tmpfs 0:24
tmpfs /run/lock tmpfs nodev,noexec,nosuid,relatime,rw,size=5120k,mode=1777 tmpfs 0:25
tmpfs /sys/fs/cgroup tmpfs mode=755,nodev,noexec,nosuid,ro tmpfs 0:26
cgroup /sys/fs/cgroup/systemd cgroup name=systemd,nodev,noexec,nosuid,relatime,release_agent=/lib/systemd/systemd-cgroups-agent,rw,xattr cgroup 0:27
pstore /sys/fs/pstore pstore nodev,noexec,nosuid,relatime,rw pstore 0:28
cgroup /sys/fs/cgroup/cpu cgroup cpu,nodev,noexec,nosuid,relatime,rw cgroup 0:29
systemd-1 /proc/sys/fs/binfmt_misc autofs direct,fd=27,maxproto=5,minproto=5,pgrp=1,relatime,rw,timeout=0 systemd-1 0:30
hugetlbfs /dev/hugepages hugetlbfs relatime,rw hugetlbfs 0:31
mqueue /dev/mqueue mqueue relatime,rw mqueue 0:15
debugfs /sys/kernel/debug debugfs relatime,rw debugfs 0:7
/lnet/image/LneTLXQT64 /boot none ro,bind /dev/sda1 8:1
/lnet/cowroot/LneTXFCEhome /home none rw,bind /dev/sda2 8:2
/lnet/cowroot/JPLive /home/JPLive none rw,bind /dev/sda2 8:2
/lnet/cowroot/JPLive /lnet/cowroot/LneTXFCEhome/JPLive none rw,bind /dev/sda2 8:2
/lnet/image/grub /boot/grub none ro,bind /dev/sda1 8:1
/lnet/image/grub /lnet/image/LneTLXQT64/grub none ro,bind /dev/sda1 8:1
/lnet/cowroot/JPLive/var-spool /var/spool none rw,bind /dev/sda2 8:2
/lnet/cowroot/LneTXFCEhome/root /root none rw,bind /dev/sda2 8:2
/lnet/cowroot/JPLive/apt-lib-amd64 /var/lib/apt none rw,bind /dev/sda2 8:2
/lnet/cowroot/JPLive/apt-cache-amd64 /var/cache/apt none rw,bind /dev/sda2 8:2
tmpfs /run/user/1001 tmpfs gid=100,mode=700,nodev,nosuid,relatime,rw,size=786088k,uid=1001 tmpfs 0:34
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-03-21 13:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-16 13:05 [PATCH] fs/namei.c: Hard link and rename should check same device instead of same mount Jordi Pujol Palomer
2016-03-16 14:25 ` Al Viro
2016-03-20 18:06 ` Jordi Pujol Palomer
2016-03-20 18:22 ` Al Viro
2016-03-21 13:35 ` Jordi Pujol Palomer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).