summaryrefslogtreecommitdiff
path: root/fs/bcachefs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs')
-rw-r--r--fs/bcachefs/btree_cache.c5
-rw-r--r--fs/bcachefs/btree_journal_iter.c17
-rw-r--r--fs/bcachefs/btree_node_scan.c4
-rw-r--r--fs/bcachefs/debug.c9
-rw-r--r--fs/bcachefs/journal.c14
-rw-r--r--fs/bcachefs/opts.h11
6 files changed, 22 insertions, 38 deletions
diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c
index 702c8f7081d7..49505653fe12 100644
--- a/fs/bcachefs/btree_cache.c
+++ b/fs/bcachefs/btree_cache.c
@@ -187,10 +187,7 @@ static struct btree *__btree_node_mem_alloc(struct bch_fs *c, gfp_t gfp)
struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *c)
{
- struct btree_cache *bc = &c->btree_cache;
- struct btree *b;
-
- b = __btree_node_mem_alloc(c, GFP_KERNEL);
+ struct btree *b = __btree_node_mem_alloc(c, GFP_KERNEL);
if (!b)
return NULL;
diff --git a/fs/bcachefs/btree_journal_iter.c b/fs/bcachefs/btree_journal_iter.c
index 341d31b3a1f1..ea839560a136 100644
--- a/fs/bcachefs/btree_journal_iter.c
+++ b/fs/bcachefs/btree_journal_iter.c
@@ -717,18 +717,6 @@ static void __journal_keys_sort(struct journal_keys *keys)
keys->nr = dst - keys->data;
}
-static bool should_rewind_entry(struct bch_fs *c, struct jset_entry *entry)
-{
- if (entry->level)
- return false;
- if (btree_id_is_alloc(entry->btree_id))
- return false;
- if (c->opts.journal_rewind_no_extents &&
- entry->btree_id == BTREE_ID_extents)
- return false;
- return true;
-}
-
int bch2_journal_keys_sort(struct bch_fs *c)
{
struct genradix_iter iter;
@@ -747,8 +735,9 @@ int bch2_journal_keys_sort(struct bch_fs *c)
cond_resched();
vstruct_for_each(&i->j, entry) {
- bool rewind = le64_to_cpu(i->j.seq) >= rewind_seq &&
- should_rewind_entry(c, entry);
+ bool rewind = !entry->level &&
+ !btree_id_is_alloc(entry->btree_id) &&
+ le64_to_cpu(i->j.seq) >= rewind_seq;
if (entry->type != (rewind
? BCH_JSET_ENTRY_overwrite
diff --git a/fs/bcachefs/btree_node_scan.c b/fs/bcachefs/btree_node_scan.c
index b4d01c378e73..cc7af8fe689e 100644
--- a/fs/bcachefs/btree_node_scan.c
+++ b/fs/bcachefs/btree_node_scan.c
@@ -261,7 +261,9 @@ static int read_btree_nodes_worker(void *p)
try_read_btree_node(w->f, ca, b, bio, sector);
}
err:
- __btree_node_data_free(b);
+ if (b)
+ __btree_node_data_free(b);
+ kfree(b);
bio_put(bio);
enumerated_ref_put(&ca->io_ref[READ], BCH_DEV_READ_REF_btree_node_scan);
closure_put(w->cl);
diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c
index 79d64052215c..07c2a0f73cc2 100644
--- a/fs/bcachefs/debug.c
+++ b/fs/bcachefs/debug.c
@@ -584,6 +584,8 @@ static ssize_t bch2_btree_transactions_read(struct file *file, char __user *buf,
i->ubuf = buf;
i->size = size;
i->ret = 0;
+
+ int srcu_idx = srcu_read_lock(&c->btree_trans_barrier);
restart:
seqmutex_lock(&c->btree_trans_lock);
list_sort(&c->btree_trans_list, list_ptr_order_cmp);
@@ -597,6 +599,11 @@ restart:
if (!closure_get_not_zero(&trans->ref))
continue;
+ if (!trans->srcu_held) {
+ closure_put(&trans->ref);
+ continue;
+ }
+
u32 seq = seqmutex_unlock(&c->btree_trans_lock);
bch2_btree_trans_to_text(&i->buf, trans);
@@ -618,6 +625,8 @@ restart:
}
seqmutex_unlock(&c->btree_trans_lock);
unlocked:
+ srcu_read_unlock(&c->btree_trans_barrier, srcu_idx);
+
if (i->buf.allocation_failure)
ret = -ENOMEM;
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c
index ce5340611de6..f22b05e02c1e 100644
--- a/fs/bcachefs/journal.c
+++ b/fs/bcachefs/journal.c
@@ -1376,6 +1376,7 @@ int bch2_dev_journal_alloc(struct bch_dev *ca, bool new_fs)
return bch_err_throw(c, erofs_filesystem_full);
}
+ unsigned nr;
int ret;
if (dynamic_fault("bcachefs:add:journal_alloc")) {
@@ -1384,19 +1385,16 @@ int bch2_dev_journal_alloc(struct bch_dev *ca, bool new_fs)
}
/* 1/128th of the device by default: */
- unsigned nr = ca->mi.nbuckets >> 7;
+ nr = ca->mi.nbuckets >> 7;
/*
- * clamp journal size to 8GB, or 32GB with large_journal option:
+ * clamp journal size to 8192 buckets or 8GB (in sectors), whichever
+ * is smaller:
*/
- unsigned max_sectors = 1 << 24;
-
- if (c->opts.large_journal)
- max_sectors *= 4;
-
nr = clamp_t(unsigned, nr,
BCH_JOURNAL_BUCKETS_MIN,
- max_sectors / ca->mi.bucket_size);
+ min(1 << 13,
+ (1 << 24) / ca->mi.bucket_size));
ret = bch2_set_nr_journal_buckets_loop(c, ca, nr, new_fs);
err:
diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h
index 4a7a60588c10..63f8e254495c 100644
--- a/fs/bcachefs/opts.h
+++ b/fs/bcachefs/opts.h
@@ -343,12 +343,6 @@ enum fsck_err_opts {
OPT_UINT(0, U32_MAX), \
BCH_SB_JOURNAL_RECLAIM_DELAY, 100, \
NULL, "Delay in milliseconds before automatic journal reclaim")\
- x(large_journal, bool, \
- OPT_FS|OPT_MOUNT|OPT_FORMAT, \
- OPT_BOOL(), \
- BCH2_NO_SB_OPT, false, \
- NULL, "Allocate a bigger than normal journal: recovery from unclean "\
- "shutdown will be slower, but more info will be available for debugging")\
x(move_bytes_in_flight, u32, \
OPT_HUMAN_READABLE|OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
OPT_UINT(1024, U32_MAX), \
@@ -395,11 +389,6 @@ enum fsck_err_opts {
OPT_UINT(0, U64_MAX), \
BCH2_NO_SB_OPT, 0, \
NULL, "Rewind journal") \
- x(journal_rewind_no_extents, bool, \
- OPT_FS|OPT_MOUNT, \
- OPT_BOOL(), \
- BCH2_NO_SB_OPT, 0, \
- NULL, "Don't rewind extents when rewinding journal") \
x(recovery_passes, u64, \
OPT_FS|OPT_MOUNT, \
OPT_BITFIELD(bch2_recovery_passes), \