Thread (18 messages) 18 messages, 2 authors, 2020-05-15
STALE2259d

[PATCH v2 03/10] block: add sectors_to_npage()/npage_to_sectors() helpers

From: Zhen Lei <hidden>
Date: 2020-05-07 07:56:41
Also in: dm-devel, linux-block, linux-mm, lkml
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

Provide the conversion of "number of sectors"/"sector number" and
"number of pages"/"page number".

Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Zhen Lei <redacted>
---
 include/linux/blkdev.h | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 934f31fc15cd..5d8daaffc38b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -910,6 +910,8 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
 #define SECTOR_SIZE		(1 << SECTOR_SHIFT)
 #endif
 #define PAGE_SECTORS		(PAGE_SIZE / SECTOR_SIZE)
+#define sectors_to_npage(nr)	((nr) / PAGE_SECTORS)
+#define npage_to_sectors(nr)	((nr) * PAGE_SECTORS)
 
 /*
  * blk_rq_pos()			: the current sector
-- 
2.26.0.106.g9fadedd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help