nvme: reject the ns when the block size is smaller than a sector
PATCH 1/1 nvme: reject the ns when the block size is smaller than a sector
The nvme spec(1.4a, figure 248) says:
"A value smaller than 9 (i.e., 512 bytes) is not supported."
--- drivers/nvme/host/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvme/host/core.c +6 -0
@@ -2161,6 +2161,12 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)blk_mq_freeze_queue (ns->disk->queue); ns->lba_shift = id->lbaf[lbaf].ds; +if (ns->lba_shift <9 ) { +pr_warn ("%s: bad lba_shift(%d)\n" , ns->disk->disk_name, ns->lba_shift); + ret =-1 ; + goto out_unfreeze; + } +nvme_set_queue_limits (ns->ctrl, ns->queue);if (ns->head->ids.csi ==NVME_CSI_ZNS ) {
Signature · 1 line
2.29.2
Quoted 16 lines · Li Feng
The nvme
spec(1.4a, figure 248)says:
"A value smaller than 9 (i.e., 512 bytes) is not supported."Signed-off-by Li Feng <[email protected]>--- drivers/nvme/host/core.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/nvme/host/core.c +0
-0@@ -2161,6 +2161,12 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)blk_mq_freeze_queue (ns->disk->queue);
drivers/nvme/host/core.c static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id) · line 2172
Quoted 10 lines
drivers/nvme/host/core.c +6
-0ns->lba_shift = id->lbaf[lbaf].ds; +if (ns->lba_shift <9 ) { +pr_warn ("%s: bad lba_shift(%d)\n" , ns->disk->disk_name, ns->lba_shift); + ret =-1 ; + goto out_unfreeze; + } +nvme_set_queue_limits (ns->ctrl, ns->queue);if (ns->head->ids.csi ==NVME_CSI_ZNS ) {
But this only catches a physical block size < 512 for NVMe, not any other block device.
Please fix it for the general case in blk_queue_physical_block_size().
Thanks,
Johannes
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerQuoted 15 lines
Quoted 15 lines
The nvme
spec(1.4a, figure 248)says:
"A value smaller than 9 (i.e., 512 bytes) is not supported."Signed-off-by Li Feng <[email protected]>--- drivers/nvme/host/core.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/nvme/host/core.c +0
-0@@ -2161,6 +2161,12 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
Quoted 5 lines
drivers/nvme/host/core.c static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id) · line 2166
Quoted 5 lines
drivers/nvme/host/core.c +3
-0blk_mq_freeze_queue (ns->disk->queue); ns->lba_shift = id->lbaf[lbaf].ds; +if (ns->lba_shift <9 ) { +pr_warn ("%s: bad lba_shift(%d)\n" , ns->disk->disk_name, ns->lba_shift); + ret =-1 ;
Meaningful errno would be useful. Also better to use dev_warn
Quoted 5 lines
Quoted 5 lines
drivers/nvme/host/core.c +3
-0+ goto out_unfreeze; + } +nvme_set_queue_limits (ns->ctrl, ns->queue);
Quoted 7 lines
drivers/nvme/host/core.c static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id) · line 2172
Quoted 2 lines
drivers/nvme/host/core.c +0
-0if (ns->head->ids.csi ==NVME_CSI_ZNS ) {But this only catches a physical block size < 512 for NVMe, not any other block device.
Please fix it for the general case in
blk_queue_physical_block_size().
We actually call that later and would probably be better to check here..
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 33 lines · Sagi Grimberg <[email protected]> 于2021年1月14日周四 上午6:13写道:
Quoted 16 lines
Quoted 16 lines
The nvme
spec(1.4a, figure 248)says:
"A value smaller than 9 (i.e., 512 bytes) is not supported."Signed-off-by Li Feng <[email protected]>--- drivers/nvme/host/core.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/nvme/host/core.c +0
-0@@ -2161,6 +2161,12 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)Quoted 5 lines
drivers/nvme/host/core.c static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id) · line 2166
Quoted 5 lines
drivers/nvme/host/core.c +3
-0blk_mq_freeze_queue (ns->disk->queue); ns->lba_shift = id->lbaf[lbaf].ds; +if (ns->lba_shift <9 ) { +pr_warn ("%s: bad lba_shift(%d)\n" , ns->disk->disk_name, ns->lba_shift); + ret =-1 ;Meaningful errno would be useful. Also better to use
dev_warnQuoted 9 lines
Quoted 7 lines
drivers/nvme/host/core.c +3
-0+ goto out_unfreeze; + } +nvme_set_queue_limits (ns->ctrl, ns->queue);if (ns->head->ids.csi ==NVME_CSI_ZNS ) {
Quoted 5 lines
Quoted 3 lines
But this only catches a physical block size < 512 for NVMe, not any other block device.
Please fix it for the general case in
blk_queue_physical_block_size().We actually call that later and would probably be better to check here..
Thanks for your comments.
The prototype is:
void blk_queue_logical_block_size(struct request_queue *, unsigned int);
So change it to:
bool blk_queue_logical_block_size(struct request_queue *, unsigned int);
And check all callers of this function, right?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 5 lines · Sagi Grimberg
Quoted 3 lines
But this only catches a physical block size < 512 for NVMe, not any other block device.
Please fix it for the general case in
blk_queue_physical_block_size().We actually call that later and would probably be better to check here..
We had a series for that a short while ago that got lost.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerQuoted 8 lines
Quoted 6 lines
Quoted 4 lines
But this only catches a physical block size < 512 for NVMe, not any other block device.
Please fix it for the general case in
blk_queue_physical_block_size().We actually call that later and would probably be better to check here..
We had a series for that a short while ago that got lost.
What was it called?
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 9 lines · Christoph Hellwig <[email protected]> 于2021年1月15日周五 上午1:43写道:
Quoted 5 lines · Sagi Grimberg
Quoted 3 lines
But this only catches a physical block size < 512 for NVMe, not any other block device.
Please fix it for the general case in
blk_queue_physical_block_size().We actually call that later and would probably be better to check here..
We had a series for that a short while ago that got lost.
Where is the series? Or could you advise on how to fix this issue is acceptable? This issue will generate an oops, check it here:
https://lkml.org/lkml/2021/1/12/1064
Thanks,
Feng Li
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme