All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@wdc.com>
To: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH v2 7/9] null_blk: discard zones on reset
Date: Wed, 11 Nov 2020 14:16:46 +0900	[thread overview]
Message-ID: <20201111051648.635300-8-damien.lemoal@wdc.com> (raw)
In-Reply-To: <20201111051648.635300-1-damien.lemoal@wdc.com>

When memory backing is enabled, use null_handle_discard() to free the
backing memory used by a zone when the zone is being reset.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/block/null_blk.h       | 2 ++
 drivers/block/null_blk_main.c  | 4 ++--
 drivers/block/null_blk_zoned.c | 3 +++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h
index 683b573b7e14..76bd190fa185 100644
--- a/drivers/block/null_blk.h
+++ b/drivers/block/null_blk.h
@@ -95,6 +95,8 @@ struct nullb {
 	char disk_name[DISK_NAME_LEN];
 };
 
+void null_handle_discard(struct nullb_device *dev, sector_t sector,
+			 sector_t nr_sectors);
 blk_status_t null_process_cmd(struct nullb_cmd *cmd,
 			      enum req_opf op, sector_t sector,
 			      unsigned int nr_sectors);
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 06b909fd230b..fa0bc65bbd1e 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1076,8 +1076,8 @@ static void nullb_fill_pattern(struct nullb *nullb, struct page *page,
 	kunmap_atomic(dst);
 }
 
-static void null_handle_discard(struct nullb_device *dev, sector_t sector,
-				sector_t nr_sectors)
+void null_handle_discard(struct nullb_device *dev, sector_t sector,
+			 sector_t nr_sectors)
 {
 	struct nullb *nullb = dev->nullb;
 	size_t n = nr_sectors << SECTOR_SHIFT;
diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c
index 905cab12ee3c..87c9b6ebdccb 100644
--- a/drivers/block/null_blk_zoned.c
+++ b/drivers/block/null_blk_zoned.c
@@ -596,6 +596,9 @@ static blk_status_t null_reset_zone(struct nullb_device *dev, struct blk_zone *z
 
 	null_unlock_zone_res(dev, flags);
 
+	if (dev->memory_backed)
+		null_handle_discard(dev, zone->start, zone->len);
+
 	return BLK_STS_OK;
 }
 
-- 
2.26.2


  parent reply	other threads:[~2020-11-11  5:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11  5:16 [PATCH v2 0/9] null_blk fixes, improvements and cleanup Damien Le Moal
2020-11-11  5:16 ` [PATCH v2 1/9] null_blk: Fix zone size initialization Damien Le Moal
2020-11-11  8:05   ` Christoph Hellwig
2020-11-11  8:06   ` Johannes Thumshirn
2020-11-11  5:16 ` [PATCH v2 2/9] null_blk: Fail zone append to conventional zones Damien Le Moal
2020-11-11  8:06   ` Christoph Hellwig
2020-11-11  8:07   ` Johannes Thumshirn
2020-11-11  5:16 ` [PATCH v2 3/9] null_blk: Align max_hw_sectors to blocksize Damien Le Moal
2020-11-11  8:06   ` Christoph Hellwig
2020-11-11  8:19     ` Damien Le Moal
2020-11-11  5:16 ` [PATCH v2 4/9] null_blk: improve zone locking Damien Le Moal
2020-11-11  8:11   ` Christoph Hellwig
2020-11-11  8:20     ` Damien Le Moal
2020-11-11  8:18   ` Johannes Thumshirn
2020-11-11  5:16 ` [PATCH v2 5/9] null_blk: Improve implicit zone close Damien Le Moal
2020-11-11  5:16 ` [PATCH v2 6/9] null_blk: cleanup discard handling Damien Le Moal
2020-11-11  8:13   ` Christoph Hellwig
2020-11-11  5:16 ` Damien Le Moal [this message]
2020-11-11  8:14   ` [PATCH v2 7/9] null_blk: discard zones on reset Christoph Hellwig
2020-11-11  8:19   ` Johannes Thumshirn
2020-11-11  5:16 ` [PATCH v2 8/9] null_blk: Allow controlling max_hw_sectors limit Damien Le Moal
2020-11-11  8:14   ` Christoph Hellwig
2020-11-11  8:22   ` Johannes Thumshirn
2020-11-11  8:23     ` Damien Le Moal
2020-11-11  5:16 ` [PATCH v2 9/9] null_blk: Move driver into its own directory Damien Le Moal
2020-11-11  7:52   ` Johannes Thumshirn
2020-11-11  6:04 ` [PATCH v2 0/9] null_blk fixes, improvements and cleanup Damien Le Moal

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=20201111051648.635300-8-damien.lemoal@wdc.com \
    --to=damien.lemoal@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    /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.