Skip to contentSkip to conversation

nfs: fix the incorrect assertion in nfs_swap_rw()

PATCH Superseded Barry Song 2 participants 3 messages Jun 17, 2024

Subsystems (6)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH 1/1 nfs: fix the incorrect assertion in nfs_swap_rw()

From: Barry Song <[email protected]>

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")
Cc NeilBrown <[email protected]>
Cc Anna Schumaker <[email protected]>
Cc Steve French <[email protected]>
Cc Trond Myklebust <[email protected]>
Cc Chuanhua Han <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Chris Li <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Jeff Layton <[email protected]>
---
 fs/nfs/direct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/direct.c +1 -1
index bb2f583eb28b..a1bfa86f467a 100644
@@ -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);
Signature · 1 line
2.34.1
#1 lore raw

fs/nfs/direct.c int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter) · line 144

Quoted 7 lines · Barry Song

+++ b/fs/nfs/direct.c

fs/nfs/direct.c +1 -1
@@ -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?

author
#2 lore raw
Quoted 11 lines · Matthew Wilcox

fs/nfs/direct.c int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter) · line 144

Quoted 7 lines · Barry Song

+++ b/fs/nfs/direct.c

fs/nfs/direct.c +1 -1
@@ -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.