2013-10-10 21:45:07

by Ming Lei

[permalink] [raw]
Subject: nfs4.1 pseudo filesystem


I want to set up the real directory as the root of the pseudo filesystem
got exported from the server. Can I do it or I have to create /export
empty directory as the root of the pseudo FS and then bind the real
directories?

I have this test, both server and client running 3.11.0+:

On the server, there is /root directory.
[root@xxx ~] ls /root
anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
Desktop disk.c Downloads install.log linux3
rpmbuild
[root@xxx ~]# ls /root/Downloads/linux-2.6.39.4
arch crypto firmware Kconfig Module.symvers security
block cscope.in.out fs kernel net sound
config cscope.out include lib README tools
config-rh cscope.po.out init MAINTAINERS REPORTING-BUGS usr
COPYING Documentation ipc Makefile samples virt
CREDITS drivers Kbuild mm scripts

I have this /etc/exports on the server:
/root *(ro,fsid=0,crossmnt,no_root_squash)
/root/Downloads/linux-2.6.39.4 *(rw,no_root_squash,nohide)
/root/linux3/Documentation/filesystems *(rw,no_root_squash,nohide)

[root@xxx ~]# cat /proc/net/rpc/nfsd.export/content
#path domain(flags)
# /root/.gvfs *()
/root *
(ro,no_root_squash,sync,wdelay,crossmnt,no_subtree_check,fsid=0,uuid=46bb42
56:d3c84b6f:bbbfff3a:8b0d912c)
[root@xxx ~]# cat /proc/net/rpc/nfsd.fh/content
#domain fsidtype fsid [path]
* 1 0x00000000 /root


On the client side, what I saw:
[root@xxx /]# mount -o vers=4.1 10.1.13.66:/ /mnt
[root@xxx /]# cd /mnt
[root@xxx mnt]# ls
anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
Desktop disk.c Downloads install.log linux3
rpmbuild
[root@xxx mnt]# cd Downloads/linux-2.6.39.4
[root@xxx linux-2.6.39.4]# ls
arch COPYING cscope.out firmware ipc lib
Module.symvers samples tools
block CREDITS cscope.po.out fs Kbuild MAINTAINERS
net scripts usr
config crypto Documentation include Kconfig Makefile
README security virt
config-rh cscope.in.out drivers init kernel mm
REPORTING-BUGS sound
[root@xxx linux-2.6.39.4]# rm REPORTING-BUGS
rm: remove regular file `REPORTING-BUGS'? y
rm: cannot remove `REPORTING-BUGS': Read-only file system

The question is:
Why can I delete this file even I specify the
mountpoint /root/Downloads/linux-2.6.39.4 to allow RW access?

Thanks
Ming



2013-10-11 18:29:47

by J. Bruce Fields

[permalink] [raw]
Subject: Re: nfs4.1 pseudo filesystem

On Fri, Oct 11, 2013 at 04:51:29PM +0000, Ming Lei wrote:
> I want to cherry-pick a few subdirectories under say /root, but I don't want to specifies all these mount directories one by one just like NFSv2/3.

Well, you're kind of stuck enumerating them whether as exports or bind
mounts.

> Does pseudo filesystem in kernel v3.11 work well enough?

But it should work anyway, yes.

Oh, wait, I see the problem: it doesn't work well if you're exporting
subdirectories and not full filesystems. Unless you do something
special at the export points (e.g. mount --bind them over themselves),
knfsd doesn't know when you've crossed an export point.

--b.

