Skip to content

Commit 80ee071

Browse files
committed
Merge branch 'nvme-5.9' of git://git.infradead.org/nvme into for-5.9/drivers
Pull NVMe updates from Christoph: "Below is the current large chunk we have in the nvme tree for 5.9: - ZNS support (Aravind, Keith, Matias, Niklas) - misc cleanups and optimizations (Baolin, Chaitanya, David, Dongli, Max, Sagi)" * 'nvme-5.9' of git://git.infradead.org/nvme: (28 commits) nvme: remove ns->disk checks nvme-pci: use standard block status symbolic names nvme-pci: use the consistent return type of nvme_pci_iod_alloc_size() nvme-pci: add a blank line after declarations nvme-pci: fix some comments issues nvme-pci: remove redundant segment validation nvme: document quirked Intel models nvme: expose reconnect_delay and ctrl_loss_tmo via sysfs nvme: support for zoned namespaces nvme: support for multiple Command Sets Supported and Effects log pages nvme: implement multiple I/O Command Set support null_blk: introduce zone capacity for zoned device block: add capacity field to zone descriptors nvme: use USEC_PER_SEC instead of magic numbers nvmet-tcp: simplify nvmet_process_resp_list nvme-tcp: optimize network stack with setting msg flags according to batch size nvme-tcp: leverage request plugging nvme-tcp: have queue prod/cons send list become a llist nvme-fcloop: verify wwnn and wwpn format nvmet: use unsigned type for u64 ...
2 parents 482c6b6 + 3913f4f commit 80ee071

File tree

26 files changed

+862
-140
lines changed

26 files changed

+862
-140
lines changed

block/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ config BLK_DEV_ZONED
8686
select MQ_IOSCHED_DEADLINE
8787
help
8888
Block layer zoned block device support. This option enables
89-
support for ZAC/ZBC host-managed and host-aware zoned block devices.
89+
support for ZAC/ZBC/ZNS host-managed and host-aware zoned block
90+
devices.
9091

91-
Say yes here if you have a ZAC or ZBC storage device.
92+
Say yes here if you have a ZAC, ZBC, or ZNS storage device.
9293

9394
config BLK_DEV_THROTTLING
9495
bool "Block layer bio throttling support"

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.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct nullb_device {
4949
unsigned long completion_nsec; /* time in ns to complete a request */
5050
unsigned long cache_size; /* disk cache size in MB */
5151
unsigned long zone_size; /* zone size in MB if device is zoned */
52+
unsigned long zone_capacity; /* zone capacity in MB if device is zoned */
5253
unsigned int zone_nr_conv; /* number of conventional zones */
5354
unsigned int submit_queues; /* number of submission queues */
5455
unsigned int home_node; /* home node for the device */

drivers/block/null_blk_main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ static unsigned long g_zone_size = 256;
200200
module_param_named(zone_size, g_zone_size, ulong, S_IRUGO);
201201
MODULE_PARM_DESC(zone_size, "Zone size in MB when block device is zoned. Must be power-of-two: Default: 256");
202202

203+
static unsigned long g_zone_capacity;
204+
module_param_named(zone_capacity, g_zone_capacity, ulong, 0444);
205+
MODULE_PARM_DESC(zone_capacity, "Zone capacity in MB when block device is zoned. Can be less than or equal to zone size. Default: Zone size");
206+
203207
static unsigned int g_zone_nr_conv;
204208
module_param_named(zone_nr_conv, g_zone_nr_conv, uint, 0444);
205209
MODULE_PARM_DESC(zone_nr_conv, "Number of conventional zones when block device is zoned. Default: 0");
@@ -341,6 +345,7 @@ NULLB_DEVICE_ATTR(mbps, uint, NULL);
341345
NULLB_DEVICE_ATTR(cache_size, ulong, NULL);
342346
NULLB_DEVICE_ATTR(zoned, bool, NULL);
343347
NULLB_DEVICE_ATTR(zone_size, ulong, NULL);
348+
NULLB_DEVICE_ATTR(zone_capacity, ulong, NULL);
344349
NULLB_DEVICE_ATTR(zone_nr_conv, uint, NULL);
345350

346351
static ssize_t nullb_device_power_show(struct config_item *item, char *page)
@@ -457,6 +462,7 @@ static struct configfs_attribute *nullb_device_attrs[] = {
457462
&nullb_device_attr_badblocks,
458463
&nullb_device_attr_zoned,
459464
&nullb_device_attr_zone_size,
465+
&nullb_device_attr_zone_capacity,
460466
&nullb_device_attr_zone_nr_conv,
461467
NULL,
462468
};
@@ -510,7 +516,8 @@ nullb_group_drop_item(struct config_group *group, struct config_item *item)
510516

511517
static ssize_t memb_group_features_show(struct config_item *item, char *page)
512518
{
513-
return snprintf(page, PAGE_SIZE, "memory_backed,discard,bandwidth,cache,badblocks,zoned,zone_size,zone_nr_conv\n");
519+
return snprintf(page, PAGE_SIZE,
520+
"memory_backed,discard,bandwidth,cache,badblocks,zoned,zone_size,zone_capacity,zone_nr_conv\n");
514521
}
515522

516523
CONFIGFS_ATTR_RO(memb_group_, features);
@@ -571,6 +578,7 @@ static struct nullb_device *null_alloc_dev(void)
571578
dev->use_per_node_hctx = g_use_per_node_hctx;
572579
dev->zoned = g_zoned;
573580
dev->zone_size = g_zone_size;
581+
dev->zone_capacity = g_zone_capacity;
574582
dev->zone_nr_conv = g_zone_nr_conv;
575583
return dev;
576584
}

