Skip to content

Commit 84fe64f

Browse files
author
Christoph Hellwig
committed
nvmet: don't look at the request_queue in nvmet_bdev_set_limits
nvmet is a consumer of the block layer and should not directly look at the request_queue. Use the bdev_ helpers to retrieve the device limits instead. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Keith Busch <[email protected]>
1 parent 8df2025 commit 84fe64f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/nvme/target/io-cmd-bdev.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
void nvmet_bdev_set_limits(struct block_device *bdev, struct nvme_id_ns *id)
1414
{
15-
const struct queue_limits *ql = &bdev_get_queue(bdev)->limits;
16-
/* Number of logical blocks per physical block. */
17-
const u32 lpp = ql->physical_block_size / ql->logical_block_size;
1815
/* Logical blocks per physical block, 0's based. */
19-
const __le16 lpp0b = to0based(lpp);
16+
const __le16 lpp0b = to0based(bdev_physical_block_size(bdev) /
17+
bdev_logical_block_size(bdev));
2018

2119
/*
2220
* For NVMe 1.2 and later, bit 1 indicates that the fields NAWUN,
@@ -42,11 +40,12 @@ void nvmet_bdev_set_limits(struct block_device *bdev, struct nvme_id_ns *id)
4240
/* NPWA = Namespace Preferred Write Alignment. 0's based */
4341
id->npwa = id->npwg;
4442
/* NPDG = Namespace Preferred Deallocate Granularity. 0's based */
45-
id->npdg = to0based(ql->discard_granularity / ql->logical_block_size);
43+
id->npdg = to0based(bdev_discard_granularity(bdev) /
44+
bdev_logical_block_size(bdev));
4645
/* NPDG = Namespace Preferred Deallocate Alignment */
4746
id->npda = id->npdg;
4847
/* NOWS = Namespace Optimal Write Size */
49-
id->nows = to0based(ql->io_opt / ql->logical_block_size);
48+
id->nows = to0based(bdev_io_opt(bdev) / bdev_logical_block_size(bdev));
5049
}
5150

5251
void nvmet_bdev_ns_disable(struct nvmet_ns *ns)

0 commit comments

Comments
 (0)