Skip to content

Commit b1fc937

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: move the zoned flag into the features field
Move the zoned flags into the features field to reclaim a little bit of space. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20240617060532.127975-23-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8023e14 commit b1fc937

10 files changed

Lines changed: 23 additions & 19 deletions

File tree

block/blk-settings.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void blk_apply_bdi_limits(struct backing_dev_info *bdi,
6868

6969
static int blk_validate_zoned_limits(struct queue_limits *lim)
7070
{
71-
if (!lim->zoned) {
71+
if (!(lim->features & BLK_FEAT_ZONED)) {
7272
if (WARN_ON_ONCE(lim->max_open_zones) ||
7373
WARN_ON_ONCE(lim->max_active_zones) ||
7474
WARN_ON_ONCE(lim->zone_write_granularity) ||
@@ -602,8 +602,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
602602
b->max_secure_erase_sectors);
603603
t->zone_write_granularity = max(t->zone_write_granularity,
604604
b->zone_write_granularity);
605-
t->zoned = max(t->zoned, b->zoned);
606-
if (!t->zoned) {
605+
if (!(t->features & BLK_FEAT_ZONED)) {
607606
t->zone_write_granularity = 0;
608607
t->max_zone_append_sectors = 0;
609608
}

drivers/block/null_blk/zoned.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int null_init_zoned_dev(struct nullb_device *dev,
158158
sector += dev->zone_size_sects;
159159
}
160160

161-
lim->zoned = true;
161+
lim->features |= BLK_FEAT_ZONED;
162162
lim->chunk_sectors = dev->zone_size_sects;
163163
lim->max_zone_append_sectors = dev->zone_append_max_sectors;
164164
lim->max_open_zones = dev->zone_max_open;

drivers/block/ublk_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,7 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd)
21962196
if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED))
21972197
return -EOPNOTSUPP;
21982198

2199-
lim.zoned = true;
2199+
lim.features |= BLK_FEAT_ZONED;
22002200
lim.max_active_zones = p->max_active_zones;
22012201
lim.max_open_zones = p->max_open_zones;
22022202
lim.max_zone_append_sectors = p->max_zone_append_sectors;

drivers/block/virtio_blk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ static int virtblk_read_zoned_limits(struct virtio_blk *vblk,
728728

729729
dev_dbg(&vdev->dev, "probing host-managed zoned device\n");
730730

731-
lim->zoned = true;
731+
lim->features |= BLK_FEAT_ZONED;
732732

733733
virtio_cread(vdev, struct virtio_blk_config,
734734
zoned.max_open_zones, &v);
@@ -1546,7 +1546,8 @@ static int virtblk_probe(struct virtio_device *vdev)
15461546
* All steps that follow use the VQs therefore they need to be
15471547
* placed after the virtio_device_ready() call above.
15481548
*/
1549-
if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && lim.zoned) {
1549+
if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
1550+
(lim.features & BLK_FEAT_ZONED)) {
15501551
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, vblk->disk->queue);
15511552
err = blk_revalidate_disk_zones(vblk->disk);
15521553
if (err)

drivers/md/dm-table.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,12 +1605,12 @@ int dm_calculate_queue_limits(struct dm_table *t,
16051605
ti->type->iterate_devices(ti, dm_set_device_limits,
16061606
&ti_limits);
16071607

1608-
if (!zoned && ti_limits.zoned) {
1608+
if (!zoned && (ti_limits.features & BLK_FEAT_ZONED)) {
16091609
/*
16101610
* After stacking all limits, validate all devices
16111611
* in table support this zoned model and zone sectors.
16121612
*/
1613-
zoned = ti_limits.zoned;
1613+
zoned = (ti_limits.features & BLK_FEAT_ZONED);
16141614
zone_sectors = ti_limits.chunk_sectors;
16151615
}
16161616

@@ -1658,12 +1658,12 @@ int dm_calculate_queue_limits(struct dm_table *t,
16581658
* zoned model on host-managed zoned block devices.
16591659
* BUT...
16601660
*/
1661-
if (limits->zoned) {
1661+
if (limits->features & BLK_FEAT_ZONED) {
16621662
/*
16631663
* ...IF the above limits stacking determined a zoned model
16641664
* validate that all of the table's devices conform to it.
16651665
*/
1666-
zoned = limits->zoned;
1666+
zoned = limits->features & BLK_FEAT_ZONED;
16671667
zone_sectors = limits->chunk_sectors;
16681668
}
16691669
if (validate_hardware_zoned(t, zoned, zone_sectors))
@@ -1834,7 +1834,8 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
18341834
* For a zoned target, setup the zones related queue attributes
18351835
* and resources necessary for zone append emulation if necessary.
18361836
*/
1837-
if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && limits->zoned) {
1837+
if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
1838+
(limits->features & limits->features & BLK_FEAT_ZONED)) {
18381839
r = dm_set_zones_restrictions(t, q, limits);
18391840
if (r)
18401841
return r;

drivers/md/dm-zone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q,
263263
if (nr_conv_zones >= ret) {
264264
lim->max_open_zones = 0;
265265
lim->max_active_zones = 0;
266-
lim->zoned = false;
266+
lim->features &= ~BLK_FEAT_ZONED;
267267
clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags);
268268
disk->nr_zones = 0;
269269
return 0;

drivers/md/dm-zoned-target.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ static void dmz_io_hints(struct dm_target *ti, struct queue_limits *limits)
10091009
limits->max_sectors = chunk_sectors;
10101010

10111011
/* We are exposing a drive-managed zoned block device */
1012-
limits->zoned = false;
1012+
limits->features &= ~BLK_FEAT_ZONED;
10131013
}
10141014

10151015
/*

drivers/nvme/host/zns.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int nvme_query_zone_info(struct nvme_ns *ns, unsigned lbaf,
108108
void nvme_update_zone_info(struct nvme_ns *ns, struct queue_limits *lim,
109109
struct nvme_zone_info *zi)
110110
{
111-
lim->zoned = 1;
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,
601601
if (sdkp->device->type != TYPE_ZBC)
602602
return 0;
603603

604-
lim->zoned = true;
604+
lim->features |= BLK_FEAT_ZONED;
605605

606606
/*
607607
* Per ZBC and ZAC specifications, writes in sequential write required

include/linux/blkdev.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,17 @@ enum {
313313

314314
/* supports I/O polling */
315315
BLK_FEAT_POLL = (1u << 9),
316+
317+
/* is a zoned device */
318+
BLK_FEAT_ZONED = (1u << 10),
316319
};
317320

318321
/*
319322
* Flags automatically inherited when stacking limits.
320323
*/
321324
#define BLK_FEAT_INHERIT_MASK \
322325
(BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA | BLK_FEAT_ROTATIONAL | \
323-
BLK_FEAT_STABLE_WRITES)
326+
BLK_FEAT_STABLE_WRITES | BLK_FEAT_ZONED)
324327

325328
/* internal flags in queue_limits.flags */
326329
enum {
@@ -372,7 +375,6 @@ struct queue_limits {
372375
unsigned char misaligned;
373376
unsigned char discard_misaligned;
374377
unsigned char raid_partial_stripes_expensive;
375-
bool zoned;
376378
unsigned int max_open_zones;
377379
unsigned int max_active_zones;
378380

@@ -654,7 +656,8 @@ static inline enum rpm_status queue_rpm_status(struct request_queue *q)
654656

655657
static inline bool blk_queue_is_zoned(struct request_queue *q)
656658
{
657-
return IS_ENABLED(CONFIG_BLK_DEV_ZONED) && q->limits.zoned;
659+
return IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
660+
(q->limits.features & BLK_FEAT_ZONED);
658661
}
659662

660663
#ifdef CONFIG_BLK_DEV_ZONED

0 commit comments

Comments
 (0)