@@ -88,7 +88,7 @@ static void ext4_unregister_li_request(struct super_block *sb);
88
88
static void ext4_clear_request_list (void );
89
89
static struct inode * ext4_get_journal_inode (struct super_block * sb ,
90
90
unsigned int journal_inum );
91
- static int ext4_validate_options (struct super_block * sb );
91
+ static int ext4_validate_options (struct fs_context * fc );
92
92
93
93
/*
94
94
* Lock ordering
@@ -915,14 +915,20 @@ void __ext4_msg(struct super_block *sb,
915
915
struct va_format vaf ;
916
916
va_list args ;
917
917
918
- atomic_inc (& EXT4_SB (sb )-> s_msg_count );
919
- if (!___ratelimit (& (EXT4_SB (sb )-> s_msg_ratelimit_state ), "EXT4-fs" ))
920
- return ;
918
+ if (sb ) {
919
+ atomic_inc (& EXT4_SB (sb )-> s_msg_count );
920
+ if (!___ratelimit (& (EXT4_SB (sb )-> s_msg_ratelimit_state ),
921
+ "EXT4-fs" ))
922
+ return ;
923
+ }
921
924
922
925
va_start (args , fmt );
923
926
vaf .fmt = fmt ;
924
927
vaf .va = & args ;
925
- printk ("%sEXT4-fs (%s): %pV\n" , prefix , sb -> s_id , & vaf );
928
+ if (sb )
929
+ printk ("%sEXT4-fs (%s): %pV\n" , prefix , sb -> s_id , & vaf );
930
+ else
931
+ printk ("%sEXT4-fs: %pV\n" , prefix , & vaf );
926
932
va_end (args );
927
933
}
928
934
@@ -2286,12 +2292,12 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2286
2292
switch (token ) {
2287
2293
case Opt_noacl :
2288
2294
case Opt_nouser_xattr :
2289
- ext4_msg (sb , KERN_WARNING , deprecated_msg , param -> key , "3.5" );
2295
+ ext4_msg (NULL , KERN_WARNING , deprecated_msg , param -> key , "3.5" );
2290
2296
break ;
2291
2297
case Opt_sb :
2292
2298
return 1 ; /* handled by get_sb_block() */
2293
2299
case Opt_removed :
2294
- ext4_msg (sb , KERN_WARNING , "Ignoring removed %s option" ,
2300
+ ext4_msg (NULL , KERN_WARNING , "Ignoring removed %s option" ,
2295
2301
param -> key );
2296
2302
return 1 ;
2297
2303
case Opt_abort :
@@ -2310,7 +2316,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2310
2316
#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT
2311
2317
sb -> s_flags |= SB_INLINECRYPT ;
2312
2318
#else
2313
- ext4_msg (sb , KERN_ERR , "inline encryption not supported" );
2319
+ ext4_msg (NULL , KERN_ERR , "inline encryption not supported" );
2314
2320
#endif
2315
2321
return 1 ;
2316
2322
case Opt_errors :
@@ -2326,22 +2332,22 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2326
2332
break ;
2327
2333
2328
2334
if (m -> token == Opt_err ) {
2329
- ext4_msg (sb , KERN_ERR , "Unrecognized mount option \"%s\" "
2335
+ ext4_msg (NULL , KERN_ERR , "Unrecognized mount option \"%s\" "
2330
2336
"or missing value" , param -> key );
2331
- return -1 ;
2337
+ return - EINVAL ;
2332
2338
}
2333
2339
2334
2340
if ((m -> flags & MOPT_NO_EXT2 ) && IS_EXT2_SB (sb )) {
2335
- ext4_msg (sb , KERN_ERR ,
2341
+ ext4_msg (NULL , KERN_ERR ,
2336
2342
"Mount option \"%s\" incompatible with ext2" ,
2337
2343
param -> key );
2338
- return -1 ;
2344
+ return - EINVAL ;
2339
2345
}
2340
2346
if ((m -> flags & MOPT_NO_EXT3 ) && IS_EXT3_SB (sb )) {
2341
- ext4_msg (sb , KERN_ERR ,
2347
+ ext4_msg (NULL , KERN_ERR ,
2342
2348
"Mount option \"%s\" incompatible with ext3" ,
2343
2349
param -> key );
2344
- return -1 ;
2350
+ return - EINVAL ;
2345
2351
}
2346
2352
2347
2353
if (m -> flags & MOPT_EXPLICIT ) {
@@ -2350,38 +2356,38 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2350
2356
} else if (m -> mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM ) {
2351
2357
set_opt2 (sb , EXPLICIT_JOURNAL_CHECKSUM );
2352
2358
} else
2353
- return -1 ;
2359
+ return - EINVAL ;
2354
2360
}
2355
2361
if (m -> flags & MOPT_CLEAR_ERR )
2356
2362
clear_opt (sb , ERRORS_MASK );
2357
2363
if (token == Opt_noquota && sb_any_quota_loaded (sb )) {
2358
- ext4_msg (sb , KERN_ERR , "Cannot change quota "
2364
+ ext4_msg (NULL , KERN_ERR , "Cannot change quota "
2359
2365
"options when quota turned on" );
2360
- return -1 ;
2366
+ return - EINVAL ;
2361
2367
}
2362
2368
2363
2369
if (m -> flags & MOPT_NOSUPPORT ) {
2364
- ext4_msg (sb , KERN_ERR , "%s option not supported" ,
2370
+ ext4_msg (NULL , KERN_ERR , "%s option not supported" ,
2365
2371
param -> key );
2366
2372
} else if (token == Opt_commit ) {
2367
2373
if (result .uint_32 == 0 )
2368
2374
sbi -> s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE ;
2369
2375
else if (result .uint_32 > INT_MAX / HZ ) {
2370
- ext4_msg (sb , KERN_ERR ,
2376
+ ext4_msg (NULL , KERN_ERR ,
2371
2377
"Invalid commit interval %d, "
2372
2378
"must be smaller than %d" ,
2373
2379
result .uint_32 , INT_MAX / HZ );
2374
- return -1 ;
2380
+ return - EINVAL ;
2375
2381
}
2376
2382
sbi -> s_commit_interval = HZ * result .uint_32 ;
2377
2383
} else if (token == Opt_debug_want_extra_isize ) {
2378
2384
if ((result .uint_32 & 1 ) ||
2379
2385
(result .uint_32 < 4 ) ||
2380
2386
(result .uint_32 >
2381
2387
(sbi -> s_inode_size - EXT4_GOOD_OLD_INODE_SIZE ))) {
2382
- ext4_msg (sb , KERN_ERR ,
2388
+ ext4_msg (NULL , KERN_ERR ,
2383
2389
"Invalid want_extra_isize %d" , result .uint_32 );
2384
- return -1 ;
2390
+ return - EINVAL ;
2385
2391
}
2386
2392
sbi -> s_want_extra_isize = result .uint_32 ;
2387
2393
} else if (token == Opt_max_batch_time ) {
@@ -2392,10 +2398,10 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2392
2398
if (result .uint_32 &&
2393
2399
(result .uint_32 > (1 << 30 ) ||
2394
2400
!is_power_of_2 (result .uint_32 ))) {
2395
- ext4_msg (sb , KERN_ERR ,
2401
+ ext4_msg (NULL , KERN_ERR ,
2396
2402
"EXT4-fs: inode_readahead_blks must be "
2397
2403
"0 or a power of 2 smaller than 2^31" );
2398
- return -1 ;
2404
+ return - EINVAL ;
2399
2405
}
2400
2406
sbi -> s_inode_readahead_blks = result .uint_32 ;
2401
2407
} else if (token == Opt_init_itable ) {
@@ -2414,24 +2420,24 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2414
2420
} else if (token == Opt_resuid ) {
2415
2421
uid = make_kuid (current_user_ns (), result .uint_32 );
2416
2422
if (!uid_valid (uid )) {
2417
- ext4_msg (sb , KERN_ERR , "Invalid uid value %d" ,
2423
+ ext4_msg (NULL , KERN_ERR , "Invalid uid value %d" ,
2418
2424
result .uint_32 );
2419
- return -1 ;
2425
+ return - EINVAL ;
2420
2426
}
2421
2427
sbi -> s_resuid = uid ;
2422
2428
} else if (token == Opt_resgid ) {
2423
2429
gid = make_kgid (current_user_ns (), result .uint_32 );
2424
2430
if (!gid_valid (gid )) {
2425
- ext4_msg (sb , KERN_ERR , "Invalid gid value %d" ,
2431
+ ext4_msg (NULL , KERN_ERR , "Invalid gid value %d" ,
2426
2432
result .uint_32 );
2427
- return -1 ;
2433
+ return - EINVAL ;
2428
2434
}
2429
2435
sbi -> s_resgid = gid ;
2430
2436
} else if (token == Opt_journal_dev ) {
2431
2437
if (is_remount ) {
2432
- ext4_msg (sb , KERN_ERR ,
2438
+ ext4_msg (NULL , KERN_ERR ,
2433
2439
"Cannot specify journal on remount" );
2434
- return -1 ;
2440
+ return - EINVAL ;
2435
2441
}
2436
2442
ctx -> journal_devnum = result .uint_32 ;
2437
2443
} else if (token == Opt_journal_path ) {
@@ -2440,26 +2446,26 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2440
2446
int error ;
2441
2447
2442
2448
if (is_remount ) {
2443
- ext4_msg (sb , KERN_ERR ,
2449
+ ext4_msg (NULL , KERN_ERR ,
2444
2450
"Cannot specify journal on remount" );
2445
- return -1 ;
2451
+ return - EINVAL ;
2446
2452
}
2447
2453
2448
2454
error = fs_lookup_param (fc , param , 1 , & path );
2449
2455
if (error ) {
2450
- ext4_msg (sb , KERN_ERR , "error: could not find "
2456
+ ext4_msg (NULL , KERN_ERR , "error: could not find "
2451
2457
"journal device path" );
2452
- return -1 ;
2458
+ return - EINVAL ;
2453
2459
}
2454
2460
2455
2461
journal_inode = d_inode (path .dentry );
2456
2462
ctx -> journal_devnum = new_encode_dev (journal_inode -> i_rdev );
2457
2463
path_put (& path );
2458
2464
} else if (token == Opt_journal_ioprio ) {
2459
2465
if (result .uint_32 > 7 ) {
2460
- ext4_msg (sb , KERN_ERR , "Invalid journal IO priority"
2466
+ ext4_msg (NULL , KERN_ERR , "Invalid journal IO priority"
2461
2467
" (must be 0-7)" );
2462
- return -1 ;
2468
+ return - EINVAL ;
2463
2469
}
2464
2470
ctx -> journal_ioprio =
2465
2471
IOPRIO_PRIO_VALUE (IOPRIO_CLASS_BE , result .uint_32 );
@@ -2468,11 +2474,11 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2468
2474
} else if (m -> flags & MOPT_DATAJ ) {
2469
2475
if (is_remount ) {
2470
2476
if (!sbi -> s_journal )
2471
- ext4_msg (sb , KERN_WARNING , "Remounting file system with no journal so ignoring journalled data option" );
2477
+ ext4_msg (NULL , KERN_WARNING , "Remounting file system with no journal so ignoring journalled data option" );
2472
2478
else if (test_opt (sb , DATA_FLAGS ) != m -> mount_opt ) {
2473
- ext4_msg (sb , KERN_ERR ,
2479
+ ext4_msg (NULL , KERN_ERR ,
2474
2480
"Cannot change data mode on remount" );
2475
- return -1 ;
2481
+ return - EINVAL ;
2476
2482
}
2477
2483
} else {
2478
2484
clear_opt (sb , DATA_FLAGS );
@@ -2482,12 +2488,12 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2482
2488
} else if (m -> flags & MOPT_QFMT ) {
2483
2489
if (sb_any_quota_loaded (sb ) &&
2484
2490
sbi -> s_jquota_fmt != m -> mount_opt ) {
2485
- ext4_msg (sb , KERN_ERR , "Cannot change journaled "
2491
+ ext4_msg (NULL , KERN_ERR , "Cannot change journaled "
2486
2492
"quota options when quota turned on" );
2487
- return -1 ;
2493
+ return - EINVAL ;
2488
2494
}
2489
2495
if (ext4_has_feature_quota (sb )) {
2490
- ext4_msg (sb , KERN_INFO ,
2496
+ ext4_msg (NULL , KERN_INFO ,
2491
2497
"Quota format mount options ignored "
2492
2498
"when QUOTA feature is enabled" );
2493
2499
return 1 ;
@@ -2504,18 +2510,18 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2504
2510
(!(sbi -> s_mount_opt & EXT4_MOUNT_DAX_ALWAYS ) ||
2505
2511
(sbi -> s_mount_opt2 & EXT4_MOUNT2_DAX_NEVER ))) {
2506
2512
fail_dax_change_remount :
2507
- ext4_msg (sb , KERN_ERR , "can't change "
2513
+ ext4_msg (NULL , KERN_ERR , "can't change "
2508
2514
"dax mount option while remounting" );
2509
- return -1 ;
2515
+ return - EINVAL ;
2510
2516
}
2511
2517
if (is_remount &&
2512
2518
(test_opt (sb , DATA_FLAGS ) ==
2513
2519
EXT4_MOUNT_JOURNAL_DATA )) {
2514
- ext4_msg (sb , KERN_ERR , "can't mount with "
2520
+ ext4_msg (NULL , KERN_ERR , "can't mount with "
2515
2521
"both data=journal and dax" );
2516
- return -1 ;
2522
+ return - EINVAL ;
2517
2523
}
2518
- ext4_msg (sb , KERN_WARNING ,
2524
+ ext4_msg (NULL , KERN_WARNING ,
2519
2525
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk" );
2520
2526
sbi -> s_mount_opt |= EXT4_MOUNT_DAX_ALWAYS ;
2521
2527
sbi -> s_mount_opt2 &= ~EXT4_MOUNT2_DAX_NEVER ;
@@ -2541,20 +2547,20 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2541
2547
break ;
2542
2548
}
2543
2549
#else
2544
- ext4_msg (sb , KERN_INFO , "dax option not supported" );
2550
+ ext4_msg (NULL , KERN_INFO , "dax option not supported" );
2545
2551
sbi -> s_mount_opt2 |= EXT4_MOUNT2_DAX_NEVER ;
2546
2552
sbi -> s_mount_opt &= ~EXT4_MOUNT_DAX_ALWAYS ;
2547
- return -1 ;
2553
+ return - EINVAL ;
2548
2554
#endif
2549
2555
} else if (token == Opt_data_err_abort ) {
2550
2556
sbi -> s_mount_opt |= m -> mount_opt ;
2551
2557
} else if (token == Opt_data_err_ignore ) {
2552
2558
sbi -> s_mount_opt &= ~m -> mount_opt ;
2553
2559
} else if (token == Opt_mb_optimize_scan ) {
2554
2560
if (result .int_32 != 0 && result .int_32 != 1 ) {
2555
- ext4_msg (sb , KERN_WARNING ,
2561
+ ext4_msg (NULL , KERN_WARNING ,
2556
2562
"mb_optimize_scan should be set to 0 or 1." );
2557
- return -1 ;
2563
+ return - EINVAL ;
2558
2564
}
2559
2565
ctx -> mb_optimize_scan = result .int_32 ;
2560
2566
} else {
@@ -2567,11 +2573,11 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param)
2567
2573
if (m -> flags & MOPT_CLEAR )
2568
2574
set = !set ;
2569
2575
else if (unlikely (!(m -> flags & MOPT_SET ))) {
2570
- ext4_msg (sb , KERN_WARNING ,
2576
+ ext4_msg (NULL , KERN_WARNING ,
2571
2577
"buggy handling of option %s" ,
2572
2578
param -> key );
2573
2579
WARN_ON (1 );
2574
- return -1 ;
2580
+ return - EINVAL ;
2575
2581
}
2576
2582
if (m -> flags & MOPT_2 ) {
2577
2583
if (set != 0 )
@@ -2639,12 +2645,17 @@ static int parse_options(char *options, struct super_block *sb,
2639
2645
}
2640
2646
}
2641
2647
2642
- return ext4_validate_options (sb );
2648
+ ret = ext4_validate_options (& fc );
2649
+ if (ret < 0 )
2650
+ return 0 ;
2651
+
2652
+ return 1 ;
2643
2653
}
2644
2654
2645
- static int ext4_validate_options (struct super_block * sb )
2655
+ static int ext4_validate_options (struct fs_context * fc )
2646
2656
{
2647
- struct ext4_sb_info * sbi = EXT4_SB (sb );
2657
+ struct ext4_sb_info * sbi = fc -> s_fs_info ;
2658
+ struct super_block * sb = sbi -> s_sb ;
2648
2659
#ifdef CONFIG_QUOTA
2649
2660
char * usr_qf_name , * grp_qf_name ;
2650
2661
/*
@@ -2653,9 +2664,9 @@ static int ext4_validate_options(struct super_block *sb)
2653
2664
* to support legacy quotas in quota files.
2654
2665
*/
2655
2666
if (test_opt (sb , PRJQUOTA ) && !ext4_has_feature_project (sb )) {
2656
- ext4_msg (sb , KERN_ERR , "Project quota feature not enabled. "
2667
+ ext4_msg (NULL , KERN_ERR , "Project quota feature not enabled. "
2657
2668
"Cannot enable project quota enforcement." );
2658
- return 0 ;
2669
+ return - EINVAL ;
2659
2670
}
2660
2671
usr_qf_name = get_qf_name (sb , sbi , USRQUOTA );
2661
2672
grp_qf_name = get_qf_name (sb , sbi , GRPQUOTA );
@@ -2667,27 +2678,28 @@ static int ext4_validate_options(struct super_block *sb)
2667
2678
clear_opt (sb , GRPQUOTA );
2668
2679
2669
2680
if (test_opt (sb , GRPQUOTA ) || test_opt (sb , USRQUOTA )) {
2670
- ext4_msg (sb , KERN_ERR , "old and new quota "
2681
+ ext4_msg (NULL , KERN_ERR , "old and new quota "
2671
2682
"format mixing" );
2672
- return 0 ;
2683
+ return - EINVAL ;
2673
2684
}
2674
2685
2675
2686
if (!sbi -> s_jquota_fmt ) {
2676
- ext4_msg (sb , KERN_ERR , "journaled quota format "
2687
+ ext4_msg (NULL , KERN_ERR , "journaled quota format "
2677
2688
"not specified" );
2678
- return 0 ;
2689
+ return - EINVAL ;
2679
2690
}
2680
2691
}
2681
2692
#endif
2682
2693
if (test_opt (sb , DIOREAD_NOLOCK )) {
2683
2694
int blocksize =
2684
2695
BLOCK_SIZE << le32_to_cpu (sbi -> s_es -> s_log_block_size );
2685
2696
if (blocksize < PAGE_SIZE )
2686
- ext4_msg (sb , KERN_WARNING , "Warning: mounting with an "
2687
- "experimental mount option 'dioread_nolock' "
2688
- "for blocksize < PAGE_SIZE" );
2697
+ ext4_msg (NULL , KERN_WARNING ,
2698
+ "Warning: mounting with an experimental "
2699
+ "option 'dioread_nolock' for "
2700
+ "blocksize < PAGE_SIZE" );
2689
2701
}
2690
- return 1 ;
2702
+ return 0 ;
2691
2703
}
2692
2704
2693
2705
static inline void ext4_show_quota_options (struct seq_file * seq ,
0 commit comments