All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk: avoid divide-by-zero with zero granularity
@ 2021-01-12 15:29 Li Feng
  2021-01-12 15:34 ` Feng Li
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Li Feng @ 2021-01-12 15:29 UTC (permalink / raw)
  To: Jens Axboe, open list:BLOCK LAYER, open list; +Cc: lifeng1519, 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 <fengli@smartx.com>
---
 include/linux/blkdev.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f94ee3089e01..4d029e95adb4 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1485,6 +1485,10 @@ static inline int queue_alignment_offset(const struct request_queue *q)
 static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
 {
 	unsigned int granularity = max(lim->physical_block_size, lim->io_min);
+	granularity = granularity >> SECTOR_SHIFT;
+	if (!granularity)
+		return 0;
+
 	unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
 		<< SECTOR_SHIFT;
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-01-13  2:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 15:29 [PATCH] blk: avoid divide-by-zero with zero granularity Li Feng
2021-01-12 15:34 ` Feng Li
2021-01-12 15:55 ` [PATCH v2] " Li Feng
2021-01-12 17:10   ` Martin K. Petersen
2021-01-12 17:27     ` Feng Li
2021-01-12 17:36       ` Johannes Thumshirn
2021-01-12 17:46         ` Martin K. Petersen
2021-01-13  2:42           ` Li Feng
2021-01-12 18:42 ` [PATCH] " kernel test robot
2021-01-12 18:42   ` kernel test robot
2021-01-12 21:49 ` kernel test robot
2021-01-12 21:49   ` kernel test robot
2021-01-12 22:57 ` kernel test robot
2021-01-12 22:57   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.