From 2940295c97f49ffe0b2f564dea394094581073e7 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 3 Apr 2021 16:24:13 -0400 Subject: bcachefs: Be more careful about JOURNAL_RES_GET_RESERVED JOURNAL_RES_GET_RESERVED should only be used for updatse that need to be done to free up space in the journal. In particular, when we're flushing keys from the key cache, if we're flushing them out of order we shouldn't be using it, since we're using up our remaining space in the journal without dropping a pin that will let us make forward progress. With this patch, BTREE_INSERT_JOURNAL_RECLAIM without BTREE_INSERT_JOURNAL_RESERVED may return -EAGAIN - we can't wait on journal reclaim if we're already in journal reclaim. This means we need to propagate these errors up to journal reclaim, indicating that flushing a journal pin should be retried in the future. This is prep work for a patch to change the way journal reclaim works, to split out flushing key cache keys because the btree key cache is too dirty from journal reclaim because we need space in the journal. Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- fs/bcachefs/journal.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'fs/bcachefs/journal.h') diff --git a/fs/bcachefs/journal.h b/fs/bcachefs/journal.h index 547c735ce3cb..a0d19fad3bdd 100644 --- a/fs/bcachefs/journal.h +++ b/fs/bcachefs/journal.h @@ -308,7 +308,6 @@ int bch2_journal_res_get_slowpath(struct journal *, struct journal_res *, #define JOURNAL_RES_GET_NONBLOCK (1 << 0) #define JOURNAL_RES_GET_CHECK (1 << 1) #define JOURNAL_RES_GET_RESERVED (1 << 2) -#define JOURNAL_RES_GET_RECLAIM (1 << 3) static inline int journal_res_get_fast(struct journal *j, struct journal_res *res, @@ -446,7 +445,7 @@ static inline int bch2_journal_preres_get_fast(struct journal *j, * into the reclaim path and deadlock: */ - if (!(flags & JOURNAL_RES_GET_RECLAIM) && + if (!(flags & JOURNAL_RES_GET_RESERVED) && new.reserved > new.remaining) return 0; } while ((v = atomic64_cmpxchg(&j->prereserved.counter, -- cgit v1.2.3