diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-24 11:34:07 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-24 11:34:07 -0400 |
commit | 980f7437e2588d100456640cb863908a3cc6fc77 (patch) | |
tree | ac19bcb02929770909af3bb6dd44a95da915c0e4 /libbcachefs/alloc_foreground.c | |
parent | ae43a58d97fc00e31770142da832fb8a249808eb (diff) |
Update bcachefs sources to 61ebcb532a bcachefs: Fix for allocating before backpointers have been checked
Diffstat (limited to 'libbcachefs/alloc_foreground.c')
-rw-r--r-- | libbcachefs/alloc_foreground.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libbcachefs/alloc_foreground.c b/libbcachefs/alloc_foreground.c index a9e0c73..186c2ed 100644 --- a/libbcachefs/alloc_foreground.c +++ b/libbcachefs/alloc_foreground.c @@ -14,6 +14,7 @@ #include "bcachefs.h" #include "alloc_background.h" #include "alloc_foreground.h" +#include "backpointers.h" #include "btree_iter.h" #include "btree_update.h" #include "btree_gc.h" @@ -333,6 +334,28 @@ static struct open_bucket *try_alloc_bucket(struct btree_trans *trans, struct bc goto err; } + if (!test_bit(BCH_FS_CHECK_BACKPOINTERS_DONE, &c->flags)) { + struct bch_backpointer bp; + u64 bp_offset = 0; + + ret = bch2_get_next_backpointer(trans, POS(ca->dev_idx, b), -1, + &bp_offset, &bp, 0); + if (ret) { + ob = ERR_PTR(ret); + goto err; + } + + if (bp_offset != U64_MAX) { + /* + * Bucket may have data in it - we don't call + * bc2h_trans_inconnsistent() because fsck hasn't + * finished yet + */ + ob = NULL; + goto err; + } + } + ob = __try_alloc_bucket(c, ca, b, reserve, &a, skipped_open, skipped_need_journal_commit, |