projects/linux·commit b3f391fd

Merge tag 'bcachefs-2024-09-21' of git://evilpiepirate.org/bcachefs

b3f391fd · Linus Torvalds <[email protected]> · 2024-09-23 10:05:41 -07:00

Pull bcachefs updates from Kent Overstreet:

 - rcu_pending, btree key cache rework: this solves lock contenting in
   the key cache, eliminating the biggest source of the srcu lock hold
   time warnings, and drastically improving performance on some metadata
   heavy workloads - on multithreaded creates we're now 3-4x faster than
   xfs.

 - We're now using an rhashtable instead of the system inode hash table;
   this is another significant performance improvement on multithreaded
   metadata workloads, eliminating more lock contention.

 - for_each_btree_key_in_subvolume_upto(): new helper for iterating over
   keys within a specific subvolume, eliminating a lot of open coded
   "subvolume_get_snapshot()" and also fixing another source of srcu
   lock time warnings, by running each loop iteration in its own
   transaction (as the existing for_each_btree_key() does).

 - More work on btree_trans locking asserts; we now assert that we don't
   hold btree node locks when trans->locked is false, which is important
   because we don't use lockdep for tracking individual btree node
   locks.

 - Some cleanups and improvements in the bset.c btree node lookup code,
   from Alan.

 - Rework of btree node pinning, which we use in backpointers fsck. The
   old hacky implementation, where the shrinker just skipped over nodes
   in the pinned range, was causing OOMs; instead we now use another
   shrinker with a much higher seeks number for pinned nodes.

 - Rebalance now uses BCH_WRITE_ONLY_SPECIFIED_DEVS; this fixes an issue
   where rebalance would sometimes fall back to allocating from the full
   filesystem, which is not what we want when it's trying to move data
   to a specific target.

 - Use __GFP_ACCOUNT, GFP_RECLAIMABLE for btree node, key cache
   allocations.

 - Idmap mounts are now supported (Hongbo Li)

 - Rename whiteouts are now supported (Hongbo Li)

 - Erasure coding can now handle devices being marked as failed, or
   forcibly removed. We still need the evacuate path for erasure coding,
   but it's getting very close to ready for people to start using.

* tag 'bcachefs-2024-09-21' of git://evilpiepirate.org/bcachefs: (99 commits)
  bcachefs: return err ptr instead of null in read sb clean
  bcachefs: Remove duplicated include in backpointers.c
  bcachefs: Don't drop devices with stripe pointers
  bcachefs: bch2_ec_stripe_head_get() now checks for change in rw devices
  bcachefs: bch_fs.rw_devs_change_count
  bcachefs: bch2_dev_remove_stripes()
  bcachefs: bch2_trigger_ptr() calculates sectors even when no device
  bcachefs: improve error messages in bch2_ec_read_extent()
  bcachefs: improve error message on too few devices for ec
  bcachefs: improve bch2_new_stripe_to_text()
  bcachefs: ec_stripe_head.nr_created
  bcachefs: bch_stripe.disk_label
  bcachefs: stripe_to_mem()
  bcachefs: EIO errcode cleanup
  bcachefs: Rework btree node pinning
  bcachefs: split up btree cache counters for live, freeable
  bcachefs: btree cache counters should be size_t
  bcachefs: Don't count "skipped access bit" as touched in btree cache scan
  bcachefs: Failed devices no longer require mounting in degraded mode
  bcachefs: bch2_dev_rcu_noerror()
  ...
Commit
b3f391fddf3cfaadda59ec8da8fd17f4520bbf42
Parents
f8ffbc36 · 025c55a4

Merge commit. Changes below are compared with the first parent: f8ffbc36.

Changes

89 files changed · +3155 −1690

