@@ -2319,9 +2319,9 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2319
2319
unsigned long old_sb_flags ;
2320
2320
int err ;
2321
2321
bool need_restart_gc = false, need_stop_gc = false;
2322
- bool need_restart_ckpt = false, need_stop_ckpt = false;
2323
2322
bool need_restart_flush = false, need_stop_flush = false;
2324
2323
bool need_restart_discard = false, need_stop_discard = false;
2324
+ bool need_enable_checkpoint = false, need_disable_checkpoint = false;
2325
2325
bool no_read_extent_cache = !test_opt (sbi , READ_EXTENT_CACHE );
2326
2326
bool no_age_extent_cache = !test_opt (sbi , AGE_EXTENT_CACHE );
2327
2327
bool enable_checkpoint = !test_opt (sbi , DISABLE_CHECKPOINT );
@@ -2485,24 +2485,6 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2485
2485
clear_sbi_flag (sbi , SBI_IS_CLOSE );
2486
2486
}
2487
2487
2488
- if ((* flags & SB_RDONLY ) || test_opt (sbi , DISABLE_CHECKPOINT ) ||
2489
- !test_opt (sbi , MERGE_CHECKPOINT )) {
2490
- f2fs_stop_ckpt_thread (sbi );
2491
- need_restart_ckpt = true;
2492
- } else {
2493
- /* Flush if the prevous checkpoint, if exists. */
2494
- f2fs_flush_ckpt_thread (sbi );
2495
-
2496
- err = f2fs_start_ckpt_thread (sbi );
2497
- if (err ) {
2498
- f2fs_err (sbi ,
2499
- "Failed to start F2FS issue_checkpoint_thread (%d)" ,
2500
- err );
2501
- goto restore_gc ;
2502
- }
2503
- need_stop_ckpt = true;
2504
- }
2505
-
2506
2488
/*
2507
2489
* We stop issue flush thread if FS is mounted as RO
2508
2490
* or if flush_merge is not passed in mount option.
@@ -2514,7 +2496,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2514
2496
} else {
2515
2497
err = f2fs_create_flush_cmd_control (sbi );
2516
2498
if (err )
2517
- goto restore_ckpt ;
2499
+ goto restore_gc ;
2518
2500
need_stop_flush = true;
2519
2501
}
2520
2502
@@ -2536,8 +2518,31 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2536
2518
err = f2fs_disable_checkpoint (sbi );
2537
2519
if (err )
2538
2520
goto restore_discard ;
2521
+ need_enable_checkpoint = true;
2539
2522
} else {
2540
2523
f2fs_enable_checkpoint (sbi );
2524
+ need_disable_checkpoint = true;
2525
+ }
2526
+ }
2527
+
2528
+ /*
2529
+ * Place this routine at the end, since a new checkpoint would be
2530
+ * triggered while remount and we need to take care of it before
2531
+ * returning from remount.
2532
+ */
2533
+ if ((* flags & SB_RDONLY ) || test_opt (sbi , DISABLE_CHECKPOINT ) ||
2534
+ !test_opt (sbi , MERGE_CHECKPOINT )) {
2535
+ f2fs_stop_ckpt_thread (sbi );
2536
+ } else {
2537
+ /* Flush if the prevous checkpoint, if exists. */
2538
+ f2fs_flush_ckpt_thread (sbi );
2539
+
2540
+ err = f2fs_start_ckpt_thread (sbi );
2541
+ if (err ) {
2542
+ f2fs_err (sbi ,
2543
+ "Failed to start F2FS issue_checkpoint_thread (%d)" ,
2544
+ err );
2545
+ goto restore_checkpoint ;
2541
2546
}
2542
2547
}
2543
2548
@@ -2555,6 +2560,13 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2555
2560
adjust_unusable_cap_perc (sbi );
2556
2561
* flags = (* flags & ~SB_LAZYTIME ) | (sb -> s_flags & SB_LAZYTIME );
2557
2562
return 0 ;
2563
+ restore_checkpoint :
2564
+ if (need_enable_checkpoint ) {
2565
+ f2fs_enable_checkpoint (sbi );
2566
+ } else if (need_disable_checkpoint ) {
2567
+ if (f2fs_disable_checkpoint (sbi ))
2568
+ f2fs_warn (sbi , "checkpoint has not been disabled" );
2569
+ }
2558
2570
restore_discard :
2559
2571
if (need_restart_discard ) {
2560
2572
if (f2fs_start_discard_thread (sbi ))
@@ -2570,13 +2582,6 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2570
2582
clear_opt (sbi , FLUSH_MERGE );
2571
2583
f2fs_destroy_flush_cmd_control (sbi , false);
2572
2584
}
2573
- restore_ckpt :
2574
- if (need_restart_ckpt ) {
2575
- if (f2fs_start_ckpt_thread (sbi ))
2576
- f2fs_warn (sbi , "background ckpt thread has stopped" );
2577
- } else if (need_stop_ckpt ) {
2578
- f2fs_stop_ckpt_thread (sbi );
2579
- }
2580
2585
restore_gc :
2581
2586
if (need_restart_gc ) {
2582
2587
if (f2fs_start_gc_thread (sbi ))
0 commit comments