diff options
| author | Kiselev, Oleg <[email protected]> | 2022-07-20 04:27:48 +0000 |
|---|---|---|
| committer | Theodore Ts'o <[email protected]> | 2022-08-03 03:56:26 +0000 |
| commit | 69cb8e9d8cd97cdf5e293b26d70a9dee3e35e6bd (patch) | |
| tree | 4c04cf154e06fd8c06738c0bc78ce665902161d7 /fs/ext4/resize.c | |
| parent | ext4: reduce computation of overhead during resize (diff) | |
| download | kernel-69cb8e9d8cd97cdf5e293b26d70a9dee3e35e6bd.tar.gz kernel-69cb8e9d8cd97cdf5e293b26d70a9dee3e35e6bd.zip | |
ext4: avoid resizing to a partial cluster size
This patch avoids an attempt to resize the filesystem to an
unaligned cluster boundary. An online resize to a size that is not
integral to cluster size results in the last iteration attempting to
grow the fs by a negative amount, which trips a BUG_ON and leaves the fs
with a corrupted in-memory superblock.
Signed-off-by: Oleg Kiselev <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>
Diffstat (limited to 'fs/ext4/resize.c')
| -rw-r--r-- | fs/ext4/resize.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 5e3a893e600e..fea2a68d067b 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -2011,6 +2011,16 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count) } brelse(bh); + /* + * For bigalloc, trim the requested size to the nearest cluster + * boundary to avoid creating an unusable filesystem. We do this + * silently, instead of returning an error, to avoid breaking + * callers that blindly resize the filesystem to the full size of + * the underlying block device. + */ + if (ext4_has_feature_bigalloc(sb)) + n_blocks_count &= ~((1 << EXT4_CLUSTER_BITS(sb)) - 1); + retry: o_blocks_count = ext4_blocks_count(es); |
