@@ -347,75 +347,34 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
347
347
348
348
/* Checkpoint list management */
349
349
350
- /*
351
- * journal_clean_one_cp_list
352
- *
353
- * Find all the written-back checkpoint buffers in the given list and
354
- * release them. If 'destroy' is set, clean all buffers unconditionally.
355
- *
356
- * Called with j_list_lock held.
357
- * Returns 1 if we freed the transaction, 0 otherwise.
358
- */
359
- static int journal_clean_one_cp_list (struct journal_head * jh , bool destroy )
360
- {
361
- struct journal_head * last_jh ;
362
- struct journal_head * next_jh = jh ;
363
-
364
- if (!jh )
365
- return 0 ;
366
-
367
- last_jh = jh -> b_cpprev ;
368
- do {
369
- jh = next_jh ;
370
- next_jh = jh -> b_cpnext ;
371
-
372
- if (!destroy && __cp_buffer_busy (jh ))
373
- return 0 ;
374
-
375
- if (__jbd2_journal_remove_checkpoint (jh ))
376
- return 1 ;
377
- /*
378
- * This function only frees up some memory
379
- * if possible so we dont have an obligation
380
- * to finish processing. Bail out if preemption
381
- * requested:
382
- */
383
- if (need_resched ())
384
- return 0 ;
385
- } while (jh != last_jh );
386
-
387
- return 0 ;
388
- }
389
-
390
350
/*
391
351
* journal_shrink_one_cp_list
392
352
*
393
- * Find 'nr_to_scan' written-back checkpoint buffers in the given list
353
+ * Find all the written-back checkpoint buffers in the given list
394
354
* and try to release them. If the whole transaction is released, set
395
355
* the 'released' parameter. Return the number of released checkpointed
396
356
* buffers.
397
357
*
398
358
* Called with j_list_lock held.
399
359
*/
400
360
static unsigned long journal_shrink_one_cp_list (struct journal_head * jh ,
401
- unsigned long * nr_to_scan ,
402
- bool * released )
361
+ bool destroy , bool * released )
403
362
{
404
363
struct journal_head * last_jh ;
405
364
struct journal_head * next_jh = jh ;
406
365
unsigned long nr_freed = 0 ;
407
366
int ret ;
408
367
409
- if (!jh || * nr_to_scan == 0 )
368
+ * released = false;
369
+ if (!jh )
410
370
return 0 ;
411
371
412
372
last_jh = jh -> b_cpprev ;
413
373
do {
414
374
jh = next_jh ;
415
375
next_jh = jh -> b_cpnext ;
416
376
417
- (* nr_to_scan )-- ;
418
- if (__cp_buffer_busy (jh ))
377
+ if (!destroy && __cp_buffer_busy (jh ))
419
378
continue ;
420
379
421
380
nr_freed ++ ;
@@ -427,7 +386,7 @@ static unsigned long journal_shrink_one_cp_list(struct journal_head *jh,
427
386
428
387
if (need_resched ())
429
388
break ;
430
- } while (jh != last_jh && * nr_to_scan );
389
+ } while (jh != last_jh );
431
390
432
391
return nr_freed ;
433
392
}
@@ -445,11 +404,11 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
445
404
unsigned long * nr_to_scan )
446
405
{
447
406
transaction_t * transaction , * last_transaction , * next_transaction ;
448
- bool released ;
407
+ bool __maybe_unused released ;
449
408
tid_t first_tid = 0 , last_tid = 0 , next_tid = 0 ;
450
409
tid_t tid = 0 ;
451
410
unsigned long nr_freed = 0 ;
452
- unsigned long nr_scanned = * nr_to_scan ;
411
+ unsigned long freed ;
453
412
454
413
again :
455
414
spin_lock (& journal -> j_list_lock );
@@ -478,10 +437,11 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
478
437
transaction = next_transaction ;
479
438
next_transaction = transaction -> t_cpnext ;
480
439
tid = transaction -> t_tid ;
481
- released = false;
482
440
483
- nr_freed += journal_shrink_one_cp_list (transaction -> t_checkpoint_list ,
484
- nr_to_scan , & released );
441
+ freed = journal_shrink_one_cp_list (transaction -> t_checkpoint_list ,
442
+ false, & released );
443
+ nr_freed += freed ;
444
+ (* nr_to_scan ) -= min (* nr_to_scan , freed );
485
445
if (* nr_to_scan == 0 )
486
446
break ;
487
447
if (need_resched () || spin_needbreak (& journal -> j_list_lock ))
@@ -502,9 +462,8 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
502
462
if (* nr_to_scan && next_tid )
503
463
goto again ;
504
464
out :
505
- nr_scanned -= * nr_to_scan ;
506
465
trace_jbd2_shrink_checkpoint_list (journal , first_tid , tid , last_tid ,
507
- nr_freed , nr_scanned , next_tid );
466
+ nr_freed , next_tid );
508
467
509
468
return nr_freed ;
510
469
}
@@ -520,7 +479,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
520
479
void __jbd2_journal_clean_checkpoint_list (journal_t * journal , bool destroy )
521
480
{
522
481
transaction_t * transaction , * last_transaction , * next_transaction ;
523
- int ret ;
482
+ bool released ;
524
483
525
484
transaction = journal -> j_checkpoint_transactions ;
526
485
if (!transaction )
@@ -531,8 +490,8 @@ void __jbd2_journal_clean_checkpoint_list(journal_t *journal, bool destroy)
531
490
do {
532
491
transaction = next_transaction ;
533
492
next_transaction = transaction -> t_cpnext ;
534
- ret = journal_clean_one_cp_list (transaction -> t_checkpoint_list ,
535
- destroy );
493
+ journal_shrink_one_cp_list (transaction -> t_checkpoint_list ,
494
+ destroy , & released );
536
495
/*
537
496
* This function only frees up some memory if possible so we
538
497
* dont have an obligation to finish processing. Bail out if
@@ -545,7 +504,7 @@ void __jbd2_journal_clean_checkpoint_list(journal_t *journal, bool destroy)
545
504
* avoids pointless scanning of transactions which still
546
505
* weren't checkpointed.
547
506
*/
548
- if (!ret )
507
+ if (!released )
549
508
return ;
550
509
} while (transaction != last_transaction );
551
510
}
0 commit comments