Skip to content

Commit 7df7c20

Browse files
Panky-codesbrauner
authored andcommitted
xfs: enable block size larger than page size support
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 <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/r/[email protected] # fix folded Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent cebf9da commit 7df7c20

File tree

6 files changed

+45
-11
lines changed

6 files changed

+45
-11
lines changed

fs/xfs/libxfs/xfs_ialloc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,6 +3033,11 @@ xfs_ialloc_setup_geometry(
30333033
igeo->ialloc_align = mp->m_dalign;
30343034
else
30353035
igeo->ialloc_align = 0;
3036+
3037+
if (mp->m_sb.sb_blocksize > PAGE_SIZE)
3038+
igeo->min_folio_order = mp->m_sb.sb_blocklog - PAGE_SHIFT;
3039+
else
3040+
igeo->min_folio_order = 0;
30363041
}
30373042

30383043
/* Compute the location of the root directory inode that is laid out by mkfs. */

fs/xfs/libxfs/xfs_shared.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ struct xfs_ino_geometry {
224224
/* precomputed value for di_flags2 */
225225
uint64_t new_diflags2;
226226

227+
/* minimum folio order of a page cache allocation */
228+
unsigned int min_folio_order;
229+
227230
};
228231

229232
#endif /* __XFS_SHARED_H__ */

fs/xfs/xfs_icache.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ xfs_inode_alloc(
8888

8989
/* VFS doesn't initialise i_mode! */
9090
VFS_I(ip)->i_mode = 0;
91-
mapping_set_large_folios(VFS_I(ip)->i_mapping);
91+
mapping_set_folio_min_order(VFS_I(ip)->i_mapping,
92+
M_IGEO(mp)->min_folio_order);
9293

9394
XFS_STATS_INC(mp, vn_active);
9495
ASSERT(atomic_read(&ip->i_pincount) == 0);
@@ -325,7 +326,8 @@ xfs_reinit_inode(
325326
inode->i_uid = uid;
326327
inode->i_gid = gid;
327328
inode->i_state = state;
328-
mapping_set_large_folios(inode->i_mapping);
329+
mapping_set_folio_min_order(inode->i_mapping,
330+
M_IGEO(mp)->min_folio_order);
329331
return error;
330332
}
331333

fs/xfs/xfs_mount.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ xfs_sb_validate_fsb_count(
134134
{
135135
uint64_t max_bytes;
136136

137-
ASSERT(PAGE_SHIFT >= sbp->sb_blocklog);
138137
ASSERT(sbp->sb_blocklog >= BBSHIFT);
139138

140139
if (check_shl_overflow(nblocks, sbp->sb_blocklog, &max_bytes))

fs/xfs/xfs_super.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,16 +1638,28 @@ xfs_fs_fill_super(
16381638
goto out_free_sb;
16391639
}
16401640

1641-
/*
1642-
* Until this is fixed only page-sized or smaller data blocks work.
1643-
*/
16441641
if (mp->m_sb.sb_blocksize > PAGE_SIZE) {
1645-
xfs_warn(mp,
1646-
"File system with blocksize %d bytes. "
1647-
"Only pagesize (%ld) or less will currently work.",
1642+
size_t max_folio_size = mapping_max_folio_size_supported();
1643+
1644+
if (!xfs_has_crc(mp)) {
1645+
xfs_warn(mp,
1646+
"V4 Filesystem with blocksize %d bytes. Only pagesize (%ld) or less is supported.",
16481647
mp->m_sb.sb_blocksize, PAGE_SIZE);
1649-
error = -ENOSYS;
1650-
goto out_free_sb;
1648+
error = -ENOSYS;
1649+
goto out_free_sb;
1650+
}
1651+
1652+
if (mp->m_sb.sb_blocksize > max_folio_size) {
1653+
xfs_warn(mp,
1654+
"block size (%u bytes) not supported; Only block size (%zu) or less is supported",
1655+
mp->m_sb.sb_blocksize, max_folio_size);
1656+
error = -ENOSYS;
1657+
goto out_free_sb;
1658+
}
1659+
1660+
xfs_warn(mp,
1661+
"EXPERIMENTAL: V5 Filesystem with Large Block Size (%d bytes) enabled.",
1662+
mp->m_sb.sb_blocksize);
16511663
}
16521664

16531665
/* Ensure this filesystem fits in the page cache limits */

include/linux/pagemap.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,19 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
374374
#define MAX_XAS_ORDER (XA_CHUNK_SHIFT * 2 - 1)
375375
#define MAX_PAGECACHE_ORDER min(MAX_XAS_ORDER, PREFERRED_MAX_PAGECACHE_ORDER)
376376

377+
/*
378+
* mapping_max_folio_size_supported() - Check the max folio size supported
379+
*
380+
* The filesystem should call this function at mount time if there is a
381+
* requirement on the folio mapping size in the page cache.
382+
*/
383+
static inline size_t mapping_max_folio_size_supported(void)
384+
{
385+
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
386+
return 1U << (PAGE_SHIFT + MAX_PAGECACHE_ORDER);
387+
return PAGE_SIZE;
388+
}
389+
377390
/*
378391
* mapping_set_folio_order_range() - Set the orders supported by a file.
379392
* @mapping: The address space of the file.

0 commit comments

Comments
 (0)