FileStatusAddDelContent
Documentation/filesystems/bcachefs/CodingStyle.rstmodified+1−1View file
fs/bcachefs/Kconfigmodified+7−0View file
fs/bcachefs/Makefilemodified+1−0View file
fs/bcachefs/acl.cmodified+1−1View file
fs/bcachefs/alloc_background.cmodified+40−5View file
fs/bcachefs/alloc_background.hmodified+2−1View file
fs/bcachefs/alloc_foreground.cmodified+24−35View file
fs/bcachefs/alloc_foreground.hmodified+3−2View file
fs/bcachefs/backpointers.cmodified+91−15View file
fs/bcachefs/backpointers.hmodified+16−7View file
fs/bcachefs/bcachefs.hmodified+8−6View file
fs/bcachefs/bcachefs_format.hmodified+2−0View file
fs/bcachefs/bset.cmodified+79−103View file
fs/bcachefs/bset.hmodified+2−2View file
fs/bcachefs/btree_cache.cmodified+180−93View file
fs/bcachefs/btree_cache.hmodified+3−0View file
fs/bcachefs/btree_gc.cmodified+5−16View file
fs/bcachefs/btree_io.cmodified+3−5View file
fs/bcachefs/btree_io.hmodified+2−2View file
fs/bcachefs/btree_iter.cmodified+39−24View file
fs/bcachefs/btree_iter.hmodified+28−24View file
fs/bcachefs/btree_key_cache.cmodified+89−316View file
fs/bcachefs/btree_key_cache_types.hmodified+5−13View file
fs/bcachefs/btree_locking.hmodified+8−5View file
fs/bcachefs/btree_trans_commit.cmodified+1−1View file
fs/bcachefs/btree_types.hmodified+38−22View file
fs/bcachefs/btree_update.cmodified+8−4View file
fs/bcachefs/btree_update_interior.cmodified+21−16View file
fs/bcachefs/btree_update_interior.hmodified+2−0View file
fs/bcachefs/buckets.cmodified+23−12View file
fs/bcachefs/buckets.hmodified+1−14View file
fs/bcachefs/buckets_types.hmodified+0−8View file
fs/bcachefs/checksum.cmodified+56−45View file
fs/bcachefs/clock.hmodified+0−9View file
fs/bcachefs/darray.cmodified+2−2View file
fs/bcachefs/darray.hmodified+10−16View file
fs/bcachefs/data_update.cmodified+1−1View file
fs/bcachefs/dirent.cmodified+17−49View file
fs/bcachefs/ec.cmodified+219−84View file
fs/bcachefs/ec.hmodified+9−2View file
fs/bcachefs/ec_format.hmodified+8−1View file
fs/bcachefs/ec_types.hmodified+1−0View file
fs/bcachefs/errcode.hmodified+12−2View file
fs/bcachefs/extents.cmodified+20−13View file
fs/bcachefs/extents.hmodified+19−5View file
fs/bcachefs/fs-common.cmodified+3−2View file
fs/bcachefs/fs-io-buffered.cmodified+15−26View file
fs/bcachefs/fs-io-direct.cmodified+1−1View file
fs/bcachefs/fs-io-pagecache.cmodified+35−55View file
fs/bcachefs/fs-io-pagecache.hmodified+1−3View file
fs/bcachefs/fs-io.cmodified+54−124View file
fs/bcachefs/fs-ioctl.cmodified+2−2View file
fs/bcachefs/fs.cmodified+277−150View file
fs/bcachefs/fs.hmodified+12−6View file
fs/bcachefs/inode.cmodified+1−1View file
fs/bcachefs/io_read.cmodified+10−8View file
fs/bcachefs/io_write.cmodified+4−3View file
fs/bcachefs/journal_io.cmodified+4−2View file
fs/bcachefs/journal_reclaim.cmodified+4−3View file
fs/bcachefs/opts.cmodified+76−9View file
fs/bcachefs/opts.hmodified+47−14View file
fs/bcachefs/rcu_pending.cadded+650−0View file
fs/bcachefs/rcu_pending.hadded+27−0View file
fs/bcachefs/rebalance.cmodified+3−0View file
fs/bcachefs/recovery.cmodified+11−11View file
fs/bcachefs/recovery_passes.cmodified+6−4View file
fs/bcachefs/replicas.cmodified+5−5View file
fs/bcachefs/replicas_format.hmodified+7−2View file
fs/bcachefs/sb-clean.cmodified+1−1View file
fs/bcachefs/sb-members.cmodified+57−0View file
fs/bcachefs/sb-members.hmodified+17−5View file
fs/bcachefs/str_hash.hmodified+1−1View file
fs/bcachefs/subvolume.hmodified+45−0View file
fs/bcachefs/subvolume_types.hmodified+2−1View file
fs/bcachefs/super-io.cmodified+5−7View file
fs/bcachefs/super.cmodified+10−75View file
fs/bcachefs/sysfs.cmodified+23−32View file
fs/bcachefs/thread_with_file.cmodified+1−1View file
fs/bcachefs/time_stats.cmodified+14−0View file
fs/bcachefs/time_stats.hmodified+2−1View file
fs/bcachefs/trace.hmodified+460−5View file
fs/bcachefs/util.cmodified+8−8View file
fs/bcachefs/util.hmodified+1−1View file
fs/bcachefs/xattr.cmodified+28−53View file
fs/bcachefs/xattr_format.hmodified+1−1View file
fs/inode.cmodified+0−8View file
include/linux/fs.hmodified+8−1View file
include/linux/generic-radix-tree.hmodified+103−2View file
lib/generic-radix-tree.cmodified+6−74View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/filesystems/bcachefs/CodingStyle.rst

