[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tuf33rhiur3h42o27sjrgs4jxhstmul3gqjbh6sjikhv7z3ntt@ebfq6ojqisp3>
Date: Thu, 19 Jun 2025 15:57:40 +0200
From: "Pankaj Raghav (Samsung)" <kernel@...kajraghav.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: Pankaj Raghav <p.raghav@...sung.com>,
Alexander Viro <viro@...iv.linux.org.uk>, Jan Kara <jack@...e.cz>, mcgrof@...nel.org,
Christian Brauner <brauner@...nel.org>, linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
gost.dev@...sung.com
Subject: Re: [PATCH v2] fs/buffer: use min folio order to calculate upper
limit in __getblk_slow()
On Thu, Jun 19, 2025 at 01:59:12PM +0100, Matthew Wilcox wrote:
> On Thu, Jun 19, 2025 at 02:10:58PM +0200, Pankaj Raghav wrote:
> > +++ b/fs/buffer.c
> > @@ -1121,9 +1121,10 @@ __getblk_slow(struct block_device *bdev, sector_t block,
> > unsigned size, gfp_t gfp)
> > {
> > bool blocking = gfpflags_allow_blocking(gfp);
> > + int blocklog = PAGE_SHIFT + mapping_min_folio_order(bdev->bd_mapping);
> >
> > if (unlikely(size & (bdev_logical_block_size(bdev) - 1) ||
> > - (size < 512 || size > PAGE_SIZE))) {
> > + (size < 512 || size > (1U << blocklog)))) {
> > printk(KERN_ERR "getblk(): invalid block size %d requested\n",
> > size);
> > printk(KERN_ERR "logical block size: %d\n",
>
> Is this what we want though? If ext4 wants to create an 8kB block size
> filesystem on top of a 512 byte sector size device, shouldn't it be
That will not be a problem because we set the min order of the FS on the
block device[1] from ext4[2] through set_blocksize() routine.
> allowed to? So just drop the max:
But I do agree with dropping it because we have these checks all over the
place. So the question is: do we need it again in a low level function
such as __getblk_slow().
>
> if (unlikely(size & (bdev_logical_block_size(bdev) - 1) ||
> - (size < 512 || size > PAGE_SIZE))) {
> + (size < 512)))) {
>
> (also, surely logical_block_size is always at least 512, so do we really
> need this check at all?)
True!
Just the alignment check with logical block size should be enough.
--
Pankaj
[1] https://elixir.bootlin.com/linux/v6.16-rc2/source/block/bdev.c#L210
[2] https://elixir.bootlin.com/linux/v6.16-rc2/source/fs/ext4/super.c#L5110
Powered by blists - more mailing lists