summaryrefslogtreecommitdiff
path: root/libbcachefs/journal_reclaim.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbcachefs/journal_reclaim.c')
-rw-r--r--libbcachefs/journal_reclaim.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/libbcachefs/journal_reclaim.c b/libbcachefs/journal_reclaim.c
index d34434f6..5b3f2548 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)