drivers/block/null_blk_zoned.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
2828
return -EINVAL;
2929
}
3030

31+
if (!dev->zone_capacity)
32+
dev->zone_capacity = dev->zone_size;
33+
34+
if (dev->zone_capacity > dev->zone_size) {
35+
pr_err("null_blk: zone capacity (%lu MB) larger than zone size (%lu MB)\n",
36+
dev->zone_capacity, dev->zone_size);
37+
return -EINVAL;
38+
}
39+
3140
dev->zone_size_sects = dev->zone_size << ZONE_SIZE_SHIFT;
3241
dev->nr_zones = dev_size >>
3342
(SECTOR_SHIFT + ilog2(dev->zone_size_sects));
@@ -47,6 +56,7 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
4756

4857
zone->start = sector;
4958
zone->len = dev->zone_size_sects;
59+
zone->capacity = zone->len;
5060
zone->wp = zone->start + zone->len;
5161
zone->type = BLK_ZONE_TYPE_CONVENTIONAL;
5262
zone->cond = BLK_ZONE_COND_NOT_WP;
@@ -59,6 +69,7 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
5969

6070
zone->start = zone->wp = sector;
6171
zone->len = dev->zone_size_sects;
72+
zone->capacity = dev->zone_capacity << ZONE_SIZE_SHIFT;
6273
zone->type = BLK_ZONE_TYPE_SEQWRITE_REQ;
6374
zone->cond = BLK_ZONE_COND_EMPTY;
6475

@@ -185,6 +196,9 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
185196
return BLK_STS_IOERR;
186197
}
187198

199+
if (zone->wp + nr_sectors > zone->start + zone->capacity)
200+
return BLK_STS_IOERR;
201+
188202
if (zone->cond != BLK_ZONE_COND_EXP_OPEN)
189203
zone->cond = BLK_ZONE_COND_IMP_OPEN;
190204

@@ -193,7 +207,7 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
193207
return ret;
194208

195209
zone->wp += nr_sectors;
196-
if (zone->wp == zone->start + zone->len)
210+
if (zone->wp == zone->start + zone->capacity)
197211
zone->cond = BLK_ZONE_COND_FULL;
198212
return BLK_STS_OK;
199213
default:

drivers/nvme/host/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ nvme-core-y := core.o
1313
nvme-core-$(CONFIG_TRACING) += trace.o
1414
nvme-core-$(CONFIG_NVME_MULTIPATH) += multipath.o
1515
nvme-core-$(CONFIG_NVM) += lightnvm.o
16+
nvme-core-$(CONFIG_BLK_DEV_ZONED) += zns.o
1617
nvme-core-$(CONFIG_FAULT_INJECTION_DEBUG_FS) += fault_inject.o
1718
nvme-core-$(CONFIG_NVME_HWMON) += hwmon.o
1819

0 commit comments

Comments
 (0)