diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-06-03 16:21:35 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2020-06-03 19:56:33 -0400 |
commit | 1952c0790c74e4e81d7066a19aabc5c55a13f10f (patch) | |
tree | 501fa5db6a5f1fd3b2412a2660e995c74ebf0bba /libbcachefs/journal_reclaim.c | |
parent | 90d54b388666b258c97be6a4e632824d136356c4 (diff) |
Update bcachefs sources to c9b4a210f9 fixup! bcachefs: Fixes for going RO
Diffstat (limited to 'libbcachefs/journal_reclaim.c')
-rw-r--r-- | libbcachefs/journal_reclaim.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/libbcachefs/journal_reclaim.c b/libbcachefs/journal_reclaim.c index d34434f..5b3f254 100644 --- a/libbcachefs/journal_reclaim.c +++ b/libbcachefs/journal_reclaim.c @@ -330,7 +330,7 @@ static void bch2_journal_pin_add_locked(struct journal *j, u64 seq, __journal_pin_drop(j, pin); - BUG_ON(!atomic_read(&pin_list->count)); + BUG_ON(!atomic_read(&pin_list->count) && seq == journal_last_seq(j)); atomic_inc(&pin_list->count); pin->seq = seq; @@ -413,10 +413,12 @@ journal_get_next_pin(struct journal *j, u64 max_seq, u64 *seq) return ret; } -static void journal_flush_pins(struct journal *j, u64 seq_to_flush, +/* returns true if we did work */ +static bool journal_flush_pins(struct journal *j, u64 seq_to_flush, unsigned min_nr) { struct journal_entry_pin *pin; + bool ret = false; u64 seq; lockdep_assert_held(&j->reclaim_lock); @@ -431,7 +433,10 @@ static void journal_flush_pins(struct journal *j, u64 seq_to_flush, BUG_ON(j->flush_in_progress != pin); j->flush_in_progress = NULL; wake_up(&j->pin_flush_wait); + ret = true; } + + return ret; } /** @@ -523,7 +528,8 @@ void bch2_journal_reclaim_work(struct work_struct *work) mutex_unlock(&j->reclaim_lock); } -static int journal_flush_done(struct journal *j, u64 seq_to_flush) +static int journal_flush_done(struct journal *j, u64 seq_to_flush, + bool *did_work) { int ret; @@ -533,7 +539,7 @@ static int journal_flush_done(struct journal *j, u64 seq_to_flush) mutex_lock(&j->reclaim_lock); - journal_flush_pins(j, seq_to_flush, 0); + *did_work = journal_flush_pins(j, seq_to_flush, 0); spin_lock(&j->lock); /* @@ -551,12 +557,17 @@ static int journal_flush_done(struct journal *j, u64 seq_to_flush) return ret; } -void bch2_journal_flush_pins(struct journal *j, u64 seq_to_flush) +bool bch2_journal_flush_pins(struct journal *j, u64 seq_to_flush) { + bool did_work = false; + if (!test_bit(JOURNAL_STARTED, &j->flags)) - return; + return false; + + closure_wait_event(&j->async_wait, + journal_flush_done(j, seq_to_flush, &did_work)); - closure_wait_event(&j->async_wait, journal_flush_done(j, seq_to_flush)); + return did_work; } int bch2_journal_flush_device_pins(struct journal *j, int dev_idx) |