View file
diff --git a/Documentation/filesystems/bcachefs/CodingStyle.rst b/Documentation/filesystems/bcachefs/CodingStyle.rst
index 0c45829..01de555 100644
--- a/Documentation/filesystems/bcachefs/CodingStyle.rst
+++ b/Documentation/filesystems/bcachefs/CodingStyle.rst
@@ -175,7 +175,7 @@ errors in our thinking by running our code and seeing what happens. If your
time is being wasted because your tools are bad or too slow - don't accept it,
fix it.
-Put effort into your documentation, commmit messages, and code comments - but
+Put effort into your documentation, commit messages, and code comments - but
don't go overboard. A good commit message is wonderful - but if the information
was important enough to go in a commit message, ask yourself if it would be
even better as a code comment.

fs/bcachefs/Kconfig

View file
diff --git a/fs/bcachefs/Kconfig b/fs/bcachefs/Kconfig
index 5cdfef3..5bac803 100644
--- a/fs/bcachefs/Kconfig
+++ b/fs/bcachefs/Kconfig
@@ -87,6 +87,13 @@ config BCACHEFS_SIX_OPTIMISTIC_SPIN
is held by another thread, spin for a short while, as long as the
thread owning the lock is running.
+config BCACHEFS_PATH_TRACEPOINTS
+ bool "Extra btree_path tracepoints"
+ depends on BCACHEFS_FS
+ help
+ Enable extra tracepoints for debugging btree_path operations; we don't
+ normally want these enabled because they happen at very high rates.
+
config MEAN_AND_VARIANCE_UNIT_TEST
tristate "mean_and_variance unit tests" if !KUNIT_ALL_TESTS
depends on KUNIT

fs/bcachefs/Makefile

View file
diff --git a/fs/bcachefs/Makefile b/fs/bcachefs/Makefile
index 0ab533a..56d20e2 100644
--- a/fs/bcachefs/Makefile
+++ b/fs/bcachefs/Makefile
@@ -69,6 +69,7 @@ bcachefs-y := \
printbuf.o \
quota.o \
rebalance.o \
+ rcu_pending.o \
recovery.o \
recovery_passes.o \
reflink.o \

fs/bcachefs/acl.c

View file
diff --git a/fs/bcachefs/acl.c b/fs/bcachefs/acl.c
index 331a17f..87f1be9 100644
--- a/fs/bcachefs/acl.c
+++ b/fs/bcachefs/acl.c
@@ -361,7 +361,7 @@ retry:
bch2_trans_begin(trans);
acl = _acl;
- ret = bch2_subvol_is_ro_trans(trans, inode->ei_subvol) ?:
+ ret = bch2_subvol_is_ro_trans(trans, inode->ei_inum.subvol) ?:
bch2_inode_peek(trans, &inode_iter, &inode_u, inode_inum(inode),
BTREE_ITER_intent);
if (ret)

fs/bcachefs/alloc_background.c

