@@ -1330,6 +1330,7 @@ static inline blk_status_t null_handle_throttled(struct nullb_cmd *cmd)
}
static inline blk_status_t null_handle_badblocks(struct nullb_cmd *cmd,
+ enum req_op op,
sector_t sector,
sector_t nr_sectors)
{
@@ -1347,6 +1348,8 @@ static inline blk_status_t null_handle_badblocks(struct nullb_cmd *cmd,
transfer_bytes = (first_bad - sector) << SECTOR_SHIFT;
__null_handle_rq(cmd, transfer_bytes);
}
+ if (dev->zoned && op == REQ_OP_WRITE)
+ null_move_zone_wp(dev, sector, first_bad - sector);
return BLK_STS_IOERR;
}
@@ -1413,7 +1416,7 @@ blk_status_t null_process_cmd(struct nullb_cmd *cmd, enum req_op op,
blk_status_t ret;
if (dev->badblocks.shift != -1) {
- ret = null_handle_badblocks(cmd, sector, nr_sectors);
+ ret = null_handle_badblocks(cmd, op, sector, nr_sectors);
if (ret != BLK_STS_OK)
return ret;
}
@@ -144,6 +144,8 @@ size_t null_zone_valid_read_len(struct nullb *nullb,
sector_t sector, unsigned int len);
ssize_t zone_cond_store(struct nullb_device *dev, const char *page,
size_t count, enum blk_zone_cond cond);
+void null_move_zone_wp(struct nullb_device *dev, sector_t zone_sector,
+ sector_t nr_sectors);
#else
static inline int null_init_zoned_dev(struct nullb_device *dev,
struct queue_limits *lim)
@@ -173,6 +175,10 @@ static inline ssize_t zone_cond_store(struct nullb_device *dev,
{
return -EOPNOTSUPP;
}
+static inline void null_move_zone_wp(struct nullb_device *dev,
+ sector_t zone_sector, sector_t nr_sectors)
+{
+}
#define null_report_zones NULL
#endif /* CONFIG_BLK_DEV_ZONED */
#endif /* __NULL_BLK_H */
@@ -347,6 +347,16 @@ static blk_status_t null_check_zone_resources(struct nullb_device *dev,
}
}
+void null_move_zone_wp(struct nullb_device *dev, sector_t zone_sector,
+ sector_t nr_sectors)
+{
+ unsigned int zno = null_zone_no(dev, zone_sector);
+ struct nullb_zone *zone = &dev->zones[zno];
+
+ if (zone->type != BLK_ZONE_TYPE_CONVENTIONAL)
+ zone->wp += nr_sectors;
+}
+
static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
unsigned int nr_sectors, bool append)
{
The previous commit modified bad blocks handling to do the partial IOs. When such partial IOs happen for zoned null_blk devices, it is expected that the write pointers also move partially. To test and debug partial write by userland tools for zoned block devices, move write pointers partially. Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> --- drivers/block/null_blk/main.c | 5 ++++- drivers/block/null_blk/null_blk.h | 6 ++++++ drivers/block/null_blk/zoned.c | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-)