>
> Thanks
> Ming
>
> -----Original Message-----
> From: J. Bruce Fields [mailto:[email protected]]
> Sent: Friday, October 11, 2013 9:30 AM
> To: Ming Lei
> Cc: [email protected]
> Subject: Re: nfs4.1 pseudo filesystem
>
> On Thu, Oct 10, 2013 at 09:39:38PM +0000, Ming Lei wrote:
> >
> > I want to set up the real directory as the root of the pseudo
> > filesystem got exported from the server.
>
> Unless you have some very good reason, I recommend just ignoring the pseudo filesystem. Just export the directories you want to without using fsid=0 or bind mounts, just as you would with NFSv2/v3. That will work fine on any recent server.
>
> --b.
>
> > Can I do it or I have to create /export empty directory as the root of
> > the pseudo FS and then bind the real directories?
> >
> > I have this test, both server and client running 3.11.0+:
> >
> > On the server, there is /root directory.
> > [root@xxx ~] ls /root
> > anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
> > Desktop disk.c Downloads install.log linux3
> > rpmbuild
> > [root@xxx ~]# ls /root/Downloads/linux-2.6.39.4
> > arch crypto firmware Kconfig Module.symvers security
> > block cscope.in.out fs kernel net sound
> > config cscope.out include lib README tools
> > config-rh cscope.po.out init MAINTAINERS REPORTING-BUGS usr
> > COPYING Documentation ipc Makefile samples virt
> > CREDITS drivers Kbuild mm scripts
> >
> > I have this /etc/exports on the server:
> > /root *(ro,fsid=0,crossmnt,no_root_squash)
> > /root/Downloads/linux-2.6.39.4 *(rw,no_root_squash,nohide)
> > /root/linux3/Documentation/filesystems *(rw,no_root_squash,nohide)
> >
> > [root@xxx ~]# cat /proc/net/rpc/nfsd.export/content #path
> > domain(flags)
> > # /root/.gvfs *()
> > /root *
> > (ro,no_root_squash,sync,wdelay,crossmnt,no_subtree_check,fsid=0,uuid=4
> > 6bb42
> > 56:d3c84b6f:bbbfff3a:8b0d912c)
> > [root@xxx ~]# cat /proc/net/rpc/nfsd.fh/content #domain fsidtype fsid
> > [path]
> > * 1 0x00000000 /root
> >
> >
> > On the client side, what I saw:
> > [root@xxx /]# mount -o vers=4.1 10.1.13.66:/ /mnt [root@xxx /]# cd
> > /mnt [root@xxx mnt]# ls
> > anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
> > Desktop disk.c Downloads install.log linux3
> > rpmbuild
> > [root@xxx mnt]# cd Downloads/linux-2.6.39.4 [root@xxx linux-2.6.39.4]#
> > ls
> > arch COPYING cscope.out firmware ipc lib
> > Module.symvers samples tools
> > block CREDITS cscope.po.out fs Kbuild MAINTAINERS
> > net scripts usr
> > config crypto Documentation include Kconfig Makefile
> > README security virt
> > config-rh cscope.in.out drivers init kernel mm
> > REPORTING-BUGS sound
> > [root@xxx linux-2.6.39.4]# rm REPORTING-BUGS
> > rm: remove regular file `REPORTING-BUGS'? y
> > rm: cannot remove `REPORTING-BUGS': Read-only file system
> >
> > The question is:
> > Why can I delete this file even I specify the mountpoint
> > /root/Downloads/linux-2.6.39.4 to allow RW access?
> >
> > Thanks
> > Ming
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-nfs"
> > in the body of a message to [email protected] More majordomo
> > info at http://vger.kernel.org/majordomo-info.html

2013-10-11 21:04:26

by Chuck Lever III

[permalink] [raw]
Subject: Re: nfs4.1 pseudo filesystem


On Oct 11, 2013, at 4:58 PM, "J. Bruce Fields" <[email protected]> wrote:

> On Fri, Oct 11, 2013 at 02:29:42PM -0400, J. Bruce Fields wrote:
>> On Fri, Oct 11, 2013 at 04:51:29PM +0000, Ming Lei wrote:
>>> I want to cherry-pick a few subdirectories under say /root, but I don't want to specifies all these mount directories one by one just like NFSv2/3.
>>
>> Well, you're kind of stuck enumerating them whether as exports or bind
>> mounts.
>>
>>> Does pseudo filesystem in kernel v3.11 work well enough?
>>
>> But it should work anyway, yes.
>>
>> Oh, wait, I see the problem: it doesn't work well if you're exporting
>> subdirectories and not full filesystems. Unless you do something
>> special at the export points (e.g. mount --bind them over themselves),
>> knfsd doesn't know when you've crossed an export point.
>
> I wonder if exportfs should be taught to mark export points as
> junctions. That might fix this kind of problem?

