Skip to content

Commit 77eb644

Browse files
Panky-codesbrauner
authored andcommitted
fs/buffer: remove the min and max limit checks in __getblk_slow()
All filesystems will already check the max and min value of their block size during their initialization. __getblk_slow() is a very low-level function to have these checks. Remove them and only check for logical block size alignment. As this check with logical block size alignment might never trigger, add WARN_ON_ONCE() to the check. As WARN_ON_ONCE() will already print the stack, remove the call to dump_stack(). Suggested-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com> Link: https://lore.kernel.org/20250626113223.181399-1-p.raghav@samsung.com Reviewed-by: Baokun Li <libaokun1@huawei.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 04a2c4b commit 77eb644

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

fs/buffer.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,14 +1122,9 @@ __getblk_slow(struct block_device *bdev, sector_t block,
11221122
{
11231123
bool blocking = gfpflags_allow_blocking(gfp);
11241124

1125-
if (unlikely(size & (bdev_logical_block_size(bdev) - 1) ||
1126-
(size < 512 || size > PAGE_SIZE))) {
1127-
printk(KERN_ERR "getblk(): invalid block size %d requested\n",
1128-
size);
1129-
printk(KERN_ERR "logical block size: %d\n",
1130-
bdev_logical_block_size(bdev));
1131-
1132-
dump_stack();
1125+
if (WARN_ON_ONCE(!IS_ALIGNED(size, bdev_logical_block_size(bdev)))) {
1126+
printk(KERN_ERR "getblk(): block size %d not aligned to logical block size %d\n",
1127+
size, bdev_logical_block_size(bdev));
11331128
return NULL;
11341129
}
11351130

0 commit comments

Comments
 (0)