1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _MM_SWAP_OPS_H 3 #define _MM_SWAP_OPS_H 4 5 #include <linux/swap.h> /* for SWAP_CLUSTER_MAX */ 6 7 struct swap_iocb { 8 union { 9 struct kiocb iocb; 10 struct bio bio; 11 }; 12 struct bio_vec bvecs[SWAP_CLUSTER_MAX]; 13 int nr_bvecs; 14 int len; 15 }; 16 17 struct swap_io_ctx { 18 struct swap_iocb *sio; 19 struct swap_info_struct *sis; 20 }; 21 22 /* 23 * SWAP_OPS_F_REQUIRE_NOFS: 24 * When set, all reclaim operations must operated as GFS_NOFS and not 25 * just GFP_NOIO, as GFP_NOIO allocations could recourse into the 26 * file system backing this swap file. 27 */ 28 #define SWAP_OPS_F_REQUIRE_NOFS (1U << 0) 29 30 struct swap_ops { 31 unsigned int flags; 32 33 bool (*can_merge)(struct folio *folio, struct folio *prev_folio, 34 size_t prev_folio_size, int rw); 35 void (*submit_write)(struct swap_io_ctx *ctx); 36 void (*submit_read)(struct swap_io_ctx *ctx); 37 }; 38 39 void swap_fs_prepare_rw(struct swap_io_ctx *ctx, int rw, struct iov_iter *iter); 40 bool swap_fs_can_merge(struct folio *folio, struct folio *prev_folio, 41 size_t prev_folio_size, int rw); 42 int swap_fs_activate(struct swap_info_struct *sis, const struct swap_ops *ops); 43 44 #endif /* _MM_SWAP_OPS_H */ 45