Re: mount gets into a state where it won't set/unset ZFS properties (atime, exec, setuid)

From: Pawel Jakub Dawidek <pjd_at_FreeBSD.org>
Date: Thu, 9 Aug 2007 19:44:10 +0200
On Thu, Aug 09, 2007 at 12:07:08PM -0500, Scot Hetzel wrote:
> While checking out a problem with mount unsetting noatime on a UFS
> system, I tested mount with both a UFS and ZFS filesystems.  The ZFS
> filesystem had several problems:
> 
> hp010# uname -a
> FreeBSD hp010.hetzel.org 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Wed Aug
> 8 10:38:34 CDT 2007
> root_at_hp010.hetzel.org:/usr/src/7x/sys/amd64/compile/GENERIC.debug
> amd64
> 
> hp010# umount /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> 
> hp010# zfs mount -a
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> 
> hp010# mount -u -o noexec,nosuid /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      off                           temporary
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local,
> noexec, nosuid)
> 
> Why doesn't the setuid property change to 'temporary' for
> rootpool/usr/ports/distfiles?
> 
> hp010# mount -u -o exec,suid /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      off                           temporary
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local,
> noexec, nosuid)
> 
> mount can't get rid of these options.
> 
> hp010# mount -u -o noatime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     off                           temporary
> rootpool/usr/ports/distfiles  exec      off                           temporary
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local,
> noatime, noexec, nosuid)
> 
> hp010# mount -u -o atime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     off                           temporary
> rootpool/usr/ports/distfiles  exec      off                           temporary
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local,
> noatime, noexec, nosuid)
> 
> Same problem with getting rid of noatime.  I would have expected mount
> to be able to be able to change the zfs properties of atime, exec back
> to on.
> 
> hp010# zfs inherit -r atime rootpool/usr/ports/distfiles
> hp010# zfs inherit -r exec rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> 
> 
> hp010# zfs set setuid=off rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    off                           local
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> 
> hp010# zfs inherit -r setuid rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> 
> We have now set everything back to the default mount options using 'zfs inherit'
> 
> hp010# mount -u -o noatime,noexec,nosuid /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> 
> Now mount can't set noatime or noexec.
> 
> hp010# zfs inherit -r setuid rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> 
> Back to the defaults again.
> 
> This last part gets a bit strange, without umounting
> /usr/ports/distfiles, I tried the following:
> 
> hp010# mount -u -o nosuid /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> hp010# zfs set setuid=off rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    off                           local
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> hp010# zfs inherit -r setuid rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> hp010# mount -u -o noatime,noexec,nosuid /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      off                           temporary
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local,
> noexec, nosuid)
> hp010# zfs inherit -r setuid rootpool/usr/ports/distfiles
> hp010# zfs inherit -r exec rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> hp010# mount -u -o noatime,noexec,nosuid /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      off                           temporary
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local,
> noexec, nosuid)
> 
> It won't set noatime when noexec and nosuid are specified.
> 
> hp010# mount -u -o noatime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> 
> Now it removed noexec, and didn't set noatime.
> 
> hp010# zfs inherit -r setuid rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> 
> Lets try setting noatime again:
> 
> hp010# mount -u -o noatime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> 
> mount shows nosuid.  Lets unset if with zfs inherit:
> 
> hp010# zfs inherit -r setuid rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> 
> nosuid is gone, lets see if we can now set noatime:
> 
> hp010# mount -u -o noatime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> 
> Again mount is showing nosuid:
> 
> hp010# mount -u -o nonoatime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> hp010# mount -u -o nonosuid /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, nosuid)
> 
> Try nonoatime and nonosuid, but mount still showing nosuid.  Using zfs
> inherit gets rid of nosuid:
> 
> hp010# zfs inherit -r setuid rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> 
> Give up, and umount the filesystem:
> 
> hp010# umount /usr/ports/distfiles
> hp010# zfs mount -a
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> hp010# mount -u -o noatime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     off                           temporary
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, noatime)
> 
> We can now set noatime, try nonoatime to unset it:
> 
> hp010# mount -u -o nonoatime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     off                           temporary
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, noatime)
> 
> That didn't work, does atime work:
> 
> hp010# mount -u -o atime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     off                           temporary
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local, noatime)
> 
> Reset atime to defaults with zfs inherit:
> 
> hp010# zfs inherit -r atime rootpool/usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> 
> Does nonoatime have any side efects now:
> 
> hp010# mount -u -o nonoatime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> 
> No side effect, lets try setting noatime:
> 
> hp010# mount -u -o noatime /usr/ports/distfiles
> hp010# zfs get atime,exec,setuid rootpool/usr/ports/distfiles ; mount
> | grep distfiles
> NAME                          PROPERTY  VALUE                         SOURCE
> rootpool/usr/ports/distfiles  atime     on                            default
> rootpool/usr/ports/distfiles  exec      on                            default
> rootpool/usr/ports/distfiles  setuid    on                            default
> rootpool/usr/ports/distfiles on /usr/ports/distfiles (zfs, local)
> hp010#
> 
> Now mount can't set noatime.

Could you file a PR for this? The code responsible for mount options
handling changed recently in ZFS, but I don't think I'll be able to
integrate it before 7.0-RELEASE.

-- 
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd_at_FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!

Received on Thu Aug 09 2007 - 15:45:11 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:16 UTC