Commit 4f235000 authored by Shin'ichiro Kawasaki's avatar Shin'ichiro Kawasaki Committed by Jens Axboe
Browse files

null_blk: replace null_process_cmd() call in null_zone_write()



As a preparation to support partial data transfer due to badblocks,
replace the null_process_cmd() call in null_zone_write() with equivalent
calls to null_handle_badblocks() and null_handle_memory_backed(). This
commit does not change behavior. It will enable null_handle_badblocks()
to return the size of partial data transfer in the following commit,
allowing null_zone_write() to move write pointers appropriately.

Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20250226100613.1622564-4-shinichiro.kawasaki@wdc.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 800c2439
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -1309,8 +1309,7 @@ static inline blk_status_t null_handle_throttled(struct nullb_cmd *cmd)
	return sts;
}

static inline blk_status_t null_handle_badblocks(struct nullb_cmd *cmd,
						 sector_t sector,
blk_status_t null_handle_badblocks(struct nullb_cmd *cmd, sector_t sector,
				   sector_t nr_sectors)
{
	struct badblocks *bb = &cmd->nq->dev->badblocks;
@@ -1326,10 +1325,8 @@ static inline blk_status_t null_handle_badblocks(struct nullb_cmd *cmd,
	return BLK_STS_IOERR;
}

static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd,
						     enum req_op op,
						     sector_t sector,
						     sector_t nr_sectors)
blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, enum req_op op,
				       sector_t sector, sector_t nr_sectors)
{
	struct nullb_device *dev = cmd->nq->dev;

+5 −0
Original line number Diff line number Diff line
@@ -132,6 +132,11 @@ blk_status_t 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_op op,
			      sector_t sector, unsigned int nr_sectors);
blk_status_t null_handle_badblocks(struct nullb_cmd *cmd, sector_t sector,
				   sector_t nr_sectors);
blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, enum req_op op,
				       sector_t sector, sector_t nr_sectors);


#ifdef CONFIG_BLK_DEV_ZONED
int null_init_zoned_dev(struct nullb_device *dev, struct queue_limits *lim);
+12 −3
Original line number Diff line number Diff line
@@ -412,9 +412,18 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
		zone->cond = BLK_ZONE_COND_IMP_OPEN;
	}

	ret = null_process_cmd(cmd, REQ_OP_WRITE, sector, nr_sectors);
	if (dev->badblocks.shift != -1) {
		ret = null_handle_badblocks(cmd, sector, nr_sectors);
		if (ret != BLK_STS_OK)
			goto unlock_zone;
	}

	if (dev->memory_backed) {
		ret = null_handle_memory_backed(cmd, REQ_OP_WRITE, sector,
						nr_sectors);
		if (ret != BLK_STS_OK)
			goto unlock_zone;
	}

	zone->wp += nr_sectors;
	if (zone->wp == zone->start + zone->capacity) {