Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity

2021-01-12 Thread Li Feng
Yes, Reject the device is the right fix. I will try to send another fix. By the way, I think this fix is good protection, maybe some other devices violate this block size constraint. Divide zero is unacceptable. Thanks, Feng Li Martin K. Petersen 于2021年1月13日周三 上午1:48写道: > > > Johannes, > > >>

Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity

2021-01-12 Thread Martin K. Petersen
Johannes, >> I use the nvme-tcp as the host, the target is spdk nvme-tcp target, >> and set a wrong block size(i.g. bs=8), then the host prints this oops: > > I think the better fix here is to reject devices which report a block size > small than a sector. Yep, Linux doesn't support logical

Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity

2021-01-12 Thread Johannes Thumshirn
On 12/01/2021 18:29, Feng Li wrote: > I use the nvme-tcp as the host, the target is spdk nvme-tcp target, > and set a wrong block size(i.g. bs=8), then the host prints this oops: I think the better fix here is to reject devices which report a block size small than a sector.

Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity

2021-01-12 Thread Feng Li
Hi Martin, I use the nvme-tcp as the host, the target is spdk nvme-tcp target, and set a wrong block size(i.g. bs=8), then the host prints this oops: [ 63.153018] nvme nvme0: creating 3 I/O queues. [ 63.181644] nvme nvme0: mapped 3/0/0 default/read/poll queues. [ 63.185568] nvme nvme0: new

Re: [PATCH v2] blk: avoid divide-by-zero with zero granularity

2021-01-12 Thread Martin K. Petersen
Li, > If the physical_block_size and io_min is less than a sector, That's not supposed to happen. What device/driver is this? -- Martin K. Petersen Oracle Linux Engineering

[PATCH v2] blk: avoid divide-by-zero with zero granularity

2021-01-12 Thread Li Feng
If the physical_block_size and io_min is less than a sector, the 'granularity >> SECTOR_SHIFT' will be zero. Signed-off-by: Li Feng --- include/linux/blkdev.h | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index