View file
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index dc3a402..645b5ed 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -30,6 +30,7 @@
#include <linux/rcupdate.h>
#include <linux/sched/task.h>
#include <linux/sort.h>
+#include <linux/jiffies.h>
static void bch2_discard_one_bucket_fast(struct bch_dev *, u64);
@@ -2183,7 +2184,7 @@ int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca,
* freespace/need_discard/need_gc_gens btrees as needed:
*/
while (1) {
- if (last_updated + HZ * 10 < jiffies) {
+ if (time_after(jiffies, last_updated + HZ * 10)) {
bch_info(ca, "%s: currently at %llu/%llu",
__func__, iter.pos.offset, ca->mi.nbuckets);
last_updated = jiffies;
@@ -2297,6 +2298,36 @@ int bch2_fs_freespace_init(struct bch_fs *c)
return 0;
}
+/* device removal */
+
+int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
+{
+ struct bpos start = POS(ca->dev_idx, 0);
+ struct bpos end = POS(ca->dev_idx, U64_MAX);
+ int ret;
+
+ /*
+ * We clear the LRU and need_discard btrees first so that we don't race
+ * with bch2_do_invalidates() and bch2_do_discards()
+ */
+ ret = bch2_dev_remove_stripes(c, ca->dev_idx) ?:
+ bch2_btree_delete_range(c, BTREE_ID_lru, start, end,
+ BTREE_TRIGGER_norun, NULL) ?:
+ bch2_btree_delete_range(c, BTREE_ID_need_discard, start, end,
+ BTREE_TRIGGER_norun, NULL) ?:
+ bch2_btree_delete_range(c, BTREE_ID_freespace, start, end,
+ BTREE_TRIGGER_norun, NULL) ?:
+ bch2_btree_delete_range(c, BTREE_ID_backpointers, start, end,
+ BTREE_TRIGGER_norun, NULL) ?:
+ bch2_btree_delete_range(c, BTREE_ID_bucket_gens, start, end,
+ BTREE_TRIGGER_norun, NULL) ?:
+ bch2_btree_delete_range(c, BTREE_ID_alloc, start, end,
+ BTREE_TRIGGER_norun, NULL) ?:
+ bch2_dev_usage_remove(c, ca->dev_idx);
+ bch_err_msg(ca, ret, "removing dev alloc info");
+ return ret;
+}
+
/* Bucket IO clocks: */
int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
@@ -2432,13 +2463,15 @@ static bool bch2_dev_has_open_write_point(struct bch_fs *c, struct bch_dev *ca)
/* device goes ro: */
void bch2_dev_allocator_remove(struct bch_fs *c, struct bch_dev *ca)
{
- unsigned i;
+ lockdep_assert_held(&c->state_lock);
/* First, remove device from allocation groups: */
- for (i = 0; i < ARRAY_SIZE(c->rw_devs); i++)
+ for (unsigned i = 0; i < ARRAY_SIZE(c->rw_devs); i++)
clear_bit(ca->dev_idx, c->rw_devs[i].d);
+ c->rw_devs_change_count++;
+
/*
* Capacity is calculated based off of devices in allocation groups:
*/
@@ -2467,11 +2500,13 @@ void bch2_dev_allocator_remove(struct bch_fs *c, struct bch_dev *ca)
/* device goes rw: */
void bch2_dev_allocator_add(struct bch_fs *c, struct bch_dev *ca)
{
- unsigned i;
+ lockdep_assert_held(&c->state_lock);
- for (i = 0; i < ARRAY_SIZE(c->rw_devs); i++)
+ for (unsigned i = 0; i < ARRAY_SIZE(c->rw_devs); i++)
if (ca->mi.data_allowed & (1 << i))
set_bit(ca->dev_idx, c->rw_devs[i].d);
+
+ c->rw_devs_change_count++;
}
void bch2_dev_allocator_background_exit(struct bch_dev *ca)

fs/bcachefs/alloc_background.h

View file
diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h
index fd790b0..f8e87c6 100644
--- a/fs/bcachefs/alloc_background.h
+++ b/fs/bcachefs/alloc_background.h
@@ -16,7 +16,7 @@ enum bch_validate_flags;
static inline bool bch2_dev_bucket_exists(struct bch_fs *c, struct bpos pos)
{
rcu_read_lock();
- struct bch_dev *ca = bch2_dev_rcu(c, pos.inode);
+ struct bch_dev *ca = bch2_dev_rcu_noerror(c, pos.inode);
bool ret = ca && bucket_valid(ca, pos.offset);
rcu_read_unlock();
return ret;
@@ -338,6 +338,7 @@ static inline const struct bch_backpointer *alloc_v4_backpointers_c(const struct
int bch2_dev_freespace_init(struct bch_fs *, struct bch_dev *, u64, u64);
int bch2_fs_freespace_init(struct bch_fs *);
+int bch2_dev_remove_alloc(struct bch_fs *, struct bch_dev *);
void bch2_recalc_capacity(struct bch_fs *);
u64 bch2_min_rw_member_capacity(struct bch_fs *);

fs/bcachefs/alloc_foreground.c

View file
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index 8563c2d..d0e0b56 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -600,6 +600,7 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans,
enum bch_watermark watermark,
enum bch_data_type data_type,
struct closure *cl,
+ bool nowait,
struct bch_dev_usage *usage)
{
struct bch_fs *c = trans->c;
@@ -609,7 +610,7 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans,
struct bucket_alloc_state s = {
.btree_bitmap = data_type == BCH_DATA_btree,
};
- bool waiting = false;
+ bool waiting = nowait;
again:
bch2_dev_usage_read_fast(ca, usage);
avail = dev_buckets_free(ca, *usage, watermark);
@@ -685,7 +686,7 @@ struct open_bucket *bch2_bucket_alloc(struct bch_fs *c, struct bch_dev *ca,
bch2_trans_do(c, NULL, NULL, 0,
PTR_ERR_OR_ZERO(ob = bch2_bucket_alloc_trans(trans, ca, watermark,
- data_type, cl, &usage)));
+ data_type, cl, false, &usage)));
return ob;
}
@@ -748,7 +749,6 @@ static int add_new_bucket(struct bch_fs *c,
unsigned nr_replicas,
unsigned *nr_effective,
bool *have_cache,
- unsigned flags,
struct open_bucket *ob)
{
unsigned durability = ob_dev(c, ob)->mi.durability;
@@ -775,7 +775,7 @@ int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
unsigned nr_replicas,
unsigned *nr_effective,
bool *have_cache,
- unsigned flags,
+ enum bch_write_flags flags,
enum bch_data_type data_type,
enum bch_watermark watermark,
struct closure *cl)
@@ -801,7 +801,8 @@ int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
continue;
}
- ob = bch2_bucket_alloc_trans(trans, ca, watermark, data_type, cl, &usage);
+ ob = bch2_bucket_alloc_trans(trans, ca, watermark, data_type,
+ cl, flags & BCH_WRITE_ALLOC_NOWAIT, &usage);
if (!IS_ERR(ob))
bch2_dev_stripe_increment_inlined(ca, stripe, &usage);
bch2_dev_put(ca);
@@ -815,7 +816,7 @@ int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
if (add_new_bucket(c, ptrs, devs_may_alloc,
nr_replicas, nr_effective,
- have_cache, flags, ob)) {
+ have_cache, ob)) {
ret = 0;
break;
}
@@ -841,7 +842,7 @@ static int bucket_alloc_from_stripe(struct btree_trans *trans,
unsigned *nr_effective,
bool *have_cache,
enum bch_watermark watermark,
- unsigned flags,
+ enum bch_write_flags flags,
struct closure *cl)
{
struct bch_fs *c = trans->c;
@@ -883,7 +884,7 @@ got_bucket:
ret = add_new_bucket(c, ptrs, devs_may_alloc,
nr_replicas, nr_effective,
- have_cache, flags, ob);
+ have_cache, ob);
out_put_head:
bch2_ec_stripe_head_put(c, h);
return ret;
@@ -922,7 +923,7 @@ static int bucket_alloc_set_writepoint(struct bch_fs *c,
unsigned nr_replicas,
unsigned *nr_effective,
bool *have_cache,
- bool ec, unsigned flags)
+ bool ec)
{
struct open_buckets ptrs_skip = { .nr = 0 };
struct open_bucket *ob;
@@ -934,7 +935,7 @@ static int bucket_alloc_set_writepoint(struct bch_fs *c,
have_cache, ec, ob))
ret = add_new_bucket(c, ptrs, devs_may_alloc,
nr_replicas, nr_effective,
- have_cache, flags, ob);
+ have_cache, ob);
else
ob_push(c, &ptrs_skip, ob);
}
@@ -950,8 +951,7 @@ static int bucket_alloc_set_partial(struct bch_fs *c,
unsigned nr_replicas,
unsigned *nr_effective,
bool *have_cache, bool ec,
- enum bch_watermark watermark,
- unsigned flags)
+ enum bch_watermark watermark)
{
int i, ret = 0;
@@ -983,7 +983,7 @@ static int bucket_alloc_set_partial(struct bch_fs *c,
ret = add_new_bucket(c, ptrs, devs_may_alloc,
nr_replicas, nr_effective,
- have_cache, flags, ob);
+ have_cache, ob);
if (ret)
break;
}
@@ -1003,7 +1003,7 @@ static int __open_bucket_add_buckets(struct btree_trans *trans,
unsigned *nr_effective,
bool *have_cache,
enum bch_watermark watermark,
- unsigned flags,
+ enum bch_write_flags flags,
struct closure *_cl)
{
struct bch_fs *c = trans->c;
@@ -1022,18 +1022,15 @@ static int __open_bucket_add_buckets(struct btree_trans *trans,
open_bucket_for_each(c, ptrs, ob, i)
__clear_bit(ob->dev, devs.d);
- if (erasure_code && ec_open_bucket(c, ptrs))
- return 0;
-
ret = bucket_alloc_set_writepoint(c, ptrs, wp, &devs,
nr_replicas, nr_effective,
- have_cache, erasure_code, flags);
+ have_cache, erasure_code);
if (ret)
return ret;
ret = bucket_alloc_set_partial(c, ptrs, wp, &devs,
nr_replicas, nr_effective,
- have_cache, erasure_code, watermark, flags);
+ have_cache, erasure_code, watermark);
if (ret)
return ret;
@@ -1074,12 +1071,12 @@ static int open_bucket_add_buckets(struct btree_trans *trans,
unsigned *nr_effective,
bool *have_cache,
enum bch_watermark watermark,
- unsigned flags,
+ enum bch_write_flags flags,
struct closure *cl)
{
int ret;
- if (erasure_code) {
+ if (erasure_code && !ec_open_bucket(trans->c, ptrs)) {
ret = __open_bucket_add_buckets(trans, ptrs, wp,
devs_have, target, erasure_code,
nr_replicas, nr_effective, have_cache,
@@ -1376,7 +1373,7 @@ int bch2_alloc_sectors_start_trans(struct btree_trans *trans,
unsigned nr_replicas,
unsigned nr_replicas_required,
enum bch_watermark watermark,
- unsigned flags,
+ enum bch_write_flags flags,
struct closure *cl,
struct write_point **wp_ret)
{
@@ -1392,8 +1389,6 @@ int bch2_alloc_sectors_start_trans(struct btree_trans *trans,
if (!IS_ENABLED(CONFIG_BCACHEFS_ERASURE_CODING))
erasure_code = false;
- BUG_ON(flags & BCH_WRITE_ONLY_SPECIFIED_DEVS);
-
BUG_ON(!nr_replicas || !nr_replicas_required);
retry:
ptrs.nr = 0;
@@ -1498,11 +1493,12 @@ err:
try_decrease_writepoints(trans, write_points_nr))
goto retry;
- if (bch2_err_matches(ret, BCH_ERR_open_buckets_empty) ||
+ if (cl && bch2_err_matches(ret, BCH_ERR_open_buckets_empty))
+ ret = -BCH_ERR_bucket_alloc_blocked;
+
+ if (cl && !(flags & BCH_WRITE_ALLOC_NOWAIT) &&
bch2_err_matches(ret, BCH_ERR_freelist_empty))
- return cl
- ? -BCH_ERR_bucket_alloc_blocked
- : -BCH_ERR_ENOSPC_bucket_alloc;
+ ret = -BCH_ERR_bucket_alloc_blocked;
return ret;
}
@@ -1733,13 +1729,6 @@ void bch2_dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
for (unsigned i = 0; i < ARRAY_SIZE(c->open_buckets); i++)
nr[c->open_buckets[i].data_type]++;
- printbuf_tabstops_reset(out);
- printbuf_tabstop_push(out, 12);
- printbuf_tabstop_push(out, 16);
- printbuf_tabstop_push(out, 16);
- printbuf_tabstop_push(out, 16);
- printbuf_tabstop_push(out, 16);
-
bch2_dev_usage_to_text(out, ca, &stats);
prt_newline(out);

fs/bcachefs/alloc_foreground.h

View file
diff --git a/fs/bcachefs/alloc_foreground.h b/fs/bcachefs/alloc_foreground.h
index 386d231..1a16fd5 100644
--- a/fs/bcachefs/alloc_foreground.h
+++ b/fs/bcachefs/alloc_foreground.h
@@ -155,9 +155,10 @@ static inline bool bch2_bucket_is_open_safe(struct bch_fs *c, unsigned dev, u64
return ret;
}
+enum bch_write_flags;
int bch2_bucket_alloc_set_trans(struct btree_trans *, struct open_buckets *,
struct dev_stripe_state *, struct bch_devs_mask *,
- unsigned, unsigned *, bool *, unsigned,
+ unsigned, unsigned *, bool *, enum bch_write_flags,
enum bch_data_type, enum bch_watermark,
struct closure *);
@@ -167,7 +168,7 @@ int bch2_alloc_sectors_start_trans(struct btree_trans *,
struct bch_devs_list *,
unsigned, unsigned,
enum bch_watermark,
- unsigned,
+ enum bch_write_flags,
struct closure *,
struct write_point **);

fs/bcachefs/backpointers.c

View file
diff --git a/fs/bcachefs/backpointers.c b/fs/bcachefs/backpointers.c
index d4da634..e11989a 100644
--- a/fs/bcachefs/backpointers.c
+++ b/fs/bcachefs/backpointers.c
@@ -9,6 +9,7 @@
#include "btree_update_interior.h"
#include "btree_write_buffer.h"
#include "checksum.h"
+#include "disk_accounting.h"
#include "error.h"
#include <linux/mm.h>
@@ -53,7 +54,7 @@ int bch2_backpointer_validate(struct bch_fs *c, struct bkey_s_c k,
struct bkey_s_c_backpointer bp = bkey_s_c_to_backpointer(k);
rcu_read_lock();
- struct bch_dev *ca = bch2_dev_rcu(c, bp.k->p.inode);
+ struct bch_dev *ca = bch2_dev_rcu_noerror(c, bp.k->p.inode);
if (!ca) {
/* these will be caught by fsck */
rcu_read_unlock();
@@ -87,7 +88,7 @@ void bch2_backpointer_to_text(struct printbuf *out, const struct bch_backpointer
void bch2_backpointer_k_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c k)
{
rcu_read_lock();
- struct bch_dev *ca = bch2_dev_rcu(c, k.k->p.inode);
+ struct bch_dev *ca = bch2_dev_rcu_noerror(c, k.k->p.inode);
if (ca) {
struct bpos bucket = bp_pos_to_bucket(ca, k.k->p);
rcu_read_unlock();
@@ -671,7 +672,7 @@ static int check_extent_to_backpointers(struct btree_trans *trans,
continue;
rcu_read_lock();
- struct bch_dev *ca = bch2_dev_rcu(c, p.ptr.dev);
+ struct bch_dev *ca = bch2_dev_rcu_noerror(c, p.ptr.dev);
if (ca)
bch2_extent_ptr_to_bp(c, ca, btree, level, k, p, entry, &bucket_pos, &bp);
rcu_read_unlock();
@@ -750,10 +751,12 @@ static int bch2_get_btree_in_memory_pos(struct btree_trans *trans,
s64 mem_may_pin = mem_may_pin_bytes(c);
int ret = 0;
+ bch2_btree_cache_unpin(c);
+
btree_interior_mask |= btree_leaf_mask;
- c->btree_cache.pinned_nodes_leaf_mask = btree_leaf_mask;
- c->btree_cache.pinned_nodes_interior_mask = btree_interior_mask;
+ c->btree_cache.pinned_nodes_mask[0] = btree_leaf_mask;
+ c->btree_cache.pinned_nodes_mask[1] = btree_interior_mask;
c->btree_cache.pinned_nodes_start = start;
c->btree_cache.pinned_nodes_end = *end = BBPOS_MAX;
@@ -775,6 +778,7 @@ static int bch2_get_btree_in_memory_pos(struct btree_trans *trans,
BBPOS(btree, b->key.k.p);
break;
}
+ bch2_node_pin(c, b);
0;
}));
}
@@ -782,12 +786,80 @@ static int bch2_get_btree_in_memory_pos(struct btree_trans *trans,
return ret;
}
+struct progress_indicator_state {
+ unsigned long next_print;
+ u64 nodes_seen;
+ u64 nodes_total;
+ struct btree *last_node;
+};
+
+static inline void progress_init(struct progress_indicator_state *s,
+ struct bch_fs *c,
+ u64 btree_id_mask)
+{
+ memset(s, 0, sizeof(*s));
+
+ s->next_print = jiffies + HZ * 10;
+
+ for (unsigned i = 0; i < BTREE_ID_NR; i++) {
+ if (!(btree_id_mask & BIT_ULL(i)))
+ continue;
+
+ struct disk_accounting_pos acc = {
+ .type = BCH_DISK_ACCOUNTING_btree,
+ .btree.id = i,
+ };
+
+ u64 v;
+ bch2_accounting_mem_read(c, disk_accounting_pos_to_bpos(&acc), &v, 1);
+ s->nodes_total += div64_ul(v, btree_sectors(c));
+ }
+}
+
+static inline bool progress_update_p(struct progress_indicator_state *s)
+{
+ bool ret = time_after_eq(jiffies, s->next_print);
+
+ if (ret)
+ s->next_print = jiffies + HZ * 10;
+ return ret;
+}
+
+static void progress_update_iter(struct btree_trans *trans,
+ struct progress_indicator_state *s,
+ struct btree_iter *iter,
+ const char *msg)
+{
+ struct bch_fs *c = trans->c;
+ struct btree *b = path_l(btree_iter_path(trans, iter))->b;
+
+ s->nodes_seen += b != s->last_node;
+ s->last_node = b;
+
+ if (progress_update_p(s)) {
+ struct printbuf buf = PRINTBUF;
+ unsigned percent = s->nodes_total
+ ? div64_u64(s->nodes_seen * 100, s->nodes_total)
+ : 0;
+
+ prt_printf(&buf, "%s: %d%%, done %llu/%llu nodes, at ",
+ msg, percent, s->nodes_seen, s->nodes_total);
+ bch2_bbpos_to_text(&buf, BBPOS(iter->btree_id, iter->pos));
+
+ bch_info(c, "%s", buf.buf);
+ printbuf_exit(&buf);
+ }
+}
+
static int bch2_check_extents_to_backpointers_pass(struct btree_trans *trans,
struct extents_to_bp_state *s)
{
struct bch_fs *c = trans->c;
+ struct progress_indicator_state progress;
int ret = 0;
+ progress_init(&progress, trans->c, BIT_ULL(BTREE_ID_extents)|BIT_ULL(BTREE_ID_reflink));
+
for (enum btree_id btree_id = 0;
btree_id < btree_id_nr_alive(c);
btree_id++) {
@@ -805,6 +877,7 @@ static int bch2_check_extents_to_backpointers_pass(struct btree_trans *trans,
BTREE_ITER_prefetch);
ret = for_each_btree_key_continue(trans, iter, 0, k, ({
+ progress_update_iter(trans, &progress, &iter, "extents_to_backpointers");
check_extent_to_backpointers(trans, s, btree_id, level, k) ?:
bch2_trans_commit(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc);
}));
@@ -865,8 +938,7 @@ int bch2_check_extents_to_backpointers(struct bch_fs *c)
bch2_trans_put(trans);
bch2_bkey_buf_exit(&s.last_flushed, c);
- c->btree_cache.pinned_nodes_leaf_mask = 0;
- c->btree_cache.pinned_nodes_interior_mask = 0;
+ bch2_btree_cache_unpin(c);
bch_err_fn(c, ret);
return ret;
@@ -920,19 +992,24 @@ static int bch2_check_backpointers_to_extents_pass(struct btree_trans *trans,
struct bbpos start,
struct bbpos end)
{
+ struct bch_fs *c = trans->c;
struct bkey_buf last_flushed;
+ struct progress_indicator_state progress;
bch2_bkey_buf_init(&last_flushed);
bkey_init(&last_flushed.k->k);
+ progress_init(&progress, trans->c, BIT_ULL(BTREE_ID_backpointers));
int ret = for_each_btree_key_commit(trans, iter, BTREE_ID_backpointers,
POS_MIN, BTREE_ITER_prefetch, k,
- NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
- check_one_backpointer(trans, start, end,
- bkey_s_c_to_backpointer(k),
- &last_flushed));
-
- bch2_bkey_buf_exit(&last_flushed, trans->c);
+ NULL, NULL, BCH_TRANS_COMMIT_no_enospc, ({
+ progress_update_iter(trans, &progress, &iter, "backpointers_to_extents");
+ check_one_backpointer(trans, start, end,
+ bkey_s_c_to_backpointer(k),
+ &last_flushed);
+ }));
+
+ bch2_bkey_buf_exit(&last_flushed, c);
return ret;
}

This diff is incomplete. Download the complete patch.

fs/bcachefs/backpointers.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/bcachefs.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/bcachefs_format.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/bset.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/bset.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_cache.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_cache.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_gc.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_io.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_io.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_iter.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_iter.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_key_cache.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_key_cache_types.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_locking.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_trans_commit.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_types.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_update.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_update_interior.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/btree_update_interior.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/buckets.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/buckets.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/buckets_types.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/checksum.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/clock.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/darray.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/darray.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/data_update.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/dirent.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/ec.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/ec.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/ec_format.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/ec_types.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/errcode.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/extents.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/extents.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/fs-common.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/fs-io-buffered.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/fs-io-direct.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/fs-io-pagecache.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/fs-io-pagecache.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/fs-io.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/fs-ioctl.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/fs.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/fs.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/inode.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/io_read.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/io_write.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/journal_io.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/journal_reclaim.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/opts.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/opts.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/rcu_pending.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/rcu_pending.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/rebalance.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/recovery.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/recovery_passes.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/replicas.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/replicas_format.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/sb-clean.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/sb-members.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/sb-members.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/str_hash.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/subvolume.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/subvolume_types.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/super-io.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/super.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/sysfs.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/thread_with_file.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/time_stats.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/time_stats.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/trace.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/util.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/util.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/xattr.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/xattr_format.h

View file

This diff is incomplete. Download the complete patch.

fs/inode.c

View file

This diff is incomplete. Download the complete patch.

include/linux/fs.h

View file

This diff is incomplete. Download the complete patch.

include/linux/generic-radix-tree.h

View file

This diff is incomplete. Download the complete patch.

lib/generic-radix-tree.c

View file

This diff is incomplete. Download the complete patch.