Message ID | 20220704124500.155247-6-hch@lst.de |
---|---|
State | New |
Headers | show |
Series | [01/17] block: remove a superflous ifdef in blkdev.h | expand |
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On 7/4/22 21:44, Christoph Hellwig wrote: > Export blkdev_zone_mgmt_all so that the nvme target can use it instead > of duplicating the functionality. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> > --- > block/blk-zoned.c | 10 +++++----- > include/linux/blkdev.h | 2 ++ > 2 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/block/blk-zoned.c b/block/blk-zoned.c > index 90a5c9cc80ab3..7fbe395fa51fc 100644 > --- a/block/blk-zoned.c > +++ b/block/blk-zoned.c > @@ -185,8 +185,8 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx, > } > } > > -static int blkdev_zone_reset_all_emulated(struct block_device *bdev, > - gfp_t gfp_mask) > +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op, > + gfp_t gfp_mask) > { > struct request_queue *q = bdev_get_queue(bdev); > sector_t capacity = get_capacity(bdev->bd_disk); > @@ -213,8 +213,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev, > continue; > } > > - bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC, > - gfp_mask); > + bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask); > bio->bi_iter.bi_sector = sector; > sector += zone_sectors; > > @@ -231,6 +230,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev, > kfree(need_reset); > return ret; > } > +EXPORT_SYMBOL_GPL(blkdev_zone_mgmt_all); > > static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask) > { > @@ -295,7 +295,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, > */ > if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) { > if (!blk_queue_zone_resetall(q)) > - return blkdev_zone_reset_all_emulated(bdev, gfp_mask); > + return blkdev_zone_mgmt_all(bdev, op, gfp_mask); > return blkdev_zone_reset_all(bdev, gfp_mask); > } > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > index 270cd0c552924..b9baee910b825 100644 > --- a/include/linux/blkdev.h > +++ b/include/linux/blkdev.h > @@ -302,6 +302,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk); > extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, > sector_t sectors, sector_t nr_sectors, > gfp_t gfp_mask); > +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op, > + gfp_t gfp_mask); > int blk_revalidate_disk_zones(struct gendisk *disk, > void (*update_driver_data)(struct gendisk *disk)); >
On 7/5/22 11:31, Damien Le Moal wrote: > On 7/4/22 21:44, Christoph Hellwig wrote: >> Export blkdev_zone_mgmt_all so that the nvme target can use it instead >> of duplicating the functionality. >> >> Signed-off-by: Christoph Hellwig <hch@lst.de> > > Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Actually, looking again at this, if we generalize blkdev_zone_reset_all_emulated() into blkdev_zone_mgmt_all(), we should not allocate the need_reset bitmap if op is not reset. And the emulation for open/close/finish all is a bit tricky as we have to look at the current state of the zones, so we still need the report. The bitmat should this be something like "do_op" and the bits in it set using a helper for the zone depending on the op. Then using that function as is in nvmet will work. Otherwise, as-is, I think it will break something in nvmet. > >> --- >> block/blk-zoned.c | 10 +++++----- >> include/linux/blkdev.h | 2 ++ >> 2 files changed, 7 insertions(+), 5 deletions(-) >> >> diff --git a/block/blk-zoned.c b/block/blk-zoned.c >> index 90a5c9cc80ab3..7fbe395fa51fc 100644 >> --- a/block/blk-zoned.c >> +++ b/block/blk-zoned.c >> @@ -185,8 +185,8 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx, >> } >> } >> >> -static int blkdev_zone_reset_all_emulated(struct block_device *bdev, >> - gfp_t gfp_mask) >> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op, >> + gfp_t gfp_mask) >> { >> struct request_queue *q = bdev_get_queue(bdev); >> sector_t capacity = get_capacity(bdev->bd_disk); >> @@ -213,8 +213,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev, >> continue; >> } >> >> - bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC, >> - gfp_mask); >> + bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask); >> bio->bi_iter.bi_sector = sector; >> sector += zone_sectors; >> >> @@ -231,6 +230,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev, >> kfree(need_reset); >> return ret; >> } >> +EXPORT_SYMBOL_GPL(blkdev_zone_mgmt_all); >> >> static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask) >> { >> @@ -295,7 +295,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, >> */ >> if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) { >> if (!blk_queue_zone_resetall(q)) >> - return blkdev_zone_reset_all_emulated(bdev, gfp_mask); >> + return blkdev_zone_mgmt_all(bdev, op, gfp_mask); >> return blkdev_zone_reset_all(bdev, gfp_mask); >> } >> >> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h >> index 270cd0c552924..b9baee910b825 100644 >> --- a/include/linux/blkdev.h >> +++ b/include/linux/blkdev.h >> @@ -302,6 +302,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk); >> extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, >> sector_t sectors, sector_t nr_sectors, >> gfp_t gfp_mask); >> +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op, >> + gfp_t gfp_mask); >> int blk_revalidate_disk_zones(struct gendisk *disk, >> void (*update_driver_data)(struct gendisk *disk)); >> > >
On 7/4/2022 5:44 AM, Christoph Hellwig wrote: > Export blkdev_zone_mgmt_all so that the nvme target can use it instead > of duplicating the functionality. > > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- Reviewed-by : Chaitanya Kulkarni <kch@nvidia.com> -ck
diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 90a5c9cc80ab3..7fbe395fa51fc 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -185,8 +185,8 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx, } } -static int blkdev_zone_reset_all_emulated(struct block_device *bdev, - gfp_t gfp_mask) +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op, + gfp_t gfp_mask) { struct request_queue *q = bdev_get_queue(bdev); sector_t capacity = get_capacity(bdev->bd_disk); @@ -213,8 +213,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev, continue; } - bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC, - gfp_mask); + bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask); bio->bi_iter.bi_sector = sector; sector += zone_sectors; @@ -231,6 +230,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev, kfree(need_reset); return ret; } +EXPORT_SYMBOL_GPL(blkdev_zone_mgmt_all); static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask) { @@ -295,7 +295,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, */ if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) { if (!blk_queue_zone_resetall(q)) - return blkdev_zone_reset_all_emulated(bdev, gfp_mask); + return blkdev_zone_mgmt_all(bdev, op, gfp_mask); return blkdev_zone_reset_all(bdev, gfp_mask); } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 270cd0c552924..b9baee910b825 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -302,6 +302,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk); extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op, sector_t sectors, sector_t nr_sectors, gfp_t gfp_mask); +int blkdev_zone_mgmt_all(struct block_device *bdev, unsigned int op, + gfp_t gfp_mask); int blk_revalidate_disk_zones(struct gendisk *disk, void (*update_driver_data)(struct gendisk *disk));
Export blkdev_zone_mgmt_all so that the nvme target can use it instead of duplicating the functionality. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-zoned.c | 10 +++++----- include/linux/blkdev.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-)