A junction is always an unreadable directory.

We'd be better off with a generic "please upcall" bit for directories. Then mountd could sort out what are junctions and what are legitimate exports, and the kernel would leave all the other directories in an export alone.

> It might mean creating junctions never get cleaned up, which is ugly
> though perhaps unlikely to be a serious problem in practice.

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com





2013-10-11 17:00:56

by Ming Lei

[permalink] [raw]
Subject: RE: nfs4.1 pseudo filesystem

I want to cherry-pick a few subdirectories under say /root, but I don't want to specifies all these mount directories one by one just like NFSv2/3.

Does pseudo filesystem in kernel v3.11 work well enough?

Thanks
Ming

-----Original Message-----
From: J. Bruce Fields [mailto:[email protected]]
Sent: Friday, October 11, 2013 9:30 AM
To: Ming Lei
Cc: [email protected]
Subject: Re: nfs4.1 pseudo filesystem

On Thu, Oct 10, 2013 at 09:39:38PM +0000, Ming Lei wrote:
>
> I want to set up the real directory as the root of the pseudo
> filesystem got exported from the server.

Unless you have some very good reason, I recommend just ignoring the pseudo filesystem. Just export the directories you want to without using fsid=0 or bind mounts, just as you would with NFSv2/v3. That will work fine on any recent server.

--b.

> Can I do it or I have to create /export empty directory as the root of
> the pseudo FS and then bind the real directories?
>
> I have this test, both server and client running 3.11.0+:
>
> On the server, there is /root directory.
> [root@xxx ~] ls /root
> anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
> Desktop disk.c Downloads install.log linux3
> rpmbuild
> [root@xxx ~]# ls /root/Downloads/linux-2.6.39.4
> arch crypto firmware Kconfig Module.symvers security
> block cscope.in.out fs kernel net sound
> config cscope.out include lib README tools
> config-rh cscope.po.out init MAINTAINERS REPORTING-BUGS usr
> COPYING Documentation ipc Makefile samples virt
> CREDITS drivers Kbuild mm scripts
>
> I have this /etc/exports on the server:
> /root *(ro,fsid=0,crossmnt,no_root_squash)
> /root/Downloads/linux-2.6.39.4 *(rw,no_root_squash,nohide)
> /root/linux3/Documentation/filesystems *(rw,no_root_squash,nohide)
>
> [root@xxx ~]# cat /proc/net/rpc/nfsd.export/content #path
> domain(flags)
> # /root/.gvfs *()
> /root *
> (ro,no_root_squash,sync,wdelay,crossmnt,no_subtree_check,fsid=0,uuid=4
> 6bb42
> 56:d3c84b6f:bbbfff3a:8b0d912c)
> [root@xxx ~]# cat /proc/net/rpc/nfsd.fh/content #domain fsidtype fsid
> [path]
> * 1 0x00000000 /root
>
>
> On the client side, what I saw:
> [root@xxx /]# mount -o vers=4.1 10.1.13.66:/ /mnt [root@xxx /]# cd
> /mnt [root@xxx mnt]# ls
> anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
> Desktop disk.c Downloads install.log linux3
> rpmbuild
> [root@xxx mnt]# cd Downloads/linux-2.6.39.4 [root@xxx linux-2.6.39.4]#
> ls
> arch COPYING cscope.out firmware ipc lib
> Module.symvers samples tools
> block CREDITS cscope.po.out fs Kbuild MAINTAINERS
> net scripts usr
> config crypto Documentation include Kconfig Makefile
> README security virt
> config-rh cscope.in.out drivers init kernel mm
> REPORTING-BUGS sound
> [root@xxx linux-2.6.39.4]# rm REPORTING-BUGS
> rm: remove regular file `REPORTING-BUGS'? y
> rm: cannot remove `REPORTING-BUGS': Read-only file system
>
> The question is:
> Why can I delete this file even I specify the mountpoint
> /root/Downloads/linux-2.6.39.4 to allow RW access?
>
> Thanks
> Ming
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs"
> in the body of a message to [email protected] More majordomo
> info at http://vger.kernel.org/majordomo-info.html

