]> www.infradead.org Git - nvme.git/commitdiff
block: move the zoned flag into the features field
authorChristoph Hellwig <hch@lst.de>
Mon, 17 Jun 2024 06:04:49 +0000 (08:04 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 19 Jun 2024 13:58:28 +0000 (07:58 -0600)
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>
block/blk-settings.c
drivers/block/null_blk/zoned.c
drivers/block/ublk_drv.c
drivers/block/virtio_blk.c
drivers/md/dm-table.c
drivers/md/dm-zone.c
drivers/md/dm-zoned-target.c
drivers/nvme/host/zns.c
drivers/scsi/sd_zbc.c
include/linux/blkdev.h

index 026ba68d829856c89a2941e86be9a0c7b4e44dd0..96e07f24bd9aa1c09fa2ddc0ee54cf18af860d98 100644 (file)
@@ -68,7 +68,7 @@ static void blk_apply_bdi_limits(struct backing_dev_info *bdi,
 
 static int blk_validate_zoned_limits(struct queue_limits *lim)
 {
-       if (!lim->zoned) {
+       if (!(lim->features & BLK_FEAT_ZONED)) {
                if (WARN_ON_ONCE(lim->max_open_zones) ||
                    WARN_ON_ONCE(lim->max_active_zones) ||
                    WARN_ON_ONCE(lim->zone_write_granularity) ||
@@ -602,8 +602,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
                                                   b->max_secure_erase_sectors);
        t->zone_write_granularity = max(t->zone_write_granularity,
                                        b->zone_write_granularity);
-       t->zoned = max(t->zoned, b->zoned);
-       if (!t->zoned) {
+       if (!(t->features & BLK_FEAT_ZONED)) {
                t->zone_write_granularity = 0;
                t->max_zone_append_sectors = 0;
        }
index f118d304f31080f65288af40dba8c602e002bcc9..ca8e739e76b981bdeefb9ae0e2fde7351f6ba74d 100644 (file)
@@ -158,7 +158,7 @@ int null_init_zoned_dev(struct nullb_device *dev,
                sector += dev->zone_size_sects;
        }
 
-       lim->zoned = true;
+       lim->features |= BLK_FEAT_ZONED;
        lim->chunk_sectors = dev->zone_size_sects;
        lim->max_zone_append_sectors = dev->zone_append_max_sectors;
        lim->max_open_zones = dev->zone_max_open;
index 4fcde099935868b4eacf91cf38a8c639218bf7bd..69c16018cbb19a54b2bbd346ec553378a9874f1d 100644 (file)
@@ -2196,7 +2196,7 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd)
                if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED))
                        return -EOPNOTSUPP;
 
-               lim.zoned = true;
+               lim.features |= BLK_FEAT_ZONED;
                lim.max_active_zones = p->max_active_zones;
                lim.max_open_zones =  p->max_open_zones;
                lim.max_zone_append_sectors = p->max_zone_append_sectors;
index 13a2f24f176628f2cd9bd40d0c255b85963b6125..cea45b296f8becea9f7bb30fd47e52a46674c44e 100644 (file)
@@ -728,7 +728,7 @@ static int virtblk_read_zoned_limits(struct virtio_blk *vblk,
 
        dev_dbg(&vdev->dev, "probing host-managed zoned device\n");
 
-       lim->zoned = true;
+       lim->features |= BLK_FEAT_ZONED;
 
        virtio_cread(vdev, struct virtio_blk_config,
                     zoned.max_open_zones, &v);
@@ -1546,7 +1546,8 @@ static int virtblk_probe(struct virtio_device *vdev)
         * All steps that follow use the VQs therefore they need to be
         * placed after the virtio_device_ready() call above.
         */
-       if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && lim.zoned) {
+       if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
+           (lim.features & BLK_FEAT_ZONED)) {
                blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, vblk->disk->queue);
                err = blk_revalidate_disk_zones(vblk->disk);
                if (err)
index ca1f136575cff4fbe4a97a0f2ecf1bee838f008b..df6313c3fe6ba4e92c3a9fff39b0cdf661af78bb 100644 (file)
@@ -1605,12 +1605,12 @@ int dm_calculate_queue_limits(struct dm_table *t,
                ti->type->iterate_devices(ti, dm_set_device_limits,
                                          &ti_limits);
 
-               if (!zoned && ti_limits.zoned) {
+               if (!zoned && (ti_limits.features & BLK_FEAT_ZONED)) {
                        /*
                         * After stacking all limits, validate all devices
                         * in table support this zoned model and zone sectors.
                         */
-                       zoned = ti_limits.zoned;
+                       zoned = (ti_limits.features & BLK_FEAT_ZONED);
                        zone_sectors = ti_limits.chunk_sectors;
                }
 
@@ -1658,12 +1658,12 @@ combine_limits:
         *   zoned model on host-managed zoned block devices.
         * BUT...
         */
-       if (limits->zoned) {
+       if (limits->features & BLK_FEAT_ZONED) {
                /*
                 * ...IF the above limits stacking determined a zoned model
                 * validate that all of the table's devices conform to it.
                 */
-               zoned = limits->zoned;
+               zoned = limits->features & BLK_FEAT_ZONED;
                zone_sectors = limits->chunk_sectors;
        }
        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,
         * For a zoned target, setup the zones related queue attributes
         * and resources necessary for zone append emulation if necessary.
         */
-       if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && limits->zoned) {
+       if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
+           (limits->features & limits->features & BLK_FEAT_ZONED)) {
                r = dm_set_zones_restrictions(t, q, limits);
                if (r)
                        return r;
index 5d66d916730efa79521594e5ad40d190e1658404..88d313229b43ff0495d319872871cb6ba412a8e4 100644 (file)
@@ -263,7 +263,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q,
        if (nr_conv_zones >= ret) {
                lim->max_open_zones = 0;
                lim->max_active_zones = 0;
-               lim->zoned = false;
+               lim->features &= ~BLK_FEAT_ZONED;
                clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags);
                disk->nr_zones = 0;
                return 0;
index 12236e6f46f39c33ca392848f2320e32c55736f3..cd0ee144973f9fd97243133a417cf0742c189b67 100644 (file)
@@ -1009,7 +1009,7 @@ static void dmz_io_hints(struct dm_target *ti, struct queue_limits *limits)
        limits->max_sectors = chunk_sectors;
 
        /* We are exposing a drive-managed zoned block device */
-       limits->zoned = false;
+       limits->features &= ~BLK_FEAT_ZONED;
 }
 
 /*
index 77aa0f440a6d2a5a538ad06e9cae9ae97c409aef..06f2417aa50de771cd6d9e08bfb9693520f804c0 100644 (file)
@@ -108,7 +108,7 @@ free_data:
 void nvme_update_zone_info(struct nvme_ns *ns, struct queue_limits *lim,
                struct nvme_zone_info *zi)
 {
-       lim->zoned = 1;
+       lim->features |= BLK_FEAT_ZONED;
        lim->max_open_zones = zi->max_open_zones;
        lim->max_active_zones = zi->max_active_zones;
        lim->max_zone_append_sectors = ns->ctrl->max_zone_append;
index 360ec980499529756257579717a0929c1fa5c161..d3f84665946ec40f43b0f8f2840bdd2277fc3452 100644 (file)
@@ -601,7 +601,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,
        if (sdkp->device->type != TYPE_ZBC)
                return 0;
 
-       lim->zoned = true;
+       lim->features |= BLK_FEAT_ZONED;
 
        /*
         * Per ZBC and ZAC specifications, writes in sequential write required
index cd27b66cbacc00656a19bbdb4b94134a0f205203..bdc30c1fb1b57bccd69319dcaac08f1199994d96 100644 (file)
@@ -313,6 +313,9 @@ enum {
 
        /* supports I/O polling */
        BLK_FEAT_POLL                           = (1u << 9),
+
+       /* is a zoned device */
+       BLK_FEAT_ZONED                          = (1u << 10),
 };
 
 /*
@@ -320,7 +323,7 @@ enum {
  */
 #define BLK_FEAT_INHERIT_MASK \
        (BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA | BLK_FEAT_ROTATIONAL | \
-        BLK_FEAT_STABLE_WRITES)
+        BLK_FEAT_STABLE_WRITES | BLK_FEAT_ZONED)
 
 /* internal flags in queue_limits.flags */
 enum {
@@ -372,7 +375,6 @@ struct queue_limits {
        unsigned char           misaligned;
        unsigned char           discard_misaligned;
        unsigned char           raid_partial_stripes_expensive;
-       bool                    zoned;
        unsigned int            max_open_zones;
        unsigned int            max_active_zones;
 
@@ -654,7 +656,8 @@ static inline enum rpm_status queue_rpm_status(struct request_queue *q)
 
 static inline bool blk_queue_is_zoned(struct request_queue *q)
 {
-       return IS_ENABLED(CONFIG_BLK_DEV_ZONED) && q->limits.zoned;
+       return IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
+               (q->limits.features & BLK_FEAT_ZONED);
 }
 
 #ifdef CONFIG_BLK_DEV_ZONED