diff mbox series

nfs: fix the incorrect assertion in nfs_swap_rw()

Message ID 20240617220135.43563-1-21cnbao@gmail.com
State New
Headers show
Series nfs: fix the incorrect assertion in nfs_swap_rw() | expand

Commit Message

Barry Song June 17, 2024, 10:01 p.m. UTC
From: Barry Song <v-songbaohua@oppo.com>

Since commit 2282679fb20b ("mm: submit multipage write for SWP_FS_OPS
swap-space"), we can plug multiple pages then unplug them all together.
That means iov_iter_count(iter) could be way bigger than PAGE_SIZE, it
actually equals the size of iov_iter_npages(iter, INT_MAX).

Note this issue has nothing to do with large folios as we don't support
THP_SWPOUT to non-block devices.

Fixes: 2282679fb20b ("mm: submit multipage write for SWP_FS_OPS swap-space")
Reported-by: Christoph Hellwig <hch@lst.de>
Closes: https://lore.kernel.org/linux-mm/20240617053201.GA16852@lst.de/
Cc: NeilBrown <neilb@suse.de>
Cc: Anna Schumaker <anna@kernel.org>
Cc: Steve French <sfrench@samba.org>
Cc: Trond Myklebust <trondmy@kernel.org>
Cc: Chuanhua Han <hanchuanhua@oppo.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Barry Song <v-songbaohua@oppo.com>
---
 fs/nfs/direct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matthew Wilcox June 17, 2024, 11:17 p.m. UTC | #1
On Tue, Jun 18, 2024 at 10:01:35AM +1200, Barry Song wrote:
> +++ b/fs/nfs/direct.c
> @@ -141,7 +141,7 @@ int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter)
>  {
>  	ssize_t ret;
>  
> -	VM_BUG_ON(iov_iter_count(iter) != PAGE_SIZE);
> +	VM_WARN_ON(iov_iter_count(iter) != iov_iter_npages(iter, INT_MAX) * PAGE_SIZE);

Why not just delete the assertion like Christoph did?
Barry Song June 17, 2024, 11:36 p.m. UTC | #2
On Tue, Jun 18, 2024 at 11:17 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Tue, Jun 18, 2024 at 10:01:35AM +1200, Barry Song wrote:
> > +++ b/fs/nfs/direct.c
> > @@ -141,7 +141,7 @@ int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter)
> >  {
> >       ssize_t ret;
> >
> > -     VM_BUG_ON(iov_iter_count(iter) != PAGE_SIZE);
> > +     VM_WARN_ON(iov_iter_count(iter) != iov_iter_npages(iter, INT_MAX) * PAGE_SIZE);
>
> Why not just delete the assertion like Christoph did?

I'm fine with either option. While maintaining this, my thought at the
time was that I might
want to reassess this assertion once mTHP swapout is supported on
swapfiles later.
diff mbox series

Patch

diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index bb2f583eb28b..a1bfa86f467a 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -141,7 +141,7 @@  int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter)
 {
 	ssize_t ret;
 
-	VM_BUG_ON(iov_iter_count(iter) != PAGE_SIZE);
+	VM_WARN_ON(iov_iter_count(iter) != iov_iter_npages(iter, INT_MAX) * PAGE_SIZE);
 
 	if (iov_iter_rw(iter) == READ)
 		ret = nfs_file_direct_read(iocb, iter, true);