History

block: Remove REQ_OP_ZONE_RESET_ALL emulation

Now that device mapper can handle resetting all zones of a mapped zoned device using REQ_OP_ZONE_RESET_ALL, all zoned block device drivers support this operation. With this, the request queue feature BLK_FEAT_ZONE_RESETALL is not necessary and the emulation code in blk-zone.c can be removed.

Damien Le Moal committed 2 years ago

Commit f2a7bea1 parent 81e77068 files · +9 −87Browse files

Unified · Split

8 files
  1. block/blk-core.c +1 −4
  2. block/blk-zoned.c +3 −73
  3. drivers/block/null_blk/zoned.c +1 −1
  4. drivers/block/ublk_drv.c +1 −1
  5. drivers/block/virtio_blk.c +1 −1
  6. drivers/nvme/host/zns.c +1 −1
  7. drivers/scsi/sd_zbc.c +1 −1
  8. include/linux/blkdev.h +0 −5
block/blk-core.c+1−4
@@ -830,11 +830,8 @@ void submit_bio_noacct(struct bio *bio) · 829 unmodified lines
830830 case REQ_OP_ZONE_OPEN:
831831 case REQ_OP_ZONE_CLOSE:
832832 case REQ_OP_ZONE_FINISH:
833− if (!bdev_is_zoned(bio->bi_bdev))
834− goto not_supported;
835− break;
836833 case REQ_OP_ZONE_RESET_ALL:
837− if (!bdev_is_zoned(bio->bi_bdev) || !blk_queue_zone_resetall(q))
834+ if (!bdev_is_zoned(bio->bi_bdev))
838835 goto not_supported;
839836 break;
840837 case REQ_OP_DRV_IN:
block/blk-zoned.c+3−73
@@ -157,70 +157,6 @@ static inline unsigned long *blk_alloc_zone_bitmap(int node, · 156 unmodified lines
157157 GFP_NOIO, node);
158158 }
159159
160−static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
161− void *data)
162−{
163− /*
164− * For an all-zones reset, ignore conventional, empty, read-only
165− * and offline zones.
166− */
167− switch (zone->cond) {
168− case BLK_ZONE_COND_NOT_WP:
169− case BLK_ZONE_COND_EMPTY:
170− case BLK_ZONE_COND_READONLY:
171− case BLK_ZONE_COND_OFFLINE:
172− return 0;
173− default:
174− set_bit(idx, (unsigned long *)data);
175− return 0;
176− }
177−}
178−
179−static int blkdev_zone_reset_all_emulated(struct block_device *bdev)
180−{
181− struct gendisk *disk = bdev->bd_disk;
182− sector_t capacity = bdev_nr_sectors(bdev);
183− sector_t zone_sectors = bdev_zone_sectors(bdev);
184− unsigned long *need_reset;
185− struct bio *bio = NULL;
186− sector_t sector = 0;
187− int ret;
188−
189− need_reset = blk_alloc_zone_bitmap(disk->queue->node, disk->nr_zones);
190− if (!need_reset)
191− return -ENOMEM;
192−
193− ret = disk->fops->report_zones(disk, 0, disk->nr_zones,
194− blk_zone_need_reset_cb, need_reset);
195− if (ret < 0)
196− goto out_free_need_reset;
197−
198− ret = 0;
199− while (sector < capacity) {
200− if (!test_bit(disk_zone_no(disk, sector), need_reset)) {
201− sector += zone_sectors;
202− continue;
203− }
204−
205− bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC,
206− GFP_KERNEL);
207− bio->bi_iter.bi_sector = sector;
208− sector += zone_sectors;
209−
210− /* This may take a while, so be nice to others */
211− cond_resched();
212− }
213−
214− if (bio) {
215− ret = submit_bio_wait(bio);
216− bio_put(bio);
217− }
218−
219−out_free_need_reset:
220− kfree(need_reset);
221− return ret;
222−}
223−
224160 static int blkdev_zone_reset_all(struct block_device *bdev)
225161 {
226162 struct bio bio;
@@ -247,7 +183,6 @@ static int blkdev_zone_reset_all(struct block_device *bdev) · 20 unmodified lines
247183 int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
248184 sector_t sector, sector_t nr_sectors)
249185 {
250− struct request_queue *q = bdev_get_queue(bdev);
251186 sector_t zone_sectors = bdev_zone_sectors(bdev);
252187 sector_t capacity = bdev_nr_sectors(bdev);
253188 sector_t end_sector = sector + nr_sectors;
@@ -275,16 +210,11 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op, · 21 unmodified lines
275210 return -EINVAL;
276211
277212 /*
278− * In the case of a zone reset operation over all zones,
279− * REQ_OP_ZONE_RESET_ALL can be used with devices supporting this
280− * command. For other devices, we emulate this command behavior by
281− * identifying the zones needing a reset.
213+ * In the case of a zone reset operation over all zones, use
214+ * REQ_OP_ZONE_RESET_ALL.
282215 */
283− if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) {
284− if (!blk_queue_zone_resetall(q))
285− return blkdev_zone_reset_all_emulated(bdev);
216+ if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity)
286217 return blkdev_zone_reset_all(bdev);
287− }
288218
289219 while (sector < end_sector) {
290220 bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, GFP_KERNEL);
drivers/block/null_blk/zoned.c+1−1
@@ -164,7 +164,7 @@ int null_init_zoned_dev(struct nullb_device *dev, · 163 unmodified lines
164164 sector += dev->zone_size_sects;
165165 }
166166
167− lim->features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;
167+ lim->features |= BLK_FEAT_ZONED;
168168 lim->chunk_sectors = dev->zone_size_sects;
169169 lim->max_zone_append_sectors = dev->zone_append_max_sectors;
170170 lim->max_open_zones = dev->zone_max_open;
drivers/block/ublk_drv.c+1−1
@@ -2194,7 +2194,7 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) · 2193 unmodified lines
21942194 if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED))
21952195 return -EOPNOTSUPP;
21962196
2197− lim.features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;
2197+ lim.features |= BLK_FEAT_ZONED;
21982198 lim.max_active_zones = p->max_active_zones;
21992199 lim.max_open_zones = p->max_open_zones;
22002200 lim.max_zone_append_sectors = p->max_zone_append_sectors;
drivers/block/virtio_blk.c+1−1
@@ -728,7 +728,7 @@ static int virtblk_read_zoned_limits(struct virtio_blk *vblk, · 727 unmodified lines
728728
729729 dev_dbg(&vdev->dev, "probing host-managed zoned device\n");
730730
731− lim->features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;
731+ lim->features |= BLK_FEAT_ZONED;
732732
733733 virtio_cread(vdev, struct virtio_blk_config,
734734 zoned.max_open_zones, &v);
drivers/nvme/host/zns.c+1−1
@@ -108,7 +108,7 @@ free_data: · 107 unmodified lines
108108 void nvme_update_zone_info(struct nvme_ns *ns, struct queue_limits *lim,
109109 struct nvme_zone_info *zi)
110110 {
111− lim->features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;
111+ lim->features |= BLK_FEAT_ZONED;
112112 lim->max_open_zones = zi->max_open_zones;
113113 lim->max_active_zones = zi->max_active_zones;
114114 lim->max_zone_append_sectors = ns->ctrl->max_zone_append;
drivers/scsi/sd_zbc.c+1−1
@@ -599,7 +599,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim, · 598 unmodified lines
599599 if (sdkp->device->type != TYPE_ZBC)
600600 return 0;
601601
602− lim->features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;
602+ lim->features |= BLK_FEAT_ZONED;
603603
604604 /*
605605 * Per ZBC and ZAC specifications, writes in sequential write required
include/linux/blkdev.h+0−5
@@ -318,9 +318,6 @@ typedef unsigned int __bitwise blk_features_t; · 317 unmodified lines
318318 /* is a zoned device */
319319 #define BLK_FEAT_ZONED ((__force blk_features_t)(1u << 10))
320320
321−/* supports Zone Reset All */
322−#define BLK_FEAT_ZONE_RESETALL ((__force blk_features_t)(1u << 11))
323−
324321 /* supports PCI(e) p2p requests */
325322 #define BLK_FEAT_PCI_P2PDMA ((__force blk_features_t)(1u << 12))
326323
@@ -618,8 +615,6 @@ void blk_queue_flag_clear(unsigned int flag, struct request_queue *q); · 291 unmodified lines
618615 test_bit(QUEUE_FLAG_NOXMERGES, &(q)->queue_flags)
619616 #define blk_queue_nonrot(q) (!((q)->limits.features & BLK_FEAT_ROTATIONAL))
620617 #define blk_queue_io_stat(q) ((q)->limits.features & BLK_FEAT_IO_STAT)
621−#define blk_queue_zone_resetall(q) \
622− ((q)->limits.features & BLK_FEAT_ZONE_RESETALL)
623618 #define blk_queue_dax(q) ((q)->limits.features & BLK_FEAT_DAX)
624619 #define blk_queue_pci_p2pdma(q) ((q)->limits.features & BLK_FEAT_PCI_P2PDMA)
625620 #ifdef CONFIG_BLK_RQ_ALLOC_TIME

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t