fs/buffer: remove the min and max limit checks in __getblk_slow()
PATCH v3 1/1 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.
---
Changes since v2:
- Removed the max and min checks in __getblk_slow().
fs/buffer.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/buffer.c +3 -7
@@ -1122,13 +1122,9 @@ __getblk_slow(struct block_device *bdev, sector_t block, {bool blocking =gfpflags_allow_blocking (gfp); -if (unlikely (size & (bdev_logical_block_size (bdev) -1 ) || - (size <512 || size >PAGE_SIZE ))) { -printk (KERN_ERR "getblk(): invalid block size %d requested\n" , - size); -printk (KERN_ERR "logical block size: %d\n" , -bdev_logical_block_size (bdev)); - +if (unlikely (size & (bdev_logical_block_size (bdev) -1 ))) { +printk (KERN_ERR "getblk(): block size %d not aligned to logical block size %d\n" , + size,bdev_logical_block_size (bdev));dump_stack ();return NULL ; }
base-commit: 6ae58121126dcf8efcc2611f216a36a5e50b8ad9
Signature · 1 line
2.49.0
Jan Kara
reviewerQuoted 7 lines · Pankaj Raghav
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.Suggested-by Matthew Wilcox <[email protected]>Signed-off-by Pankaj Raghav <[email protected]>
I know this is a bikeshedding but FWIW this is in the should never trigger territory so I'd be inclined to just make it WARN_ON_ONCE() and completely delete it once we refactor bh apis to make sure nobody can call bh functions with anything else than sb->s_blocksize.
Honza
Quoted 33 lines
---
Changes since v2:
- Removed the max and min checks in__getblk_slow().fs/buffer.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)fs/buffer.c +3
-7@@ -1122,13 +1122,9 @@ __getblk_slow(struct block_device *bdev, sector_t block, {bool blocking =gfpflags_allow_blocking (gfp); -if (unlikely (size & (bdev_logical_block_size (bdev) -1 ) || - (size <512 || size >PAGE_SIZE ))) { -printk (KERN_ERR "getblk(): invalid block size %d requested\n" , - size); -printk (KERN_ERR "logical block size: %d\n" , -bdev_logical_block_size (bdev)); - +if (unlikely (size & (bdev_logical_block_size (bdev) -1 ))) { +printk (KERN_ERR "getblk(): block size %d not aligned to logical block size %d\n" , + size,bdev_logical_block_size (bdev));dump_stack ();return NULL ; }base-commit:
6ae58121126dcf8efcc2611f216a36a5e50b8ad9Signature · 1 line
2.49.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 6 lines · Jan Kara
Quoted 5 lines · Pankaj Raghav
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.
Quoted 8 lines
Quoted 2 lines
Suggested-by Matthew Wilcox <[email protected]>Signed-off-by Pankaj Raghav <[email protected]>I know this is a bikeshedding but FWIW this is in the should never trigger territory so I'd be inclined to just make it
WARN_ON_ONCE()and completely delete it once we refactor bh apis to make sure nobody can call bh functions with anything else thansb->s_blocksize.
Something like this:
fs/buffer.c +1 -2
@@ -1122,10 +1122,9 @@ __getblk_slow(struct block_device *bdev, sector_t block, {bool blocking =gfpflags_allow_blocking (gfp); -if (unlikely (size & (bdev_logical_block_size (bdev) -1 ))) { +if (WARN_ON_ONCE (size & (bdev_logical_block_size (bdev) -1 ))) {printk (KERN_ERR "getblk(): block size %d not aligned to logical block size %d\n" , size,bdev_logical_block_size (bdev)); -dump_stack ();return NULL ; }
I assume we don't need the dump_stack() anymore as we will print them with WARN_ON_ONCE anyway?
--
Pankaj
Quoted 33 lines · Pankaj Raghav (Samsung)
Quoted 6 lines · Jan Kara
Quoted 5 lines · Pankaj Raghav
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.Quoted 8 lines
Quoted 2 lines
Suggested-by Matthew Wilcox <[email protected]>Signed-off-by Pankaj Raghav <[email protected]>I know this is a bikeshedding but FWIW this is in the should never trigger territory so I'd be inclined to just make it
WARN_ON_ONCE()and completely delete it once we refactor bh apis to make sure nobody can call bh functions with anything else thansb->s_blocksize.Something like this:
fs/buffer.c +1
-2@@ -1122,10 +1122,9 @@ __getblk_slow(struct block_device *bdev, sector_t block, {bool blocking =gfpflags_allow_blocking (gfp); -if (unlikely (size & (bdev_logical_block_size (bdev) -1 ))) { +if (WARN_ON_ONCE (size & (bdev_logical_block_size (bdev) -1 ))) {printk (KERN_ERR "getblk(): block size %d not aligned to logical block size %d\n" , size,bdev_logical_block_size (bdev)); -dump_stack ();return NULL ; }
Quoted 2 lines
I assume we don't need the
dump_stack()anymore as we will print them withWARN_ON_ONCEanyway?
Correct. Thanks! Feel free to add:
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR