From owner-freebsd-fs@freebsd.org Fri Sep 15 16:37:08 2017 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD01CE21541; Fri, 15 Sep 2017 16:37:08 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 6B4836E84A; Fri, 15 Sep 2017 16:37:07 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id TAA21439; Fri, 15 Sep 2017 19:37:00 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1dstbv-0001KC-SP; Fri, 15 Sep 2017 19:36:59 +0300 Subject: Re: mount / unmount and mountcheckdirs() To: Edward Napierala Cc: Konstantin Belousov , Kirk McKusick , freebsd-fs , "freebsd-arch@freebsd.org" References: <134c7c6e-f4f1-ef38-cc50-0e56c27c9fb8@FreeBSD.org> <201709150314.v8F3Ea6B085072@chez.mckusick.com> <20170915092001.GK78693@kib.kiev.ua> From: Andriy Gapon Message-ID: <59255d6c-07fc-19ab-0a8a-914ada69680a@FreeBSD.org> Date: Fri, 15 Sep 2017 19:36:04 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Sep 2017 16:37:08 -0000 On 15/09/2017 19:02, Edward Napierala wrote: > 2017-09-15 12:56 GMT+01:00 Andriy Gapon >: > > On 15/09/2017 13:08, Edward Napierala wrote: > > 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) > > Interesting, I thought that /dev/md0 would get mounted as soon as /media/md0 is > looked up.  But maybe that would be sub-optimal for some common scenarios... > FWIW, ZFS snapshots get auto-mounted under .zfs as soon as there is a lookup. > > > You really don't want it to work that way.  If you have a directory with thousands > of mountpoints inside, you don't want to mount all of them every time you do "ls" > in that directory. Well, "ls" wouldn't trigger the mounting as it's just VOP_READDIR in the parent vnode, "ls -l" (or any other options that require file attributes) is a different story :-) > Same problem with mounting on "cd".  That's why autofs triggers > in three cases: in VOP_READDIR(9), VOP_GETATTR(9), and VOP_LOOKUP(9) > with the vnode as a parent dir. Well, "cd" is also a different story, you can't cd to hundreds of directories at once. Of course, the filesystem doesn't really know if it's "cd" or something else that triggered VOP_LOOKUP. Although VOP_ACCESS could be used as a hint, it is a rather weak hint. In any case, I prefer the mount-on-lookup approach as it is "more seamless". -- Andriy Gapon