diff options
Diffstat (limited to 'fs/bcachefs')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 7 | ||||
-rw-r--r-- | fs/bcachefs/disk_accounting.c | 35 | ||||
-rw-r--r-- | fs/bcachefs/io_read.c | 23 | ||||
-rw-r--r-- | fs/bcachefs/journal_io.c | 31 | ||||
-rw-r--r-- | fs/bcachefs/recovery_passes_format.h | 6 | ||||
-rw-r--r-- | fs/bcachefs/sb-errors_format.h | 3 | ||||
-rw-r--r-- | fs/bcachefs/trace.h | 10 |
7 files changed, 44 insertions, 71 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 76f430f93dc1..99d6866b33d0 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -3271,9 +3271,10 @@ void *__bch2_trans_kmalloc(struct btree_trans *trans, size_t size, unsigned long EBUG_ON(trans->mem_bytes); EBUG_ON(trans->mem_top); EBUG_ON(new_bytes > BTREE_TRANS_MEM_MAX); - + bool lock_dropped = false; - new_mem = allocate_dropping_locks_norelock(trans, lock_dropped, kmalloc(new_bytes, _gfp)); + new_mem = allocate_dropping_locks_norelock(trans, lock_dropped, + kmalloc(new_bytes, _gfp|__GFP_NOWARN)); if (!new_mem) { new_mem = mempool_alloc(&c->btree_trans_mem_pool, GFP_KERNEL); new_bytes = BTREE_TRANS_MEM_MAX; @@ -3525,7 +3526,7 @@ got_trans: if (s->max_mem) { unsigned expected_mem_bytes = roundup_pow_of_two(s->max_mem); - trans->mem = kmalloc(expected_mem_bytes, GFP_KERNEL); + trans->mem = kmalloc(expected_mem_bytes, GFP_KERNEL|__GFP_NOWARN); if (likely(trans->mem)) trans->mem_bytes = expected_mem_bytes; } diff --git a/fs/bcachefs/disk_accounting.c b/fs/bcachefs/disk_accounting.c index 809c76b68ba8..5863b5a30b61 100644 --- a/fs/bcachefs/disk_accounting.c +++ b/fs/bcachefs/disk_accounting.c @@ -11,6 +11,7 @@ #include "disk_accounting.h" #include "error.h" #include "journal_io.h" +#include "recovery_passes.h" #include "replicas.h" /* @@ -910,6 +911,40 @@ int bch2_accounting_read(struct bch_fs *c) u64 v[BCH_ACCOUNTING_MAX_COUNTERS]; bch2_accounting_mem_read_counters(acc, i, v, ARRAY_SIZE(v), false); + /* + * Check for underflow, schedule check_allocations + * necessary: + * + * XXX - see if we can factor this out to run on a bkey + * so we can check everything lazily, right now we don't + * check the non in-mem counters at all + */ + bool underflow = false; + for (unsigned j = 0; j < acc->k.data[i].nr_counters; j++) + underflow |= (s64) v[j] < 0; + + if (underflow) { + CLASS(printbuf, buf)(); + bch2_log_msg_start(c, &buf); + + prt_printf(&buf, "Accounting underflow for\n"); + bch2_accounting_key_to_text(&buf, &k); + + for (unsigned j = 0; j < acc->k.data[i].nr_counters; j++) + prt_printf(&buf, " %lli", v[j]); + + bool print = bch2_count_fsck_err(c, accounting_key_underflow, &buf); + unsigned pos = buf.pos; + ret = bch2_run_explicit_recovery_pass(c, &buf, + BCH_RECOVERY_PASS_check_allocations, 0); + print |= buf.pos != pos; + + if (print) + bch2_print_str(c, KERN_ERR, buf.buf); + if (ret) + return ret; + } + switch (k.type) { case BCH_DISK_ACCOUNTING_persistent_reserved: usage->reserved += v[0] * k.persistent_reserved.nr_replicas; diff --git a/fs/bcachefs/io_read.c b/fs/bcachefs/io_read.c index 57bd52443f29..e7d53ab1cf55 100644 --- a/fs/bcachefs/io_read.c +++ b/fs/bcachefs/io_read.c @@ -10,7 +10,6 @@ #include "alloc_background.h" #include "alloc_foreground.h" #include "async_objs.h" -#include "btree_cache.h" #include "btree_update.h" #include "buckets.h" #include "checksum.h" @@ -1291,17 +1290,6 @@ retry_pick: trace_and_count(c, io_read_split, &orig->bio); } - if (trace_io_read_enabled()) { - CLASS(printbuf, buf)(); - prt_str(&buf, "data_btree="); - prt_str(&buf, bch2_btree_id_str(data_btree)); - prt_str(&buf, " read_pos="); - bch2_bpos_to_text(&buf, read_pos); - prt_printf(&buf, " offset_into_extent=%u\n", offset_into_extent); - bch2_bkey_val_to_text(&buf, c, k); - trace_io_read(c, buf.buf); - } - /* * Unlock the iterator while the btree node's lock is still in * cache, before doing the IO: @@ -1440,17 +1428,6 @@ int __bch2_read(struct btree_trans *trans, struct bch_read_bio *rbio, bkey_start_offset(k.k); unsigned sectors = k.k->size - offset_into_extent; - if (trace_io_read_lookup_enabled()) { - CLASS(printbuf, buf)(); - prt_str(&buf, "data_btree="); - prt_str(&buf, bch2_btree_id_str(data_btree)); - prt_str(&buf, " read_pos="); - bch2_bpos_to_text(&buf, iter.pos); - prt_printf(&buf, " offset_into_extent=%llu\n", offset_into_extent); - bch2_bkey_val_to_text(&buf, c, k); - trace_io_read_lookup(c, buf.buf); - } - bch2_bkey_buf_reassemble(&sk, c, k); ret = bch2_read_indirect_extent(trans, &data_btree, diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 9a75f5d2733c..f33b2c2d13c0 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -191,27 +191,6 @@ static int journal_entry_add(struct bch_fs *c, struct bch_dev *ca, } } - /* Drop overwrites, log entries if we don't need them: */ - if (!c->opts.retain_recovery_info && - !c->opts.journal_rewind) { - vstruct_for_each_safe(j, src) - if (vstruct_end(src) > vstruct_end(j)) - goto nocompact; - - struct jset_entry *dst = j->start; - vstruct_for_each_safe(j, src) { - if (src->type == BCH_JSET_ENTRY_log || - src->type == BCH_JSET_ENTRY_overwrite) - continue; - - memcpy(dst, src, vstruct_bytes(src)); - dst = vstruct_next(dst); - } - - j->u64s = cpu_to_le32((u64 *) dst - j->_data); - bytes = vstruct_bytes(j); - } -nocompact: jlist->last_seq = max(jlist->last_seq, last_seq); if (seq < c->journal_entries_base_seq || @@ -230,14 +209,6 @@ nocompact: */ dup = *_i; if (dup) { - if (dup->j.seq != j->seq) { - bch_err(c, "dup seq %llu != slot seq %llu, base seq %llu\n", - le64_to_cpu(dup->j.seq), - le64_to_cpu(j->seq), - c->journal_entries_base_seq); - BUG(); - } - bool identical = bytes == vstruct_bytes(&dup->j) && !memcmp(j, &dup->j, bytes); bool not_identical = !identical && @@ -268,7 +239,6 @@ nocompact: if (entry_ptr.csum_good && !identical) goto replace; - BUG_ON(dup->j.seq != j->seq); return ret; } replace: @@ -291,7 +261,6 @@ replace: darray_push(&i->ptrs, entry_ptr); } - BUG_ON(le64_to_cpu(i->j.seq) != seq); *_i = i; fsck_err: return ret; diff --git a/fs/bcachefs/recovery_passes_format.h b/fs/bcachefs/recovery_passes_format.h index 05f1c09955b4..2696eee00345 100644 --- a/fs/bcachefs/recovery_passes_format.h +++ b/fs/bcachefs/recovery_passes_format.h @@ -32,9 +32,6 @@ x(check_allocations, 5, PASS_FSCK_ALLOC) \ x(trans_mark_dev_sbs, 6, PASS_ALWAYS|PASS_SILENT|PASS_ALLOC) \ x(fs_journal_alloc, 7, PASS_ALWAYS|PASS_SILENT|PASS_ALLOC) \ - x(reconstruct_snapshots, 38, 0) \ - x(check_snapshot_trees, 18, PASS_ONLINE|PASS_FSCK) \ - x(check_snapshots, 19, PASS_ONLINE|PASS_FSCK) \ x(set_may_go_rw, 8, PASS_ALWAYS|PASS_SILENT) \ x(journal_replay, 9, PASS_ALWAYS) \ x(check_alloc_info, 10, PASS_ONLINE|PASS_FSCK_ALLOC) \ @@ -45,6 +42,9 @@ x(check_alloc_to_lru_refs, 15, PASS_ONLINE|PASS_FSCK_ALLOC) \ x(fs_freespace_init, 16, PASS_ALWAYS|PASS_SILENT) \ x(bucket_gens_init, 17, 0) \ + x(reconstruct_snapshots, 38, 0) \ + x(check_snapshot_trees, 18, PASS_ONLINE|PASS_FSCK) \ + x(check_snapshots, 19, PASS_ONLINE|PASS_FSCK) \ x(check_subvols, 20, PASS_ONLINE|PASS_FSCK) \ x(check_subvol_children, 35, PASS_ONLINE|PASS_FSCK) \ x(delete_dead_snapshots, 21, PASS_ONLINE|PASS_FSCK) \ diff --git a/fs/bcachefs/sb-errors_format.h b/fs/bcachefs/sb-errors_format.h index 5317b1bfe2e5..aa0ea1ec9f10 100644 --- a/fs/bcachefs/sb-errors_format.h +++ b/fs/bcachefs/sb-errors_format.h @@ -328,6 +328,7 @@ enum bch_fsck_flags { x(accounting_key_replicas_devs_unsorted, 280, FSCK_AUTOFIX) \ x(accounting_key_version_0, 282, FSCK_AUTOFIX) \ x(accounting_key_nr_counters_wrong, 307, FSCK_AUTOFIX) \ + x(accounting_key_underflow, 325, FSCK_AUTOFIX) \ x(logged_op_but_clean, 283, FSCK_AUTOFIX) \ x(compression_opt_not_marked_in_sb, 295, FSCK_AUTOFIX) \ x(compression_type_not_marked_in_sb, 296, FSCK_AUTOFIX) \ @@ -336,7 +337,7 @@ enum bch_fsck_flags { x(dirent_stray_data_after_cf_name, 305, 0) \ x(rebalance_work_incorrectly_set, 309, FSCK_AUTOFIX) \ x(rebalance_work_incorrectly_unset, 310, FSCK_AUTOFIX) \ - x(MAX, 325, 0) + x(MAX, 326, 0) enum bch_sb_error_id { #define x(t, n, ...) BCH_FSCK_ERR_##t = n, diff --git a/fs/bcachefs/trace.h b/fs/bcachefs/trace.h index 788ab8f9fc1e..269cdf1a87a4 100644 --- a/fs/bcachefs/trace.h +++ b/fs/bcachefs/trace.h @@ -322,16 +322,6 @@ DEFINE_EVENT(bio, io_read_fail_and_poison, TP_ARGS(bio) ); -DEFINE_EVENT(fs_str, io_read_lookup, - TP_PROTO(struct bch_fs *c, const char *str), - TP_ARGS(c, str) -); - -DEFINE_EVENT(fs_str, io_read, - TP_PROTO(struct bch_fs *c, const char *str), - TP_ARGS(c, str) -); - /* ec.c */ TRACE_EVENT(stripe_create, |