public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>,
	brauner@kernel.org, hare@suse.de, david@fromorbit.com,
	kbusch@kernel.org, john.g.garry@oracle.com, hch@lst.de,
	ritesh.list@gmail.com, linux-fsdevel@vger.kernel.org,
	linux-block@vger.kernel.org, gost.dev@samsung.com,
	p.raghav@samsung.com, da.gomez@samsung.com,
	kernel@pankajraghav.com,
	Kent Overstreet <kent.overstreet@linux.dev>
Subject: Re: [PATCH] bdev: add back PAGE_SIZE block size validation for sb_set_blocksize()'
Date: Wed, 5 Mar 2025 10:48:34 -0800	[thread overview]
Message-ID: <20250305184834.GE2803771@frogsfrogsfrogs> (raw)
In-Reply-To: <Z8iEMv354ThMRr0b@bombadil.infradead.org>

On Wed, Mar 05, 2025 at 09:04:50AM -0800, Luis Chamberlain wrote:
> On Wed, Mar 05, 2025 at 02:15:47PM +0000, Matthew Wilcox wrote:
> > On Tue, Mar 04, 2025 at 10:33:30PM -0800, Darrick J. Wong wrote:
> > > > So this is expedient because XFS happens to not call sb_set_blocksize()?
> > > > What is the path forward for filesystems which call sb_set_blocksize()
> > > > today and want to support LBS in future?
> > > 
> > > Well they /could/ set sb_blocksize/sb_blocksize_bits themselves, like
> > > XFS does.
> > 
> > I'm kind of hoping that isn't the answer.
> 
> set_blocksize() can be used. The only extra steps the filesystem needs
> to in addition is:
> 
> 	sb->s_blocksize = size;
> 	sb->s_blocksize_bits = blksize_bits(size);
> 
> Which is what both XFS and bcachefs do.
> 
> We could modify sb to add an LBS flag but that alone would not suffice
> either as the upper limit is still a filesystem specific limit. Additionally
> it also does not suffice for filesystems that support a different device
> for metadata writes, for instance XFS supports this and uses the sector
> size for set_blocksize().
> 
> So I think that if ext4 for example wants to use LBS then simply it
> would open code the above two lines and use set_blocksize(). Let me know
> if you have any other recommendations.

int sb_set_large_blocksize(struct super_block *sb, int size)
{
	if (set_blocksize(sb->s_bdev_file, size))
		return 0;
	sb->s_blocksize = size;
	sb->s_blocksize_bits = blksize_bits(size);
	return sb->s_blocksize;
}
EXPORT_SYMBOL_GPL(sb_set_large_blocksize);

int sb_set_blocksize(struct super_block *sb, int size)
{
	if (size > PAGE_SIZE)
		return 0;
	return sb_set_large_blocksize(sb, size);
}
EXPORT_SYMBOL(sb_set_blocksize);

Though you'll note that this doesn't help XFS, or any other filesystem
where the bdev block size isn't set to the fs block size.  But xfs can
just be weird on its own like always. ;)

--D

> 
>   Luis

  reply	other threads:[~2025-03-05 18:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05  1:53 [PATCH] bdev: add back PAGE_SIZE block size validation for sb_set_blocksize() Luis Chamberlain
2025-03-05  6:04 ` Matthew Wilcox
2025-03-05  6:33   ` Darrick J. Wong
2025-03-05 14:15     ` Matthew Wilcox
2025-03-05 17:04       ` [PATCH] bdev: add back PAGE_SIZE block size validation for sb_set_blocksize()' Luis Chamberlain
2025-03-05 18:48         ` Darrick J. Wong [this message]
2025-03-05 19:55           ` Luis Chamberlain
2025-03-05  7:18 ` [PATCH] bdev: add back PAGE_SIZE block size validation for sb_set_blocksize() Hannes Reinecke
2025-03-05 17:05   ` Luis Chamberlain
2025-03-06 18:39 ` Kent Overstreet
2025-03-07  0:45   ` Luis Chamberlain
2025-03-07  1:43     ` Kent Overstreet

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=20250305184834.GE2803771@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=brauner@kernel.org \
    --cc=da.gomez@samsung.com \
    --cc=david@fromorbit.com \
    --cc=gost.dev@samsung.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=john.g.garry@oracle.com \
    --cc=kbusch@kernel.org \
    --cc=kent.overstreet@linux.dev \
    --cc=kernel@pankajraghav.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=p.raghav@samsung.com \
    --cc=ritesh.list@gmail.com \
    --cc=willy@infradead.org \
    /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