summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorKelvin Zhang <zhangxp1998@gmail.com>2026-09-03 16:56:21 -0700
committerJaegeuk Kim <jaegeuk@kernel.org>2026-09-14 15:21:47 +0000
commit0d83f165142ff431b36f39ccd6a50ac3a7621292 (patch)
tree444ac934c5115ec00ec5a5f08e20a2a70c5ea54e /include/linux
parentb32d4bdbae616dec768252b86845d9358c770a15 (diff)
downloadlinux-next-0d83f165142ff431b36f39ccd6a50ac3a7621292.tar.gz
linux-next-0d83f165142ff431b36f39ccd6a50ac3a7621292.zip
f2fs: parameterize byte and block conversion macros
Byte-to-block and block-to-byte conversion helpers previously relied on global PAGE_SIZE, PAGE_SHIFT, or F2FS_BLKSIZE_BITS. Parameterize F2FS_BYTES_TO_BLK, F2FS_BLK_TO_BYTES, F2FS_BLK_END_BYTES, F2FS_BLK_ALIGN, and max_file_blocks with struct f2fs_sb_info *sbi using sbi->log_blocksize. Update all call sites across data mapping, file operations, fiemap queries, fsverity checks, NAT bitmap allocations, and truncate paths. Signed-off-by: Kelvin Zhang <zhangxp1998@gmail.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/f2fs_fs.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index 33995cd3dd6d..4c9540981db4 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -28,10 +28,15 @@
#define COMPRESS_ADDR ((block_t)-2) /* used as compressed data flag */
#define F2FS_BLKSIZE_MASK (F2FS_BLKSIZE - 1)
-#define F2FS_BYTES_TO_BLK(bytes) ((unsigned long long)(bytes) >> F2FS_BLKSIZE_BITS)
-#define F2FS_BLK_TO_BYTES(blk) ((unsigned long long)(blk) << F2FS_BLKSIZE_BITS)
-#define F2FS_BLK_END_BYTES(blk) (F2FS_BLK_TO_BYTES(blk + 1) - 1)
-#define F2FS_BLK_ALIGN(x) (F2FS_BYTES_TO_BLK((x) + F2FS_BLKSIZE - 1))
+#define F2FS_BYTES_TO_BLK(sbi, bytes) \
+ ((unsigned long long)(bytes) >> (sbi)->log_blocksize)
+#define F2FS_BLK_TO_BYTES(sbi, blk) \
+ ((unsigned long long)(blk) << (sbi)->log_blocksize)
+#define F2FS_BLK_END_BYTES(sbi, blk) \
+ (F2FS_BLK_TO_BYTES(sbi, (blk) + 1) - 1)
+#define F2FS_BLK_ALIGN(sbi, bytes) \
+ F2FS_BYTES_TO_BLK(sbi, (unsigned long long)(bytes) + \
+ (sbi)->blocksize - 1)
/* 0, 1(node nid), 2(meta nid) are reserved node id */
#define F2FS_RESERVED_NODE_NUM 3