All of lore.kernel.org
 help / color / mirror / Atom feed
From: Minchan Kim <minchan@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm <linux-mm@kvack.org>, Jens Axboe <axboe@kernel.dk>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Seth Jennings <sjenning@redhat.com>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Minchan Kim <minchan@kernel.org>
Subject: [PATCH 1/3] frontswap: support backing_dev
Date: Mon, 10 Jul 2023 15:16:57 -0700	[thread overview]
Message-ID: <20230710221659.2473460-2-minchan@kernel.org> (raw)
In-Reply-To: <20230710221659.2473460-1-minchan@kernel.org>

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(-)

diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
index eaa0ac5f9003..466d617dc3c7 100644
--- a/include/linux/frontswap.h
+++ b/include/linux/frontswap.h
@@ -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);
diff --git a/mm/frontswap.c b/mm/frontswap.c
index 2fb5df3384b8..967ce610a1de 100644
--- a/mm/frontswap.c
+++ b/mm/frontswap.c
@@ -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,
diff --git a/mm/swapfile.c b/mm/swapfile.c
index a6945c2e0d03..a9424fd226bc 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -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);
diff --git a/mm/zswap.c b/mm/zswap.c
index c122f042a49d..9247e3adc21f 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -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;
 
-- 
2.41.0.255.g8b1d071c50-goog



  reply	other threads:[~2023-07-10 22:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-10 22:16 [PATCH 0/3] zram: use frontswap for zram swap usecase Minchan Kim
2023-07-10 22:16 ` Minchan Kim [this message]
2023-07-10 22:16 ` [PATCH 2/3] zram: support frontswap Minchan Kim
2023-07-11 10:08   ` Alexey Romanov
2023-07-11 23:58     ` Minchan Kim
2023-07-10 22:16 ` [PATCH 3/3] zram: remove swap_slot_free_notify Minchan Kim
2023-07-11 10:09   ` Alexey Romanov
2023-07-11  5:17 ` [PATCH 0/3] zram: use frontswap for zram swap usecase Christoph Hellwig
2023-07-11 17:52   ` Nhat Pham
2023-07-11 23:56     ` Minchan Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230710221659.2473460-2-minchan@kernel.org \
    --to=minchan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=senozhatsky@chromium.org \
    --cc=sjenning@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.