From: Baokun Li <libaokun1@huawei.com>
To: Pankaj Raghav <p.raghav@samsung.com>
Cc: Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
<mcgrof@kernel.org>, Alexander Viro <viro@zeniv.linux.org.uk>,
<linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
<kernel@pankajraghav.com>, <gost.dev@samsung.com>,
Matthew Wilcox <willy@infradead.org>,
Zhang Yi <yi.zhang@huawei.com>, Yang Erkun <yangerkun@huawei.com>
Subject: Re: [PATCH v4] fs/buffer: remove the min and max limit checks in __getblk_slow()
Date: Fri, 27 Jun 2025 10:02:30 +0800 [thread overview]
Message-ID: <3398cb62-3666-4a79-84c1-3b967059cd77@huawei.com> (raw)
In-Reply-To: <20250626113223.181399-1-p.raghav@samsung.com>
On 2025/6/26 19:32, Pankaj Raghav wrote:
> 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>
Makes sense. Feel free to add:
Reviewed-by: Baokun Li <libaokun1@huawei.com>
> ---
> Changes since v3:
> - Use WARN_ON_ONCE on the logical block size check and remove the call
> to dump_stack.
> - Use IS_ALIGNED() to check for aligned instead of open coding the
> check.
>
> fs/buffer.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/fs/buffer.c b/fs/buffer.c
> index d61073143127..565fe88773c2 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -1122,14 +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));
> -
> - dump_stack();
> + if (WARN_ON_ONCE(!IS_ALIGNED(size, bdev_logical_block_size(bdev)))) {
> + printk(KERN_ERR "getblk(): block size %d not aligned to logical block size %d\n",
> + size, bdev_logical_block_size(bdev));
> return NULL;
> }
>
>
> base-commit: b39f7d75dc41b5f5d028192cd5d66cff71179f35
next prev parent reply other threads:[~2025-06-27 2:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 11:32 Pankaj Raghav
2025-06-27 2:02 ` Baokun Li [this message]
2025-06-29 10:15 ` David Laight
2025-06-30 10:05 ` Pankaj Raghav (Samsung)
2025-07-01 11:56 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3398cb62-3666-4a79-84c1-3b967059cd77@huawei.com \
--to=libaokun1@huawei.com \
--cc=brauner@kernel.org \
--cc=gost.dev@samsung.com \
--cc=jack@suse.cz \
--cc=kernel@pankajraghav.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=p.raghav@samsung.com \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®