bcahcefs fixes for rc2
cover bcahcefs fixes for rc2
Nothing terribly exciting, things have been stabilizing nicely...
the btree_trans_peek_key_cache fix finishes fixing an oops that I've had reports of from a few people
'journal stuck timeout' change addresses another source of SRCU lock hold time warnings; the main remaining one? I'm not seeing it in the CI anymore with that fix.
'improve journal pin flushing' addresses slow & hanging unmounts
'trace_move_extent_finish' improvement is to help us debug the 'rebalance not making progress' issues
Kent Overstreet (11):
bcachefs: Fix btree_trans_peek_key_cache()
bcachefs: Reduce stack frame size of __bch2_str_hash_check_key()
bcachefs: "Journal stuck" timeout now takes into account device
latency
bcachefs: bset_blacklisted_journal_seq is now AUTOFIX
bcachefs: Improve decompression error messages
bcachefs: rebalance, copygc enabled are runtime opts
bcachefs: fix bch2_btree_node_flags
bcachefs: Improve journal pin flushing
bcachefs: Journal writes are now IOPRIO_CLASS_RT
bcachefs: Fix trace_copygc
bcachefs: Improve trace_move_extent_finish
fs/bcachefs/btree_cache.c | 5 +- fs/bcachefs/btree_iter.c | 3 +- fs/bcachefs/btree_key_cache.c | 4 +- fs/bcachefs/btree_trans_commit.c | 2 +- fs/bcachefs/compress.c | 31 +++++-- fs/bcachefs/compress.h | 4 +- fs/bcachefs/data_update.c | 50 +++++++---- fs/bcachefs/debug.c | 1 + fs/bcachefs/io_write.c | 4 +- fs/bcachefs/io_write.h | 2 + fs/bcachefs/journal.c | 92 +++++++------------- fs/bcachefs/journal.h | 9 +- fs/bcachefs/journal_io.c | 2 + fs/bcachefs/journal_reclaim.c | 142 ++++++++++++++++++++++++++----- fs/bcachefs/journal_reclaim.h | 3 + fs/bcachefs/journal_types.h | 13 +-- fs/bcachefs/movinggc.c | 11 ++- fs/bcachefs/opts.h | 4 +- fs/bcachefs/sb-errors_format.h | 2 +- fs/bcachefs/str_hash.c | 24 +++--- fs/bcachefs/trace.h | 26 +++--- 21 files changed, 275 insertions(+), 159 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/11 bcachefs: Fix btree_trans_peek_key_cache()
BTREE_ITER_cached_nofill has some tricky corner cases; it's used internally for iterators that aren't walking the key cache, but need to be coherent with the key cache.
It tells traverse to look up and lock the key cache entry if present, but don't create one if it doesn't exist.
That means we have to have a BTREE_ITER_UPTODATE path (because after traverse the path has to be UPTODATE, or we pop assertions) that doesn't point to anything (which is the less bad option, taken by the previous fix).
The previous fix for this path missed an issue that can happen in bch2_trans_peek_key_cache(): we can't set should_be_locked on a path that doesn't point to anything and doesn't hold locks.
--- fs/bcachefs/btree_iter.c | 3 +-- fs/bcachefs/btree_key_cache.c | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-)
fs/bcachefs/btree_iter.c +1 -2
@@ -2239,8 +2239,6 @@ struct bkey_s_c btree_trans_peek_key_cache(struct btree_iter *iter, struct bposif (unlikely (ret))return bkey_s_c_err (ret); -btree_path_set_should_be_locked (trans, trans->paths + iter->key_cache_path); - k =bch2_btree_path_peek_slot (trans->paths + iter->key_cache_path, &u);if (!k.k)return k;
@@ -2251,6 +2249,7 @@ struct bkey_s_c btree_trans_peek_key_cache(struct btree_iter *iter, struct bpos iter->k = u; k.k = &iter->k; +btree_path_set_should_be_locked (trans, trans->paths + iter->key_cache_path);return k; }
fs/bcachefs/btree_key_cache.c +3 -1
@@ -291,8 +291,10 @@ static noinline int btree_key_cache_fill(struct btree_trans *trans, struct btree_path *ck_path, unsigned flags) { -if (flags & BTREE_ITER_cached_nofill) +if (flags & BTREE_ITER_cached_nofill) { + ck_path->l[0 ].b =NULL ;return 0 ; + }struct bch_fs *c = trans->c;struct btree_iter iter;
Signature · 1 line
2.45.2
PATCH 2/11 bcachefs: Reduce stack frame size of __bch2_str_hash_check_key()
In reply to Kent OverstreetWe don't need all the helpers inlined here.
--- fs/bcachefs/str_hash.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
fs/bcachefs/str_hash.c +12 -12
@@ -31,11 +31,11 @@ static int bch2_dirent_has_target(struct btree_trans *trans, struct bkey_s_c_dir } } -static int fsck_rename_dirent (struct btree_trans *trans, -struct snapshots_seen *s, -const struct bch_hash_desc desc, -struct bch_hash_info *hash_info, -struct bkey_s_c_dirent old) +static noinline int fsck_rename_dirent(struct btree_trans *trans, +struct snapshots_seen *s, +const struct bch_hash_desc desc, +struct bch_hash_info *hash_info, +struct bkey_s_c_dirent old) {struct qstr old_name =bch2_dirent_get_name (old);struct bkey_i_dirent *new =bch2_trans_kmalloc (trans,bkey_bytes (old.k) +32 );
@@ -71,11 +71,11 @@ static int fsck_rename_dirent(struct btree_trans *trans,return bch2_fsck_update_backpointers (trans, s, desc, hash_info, &new->k_i); } -static int hash_pick_winner (struct btree_trans *trans, -const struct bch_hash_desc desc, -struct bch_hash_info *hash_info, -struct bkey_s_c k1, -struct bkey_s_c k2) +static noinline int hash_pick_winner(struct btree_trans *trans, +const struct bch_hash_desc desc, +struct bch_hash_info *hash_info, +struct bkey_s_c k1, +struct bkey_s_c k2) {if (bkey_val_bytes (k1.k) ==bkey_val_bytes (k2.k) && !memcmp (k1.v, k2.v,bkey_val_bytes (k1.k)))
@@ -142,8 +142,8 @@ static int repair_inode_hash_info(struct btree_trans *trans,* All versions of the same inode in different snapshots must have the same hash * seed/type: verify that the hash info we're using matches the root */ -static int check_inode_hash_info_matches_root (struct btree_trans *trans,u64 inum, -struct bch_hash_info *hash_info) +static noinline int check_inode_hash_info_matches_root(struct btree_trans *trans, u64 inum, +struct bch_hash_info *hash_info) {struct bch_fs *c = trans->c;struct btree_iter iter;
Signature · 1 line
2.45.2
PATCH 3/11 bcachefs: "Journal stuck" timeout now takes into account device latency
In reply to Kent OverstreetIf a block device (e.g. your typical consumer SSD) is taking multiple seconds for IOs (typically flushes), we don't want to emit the "journal stuck" message prematurely.
Also, make sure to drop the btree_trans srcu lock if we're blocking for more than a second.
--- fs/bcachefs/btree_trans_commit.c | 2 +- fs/bcachefs/journal.c | 32 ++++++++++++++++++++++++++++---- fs/bcachefs/journal.h | 7 ++++--- 3 files changed, 33 insertions(+), 8 deletions(-)
fs/bcachefs/btree_trans_commit.c +1 -1
@@ -348,7 +348,7 @@ static __always_inline int bch2_trans_journal_res_get(struct btree_trans *trans, unsigned flags) {return bch2_journal_res_get (&trans->c->journal, &trans->journal_res, - trans->journal_u64s, flags); + trans->journal_u64s, flags, trans); }#define JSET_ENTRY_LOG_U64s 4
fs/bcachefs/journal.c +28 -4
@@ -601,6 +601,16 @@ static int __journal_res_get(struct journal *j, struct journal_res *res, : -BCH_ERR_journal_res_get_blocked; } +static unsigned max_dev_latency (struct bch_fs *c) +{ +u64 nsecs =0 ; + +for_each_rw_member (c, ca) + nsecs =max (nsecs, ca->io_latency[WRITE ].stats.max_duration); + +return nsecs_to_jiffies (nsecs); +} +/* * Essentially the entry function to the journaling code. When bcachefs is doing * a btree insert, it calls this function to get the current journal write.
@@ -612,17 +622,31 @@ static int __journal_res_get(struct journal *j, struct journal_res *res,* btree node write locks. */ int bch2_journal_res_get_slowpath (struct journal *j,struct journal_res *res, -unsigned flags) +unsigned flags, +struct btree_trans *trans) {int ret;if (closure_wait_event_timeout (&j->async_wait, (ret =__journal_res_get (j, res, flags)) != -BCH_ERR_journal_res_get_blocked || (flags &JOURNAL_RES_GET_NONBLOCK ), -HZ *10 )) +HZ ))return ret; +if (trans) +bch2_trans_unlock_long (trans); + struct bch_fs *c = container_of(j, struct bch_fs, journal); +int remaining_wait =max (max_dev_latency (c) *2 ,HZ *10 ); + + remaining_wait =max (0 , remaining_wait -HZ ); + +if (closure_wait_event_timeout (&j->async_wait, + (ret =__journal_res_get (j, res, flags)) != -BCH_ERR_journal_res_get_blocked || + (flags &JOURNAL_RES_GET_NONBLOCK ), + remaining_wait)) +return ret; +struct printbuf buf =PRINTBUF ;bch2_journal_debug_to_text (&buf, j); bch_err(c, "Journal stuck? Waited for 10 seconds...\n%s",
@@ -727,7 +751,7 @@ int bch2_journal_flush_seq_async(struct journal *j, u64 seq,* livelock: */ sched_annotate_sleep (); - ret =bch2_journal_res_get (j, &res,jset_u64s (0 ),0 ); + ret =bch2_journal_res_get (j, &res,jset_u64s (0 ),0 ,NULL );if (ret)return ret;
@@ -848,7 +872,7 @@ bool bch2_journal_noflush_seq(struct journal *j, u64 start, u64 end)static int __bch2_journal_meta (struct journal *j) {struct journal_res res = {}; -int ret =bch2_journal_res_get (j, &res,jset_u64s (0 ),0 ); +int ret =bch2_journal_res_get (j, &res,jset_u64s (0 ),0 ,NULL );if (ret)return ret;
fs/bcachefs/journal.h +4 -3
@@ -312,7 +312,7 @@ static inline void bch2_journal_res_put(struct journal *j, }int bch2_journal_res_get_slowpath (struct journal *,struct journal_res *, -unsigned ); +unsigned ,struct btree_trans *);/* First bits for BCH_WATERMARK: */ enum journal_res_flags {
@@ -368,7 +368,8 @@ static inline int journal_res_get_fast(struct journal *j, }static inline int bch2_journal_res_get (struct journal *j,struct journal_res *res, -unsigned u64s,unsigned flags) +unsigned u64s,unsigned flags, +struct btree_trans *trans) {int ret;
@@ -380,7 +381,7 @@ static inline int bch2_journal_res_get(struct journal *j, struct journal_res *reif (journal_res_get_fast (j, res, flags)) goto out; - ret =bch2_journal_res_get_slowpath (j, res, flags); + ret =bch2_journal_res_get_slowpath (j, res, flags, trans);if (ret)return ret; out:
Signature · 1 line
2.45.2
PATCH 4/11 bcachefs: bset_blacklisted_journal_seq is now AUTOFIX
In reply to Kent Overstreet--- fs/bcachefs/sb-errors_format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/bcachefs/sb-errors_format.h +1 -1
@@ -57,7 +57,7 @@ enum bch_fsck_flags { x(bset_wrong_sector_offset, 44, 0) \ x(bset_empty, 45, 0) \ x(bset_bad_seq, 46, 0) \ - x(bset_blacklisted_journal_seq, 47, 0) \ + x(bset_blacklisted_journal_seq, 47, FSCK_AUTOFIX) \ x(first_bset_blacklisted_journal_seq, 48, FSCK_AUTOFIX) \ x(btree_node_bad_btree, 49, 0) \x (btree_node_bad_level,50 ,0 ) \
Signature · 1 line
2.45.2
PATCH 5/11 bcachefs: Improve decompression error messages
In reply to Kent OverstreetRatelimit them, and use the new bch2_write_op_error() helper that prints path and file offset.
--- fs/bcachefs/compress.c | 31 ++++++++++++++++++++++--------- fs/bcachefs/compress.h | 4 ++-- fs/bcachefs/io_write.c | 4 ++-- fs/bcachefs/io_write.h | 2 ++ 4 files changed, 28 insertions(+), 13 deletions(-)
fs/bcachefs/compress.c +22 -9
@@ -4,6 +4,7 @@#include "compress.h" #include "error.h" #include "extents.h" +#include "io_write.h" #include "opts.h" #include "super-io.h"
@@ -254,11 +255,14 @@ static int __bio_uncompress(struct bch_fs *c, struct bio *src, goto out; } -int bch2_bio_uncompress_inplace (struct bch_fs *c,struct bio *bio, -struct bch_extent_crc_unpacked *crc) +int bch2_bio_uncompress_inplace (struct bch_write_op *op, +struct bio *bio) { +struct bch_fs *c = op->c; +struct bch_extent_crc_unpacked *crc = &op->crc;struct bbuf data = {NULL };size_t dst_len = crc->uncompressed_size <<9 ; +int ret =0 ;/* bio must own its pages: */ BUG_ON (!bio->bi_vcnt);
@@ -266,17 +270,26 @@ int bch2_bio_uncompress_inplace(struct bch_fs *c, struct bio *bio,if (crc->uncompressed_size <<9 > c->opts.encoded_extent_max || crc->compressed_size <<9 > c->opts.encoded_extent_max) { -bch_err (c,"error rewriting existing data: extent too big" ); +struct printbuf buf =PRINTBUF ; +bch2_write_op_error (&buf, op); +prt_printf (&buf,"error rewriting existing data: extent too big" ); +bch_err_ratelimited (c,"%s" , buf.buf); +printbuf_exit (&buf);return -EIO ; } data =__bounce_alloc (c, dst_len,WRITE );if (__bio_uncompress (c, bio, data.b, *crc)) { -if (!c->opts.no_data_io) -bch_err (c,"error rewriting existing data: decompression error" ); -bio_unmap_or_unbounce (c, data); -return -EIO ; +if (!c->opts.no_data_io) { +struct printbuf buf =PRINTBUF ; +bch2_write_op_error (&buf, op); +prt_printf (&buf,"error rewriting existing data: decompression error" ); +bch_err_ratelimited (c,"%s" , buf.buf); +printbuf_exit (&buf); + } + ret = -EIO ; + goto err; }/*
@@ -293,9 +306,9 @@ int bch2_bio_uncompress_inplace(struct bch_fs *c, struct bio *bio, crc->uncompressed_size = crc->live_size; crc->offset =0 ; crc->csum = (struct bch_csum ) {0 ,0 }; - +err:bio_unmap_or_unbounce (c, data); -return 0 ; +return ret; } int bch2_bio_uncompress(struct bch_fs *c, struct bio *src,
fs/bcachefs/compress.h +2 -2
@@ -47,8 +47,8 @@ static inline enum bch_compression_type bch2_compression_opt_to_type(unsigned v)return __bch2_compression_opt_to_type[bch2_compression_decode (v).type]; } -int bch2_bio_uncompress_inplace (struct bch_fs *,struct bio *, -struct bch_extent_crc_unpacked *); +struct bch_write_op ; +int bch2_bio_uncompress_inplace (struct bch_write_op *,struct bio *);int bch2_bio_uncompress (struct bch_fs *,struct bio *,struct bio *,struct bvec_iter ,struct bch_extent_crc_unpacked ); unsigned bch2_bio_compress(struct bch_fs *, struct bio *, size_t *,
fs/bcachefs/io_write.c +2 -2
@@ -406,7 +406,7 @@ static void __bch2_write_op_error(struct printbuf *out, struct bch_write_op *op, op->flags & BCH_WRITE_MOVE ? "(internal move)" : ""); } -static void bch2_write_op_error (struct printbuf *out,struct bch_write_op *op) +void bch2_write_op_error (struct printbuf *out,struct bch_write_op *op) {__bch2_write_op_error (out, op, op->pos.offset); }
@@ -873,7 +873,7 @@ static enum prep_encoded_ret {if (bch2_crc_cmp (op->crc.csum, csum) && !c->opts.no_data_io)return PREP_ENCODED_CHECKSUM_ERR ; -if (bch2_bio_uncompress_inplace (c, bio, &op->crc)) +if (bch2_bio_uncompress_inplace (op, bio))return PREP_ENCODED_ERR ; }
fs/bcachefs/io_write.h +2 -0
@@ -20,6 +20,8 @@ static inline void bch2_latency_acct(struct bch_dev *ca, u64 submit_time, int rwvoid bch2_submit_wbio_replicas (struct bch_write_bio *,struct bch_fs *,enum bch_data_type ,const struct bkey_i *,bool ); +void bch2_write_op_error (struct printbuf *out,struct bch_write_op *op); +#define BCH_WRITE_FLAGS () \ x(ALLOC_NOWAIT) \ x(CACHED) \
Signature · 1 line
2.45.2
PATCH 6/11 bcachefs: rebalance, copygc enabled are runtime opts
In reply to Kent OverstreetFix a regression from when these were switched to normal opts.h options.
--- fs/bcachefs/opts.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/bcachefs/opts.h +2 -2
@@ -476,13 +476,13 @@ enum fsck_err_opts { NULL, "Enable nocow mode: enables runtime locking in\n"\ "data move path needed if nocow will ever be in use\n")\ x(copygc_enabled, u8, \ - OPT_FS|OPT_MOUNT, \ + OPT_FS|OPT_MOUNT|OPT_RUNTIME, \ OPT_BOOL(), \ BCH2_NO_SB_OPT, true, \ NULL, "Enable copygc: disable for debugging, or to\n"\ "quiet the system when doing performance testing\n")\x (rebalance_enabled, u8, \ -OPT_FS |OPT_MOUNT , \ +OPT_FS |OPT_MOUNT |OPT_RUNTIME , \OPT_BOOL (), \BCH2_NO_SB_OPT , true, \ NULL, "Enable rebalance: disable for debugging, or to\n"\
Signature · 1 line
2.45.2
PATCH 7/11 bcachefs: fix bch2_btree_node_flags
In reply to Kent Overstreet--- fs/bcachefs/btree_cache.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/bcachefs/btree_cache.c +4 -1
@@ -24,7 +24,10 @@ do { \ }while (0 ) const char * const bch2_btree_node_flags[] = { -#define x(f) #f, +"typebit" , +"typebit" , +"typebit" , +#define x(f) [BTREE_NODE_##f] = #f,BTREE_FLAGS () #undef x NULL
Signature · 1 line
2.45.2
PATCH 8/11 bcachefs: Improve journal pin flushing
In reply to Kent OverstreetRunning the preempt tiering tests with a lower than normal journal reclaim delay turned up a shutdown hang - a lost wakeup, caused because flushing a journal pin (e.g. key cache/write buffer) can generate a new journal pin.
The "simple" fix of adding the correct wakeup didn't work because of ordering issues; if we flush btree node pins too aggressively before other pins have completed, we end up spinning where each flush iteration generates new work.
So to fix this correctly:
- The list of flushed journal pins is now broken out by type, so that we can wait for key cache/write buffer pin flushing to complete before flushing dirty btree nodes
- A new closure_waitlist is added for bch2_journal_flush_pins; this one is only used under or when we're taking the journal lock, so it's pretty cheap to add rigorously correct wakeups to journal_pin_set() and journal_pin_drop().
Additionally, bch2_journal_seq_pins_to_text() is moved to journal_reclaim.c, where it belongs, along with a bit of other small renaming and refactoring.
Besides fixing the hang, the better ordering between key cache/write buffer flushing and btree node flushing should help or fix the "unmount taking excessively long" a few users have been noticing.
--- fs/bcachefs/debug.c | 1 + fs/bcachefs/journal.c | 60 +------------- fs/bcachefs/journal.h | 2 - fs/bcachefs/journal_reclaim.c | 142 +++++++++++++++++++++++++++++----- fs/bcachefs/journal_reclaim.h | 3 + fs/bcachefs/journal_types.h | 13 ++-- 6 files changed, 136 insertions(+), 85 deletions(-)
fs/bcachefs/debug.c +1 -0
@@ -20,6 +20,7 @@#include "extents.h" #include "fsck.h" #include "inode.h" +#include "journal_reclaim.h" #include "super.h" #include <linux/console.h>
fs/bcachefs/journal.c +4 -56
69 lines not on this page · raw message
fs/bcachefs/journal.h +0 -2
@@ -430,8 +430,6 @@ struct journal_buf *bch2_next_write_buffer_flush_journal_buf(struct journal *, uvoid __bch2_journal_debug_to_text (struct printbuf *,struct journal *);void bch2_journal_debug_to_text (struct printbuf *,struct journal *); -void bch2_journal_pins_to_text (struct printbuf *,struct journal *); -bool bch2_journal_seq_pins_to_text (struct printbuf *,struct journal *,u64 *);int bch2_set_nr_journal_buckets (struct bch_fs *,struct bch_dev *,unsigned nr);
fs/bcachefs/journal_reclaim.c +121 -21
229 lines not on this page · raw message
fs/bcachefs/journal_reclaim.h +3 -0
@@ -78,4 +78,7 @@ static inline bool bch2_journal_flush_all_pins(struct journal *j)int bch2_journal_flush_device_pins (struct journal *,int ); +void bch2_journal_pins_to_text (struct printbuf *,struct journal *); +bool bch2_journal_seq_pins_to_text (struct printbuf *,struct journal *,u64 *); +#endif /* _BCACHEFS_JOURNAL_RECLAIM_H */
fs/bcachefs/journal_types.h +7 -6
@@ -53,15 +53,15 @@ struct journal_buf {*/ enum journal_pin_type { - JOURNAL_PIN_btree, - JOURNAL_PIN_key_cache, - JOURNAL_PIN_other, -JOURNAL_PIN_NR , + JOURNAL_PIN_TYPE_btree, + JOURNAL_PIN_TYPE_key_cache, + JOURNAL_PIN_TYPE_other, +JOURNAL_PIN_TYPE_NR , };struct journal_entry_pin_list { -struct list_head list[JOURNAL_PIN_NR ]; -struct list_head flushed; +struct list_head unflushed[JOURNAL_PIN_TYPE_NR ]; +struct list_head flushed[JOURNAL_PIN_TYPE_NR ];atomic_t count;struct bch_devs_list devs; };
@@ -226,6 +226,7 @@ struct journal {/* Used when waiting because the journal was full */ wait_queue_head_t wait;struct closure_waitlist async_wait; +struct closure_waitlist reclaim_flush_wait;struct delayed_work write_work;struct workqueue_struct *wq;
Signature · 1 line
2.45.2
PATCH 9/11 bcachefs: Journal writes are now IOPRIO_CLASS_RT
In reply to Kent OverstreetSystem performance is particularly sensitive to journal write latency, the number of outstanding journal writes is bounded and we can't issue journal flushes until other journal writes have completed.
--- fs/bcachefs/journal_io.c | 2 ++ 1 file changed, 2 insertions(+)
fs/bcachefs/journal_io.c +2 -0
@@ -17,6 +17,7 @@#include "sb-clean.h" #include "trace.h" +#include <linux/ioprio.h> #include <linux/string_choices.h> void bch2_journal_pos_from_member_info_set (struct bch_fs *c)
@@ -1763,6 +1764,7 @@ static CLOSURE_CALLBACK(journal_write_submit) bio->bi_iter.bi_sector = ptr->offset; bio->bi_end_io = journal_write_endio; bio->bi_private = ca; + bio->bi_ioprio =IOPRIO_PRIO_VALUE (IOPRIO_CLASS_RT ,0 );BUG_ON (bio->bi_iter.bi_sector == ca->prev_journal_sector); ca->prev_journal_sector = bio->bi_iter.bi_sector;
Signature · 1 line
2.45.2
PATCH 10/11 bcachefs: Fix trace_copygc
In reply to Kent Overstreet--- fs/bcachefs/movinggc.c | 11 +++++++---- fs/bcachefs/trace.h | 26 ++++++++++++-------------- 2 files changed, 19 insertions(+), 18 deletions(-)
fs/bcachefs/movinggc.c +7 -4
@@ -215,7 +215,8 @@ static int bch2_copygc(struct moving_context *ctxt, };move_buckets buckets = {0 };struct move_bucket_in_flight *f; -u64 moved =atomic64_read (&ctxt->stats->sectors_moved); +u64 sectors_seen =atomic64_read (&ctxt->stats->sectors_seen); +u64 sectors_moved =atomic64_read (&ctxt->stats->sectors_moved);int ret =0 ; ret =bch2_copygc_get_buckets (ctxt, buckets_in_flight, &buckets);
@@ -245,7 +246,6 @@ static int bch2_copygc(struct moving_context *ctxt, *did_work = true; } err: -darray_exit (&buckets);/* no entries in LRU btree found, or got to end: */ if (bch2_err_matches (ret,ENOENT ))
@@ -254,8 +254,11 @@ static int bch2_copygc(struct moving_context *ctxt,if (ret <0 && !bch2_err_matches (ret,EROFS ))bch_err_msg (c, ret,"from bch2_move_data()" ); - moved =atomic64_read (&ctxt->stats->sectors_moved) - moved; -trace_and_count (c, copygc, c, moved,0 ,0 ,0 ); + sectors_seen =atomic64_read (&ctxt->stats->sectors_seen) - sectors_seen; + sectors_moved =atomic64_read (&ctxt->stats->sectors_moved) - sectors_moved; +trace_and_count (c, copygc, c, buckets.nr, sectors_seen, sectors_moved); + +darray_exit (&buckets);return ret; }
fs/bcachefs/trace.h +12 -14
@@ -902,32 +902,30 @@ TRACE_EVENT(evacuate_bucket,TRACE_EVENT (copygc, TP_PROTO(struct bch_fs *c, - u64 sectors_moved, u64 sectors_not_moved, - u64 buckets_moved, u64 buckets_not_moved), -TP_ARGS (c, - sectors_moved, sectors_not_moved, - buckets_moved, buckets_not_moved), + u64 buckets, + u64 sectors_seen, + u64 sectors_moved), +TP_ARGS (c, buckets, sectors_seen, sectors_moved),TP_STRUCT__entry ( __field(dev_t, dev ) + __field(u64, buckets ) + __field(u64, sectors_seen )__field (u64, sectors_moved ) - __field(u64, sectors_not_moved ) - __field(u64, buckets_moved ) -__field (u64, buckets_not_moved ) ),TP_fast_assign ( __entry->dev = c->dev; + __entry->buckets = buckets; + __entry->sectors_seen = sectors_seen; __entry->sectors_moved = sectors_moved; - __entry->sectors_not_moved = sectors_not_moved; - __entry->buckets_moved = buckets_moved; - __entry->buckets_not_moved = buckets_moved; ), -TP_printk ("%d,%d sectors moved %llu remain %llu buckets moved %llu remain %llu" , +TP_printk ("%d,%d buckets %llu sectors seen %llu moved %llu" ,MAJOR (__entry->dev),MINOR (__entry->dev), - __entry->sectors_moved, __entry->sectors_not_moved, - __entry->buckets_moved, __entry->buckets_not_moved) + __entry->buckets, + __entry->sectors_seen, + __entry->sectors_moved) ); TRACE_EVENT(copygc_wait,
Signature · 1 line
2.45.2
PATCH 11/11 bcachefs: Improve trace_move_extent_finish
In reply to Kent OverstreetWe're currently debugging issues with rebalance, where it's not making progress as quickly as it should be (or sometimes not at all).
Add the full data_update to the move_extent_finish tracepoint, so we can check that the replicas we wrote match what we were supposed to do.
--- fs/bcachefs/data_update.c | 50 ++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 16 deletions(-)
fs/bcachefs/data_update.c +34 -16
@@ -91,15 +91,28 @@ static bool bkey_nocow_lock(struct bch_fs *c, struct moving_context *ctxt, strucreturn true; } -static void trace_move_extent_finish2 (struct bch_fs *c,struct bkey_s_c k) +static noinline void trace_move_extent_finish2(struct data_update *u, +struct bkey_i *new, +struct bkey_i *insert) { -if (trace_move_extent_finish_enabled ()) { -struct printbuf buf =PRINTBUF ; +struct bch_fs *c = u->op.c; +struct printbuf buf =PRINTBUF ; -bch2_bkey_val_to_text (&buf, c, k); -trace_move_extent_finish (c, buf.buf); -printbuf_exit (&buf); - } +prt_newline (&buf); + +bch2_data_update_to_text (&buf, u); +prt_newline (&buf); + +prt_str_indented (&buf,"new replicas:\t" ); +bch2_bkey_val_to_text (&buf, c,bkey_i_to_s_c (new)); +prt_newline (&buf); + +prt_str_indented (&buf,"insert:\t" ); +bch2_bkey_val_to_text (&buf, c,bkey_i_to_s_c (insert)); +prt_newline (&buf); + +trace_move_extent_finish (c, buf.buf); +printbuf_exit (&buf); } static void trace_move_extent_fail2(struct data_update *m,
@@ -372,7 +385,8 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,bch2_btree_iter_set_pos (&iter, next_pos);this_cpu_add (c->counters[BCH_COUNTER_move_extent_finish], new->k.size); -trace_move_extent_finish2 (c,bkey_i_to_s_c (&new->k_i)); +if (trace_move_extent_finish_enabled ()) +trace_move_extent_finish2 (m, &new->k_i, insert); } err:if (bch2_err_matches (ret, BCH_ERR_transaction_restart))
@@ -525,34 +539,38 @@ void bch2_data_update_opts_to_text(struct printbuf *out, struct bch_fs *c, struct data_update_opts *data_opts) {printbuf_tabstop_push (out,20 ); -prt_str (out,"rewrite ptrs:\t" ); + +prt_str_indented (out,"rewrite ptrs:\t" );bch2_prt_u64_base2 (out, data_opts->rewrite_ptrs);prt_newline (out); -prt_str (out,"kill ptrs:\t" ); +prt_str_indented (out,"kill ptrs:\t" );bch2_prt_u64_base2 (out, data_opts->kill_ptrs);prt_newline (out); -prt_str (out,"target:\t" ); +prt_str_indented (out,"target:\t" );bch2_target_to_text (out, c, data_opts->target);prt_newline (out); -prt_str (out,"compression:\t" ); +prt_str_indented (out,"compression:\t" );bch2_compression_opt_to_text (out, io_opts->background_compression);prt_newline (out); -prt_str (out,"opts.replicas:\t" ); +prt_str_indented (out,"opts.replicas:\t" );prt_u64 (out, io_opts->data_replicas); +prt_newline (out); -prt_str (out,"extra replicas:\t" ); +prt_str_indented (out,"extra replicas:\t" );prt_u64 (out, data_opts->extra_replicas); }void bch2_data_update_to_text (struct printbuf *out,struct data_update *m) { -bch2_bkey_val_to_text (out, m->op.c,bkey_i_to_s_c (m->k.k)); -prt_newline (out);bch2_data_update_opts_to_text (out, m->op.c, &m->op.opts, &m->data_opts); +prt_newline (out); + +prt_str_indented (out,"old key:\t" ); +bch2_bkey_val_to_text (out, m->op.c,bkey_i_to_s_c (m->k.k)); } int bch2_extent_drop_ptrs(struct btree_trans *trans,
Signature · 1 line
2.45.2