@@ -5178,6 +5178,18 @@ static int ext4_block_group_meta_init(struct super_block *sb, int silent)
5178
5178
return 0 ;
5179
5179
}
5180
5180
5181
+ /*
5182
+ * It's hard to get stripe aligned blocks if stripe is not aligned with
5183
+ * cluster, just disable stripe and alert user to simplify code and avoid
5184
+ * stripe aligned allocation which will rarely succeed.
5185
+ */
5186
+ static bool ext4_is_stripe_incompatible (struct super_block * sb , unsigned long stripe )
5187
+ {
5188
+ struct ext4_sb_info * sbi = EXT4_SB (sb );
5189
+ return (stripe > 0 && sbi -> s_cluster_ratio > 1 &&
5190
+ stripe % sbi -> s_cluster_ratio != 0 );
5191
+ }
5192
+
5181
5193
static int __ext4_fill_super (struct fs_context * fc , struct super_block * sb )
5182
5194
{
5183
5195
struct ext4_super_block * es = NULL ;
@@ -5287,13 +5299,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
5287
5299
goto failed_mount3 ;
5288
5300
5289
5301
sbi -> s_stripe = ext4_get_stripe_size (sbi );
5290
- /*
5291
- * It's hard to get stripe aligned blocks if stripe is not aligned with
5292
- * cluster, just disable stripe and alert user to simpfy code and avoid
5293
- * stripe aligned allocation which will rarely successes.
5294
- */
5295
- if (sbi -> s_stripe > 0 && sbi -> s_cluster_ratio > 1 &&
5296
- sbi -> s_stripe % sbi -> s_cluster_ratio != 0 ) {
5302
+ if (ext4_is_stripe_incompatible (sb , sbi -> s_stripe )) {
5297
5303
ext4_msg (sb , KERN_WARNING ,
5298
5304
"stripe (%lu) is not aligned with cluster size (%u), "
5299
5305
"stripe is disabled" ,
@@ -6457,6 +6463,15 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
6457
6463
6458
6464
}
6459
6465
6466
+ if ((ctx -> spec & EXT4_SPEC_s_stripe ) &&
6467
+ ext4_is_stripe_incompatible (sb , ctx -> s_stripe )) {
6468
+ ext4_msg (sb , KERN_WARNING ,
6469
+ "stripe (%lu) is not aligned with cluster size (%u), "
6470
+ "stripe is disabled" ,
6471
+ ctx -> s_stripe , sbi -> s_cluster_ratio );
6472
+ ctx -> s_stripe = 0 ;
6473
+ }
6474
+
6460
6475
/*
6461
6476
* Changing the DIOREAD_NOLOCK or DELALLOC mount options may cause
6462
6477
* two calls to ext4_should_dioread_nolock() to return inconsistent
0 commit comments