From: Neil Brown <neilb@suse.com>
To: util-linux@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: mount does not accurately identify existing NFS mounts, and shouldn't try.
Date: Mon, 19 Oct 2015 12:08:41 +1100 [thread overview]
Message-ID: <87twpnll5y.fsf@notabene.neil.brown.name> (raw)
[-- Attachment #1: Type: text/plain, Size: 2328 bytes --]
When I run "mount -a" (and possibly in other circumstances) mount
attempts to determine if the requested filesystem is already mounted.
It seems to have some handling for various special cases, but doesn't
handle all cases properly.
For example, if I have
server:/export /import nfs ....
192.168.1.1:/private private nfs ....
in /etc/fstab and the IP address of 'server' is 192.168.1.1,
then both entries will appear in /proc/mounts with the same host name
(depending on which order there were mounted).
When I run "mount -a" a second time it will detect that one of these is
already correctly mounted, and will ignore it.
The other will not be detected as already being mounted (as the hostname
appears different) and "mount -a" will try to mount it again.
This will fail with "EBUSY" and mount will report an error
.... is busy or already mounted.
So while both filesystems are already mounted, we only get an error for
one of them.
The irony here is that while it is hard for user-space to determine
if the mounted filesystem matches the requested filesystem it is trivial
for the kernel.
For NFS we could try canonicalizing the server name, but undoubtedly
other issues would arrive. I believe there are similar issues with
btrfs and submount, though I have looked closely.
For the kernel, it is as simple as
/* Refuse the same filesystem on the same mount point */
err = -EBUSY;
if (path->mnt->mnt_sb == newmnt->mnt.mnt_sb &&
path->mnt->mnt_root == path->dentry)
goto unlock;
This is the *only* time that the kernel returns EBUSY for a "mount a new
filesystem" request (remount can return EBUSY for other reasons I
think).
So in the case where "mount" thinks it should check if the filesystem is
already mounted and ignore the request if it is, the best thing it can
do is to just try the mount and ignore any "EBUSY" error status - treat
that the same as success.
So all that code for "is this the same mountpoint" can probably be
discarded.
Did I miss any important consideration there?
Unfortunately this change could be awkward to implement as /sbin/mount
decides whether to try the mount and (for NFS), /sbin/mount.nfs gives an
error message if EBUSY is returned. Would we need to pass a "noebusy"
flag, but only if mount.nfs were willing to accept it....
Any suggestions?
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
next reply other threads:[~2015-10-19 1:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-19 1:08 Neil Brown [this message]
2015-10-30 10:55 ` mount does not accurately identify existing NFS mounts, and shouldn't try Karel Zak
2015-10-30 22:46 ` Neil Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87twpnll5y.fsf@notabene.neil.brown.name \
--to=neilb@suse.com \
--cc=linux-nfs@vger.kernel.org \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox