diff mbox series

[v10,10/10] xfs: enable block size larger than page size support

Message ID 20240715094457.452836-11-kernel@pankajraghav.com (mailing list archive)
State New
Headers show
Series enable bs > ps in XFS | expand

Commit Message

Pankaj Raghav (Samsung) July 15, 2024, 9:44 a.m. UTC
From: Pankaj Raghav <p.raghav@samsung.com>

Page cache now has the ability to have a minimum order when allocating
a folio which is a prerequisite to add support for block size > page
size.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 fs/xfs/libxfs/xfs_ialloc.c |  5 +++++
 fs/xfs/libxfs/xfs_shared.h |  3 +++
 fs/xfs/xfs_icache.c        |  6 ++++--
 fs/xfs/xfs_mount.c         |  1 -
 fs/xfs/xfs_super.c         | 30 ++++++++++++++++++++++--------
 5 files changed, 34 insertions(+), 11 deletions(-)

Comments

Darrick J. Wong July 15, 2024, 4:46 p.m. UTC | #1
On Mon, Jul 15, 2024 at 11:44:57AM +0200, Pankaj Raghav (Samsung) wrote:
> From: Pankaj Raghav <p.raghav@samsung.com>
> 
> Page cache now has the ability to have a minimum order when allocating
> a folio which is a prerequisite to add support for block size > page
> size.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>  fs/xfs/libxfs/xfs_ialloc.c |  5 +++++
>  fs/xfs/libxfs/xfs_shared.h |  3 +++
>  fs/xfs/xfs_icache.c        |  6 ++++--
>  fs/xfs/xfs_mount.c         |  1 -
>  fs/xfs/xfs_super.c         | 30 ++++++++++++++++++++++--------
>  5 files changed, 34 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index 14c81f227c5bb..1e76431d75a4b 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -3019,6 +3019,11 @@ xfs_ialloc_setup_geometry(
>  		igeo->ialloc_align = mp->m_dalign;
>  	else
>  		igeo->ialloc_align = 0;
> +
> +	if (mp->m_sb.sb_blocksize > PAGE_SIZE)
> +		igeo->min_folio_order = mp->m_sb.sb_blocklog - PAGE_SHIFT;
> +	else
> +		igeo->min_folio_order = 0;
>  }
>  
>  /* Compute the location of the root directory inode that is laid out by mkfs. */
> diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
> index 34f104ed372c0..e67a1c7cc0b02 100644
> --- a/fs/xfs/libxfs/xfs_shared.h
> +++ b/fs/xfs/libxfs/xfs_shared.h
> @@ -231,6 +231,9 @@ struct xfs_ino_geometry {
>  	/* precomputed value for di_flags2 */
>  	uint64_t	new_diflags2;
>  
> +	/* minimum folio order of a page cache allocation */
> +	unsigned int	min_folio_order;
> +
>  };
>  
>  #endif /* __XFS_SHARED_H__ */
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index cf629302d48e7..0fcf235e50235 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -88,7 +88,8 @@ xfs_inode_alloc(
>  
>  	/* VFS doesn't initialise i_mode! */
>  	VFS_I(ip)->i_mode = 0;
> -	mapping_set_large_folios(VFS_I(ip)->i_mapping);
> +	mapping_set_folio_min_order(VFS_I(ip)->i_mapping,
> +				    M_IGEO(mp)->min_folio_order);
>  
>  	XFS_STATS_INC(mp, vn_active);
>  	ASSERT(atomic_read(&ip->i_pincount) == 0);
> @@ -325,7 +326,8 @@ xfs_reinit_inode(
>  	inode->i_uid = uid;
>  	inode->i_gid = gid;
>  	inode->i_state = state;
> -	mapping_set_large_folios(inode->i_mapping);
> +	mapping_set_folio_min_order(inode->i_mapping,
> +				    M_IGEO(mp)->min_folio_order);
>  	return error;
>  }
>  
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 3949f720b5354..c6933440f8066 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -134,7 +134,6 @@ xfs_sb_validate_fsb_count(
>  {
>  	uint64_t		max_bytes;
>  
> -	ASSERT(PAGE_SHIFT >= sbp->sb_blocklog);
>  	ASSERT(sbp->sb_blocklog >= BBSHIFT);
>  
>  	if (check_shl_overflow(nblocks, sbp->sb_blocklog, &max_bytes))
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 27e9f749c4c7f..3c455ef588d48 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1638,16 +1638,30 @@ xfs_fs_fill_super(
>  		goto out_free_sb;
>  	}
>  
> -	/*
> -	 * Until this is fixed only page-sized or smaller data blocks work.
> -	 */
>  	if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
> -		xfs_warn(mp,
> -		"File system with blocksize %d bytes. "
> -		"Only pagesize (%ld) or less will currently work.",
> +		size_t max_folio_size = mapping_max_folio_size_supported();
> +
> +		if (!xfs_has_crc(mp)) {
> +			xfs_warn(mp,
> +"V4 Filesystem with blocksize %d bytes. Only pagesize (%ld) or less is supported.",
>  				mp->m_sb.sb_blocksize, PAGE_SIZE);
> -		error = -ENOSYS;
> -		goto out_free_sb;
> +			error = -ENOSYS;
> +			goto out_free_sb;
> +		}
> +
> +		if (mp->m_sb.sb_blocksize > max_folio_size) {
> +			xfs_warn(mp,
> +"block size (%u bytes) not supported; maximum folio size supported in "\
> +"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> +			mp->m_sb.sb_blocksize, max_folio_size,
> +			MAX_PAGECACHE_ORDER);
> +			error = -ENOSYS;
> +			goto out_free_sb;

Nit: Continuation lines should be indented, not lined up with the next
statement:

			xfs_warn(mp,
"block size (%u bytes) not supported; maximum folio size supported in "\
"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
					mp->m_sb.sb_blocksize,
					max_folio_size,
					MAX_PAGECACHE_ORDER);
			error = -ENOSYS;
			goto out_free_sb;

With that fixed,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> +		}
> +
> +		xfs_warn(mp,
> +"EXPERIMENTAL: V5 Filesystem with Large Block Size (%d bytes) enabled.",
> +			mp->m_sb.sb_blocksize);
>  	}
>  
>  	/* Ensure this filesystem fits in the page cache limits */
> -- 
> 2.44.1
> 
>
Matthew Wilcox July 16, 2024, 3:29 p.m. UTC | #2
On Mon, Jul 15, 2024 at 11:44:57AM +0200, Pankaj Raghav (Samsung) wrote:
> +++ b/fs/xfs/xfs_super.c
> @@ -1638,16 +1638,30 @@ xfs_fs_fill_super(
>  		goto out_free_sb;
>  	}
>  
> -	/*
> -	 * Until this is fixed only page-sized or smaller data blocks work.
> -	 */
>  	if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
> -		xfs_warn(mp,
> -		"File system with blocksize %d bytes. "
> -		"Only pagesize (%ld) or less will currently work.",
> +		size_t max_folio_size = mapping_max_folio_size_supported();
> +
> +		if (!xfs_has_crc(mp)) {
> +			xfs_warn(mp,
> +"V4 Filesystem with blocksize %d bytes. Only pagesize (%ld) or less is supported.",
>  				mp->m_sb.sb_blocksize, PAGE_SIZE);
> -		error = -ENOSYS;
> -		goto out_free_sb;
> +			error = -ENOSYS;
> +			goto out_free_sb;
> +		}
> +
> +		if (mp->m_sb.sb_blocksize > max_folio_size) {
> +			xfs_warn(mp,
> +"block size (%u bytes) not supported; maximum folio size supported in "\
> +"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> +			mp->m_sb.sb_blocksize, max_folio_size,
> +			MAX_PAGECACHE_ORDER);

Again, too much message.  Way too much.  We shouldn't even allow block
devices to be created if their block size is larger than the max supported
by the page cache.
Darrick J. Wong July 16, 2024, 5:40 p.m. UTC | #3
On Tue, Jul 16, 2024 at 04:29:05PM +0100, Matthew Wilcox wrote:
> On Mon, Jul 15, 2024 at 11:44:57AM +0200, Pankaj Raghav (Samsung) wrote:
> > +++ b/fs/xfs/xfs_super.c
> > @@ -1638,16 +1638,30 @@ xfs_fs_fill_super(
> >  		goto out_free_sb;
> >  	}
> >  
> > -	/*
> > -	 * Until this is fixed only page-sized or smaller data blocks work.
> > -	 */
> >  	if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
> > -		xfs_warn(mp,
> > -		"File system with blocksize %d bytes. "
> > -		"Only pagesize (%ld) or less will currently work.",
> > +		size_t max_folio_size = mapping_max_folio_size_supported();
> > +
> > +		if (!xfs_has_crc(mp)) {
> > +			xfs_warn(mp,
> > +"V4 Filesystem with blocksize %d bytes. Only pagesize (%ld) or less is supported.",
> >  				mp->m_sb.sb_blocksize, PAGE_SIZE);
> > -		error = -ENOSYS;
> > -		goto out_free_sb;
> > +			error = -ENOSYS;
> > +			goto out_free_sb;
> > +		}
> > +
> > +		if (mp->m_sb.sb_blocksize > max_folio_size) {
> > +			xfs_warn(mp,
> > +"block size (%u bytes) not supported; maximum folio size supported in "\
> > +"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> > +			mp->m_sb.sb_blocksize, max_folio_size,
> > +			MAX_PAGECACHE_ORDER);
> 
> Again, too much message.  Way too much.  We shouldn't even allow block
> devices to be created if their block size is larger than the max supported
> by the page cache.

Filesystem blocksize != block device blocksize.  xfs still needs this
check because one can xfs_copy a 64k-fsblock xfs to a hdd with 512b
sectors and try to mount that on x86.

Assuming there /is/ some fs that allows 1G blocksize, you'd then really
want a mount check that would prevent you from mounting that.

--D
Matthew Wilcox July 16, 2024, 5:46 p.m. UTC | #4
On Tue, Jul 16, 2024 at 10:40:16AM -0700, Darrick J. Wong wrote:
> On Tue, Jul 16, 2024 at 04:29:05PM +0100, Matthew Wilcox wrote:
> > On Mon, Jul 15, 2024 at 11:44:57AM +0200, Pankaj Raghav (Samsung) wrote:
> > > +++ b/fs/xfs/xfs_super.c
> > > @@ -1638,16 +1638,30 @@ xfs_fs_fill_super(
> > >  		goto out_free_sb;
> > >  	}
> > >  
> > > -	/*
> > > -	 * Until this is fixed only page-sized or smaller data blocks work.
> > > -	 */
> > >  	if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
> > > -		xfs_warn(mp,
> > > -		"File system with blocksize %d bytes. "
> > > -		"Only pagesize (%ld) or less will currently work.",
> > > +		size_t max_folio_size = mapping_max_folio_size_supported();
> > > +
> > > +		if (!xfs_has_crc(mp)) {
> > > +			xfs_warn(mp,
> > > +"V4 Filesystem with blocksize %d bytes. Only pagesize (%ld) or less is supported.",
> > >  				mp->m_sb.sb_blocksize, PAGE_SIZE);
> > > -		error = -ENOSYS;
> > > -		goto out_free_sb;
> > > +			error = -ENOSYS;
> > > +			goto out_free_sb;
> > > +		}
> > > +
> > > +		if (mp->m_sb.sb_blocksize > max_folio_size) {
> > > +			xfs_warn(mp,
> > > +"block size (%u bytes) not supported; maximum folio size supported in "\
> > > +"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> > > +			mp->m_sb.sb_blocksize, max_folio_size,
> > > +			MAX_PAGECACHE_ORDER);
> > 
> > Again, too much message.  Way too much.  We shouldn't even allow block
> > devices to be created if their block size is larger than the max supported
> > by the page cache.
> 
> Filesystem blocksize != block device blocksize.  xfs still needs this
> check because one can xfs_copy a 64k-fsblock xfs to a hdd with 512b
> sectors and try to mount that on x86.
> 
> Assuming there /is/ some fs that allows 1G blocksize, you'd then really
> want a mount check that would prevent you from mounting that.

Absolutely, we need to have an fs blocksize check in the fs (if only
because fs fuzzers will put random values in fields and expect the system
to not crash).  But that should have nothing to do with page cache size.
Darrick J. Wong July 16, 2024, 10:37 p.m. UTC | #5
On Tue, Jul 16, 2024 at 06:46:40PM +0100, Matthew Wilcox wrote:
> On Tue, Jul 16, 2024 at 10:40:16AM -0700, Darrick J. Wong wrote:
> > On Tue, Jul 16, 2024 at 04:29:05PM +0100, Matthew Wilcox wrote:
> > > On Mon, Jul 15, 2024 at 11:44:57AM +0200, Pankaj Raghav (Samsung) wrote:
> > > > +++ b/fs/xfs/xfs_super.c
> > > > @@ -1638,16 +1638,30 @@ xfs_fs_fill_super(
> > > >  		goto out_free_sb;
> > > >  	}
> > > >  
> > > > -	/*
> > > > -	 * Until this is fixed only page-sized or smaller data blocks work.
> > > > -	 */
> > > >  	if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
> > > > -		xfs_warn(mp,
> > > > -		"File system with blocksize %d bytes. "
> > > > -		"Only pagesize (%ld) or less will currently work.",
> > > > +		size_t max_folio_size = mapping_max_folio_size_supported();
> > > > +
> > > > +		if (!xfs_has_crc(mp)) {
> > > > +			xfs_warn(mp,
> > > > +"V4 Filesystem with blocksize %d bytes. Only pagesize (%ld) or less is supported.",
> > > >  				mp->m_sb.sb_blocksize, PAGE_SIZE);
> > > > -		error = -ENOSYS;
> > > > -		goto out_free_sb;
> > > > +			error = -ENOSYS;
> > > > +			goto out_free_sb;
> > > > +		}
> > > > +
> > > > +		if (mp->m_sb.sb_blocksize > max_folio_size) {
> > > > +			xfs_warn(mp,
> > > > +"block size (%u bytes) not supported; maximum folio size supported in "\
> > > > +"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> > > > +			mp->m_sb.sb_blocksize, max_folio_size,
> > > > +			MAX_PAGECACHE_ORDER);
> > > 
> > > Again, too much message.  Way too much.  We shouldn't even allow block
> > > devices to be created if their block size is larger than the max supported
> > > by the page cache.
> > 
> > Filesystem blocksize != block device blocksize.  xfs still needs this
> > check because one can xfs_copy a 64k-fsblock xfs to a hdd with 512b
> > sectors and try to mount that on x86.
> > 
> > Assuming there /is/ some fs that allows 1G blocksize, you'd then really
> > want a mount check that would prevent you from mounting that.
> 
> Absolutely, we need to have an fs blocksize check in the fs (if only
> because fs fuzzers will put random values in fields and expect the system
> to not crash).  But that should have nothing to do with page cache size.

I don't understand your objection -- we're setting the minimum folio
order on a file's pagecache to match the fs-wide blocksize.  If the
pagecache can't possibly fulfill our fs-wide requirement, then why would
we continue the mount?

Let's pretend that MAX_PAGECACHE_ORDER is 1.  The filesystem has 16k
blocks, the CPU has 4k base pages.  xfs will try to set the min folio
order to 2 via mapping_set_folio_order_range.  That function clamps it
to 1, so we try to cache a 16k fsblock with 8k pages.  Does that
actually work?

If not, then doesn't it make more more sense to fail the mount?

--D
Pankaj Raghav (Samsung) July 17, 2024, 10:02 a.m. UTC | #6
On Tue, Jul 16, 2024 at 06:46:40PM +0100, Matthew Wilcox wrote:
> On Tue, Jul 16, 2024 at 10:40:16AM -0700, Darrick J. Wong wrote:
> > On Tue, Jul 16, 2024 at 04:29:05PM +0100, Matthew Wilcox wrote:
> > > On Mon, Jul 15, 2024 at 11:44:57AM +0200, Pankaj Raghav (Samsung) wrote:
> > > > +++ b/fs/xfs/xfs_super.c
> > > > @@ -1638,16 +1638,30 @@ xfs_fs_fill_super(
> > > >  		goto out_free_sb;
> > > >  	}
> > > >  
> > > > -	/*
> > > > -	 * Until this is fixed only page-sized or smaller data blocks work.
> > > > -	 */
> > > >  	if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
> > > > -		xfs_warn(mp,
> > > > -		"File system with blocksize %d bytes. "
> > > > -		"Only pagesize (%ld) or less will currently work.",
> > > > +		size_t max_folio_size = mapping_max_folio_size_supported();
> > > > +
> > > > +		if (!xfs_has_crc(mp)) {
> > > > +			xfs_warn(mp,
> > > > +"V4 Filesystem with blocksize %d bytes. Only pagesize (%ld) or less is supported.",
> > > >  				mp->m_sb.sb_blocksize, PAGE_SIZE);
> > > > -		error = -ENOSYS;
> > > > -		goto out_free_sb;
> > > > +			error = -ENOSYS;
> > > > +			goto out_free_sb;
> > > > +		}
> > > > +
> > > > +		if (mp->m_sb.sb_blocksize > max_folio_size) {
> > > > +			xfs_warn(mp,
> > > > +"block size (%u bytes) not supported; maximum folio size supported in "\
> > > > +"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> > > > +			mp->m_sb.sb_blocksize, max_folio_size,
> > > > +			MAX_PAGECACHE_ORDER);
> > > 
> > > Again, too much message.  Way too much.  We shouldn't even allow block
> > > devices to be created if their block size is larger than the max supported
> > > by the page cache.
> > 
> > Filesystem blocksize != block device blocksize.  xfs still needs this
> > check because one can xfs_copy a 64k-fsblock xfs to a hdd with 512b
> > sectors and try to mount that on x86.
> > 
> > Assuming there /is/ some fs that allows 1G blocksize, you'd then really
> > want a mount check that would prevent you from mounting that.
> 
> Absolutely, we need to have an fs blocksize check in the fs (if only
> because fs fuzzers will put random values in fields and expect the system
> to not crash).  But that should have nothing to do with page cache size.

Ok, now I am not sure if I completely misunderstood the previous
comments. 

One of the comments you gave in the previous series is this[1]:

```
> What are callers supposed to do with an error? In the case of
> setting up a newly allocated inode in XFS, the error would be
> returned in the middle of a transaction and so this failure would
> result in a filesystem shutdown.

I suggest you handle it better than this.  If the device is asking for a
blocksize > PMD_SIZE, you should fail to mount it.  If the device is
asking for a blocksize > PAGE_SIZE and CONFIG_TRANSPARENT_HUGEPAGE is
not set, you should also decline to mount the filesystem.
```

That is exactly what we are doing here. We check for what can page cache
support and decline to mount if the max order supported is less than the
block size of the filesystem.

Maybe we can trim the the error message to just:

"block size (%u bytes) not supported; Only block size (%ld) or less is supported "\
					mp->m_sb.sb_blocksize,
					max_folio_size);

Let me know what you think.

[1]https://lore.kernel.org/linux-fsdevel/Zoc2rCPC5thSIuoR@casper.infradead.org/
Pankaj Raghav (Samsung) July 22, 2024, 2:12 p.m. UTC | #7
> > +
> > +		if (mp->m_sb.sb_blocksize > max_folio_size) {
> > +			xfs_warn(mp,
> > +"block size (%u bytes) not supported; maximum folio size supported in "\
> > +"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> > +			mp->m_sb.sb_blocksize, max_folio_size,
> > +			MAX_PAGECACHE_ORDER);
> > +			error = -ENOSYS;
> > +			goto out_free_sb;
> 
> Nit: Continuation lines should be indented, not lined up with the next
> statement:
> 
> 			xfs_warn(mp,
> "block size (%u bytes) not supported; maximum folio size supported in "\
> "the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> 					mp->m_sb.sb_blocksize,
> 					max_folio_size,
> 					MAX_PAGECACHE_ORDER);
> 			error = -ENOSYS;
> 			goto out_free_sb;

@Darrick: As willy pointed out, the error message is a bit long here.
Can we make as follows:

"block size (%u bytes) not supported; Only block size (%ld) or less is supported "\
                                        mp->m_sb.sb_blocksize,
                                        max_folio_size);

This is similar to the previous error and it is more concise IMO.

> 
> With that fixed,
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> 
> --D
>
Darrick J. Wong July 22, 2024, 6:49 p.m. UTC | #8
On Mon, Jul 22, 2024 at 02:12:20PM +0000, Pankaj Raghav (Samsung) wrote:
> > > +
> > > +		if (mp->m_sb.sb_blocksize > max_folio_size) {
> > > +			xfs_warn(mp,
> > > +"block size (%u bytes) not supported; maximum folio size supported in "\
> > > +"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> > > +			mp->m_sb.sb_blocksize, max_folio_size,
> > > +			MAX_PAGECACHE_ORDER);
> > > +			error = -ENOSYS;
> > > +			goto out_free_sb;
> > 
> > Nit: Continuation lines should be indented, not lined up with the next
> > statement:
> > 
> > 			xfs_warn(mp,
> > "block size (%u bytes) not supported; maximum folio size supported in "\
> > "the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
> > 					mp->m_sb.sb_blocksize,
> > 					max_folio_size,
> > 					MAX_PAGECACHE_ORDER);
> > 			error = -ENOSYS;
> > 			goto out_free_sb;
> 
> @Darrick: As willy pointed out, the error message is a bit long here.
> Can we make as follows:
> 
> "block size (%u bytes) not supported; Only block size (%ld) or less is supported "\
>                                         mp->m_sb.sb_blocksize,
>                                         max_folio_size);
> 
> This is similar to the previous error and it is more concise IMO.

Ah, ok.  I suppose printing max_folio_size *and* MAX_PAGECACHE_ORDER is
redundant.  The shortened version above is ok by me.

--D

> > 
> > With that fixed,
> > Reviewed-by: Darrick J. Wong <djwong@kernel.org>
> > 
> > --D
> > 
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 14c81f227c5bb..1e76431d75a4b 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -3019,6 +3019,11 @@  xfs_ialloc_setup_geometry(
 		igeo->ialloc_align = mp->m_dalign;
 	else
 		igeo->ialloc_align = 0;
+
+	if (mp->m_sb.sb_blocksize > PAGE_SIZE)
+		igeo->min_folio_order = mp->m_sb.sb_blocklog - PAGE_SHIFT;
+	else
+		igeo->min_folio_order = 0;
 }
 
 /* Compute the location of the root directory inode that is laid out by mkfs. */
diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
index 34f104ed372c0..e67a1c7cc0b02 100644
--- a/fs/xfs/libxfs/xfs_shared.h
+++ b/fs/xfs/libxfs/xfs_shared.h
@@ -231,6 +231,9 @@  struct xfs_ino_geometry {
 	/* precomputed value for di_flags2 */
 	uint64_t	new_diflags2;
 
+	/* minimum folio order of a page cache allocation */
+	unsigned int	min_folio_order;
+
 };
 
 #endif /* __XFS_SHARED_H__ */
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index cf629302d48e7..0fcf235e50235 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -88,7 +88,8 @@  xfs_inode_alloc(
 
 	/* VFS doesn't initialise i_mode! */
 	VFS_I(ip)->i_mode = 0;
-	mapping_set_large_folios(VFS_I(ip)->i_mapping);
+	mapping_set_folio_min_order(VFS_I(ip)->i_mapping,
+				    M_IGEO(mp)->min_folio_order);
 
 	XFS_STATS_INC(mp, vn_active);
 	ASSERT(atomic_read(&ip->i_pincount) == 0);
@@ -325,7 +326,8 @@  xfs_reinit_inode(
 	inode->i_uid = uid;
 	inode->i_gid = gid;
 	inode->i_state = state;
-	mapping_set_large_folios(inode->i_mapping);
+	mapping_set_folio_min_order(inode->i_mapping,
+				    M_IGEO(mp)->min_folio_order);
 	return error;
 }
 
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 3949f720b5354..c6933440f8066 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -134,7 +134,6 @@  xfs_sb_validate_fsb_count(
 {
 	uint64_t		max_bytes;
 
-	ASSERT(PAGE_SHIFT >= sbp->sb_blocklog);
 	ASSERT(sbp->sb_blocklog >= BBSHIFT);
 
 	if (check_shl_overflow(nblocks, sbp->sb_blocklog, &max_bytes))
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 27e9f749c4c7f..3c455ef588d48 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1638,16 +1638,30 @@  xfs_fs_fill_super(
 		goto out_free_sb;
 	}
 
-	/*
-	 * Until this is fixed only page-sized or smaller data blocks work.
-	 */
 	if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
-		xfs_warn(mp,
-		"File system with blocksize %d bytes. "
-		"Only pagesize (%ld) or less will currently work.",
+		size_t max_folio_size = mapping_max_folio_size_supported();
+
+		if (!xfs_has_crc(mp)) {
+			xfs_warn(mp,
+"V4 Filesystem with blocksize %d bytes. Only pagesize (%ld) or less is supported.",
 				mp->m_sb.sb_blocksize, PAGE_SIZE);
-		error = -ENOSYS;
-		goto out_free_sb;
+			error = -ENOSYS;
+			goto out_free_sb;
+		}
+
+		if (mp->m_sb.sb_blocksize > max_folio_size) {
+			xfs_warn(mp,
+"block size (%u bytes) not supported; maximum folio size supported in "\
+"the page cache is (%ld bytes). Check MAX_PAGECACHE_ORDER (%d)",
+			mp->m_sb.sb_blocksize, max_folio_size,
+			MAX_PAGECACHE_ORDER);
+			error = -ENOSYS;
+			goto out_free_sb;
+		}
+
+		xfs_warn(mp,
+"EXPERIMENTAL: V5 Filesystem with Large Block Size (%d bytes) enabled.",
+			mp->m_sb.sb_blocksize);
 	}
 
 	/* Ensure this filesystem fits in the page cache limits */