From: Matthew Wilcox <willy@infradead.org>
To: David Howells <dhowells@redhat.com>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>,
Christoph Hellwig <hch@lst.de>,
Trond Myklebust <trond.myklebust@primarydata.com>,
linux-nfs@vger.kernel.org, viro@zeniv.linux.org.uk,
jlayton@kernel.org, sfrench@samba.org,
torvalds@linux-foundation.org, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v2 1/5] nfs: Fix write to swapfile failure due to generic_write_checks()
Date: Fri, 13 Aug 2021 04:09:39 +0100 [thread overview]
Message-ID: <YRXicziD5Jy74PZj@casper.infradead.org> (raw)
In-Reply-To: <162879972678.3306668.10709543333474121000.stgit@warthog.procyon.org.uk>
On Thu, Aug 12, 2021 at 09:22:06PM +0100, David Howells wrote:
> Trying to use a swapfile on NFS results in every DIO write failing with
> ETXTBSY because generic_write_checks(), as called by nfs_direct_write()
> from nfs_direct_IO(), forbids writes to swapfiles.
Why does nfs_direct_write() call generic_write_checks()?
ie call generic_write_checks() earlier, and only swap would bypass them.
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 2e894fec036b..7e2ca6b5fc5f 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -905,9 +905,6 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n",
file, iov_iter_count(iter), (long long) iocb->ki_pos);
- result = generic_write_checks(iocb, iter);
- if (result <= 0)
- return result;
count = result;
nfs_add_stats(mapping->host, NFSIOS_DIRECTWRITTENBYTES, count);
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 1fef107961bc..91b2e3214836 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -611,6 +611,10 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
errseq_t since;
int error;
+ result = generic_write_checks(iocb, from);
+ if (result < 0)
+ return result;
+
result = nfs_key_timeout_notify(file, inode);
if (result)
return result;
@@ -621,8 +625,6 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
dprintk("NFS: write(%pD2, %zu@%Ld)\n",
file, iov_iter_count(from), (long long) iocb->ki_pos);
- if (IS_SWAPFILE(inode))
- goto out_swapfile;
/*
* O_APPEND implies that we must revalidate the file length.
*/
@@ -636,7 +638,6 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
since = filemap_sample_wb_err(file->f_mapping);
nfs_start_io_write(inode);
- result = generic_write_checks(iocb, from);
if (result > 0) {
current->backing_dev_info = inode_to_bdi(inode);
result = generic_perform_write(file, from, iocb->ki_pos);
@@ -677,10 +678,6 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written);
out:
return result;
-
-out_swapfile:
- printk(KERN_INFO "NFS: attempt to write to active swap file!\n");
- return -ETXTBSY;
}
EXPORT_SYMBOL_GPL(nfs_file_write);
next prev parent reply other threads:[~2021-08-13 3:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-12 20:21 [RFC PATCH v2 0/5] mm: Fix NFS swapfiles and use DIO for swapfiles David Howells
2021-08-12 20:22 ` [RFC PATCH v2 1/5] nfs: Fix write to swapfile failure due to generic_write_checks() David Howells
2021-08-13 3:09 ` Matthew Wilcox [this message]
2021-08-13 7:02 ` Christoph Hellwig
2021-08-19 22:38 ` NeilBrown
2021-08-12 20:22 ` [RFC PATCH v2 2/5] mm: Remove the callback func argument from __swap_writepage() David Howells
2021-08-13 7:03 ` Christoph Hellwig
2021-08-12 20:22 ` [RFC PATCH v2 3/5] mm: Make swap_readpage() for SWP_FS_OPS use ->direct_IO() not ->readpage() David Howells
2021-08-12 21:23 ` Matthew Wilcox
2021-08-13 7:12 ` Christoph Hellwig
2021-08-12 20:22 ` [RFC PATCH v2 4/5] mm: Make __swap_writepage() do async DIO if asked for it David Howells
2021-08-12 20:22 ` [RFC PATCH v2 5/5] mm: Remove swap BIO paths and only use DIO paths [BROKEN] David Howells
2021-08-13 7:14 ` Christoph Hellwig
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=YRXicziD5Jy74PZj@casper.infradead.org \
--to=willy@infradead.org \
--cc=darrick.wong@oracle.com \
--cc=dhowells@redhat.com \
--cc=hch@lst.de \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=sfrench@samba.org \
--cc=torvalds@linux-foundation.org \
--cc=trond.myklebust@primarydata.com \
--cc=viro@zeniv.linux.org.uk \
/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).