Skip to content

Commit cebf9da

Browse files
Panky-codesbrauner
authored andcommitted
xfs: make the calculation generic in xfs_sb_validate_fsb_count()
Instead of assuming that PAGE_SHIFT is always higher than the blocklog, make the calculation generic so that page cache count can be calculated correctly for LBS. Signed-off-by: Pankaj Raghav <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Darrick J. Wong <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Reviewed-by: Daniel Gomez <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 79012cf commit cebf9da

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/xfs/xfs_mount.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,16 @@ xfs_sb_validate_fsb_count(
132132
xfs_sb_t *sbp,
133133
uint64_t nblocks)
134134
{
135+
uint64_t max_bytes;
136+
135137
ASSERT(PAGE_SHIFT >= sbp->sb_blocklog);
136138
ASSERT(sbp->sb_blocklog >= BBSHIFT);
137139

140+
if (check_shl_overflow(nblocks, sbp->sb_blocklog, &max_bytes))
141+
return -EFBIG;
142+
138143
/* Limited by ULONG_MAX of page cache index */
139-
if (nblocks >> (PAGE_SHIFT - sbp->sb_blocklog) > ULONG_MAX)
144+
if (max_bytes >> PAGE_SHIFT > ULONG_MAX)
140145
return -EFBIG;
141146
return 0;
142147
}

0 commit comments

Comments
 (0)