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
830 case REQ_OP_ZONE_OPEN:830 case REQ_OP_ZONE_OPEN:
831 case REQ_OP_ZONE_CLOSE:831 case REQ_OP_ZONE_CLOSE:
832 case REQ_OP_ZONE_FINISH:832 case REQ_OP_ZONE_FINISH:
833 if (!bdev_is_zoned(bio->bi_bdev))
834 goto not_supported;
835 break;
836 case REQ_OP_ZONE_RESET_ALL:833 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))
838 goto not_supported;835 goto not_supported;
839 break;836 break;
840 case REQ_OP_DRV_IN:837 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
157 GFP_NOIO, node);157 GFP_NOIO, node);
158}158}
159 159
160static 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
179static 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
219out_free_need_reset:
220 kfree(need_reset);
221 return ret;
222}
223
224static int blkdev_zone_reset_all(struct block_device *bdev)160static int blkdev_zone_reset_all(struct block_device *bdev)
225{161{
226 struct bio bio;162 struct bio bio;
@@ -247,7 +183,6 @@ static int blkdev_zone_reset_all(struct block_device *bdev) · 20 unmodified lines
247int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,183int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
248 sector_t sector, sector_t nr_sectors)184 sector_t sector, sector_t nr_sectors)
249{185{
250 struct request_queue *q = bdev_get_queue(bdev);
251 sector_t zone_sectors = bdev_zone_sectors(bdev);186 sector_t zone_sectors = bdev_zone_sectors(bdev);
252 sector_t capacity = bdev_nr_sectors(bdev);187 sector_t capacity = bdev_nr_sectors(bdev);
253 sector_t end_sector = sector + nr_sectors;188 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
275 return -EINVAL;210 return -EINVAL;
276 211
277 /*212 /*
278 * In the case of a zone reset operation over all zones,213 * In the case of a zone reset operation over all zones, use
279 * REQ_OP_ZONE_RESET_ALL can be used with devices supporting this214 * REQ_OP_ZONE_RESET_ALL.
280 * command. For other devices, we emulate this command behavior by
281 * identifying the zones needing a reset.
282 */215 */
283 if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) {216 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);
286 return blkdev_zone_reset_all(bdev);217 return blkdev_zone_reset_all(bdev);
287 }
288 218
289 while (sector < end_sector) {219 while (sector < end_sector) {
290 bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, GFP_KERNEL);220 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
164 sector += dev->zone_size_sects;164 sector += dev->zone_size_sects;
165 }165 }
166 166
167 lim->features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;167 lim->features |= BLK_FEAT_ZONED;
168 lim->chunk_sectors = dev->zone_size_sects;168 lim->chunk_sectors = dev->zone_size_sects;
169 lim->max_zone_append_sectors = dev->zone_append_max_sectors;169 lim->max_zone_append_sectors = dev->zone_append_max_sectors;
170 lim->max_open_zones = dev->zone_max_open;170 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
2194 if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED))2194 if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED))
2195 return -EOPNOTSUPP;2195 return -EOPNOTSUPP;
2196 2196
2197 lim.features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;2197 lim.features |= BLK_FEAT_ZONED;
2198 lim.max_active_zones = p->max_active_zones;2198 lim.max_active_zones = p->max_active_zones;
2199 lim.max_open_zones = p->max_open_zones;2199 lim.max_open_zones = p->max_open_zones;
2200 lim.max_zone_append_sectors = p->max_zone_append_sectors;2200 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
728 728
729 dev_dbg(&vdev->dev, "probing host-managed zoned device\n");729 dev_dbg(&vdev->dev, "probing host-managed zoned device\n");
730 730
731 lim->features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;731 lim->features |= BLK_FEAT_ZONED;
732 732
733 virtio_cread(vdev, struct virtio_blk_config,733 virtio_cread(vdev, struct virtio_blk_config,
734 zoned.max_open_zones, &v);734 zoned.max_open_zones, &v);
drivers/nvme/host/zns.c+1−1
@@ -108,7 +108,7 @@ free_data: · 107 unmodified lines
108void nvme_update_zone_info(struct nvme_ns *ns, struct queue_limits *lim,108void nvme_update_zone_info(struct nvme_ns *ns, struct queue_limits *lim,
109 struct nvme_zone_info *zi)109 struct nvme_zone_info *zi)
110{110{
111 lim->features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;111 lim->features |= BLK_FEAT_ZONED;
112 lim->max_open_zones = zi->max_open_zones;112 lim->max_open_zones = zi->max_open_zones;
113 lim->max_active_zones = zi->max_active_zones;113 lim->max_active_zones = zi->max_active_zones;
114 lim->max_zone_append_sectors = ns->ctrl->max_zone_append;114 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
599 if (sdkp->device->type != TYPE_ZBC)599 if (sdkp->device->type != TYPE_ZBC)
600 return 0;600 return 0;
601 601
602 lim->features |= BLK_FEAT_ZONED | BLK_FEAT_ZONE_RESETALL;602 lim->features |= BLK_FEAT_ZONED;
603 603
604 /*604 /*
605 * Per ZBC and ZAC specifications, writes in sequential write required605 * 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
318/* is a zoned device */318/* is a zoned device */
319#define BLK_FEAT_ZONED ((__force blk_features_t)(1u << 10))319#define BLK_FEAT_ZONED ((__force blk_features_t)(1u << 10))
320 320
321/* supports Zone Reset All */
322#define BLK_FEAT_ZONE_RESETALL ((__force blk_features_t)(1u << 11))
323
324/* supports PCI(e) p2p requests */321/* supports PCI(e) p2p requests */
325#define BLK_FEAT_PCI_P2PDMA ((__force blk_features_t)(1u << 12))322#define BLK_FEAT_PCI_P2PDMA ((__force blk_features_t)(1u << 12))
326 323
@@ -618,8 +615,6 @@ void blk_queue_flag_clear(unsigned int flag, struct request_queue *q); · 291 unmodified lines
618 test_bit(QUEUE_FLAG_NOXMERGES, &(q)->queue_flags)615 test_bit(QUEUE_FLAG_NOXMERGES, &(q)->queue_flags)
619#define blk_queue_nonrot(q) (!((q)->limits.features & BLK_FEAT_ROTATIONAL))616#define blk_queue_nonrot(q) (!((q)->limits.features & BLK_FEAT_ROTATIONAL))
620#define blk_queue_io_stat(q) ((q)->limits.features & BLK_FEAT_IO_STAT)617#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)
623#define blk_queue_dax(q) ((q)->limits.features & BLK_FEAT_DAX)618#define blk_queue_dax(q) ((q)->limits.features & BLK_FEAT_DAX)
624#define blk_queue_pci_p2pdma(q) ((q)->limits.features & BLK_FEAT_PCI_P2PDMA)619#define blk_queue_pci_p2pdma(q) ((q)->limits.features & BLK_FEAT_PCI_P2PDMA)
625#ifdef CONFIG_BLK_RQ_ALLOC_TIME620#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