Skip to content

Commit 82394db

Browse files
MatiasBjorlingChristoph Hellwig
authored andcommitted
block: add capacity field to zone descriptors
In the zoned storage model, the sectors within a zone are typically all writeable. With the introduction of the Zoned Namespace (ZNS) Command Set in the NVM Express organization, the model was extended to have a specific writeable capacity. Extend the zone descriptor data structure with a zone capacity field to indicate to the user how many sectors in a zone are writeable. Introduce backward compatibility in the zone report ioctl by extending the zone report header data structure with a flags field to indicate if the capacity field is available. Reviewed-by: Jens Axboe <axboe@kernel.dk> Reviewed-by: Javier González <javier.gonz@samsung.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Daniel Wagner <dwagner@suse.de> Signed-off-by: Matias Bjørling <matias.bjorling@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent f5af577 commit 82394db

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎block/blk-zoned.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
312312
return ret;
313313

314314
rep.nr_zones = ret;
315+
rep.flags = BLK_ZONE_REP_CAPACITY;
315316
if (copy_to_user(argp, &rep, sizeof(struct blk_zone_report)))
316317
return -EFAULT;
317318
return 0;

‎drivers/block/null_blk_zoned.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
4747

4848
zone->start = sector;
4949
zone->len = dev->zone_size_sects;
50+
zone->capacity = zone->len;
5051
zone->wp = zone->start + zone->len;
5152
zone->type = BLK_ZONE_TYPE_CONVENTIONAL;
5253
zone->cond = BLK_ZONE_COND_NOT_WP;
@@ -59,6 +60,7 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
5960

6061
zone->start = zone->wp = sector;
6162
zone->len = dev->zone_size_sects;
63+
zone->capacity = zone->len;
6264
zone->type = BLK_ZONE_TYPE_SEQWRITE_REQ;
6365
zone->cond = BLK_ZONE_COND_EMPTY;
6466

‎drivers/scsi/sd_zbc.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf,
5959
zone.non_seq = 1;
6060

6161
zone.len = logical_to_sectors(sdp, get_unaligned_be64(&buf[8]));
62+
zone.capacity = zone.len;
6263
zone.start = logical_to_sectors(sdp, get_unaligned_be64(&buf[16]));
6364
zone.wp = logical_to_sectors(sdp, get_unaligned_be64(&buf[24]));
6465
if (zone.type != ZBC_ZONE_TYPE_CONV &&

‎include/uapi/linux/blkzoned.h‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ enum blk_zone_cond {
7373
BLK_ZONE_COND_OFFLINE = 0xF,
7474
};
7575

76+
/**
77+
* enum blk_zone_report_flags - Feature flags of reported zone descriptors.
78+
*
79+
* @BLK_ZONE_REP_CAPACITY: Zone descriptor has capacity field.
80+
*/
81+
enum blk_zone_report_flags {
82+
BLK_ZONE_REP_CAPACITY = (1 << 0),
83+
};
84+
7685
/**
7786
* struct blk_zone - Zone descriptor for BLKREPORTZONE ioctl.
7887
*
@@ -99,7 +108,9 @@ struct blk_zone {
99108
__u8 cond; /* Zone condition */
100109
__u8 non_seq; /* Non-sequential write resources active */
101110
__u8 reset; /* Reset write pointer recommended */
102-
__u8 reserved[36];
111+
__u8 resv[4];
112+
__u64 capacity; /* Zone capacity in number of sectors */
113+
__u8 reserved[24];
103114
};
104115

105116
/**
@@ -115,7 +126,7 @@ struct blk_zone {
115126
struct blk_zone_report {
116127
__u64 sector;
117128
__u32 nr_zones;
118-
__u8 reserved[4];
129+
__u32 flags;
119130
struct blk_zone zones[0];
120131
};
121132

0 commit comments

Comments
 (0)