mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-05 08:44:14 +02:00
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>
45 lines
1.1 KiB
C
45 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _MM_SWAP_OPS_H
|
|
#define _MM_SWAP_OPS_H
|
|
|
|
#include <linux/swap.h> /* for SWAP_CLUSTER_MAX */
|
|
|
|
struct swap_iocb {
|
|
union {
|
|
struct kiocb iocb;
|
|
struct bio bio;
|
|
};
|
|
struct bio_vec bvecs[SWAP_CLUSTER_MAX];
|
|
int nr_bvecs;
|
|
int len;
|
|
};
|
|
|
|
struct swap_io_ctx {
|
|
struct swap_iocb *sio;
|
|
struct swap_info_struct *sis;
|
|
};
|
|
|
|
/*
|
|
* SWAP_OPS_F_REQUIRE_NOFS:
|
|
* When set, all reclaim operations must operated as GFS_NOFS and not
|
|
* just GFP_NOIO, as GFP_NOIO allocations could recourse into the
|
|
* file system backing this swap file.
|
|
*/
|
|
#define SWAP_OPS_F_REQUIRE_NOFS (1U << 0)
|
|
|
|
struct swap_ops {
|
|
unsigned int flags;
|
|
|
|
bool (*can_merge)(struct folio *folio, struct folio *prev_folio,
|
|
size_t prev_folio_size, int rw);
|
|
void (*submit_write)(struct swap_io_ctx *ctx);
|
|
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 */
|