@@ -7,8 +7,10 @@
#include <linux/bitops.h>
#include <linux/jump_label.h>
+struct block_device;
+
struct frontswap_ops {
- void (*init)(unsigned); /* this swap type was just swapon'ed */
+ void (*init)(unsigned, struct block_device *); /* this swap type was just swapon'ed */
int (*store)(unsigned, pgoff_t, struct page *); /* store a page */
int (*load)(unsigned, pgoff_t, struct page *, bool *); /* load a page */
void (*invalidate_page)(unsigned, pgoff_t); /* page no longer needed */
@@ -17,7 +19,8 @@ struct frontswap_ops {
int frontswap_register_ops(const struct frontswap_ops *ops);
-extern void frontswap_init(unsigned type, unsigned long *map);
+extern void frontswap_init(unsigned type, unsigned long *map,
+ struct block_device *bdev);
extern int __frontswap_store(struct page *page);
extern int __frontswap_load(struct page *page);
extern void __frontswap_invalidate_page(unsigned, pgoff_t);
@@ -107,7 +107,7 @@ int frontswap_register_ops(const struct frontswap_ops *ops)
/*
* Called when a swap device is swapon'd.
*/
-void frontswap_init(unsigned type, unsigned long *map)
+void frontswap_init(unsigned type, unsigned long *map, struct block_device *bdev)
{
struct swap_info_struct *sis = swap_info[type];
@@ -128,7 +128,7 @@ void frontswap_init(unsigned type, unsigned long *map)
if (!frontswap_enabled())
return;
- frontswap_ops->init(type);
+ frontswap_ops->init(type, bdev);
}
static bool __frontswap_test(struct swap_info_struct *sis,
@@ -2339,7 +2339,8 @@ static void enable_swap_info(struct swap_info_struct *p, int prio,
unsigned long *frontswap_map)
{
if (IS_ENABLED(CONFIG_FRONTSWAP))
- frontswap_init(p->type, frontswap_map);
+ frontswap_init(p->type, frontswap_map, p->bdev);
+
spin_lock(&swap_lock);
spin_lock(&p->lock);
setup_swap_info(p, prio, swap_map, cluster_info);
@@ -1510,7 +1510,7 @@ static void zswap_frontswap_invalidate_area(unsigned type)
zswap_trees[type] = NULL;
}
-static void zswap_frontswap_init(unsigned type)
+static void zswap_frontswap_init(unsigned type, struct block_device *bdev)
{
struct zswap_tree *tree;
Modify frontswap to be used as a block device driver for swap partitions. Signed-off-by: Minchan Kim <minchan@kernel.org> --- include/linux/frontswap.h | 7 +++++-- mm/frontswap.c | 4 ++-- mm/swapfile.c | 3 ++- mm/zswap.c | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-)