From: NeilBrown <neilb@suse.com>
To: "Linux NFS" <linux-nfs@vger.kernel.org>
Subject: A NFS mount can still write to the server after 'umount' has completed.
Date: Thu, 09 Mar 2017 14:36:55 +1100 [thread overview]
Message-ID: <871su7i0iw.fsf@notabene.neil.brown.name> (raw)
[-- Attachment #1: Type: text/plain, Size: 1706 bytes --]
I've been chasing down a problem where a customer has a localhost mount,
and the sequence
unmount -at nfs,nfs4
stop nfsserver
sync
hangs on the sync. The 'sync' is trying to write to the NFS filesystem
that has just been unmounted.
I have duplicated the problem on a current mainline kernel.
There are two important facts that lead to the explanation of this.
1/ whenever a 'struct file' is open, an s_active reference is held on
the superblock, via "open_context" calling nfs_sb_active().
This doesn't prevent "unmount" from succeeding (i.e. EBUSY isn't
returned), but does prevent the actual unmount from happening
(->kill_sb() isn't called).
2/ When a memory mapping of a file is torn down, the file is
"released", causing the context to be discarded and the sb_active
reference released, but unlike close(2), file_operations->flush()
is not called.
Consequently, if you:
open an NFS file
mmap some pages PROT_WRITE
close the file
modify the pages
unmap the pages
unmount the filesystem
the filesystem will remain active, and the pages will remain dirty.
If you then make the nfs server unavailable - e.g. stop it, or tear down
the network connection - and then call 'sync', the sync will hang.
This is surprising, at the least :-)
I have two ideas how it might be fixed.
One is to call nfs_file_flush() from within nfs_file_release().
This is probably simplest (and appears to work).
The other is to add a ".close" to nfs_file_vm_ops. This could trigger a
(partial) flush whenever a page is unmapped. As closing an NFS file
always triggers a flush, it seems reasonable that unmapping a page
would trigger a flush of that page.
Thoughts?
Thanks,
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next reply other threads:[~2017-03-09 3:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-09 3:36 NeilBrown [this message]
2017-03-09 4:46 ` A NFS mount can still write to the server after 'umount' has completed NeilBrown
2017-03-09 13:21 ` Trond Myklebust
2017-03-09 21:38 ` NeilBrown
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=871su7i0iw.fsf@notabene.neil.brown.name \
--to=neilb@suse.com \
--cc=linux-nfs@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;
as well as URLs for NNTP newsgroup(s).