summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2026-07-23 07:46:06 +0200
committerAndrew Morton <akpm@linux-foundation.org>2026-08-20 18:24:43 -0700
commit5146bf026d4c198ebe6ae2dbd2e7f90808375b49 (patch)
tree5e55ac66f7ed964b034b1296c5c32cd05b2e052f /include
parent31916052a89000023db37b99b69f8463ea87476f (diff)
downloadlinux-next-5146bf026d4c198ebe6ae2dbd2e7f90808375b49.tar.gz
linux-next-5146bf026d4c198ebe6ae2dbd2e7f90808375b49.zip
mm/swap: move swap_ops into file systems for file system-based swap
Currently swap to and from file systems goes through two indirect calls between the swap ops and the swap_rw method. Reduce this by directly providing the swap_ops from the file system. For this refactor swap_fs_submit into a swap_fs_prepare_rw helper that initializes the iov_iter on the callers stack so that file systems can call it directly, and use that to initialize file system specific ops in the NFS and SMB clients, which then get passed to swap_fs_activate. Link: https://lore.kernel.org/20260723054622.3460249-4-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Chris Li <chrisl@kernel.org> Cc: Baoquan He <baoquan.he@linux.dev> Cc: Kairui Song <kasong@tencent.com> Cc: Kairui Song <ryncsn@gmail.com> Cc: Kemeng Shi <shikemeng@huaweicloud.com> Cc: Nhat Pham <nphamcs@gmail.com> Cc: Steve French <sfrench@samba.org> Cc: Usama Arif <usama.arif@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/nfs_fs.h1
-rw-r--r--include/linux/swap.h6
-rw-r--r--include/linux/swap_ops.h5
4 files changed, 5 insertions, 8 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 50ce731a2b78..87b5e9957c00 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -438,7 +438,6 @@ struct address_space_operations {
int (*swap_activate)(struct swap_info_struct *sis, struct file *file,
sector_t *span);
void (*swap_deactivate)(struct file *file);
- int (*swap_rw)(struct kiocb *iocb, struct iov_iter *iter);
};
extern const struct address_space_operations empty_aops;
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index ec17e602c979..764056498eba 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -548,7 +548,6 @@ static inline const struct cred *nfs_file_cred(struct file *file)
/*
* linux/fs/nfs/direct.c
*/
-int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter);
ssize_t nfs_file_direct_read(struct kiocb *iocb,
struct iov_iter *iter, bool swap);
ssize_t nfs_file_direct_write(struct kiocb *iocb,
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 8dd68733c955..5658a1634b85 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -341,8 +341,6 @@ extern void __meminit kswapd_run(int nid);
extern void __meminit kswapd_stop(int nid);
#ifdef CONFIG_SWAP
-
-int swap_fs_activate(struct swap_info_struct *sis);
int add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
unsigned long nr_pages, sector_t start_block);
int generic_swapfile_activate(struct swap_info_struct *, struct file *,
@@ -468,10 +466,6 @@ static inline bool folio_free_swap(struct folio *folio)
return false;
}
-static inline int swap_fs_activate(struct swap_info_struct *sis)
-{
- return -EINVAL;
-}
static inline int add_swap_extent(struct swap_info_struct *sis,
unsigned long start_page,
unsigned long nr_pages, sector_t start_block)
diff --git a/include/linux/swap_ops.h b/include/linux/swap_ops.h
index e92b4f532604..57ac6c703f68 100644
--- a/include/linux/swap_ops.h
+++ b/include/linux/swap_ops.h
@@ -36,4 +36,9 @@ struct swap_ops {
void (*submit_read)(struct swap_io_ctx *ctx);
};
+void swap_fs_prepare_rw(struct swap_io_ctx *ctx, int rw, struct iov_iter *iter);
+bool swap_fs_can_merge(struct folio *folio, struct folio *prev_folio,
+ size_t prev_folio_size, int rw);
+int swap_fs_activate(struct swap_info_struct *sis, const struct swap_ops *ops);
+
#endif /* _MM_SWAP_OPS_H */