@@ -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);
@@ -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;
@@ -595,6 +595,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;
}
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(-)