2013-10-11 20:58:37

by J. Bruce Fields

[permalink] [raw]
Subject: Re: nfs4.1 pseudo filesystem

On Fri, Oct 11, 2013 at 02:29:42PM -0400, J. Bruce Fields wrote:
> On Fri, Oct 11, 2013 at 04:51:29PM +0000, Ming Lei wrote:
> > I want to cherry-pick a few subdirectories under say /root, but I don't want to specifies all these mount directories one by one just like NFSv2/3.
>
> Well, you're kind of stuck enumerating them whether as exports or bind
> mounts.
>
> > Does pseudo filesystem in kernel v3.11 work well enough?
>
> But it should work anyway, yes.
>
> Oh, wait, I see the problem: it doesn't work well if you're exporting
> subdirectories and not full filesystems. Unless you do something
> special at the export points (e.g. mount --bind them over themselves),
> knfsd doesn't know when you've crossed an export point.

I wonder if exportfs should be taught to mark export points as
junctions. That might fix this kind of problem?

It might mean creating junctions never get cleaned up, which is ugly
though perhaps unlikely to be a serious problem in practice.

--b.

2013-10-11 16:30:23

by J. Bruce Fields

[permalink] [raw]
Subject: Re: nfs4.1 pseudo filesystem

On Thu, Oct 10, 2013 at 09:39:38PM +0000, Ming Lei wrote:
>
> I want to set up the real directory as the root of the pseudo filesystem
> got exported from the server.

Unless you have some very good reason, I recommend just ignoring the
pseudo filesystem. Just export the directories you want to without
using fsid=0 or bind mounts, just as you would with NFSv2/v3. That will
work fine on any recent server.

--b.

> Can I do it or I have to create /export
> empty directory as the root of the pseudo FS and then bind the real
> directories?
>
> I have this test, both server and client running 3.11.0+:
>
> On the server, there is /root directory.
> [root@xxx ~] ls /root
> anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
> Desktop disk.c Downloads install.log linux3
> rpmbuild
> [root@xxx ~]# ls /root/Downloads/linux-2.6.39.4
> arch crypto firmware Kconfig Module.symvers security
> block cscope.in.out fs kernel net sound
> config cscope.out include lib README tools
> config-rh cscope.po.out init MAINTAINERS REPORTING-BUGS usr
> COPYING Documentation ipc Makefile samples virt
> CREDITS drivers Kbuild mm scripts
>
> I have this /etc/exports on the server:
> /root *(ro,fsid=0,crossmnt,no_root_squash)
> /root/Downloads/linux-2.6.39.4 *(rw,no_root_squash,nohide)
> /root/linux3/Documentation/filesystems *(rw,no_root_squash,nohide)
>
> [root@xxx ~]# cat /proc/net/rpc/nfsd.export/content
> #path domain(flags)
> # /root/.gvfs *()
> /root *
> (ro,no_root_squash,sync,wdelay,crossmnt,no_subtree_check,fsid=0,uuid=46bb42
> 56:d3c84b6f:bbbfff3a:8b0d912c)
> [root@xxx ~]# cat /proc/net/rpc/nfsd.fh/content
> #domain fsidtype fsid [path]
> * 1 0x00000000 /root
>
>
> On the client side, what I saw:
> [root@xxx /]# mount -o vers=4.1 10.1.13.66:/ /mnt
> [root@xxx /]# cd /mnt
> [root@xxx mnt]# ls
> anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
> Desktop disk.c Downloads install.log linux3
> rpmbuild
> [root@xxx mnt]# cd Downloads/linux-2.6.39.4
> [root@xxx linux-2.6.39.4]# ls
> arch COPYING cscope.out firmware ipc lib
> Module.symvers samples tools
> block CREDITS cscope.po.out fs Kbuild MAINTAINERS
> net scripts usr
> config crypto Documentation include Kconfig Makefile
> README security virt
> config-rh cscope.in.out drivers init kernel mm
> REPORTING-BUGS sound
> [root@xxx linux-2.6.39.4]# rm REPORTING-BUGS
> rm: remove regular file `REPORTING-BUGS'? y
> rm: cannot remove `REPORTING-BUGS': Read-only file system
>
> The question is:
> Why can I delete this file even I specify the
> mountpoint /root/Downloads/linux-2.6.39.4 to allow RW access?
>
> Thanks
> Ming
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2013-10-12 06:42:38

