[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <164323750168.5493.12090358551960276049@noble.neil.brown.name>
Date: Thu, 27 Jan 2022 09:51:41 +1100
From: "NeilBrown" <neilb@...e.de>
To: "Mark Hemment" <markhemm@...glemail.com>
Cc: "Trond Myklebust" <trond.myklebust@...merspace.com>,
"Anna Schumaker" <anna.schumaker@...app.com>,
"Chuck Lever" <chuck.lever@...cle.com>,
"Andrew Morton" <akpm@...ux-foundation.org>,
"Mel Gorman" <mgorman@...e.de>,
"Christoph Hellwig" <hch@...radead.org>,
"David Howells" <dhowells@...hat.com>, linux-nfs@...r.kernel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 14/23] NFS: swap IO handling is slightly different for O_DIRECT IO
On Tue, 25 Jan 2022, Mark Hemment wrote:
> On Mon, 24 Jan 2022 at 03:53, NeilBrown <neilb@...e.de> wrote:
> >
> > 1/ Taking the i_rwsem for swap IO triggers lockdep warnings regarding
> > possible deadlocks with "fs_reclaim". These deadlocks could, I believe,
> > eventuate if a buffered read on the swapfile was attempted.
> >
> > We don't need coherence with the page cache for a swap file, and
> > buffered writes are forbidden anyway. There is no other need for
> > i_rwsem during direct IO. So never take it for swap_rw()
> >
> > 2/ generic_write_checks() explicitly forbids writes to swap, and
> > performs checks that are not needed for swap. So bypass it
> > for swap_rw().
> >
> > Signed-off-by: NeilBrown <neilb@...e.de>
> > ---
> > fs/nfs/direct.c | 30 +++++++++++++++++++++---------
> > fs/nfs/file.c | 4 ++--
> > include/linux/nfs_fs.h | 4 ++--
> > 3 files changed, 25 insertions(+), 13 deletions(-)
> >
> ...
> > @@ -943,7 +954,8 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
> > pos >> PAGE_SHIFT, end);
> > }
> >
> > - nfs_end_io_direct(inode);
> > + if (!swap)
> > + nfs_end_io_direct(inode);
>
> Just above this code diff, there is;
> if (mapping->nrpages) {
> invalidate_inode_pages2_range(mapping,
> pos >> PAGE_SHIFT, end);
> }
>
> This invalidation looks strange/wrong for a NFS swap write. Should it
> be disabled for the swap case?
Yes, I think it should - particularly as we don't take the mutex in the
swap case. Thanks!
This change improves the look of the code too :-)
Thanks,
NeilBrown
Powered by blists - more mailing lists