Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Sep 2017 19:27:52 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Edward Napierala <trasz@freebsd.org>
Cc:        Kirk McKusick <mckusick@mckusick.com>, freebsd-fs <freebsd-fs@freebsd.org>, Andriy Gapon <avg@freebsd.org>, "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>
Subject:   Re: mount / unmount and mountcheckdirs()
Message-ID:  <20170915162752.GX78693@kib.kiev.ua>
In-Reply-To: <CAFLM3-oEvMxvTNL7cRPrQsNonxe89NFXY_yirhWcHprrvaem2Q@mail.gmail.com>
References:  <134c7c6e-f4f1-ef38-cc50-0e56c27c9fb8@FreeBSD.org> <201709150314.v8F3Ea6B085072@chez.mckusick.com> <20170915092001.GK78693@kib.kiev.ua> <CAFLM3-rqg9Pso636Y3Vm6JT0WxWossEfvnsMmmAbC-jEkvyS7Q@mail.gmail.com> <20170915103037.GM78693@kib.kiev.ua> <CAFLM3-oPXg1we2f6comaJCyUQU3OMuSR6YgupQD3qDMbM5o%2B=g@mail.gmail.com> <20170915110033.GO78693@kib.kiev.ua> <CAFLM3-q8eUPRwBOJU-in-syb3vgBnNm23aoJ0XCA7=C=BQkT7A@mail.gmail.com> <20170915114533.GS78693@kib.kiev.ua> <CAFLM3-oEvMxvTNL7cRPrQsNonxe89NFXY_yirhWcHprrvaem2Q@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Sep 15, 2017 at 05:06:10PM +0100, Edward Napierala wrote:
> 2017-09-15 12:45 GMT+01:00 Konstantin Belousov <kostikbel@gmail.com>:
> 
> > On Fri, Sep 15, 2017 at 12:31:05PM +0100, Edward Napierala wrote:
> > > 2017-09-15 12:00 GMT+01:00 Konstantin Belousov <kostikbel@gmail.com>:
> > >
> > > > On Fri, Sep 15, 2017 at 11:49:17AM +0100, Edward Napierala wrote:
> > > > > 2017-09-15 11:30 GMT+01:00 Konstantin Belousov <kostikbel@gmail.com
> > >:
> > > > >
> > > > > > On Fri, Sep 15, 2017 at 11:08:31AM +0100, Edward Napierala wrote:
> > > > > > > 2017-09-15 10:20 GMT+01:00 Konstantin Belousov <
> > kostikbel@gmail.com
> > > > >:
> > > > > > > > I believe that the current autofs does not allow a process to
> > get
> > > > into
> > > > > > > > this situation at all.
> > > > > > > >
> > > > > > >
> > > > > > > It does.  For example:
> > > > > > >
> > > > > > > [trasz@v2:~]% cd /media/md0
> > > > > > > [trasz@v2:/media/md0]% mount
> > > > > > > /dev/ada0s1a on / (ufs, local, noatime, journaled soft-updates)
> > > > > > > devfs on /dev (devfs, local, multilabel)
> > > > > > > map -hosts on /net (autofs)
> > > > > > > map -media on /media (autofs)
> > > > > > > [trasz@v2:/media/md0]% ls
> > > > > > > [trasz@v2:/media/md0]% mount
> > > > > > > /dev/ada0s1a on / (ufs, local, noatime, journaled soft-updates)
> > > > > > > devfs on /dev (devfs, local, multilabel)
> > > > > > > map -hosts on /net (autofs)
> > > > > > > map -media on /media (autofs)
> > > > > > > /dev/md0 on /media/md0 (ufs, local, noatime, nosuid, automounted)
> > > > > > >
> > > > > > > Getting rid of mountcheckdirs() in the unmount path should be
> > fine, I
> > > > > > think.
> > > > > > How the example proves that mountcheckdirs() can be removed ?
> > > > >
> > > > >
> > > > > In the unmount path?  It doesn't; I just don't think autofs would be
> > > > > affected,
> > > > > since having a current working directory in a mountpoint prevents the
> > > > > unmount
> > > > > (unless it's forced).
> > > > >
> > > > > In the mount path?  See below.
> > > > >
> > > > >
> > > > > > How can
> > > > > > we see which directory content was printed by ls, the covered or
> > > > mounted ?
> > > > > >
> > > > >
> > > > > Well, it would be pretty useless if you got the covered directory.
> > > > This is exactly what is being discussed.
> > > >
> > > > > But ok, here's
> > > > > a better example, one that actually shows that:
> > > > >
> > > > > [trasz@v2:/media/md0]% mount
> > > > > /dev/ada0s1a on / (ufs, local, noatime, journaled soft-updates)
> > > > > devfs on /dev (devfs, local, multilabel)
> > > > > map -hosts on /net (autofs)
> > > > > map -media on /media (autofs)
> > > > > [trasz@v2:/media/md0]% ls -al
> > > > > total 9
> > > > > drwxr-xr-x  3 root  wheel     512 Sep 10 10:16 .
> > > > > drwxr-xr-x  3 root  wheel     512 Sep  8 11:42 ..
> > > > > drwxrwxr-x  2 root  operator  512 Sep 10 10:16 .snap
> > > > > [trasz@v2:/media/md0]% mount
> > > > > /dev/ada0s1a on / (ufs, local, noatime, journaled soft-updates)
> > > > > devfs on /dev (devfs, local, multilabel)
> > > > > map -hosts on /net (autofs)
> > > > > map -media on /media (autofs)
> > > > > /dev/md0 on /media/md0 (ufs, local, noatime, nosuid, automounted)
> > > > >
> > > > > Notice the .snap/ directory; it's an empty UFS filesystem.
> > > > And the .snap is from the /dev/md0 volume, right ?
> > > >
> > >
> > > Yes.
> > >
> > >
> > > > If yes, then this demonstration indeed proves that autofs behaves as
> > > > intended on mount.
> > > >
> > >
> > > Exactly.  And, from what I understand, that would break if
> > mountcheckdirs()
> > > got removed from the mount path.
> >
> > Even for autofs ?  Don't autofs postpone lookup() completion until the
> > mount occurs ?
> >
> 
> It does, and that case might work - I'm not sure, but it might.  But what
> happens afterwards, after the syscall that triggered the mount completes?
> You would still have a shell with cwd in that dir, now covered by another
> filesystem.  Autofs doesn't do anything to "lift" the process to the newly
> mounted filesystem root.
The change of the current directory should have already triggered the action,
because it was preceeded by lookup.  At least this is my understanding of
the flow.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170915162752.GX78693>