by Minlan Wang

[permalink] [raw]
Subject: RE: nfs4.1 pseudo filesystem

Hi, Ming,
I guess the problem here is that the filesystem on "/root", "/root/Downloads/linux-2.6.39.4", and "/root/linux3/Documentation/filesystems" are the same filesystem.
So when your client tried to access anything within the three directories, they all use the export "/root *(ro,fsid=0,crossmnt,no_root_squash)" to determin their permission.
Try to mount some other filesystems on your "real" exports, I mean, the exports with fsid other than 0, then do your tests.

B.R
Minlan Wang


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ming Lei
Sent: Friday, October 11, 2013 5:40 AM
To: [email protected]
Subject: nfs4.1 pseudo filesystem


I want to set up the real directory as the root of the pseudo filesystem
got exported from the server. Can I do it or I have to create /export
empty directory as the root of the pseudo FS and then bind the real
directories?

I have this test, both server and client running 3.11.0+:

On the server, there is /root directory.
[root@xxx ~] ls /root
anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
Desktop disk.c Downloads install.log linux3
rpmbuild
[root@xxx ~]# ls /root/Downloads/linux-2.6.39.4
arch crypto firmware Kconfig Module.symvers security
block cscope.in.out fs kernel net sound
config cscope.out include lib README tools
config-rh cscope.po.out init MAINTAINERS REPORTING-BUGS usr
COPYING Documentation ipc Makefile samples virt
CREDITS drivers Kbuild mm scripts

I have this /etc/exports on the server:
/root *(ro,fsid=0,crossmnt,no_root_squash)
/root/Downloads/linux-2.6.39.4 *(rw,no_root_squash,nohide)
/root/linux3/Documentation/filesystems *(rw,no_root_squash,nohide)

[root@xxx ~]# cat /proc/net/rpc/nfsd.export/content
#path domain(flags)
# /root/.gvfs *()
/root *
(ro,no_root_squash,sync,wdelay,crossmnt,no_subtree_check,fsid=0,uuid=46bb42
56:d3c84b6f:bbbfff3a:8b0d912c)
[root@xxx ~]# cat /proc/net/rpc/nfsd.fh/content
#domain fsidtype fsid [path]
* 1 0x00000000 /root


On the client side, what I saw:
[root@xxx /]# mount -o vers=4.1 10.1.13.66:/ /mnt
[root@xxx /]# cd /mnt
[root@xxx mnt]# ls
anaconda-ks.cfg disk Documents fs_log.old install.log.syslog Public
Desktop disk.c Downloads install.log linux3
rpmbuild
[root@xxx mnt]# cd Downloads/linux-2.6.39.4
[root@xxx linux-2.6.39.4]# ls
arch COPYING cscope.out firmware ipc lib
Module.symvers samples tools
block CREDITS cscope.po.out fs Kbuild MAINTAINERS
net scripts usr
config crypto Documentation include Kconfig Makefile
README security virt
config-rh cscope.in.out drivers init kernel mm
REPORTING-BUGS sound
[root@xxx linux-2.6.39.4]# rm REPORTING-BUGS
rm: remove regular file `REPORTING-BUGS'? y
rm: cannot remove `REPORTING-BUGS': Read-only file system

The question is:
Why can I delete this file even I specify the
mountpoint /root/Downloads/linux-2.6.39.4 to allow RW access?

Thanks
Ming