diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-07-17 21:40:39 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-03 22:52:25 -0400 |
commit | b1febe789351fe438c9ed877eb58def535834a3c (patch) | |
tree | 48bec44c44952b059f56e568d2bbffc6c2b23855 | |
parent | 2fea95fa120cd5bda86890bbfee244e8519495d1 (diff) |
bcachefs: Improve bucket_alloc_fail tracepoint
We should be printing the number of free buckets, not just the number of
available buckets.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/alloc_foreground.c | 9 | ||||
-rw-r--r-- | fs/bcachefs/movinggc.h | 1 | ||||
-rw-r--r-- | include/trace/events/bcachefs.h | 17 |
3 files changed, 23 insertions, 4 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index 7a878a6906ab..519a7c2c6c68 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -26,6 +26,7 @@ #include "error.h" #include "io.h" #include "journal.h" +#include "movinggc.h" #include <linux/math64.h> #include <linux/rculist.h> @@ -506,7 +507,7 @@ struct open_bucket *bch2_bucket_alloc(struct bch_fs *c, struct bch_dev *ca, int ret; again: usage = bch2_dev_usage_read(ca); - avail = dev_buckets_free(ca, usage,reserve); + avail = dev_buckets_free(ca, usage, reserve); if (usage.d[BCH_DATA_need_discard].buckets > avail) bch2_do_discards(c); @@ -556,7 +557,11 @@ err: ob = ERR_PTR(ret ?: -FREELIST_EMPTY); if (IS_ERR(ob)) { - trace_bucket_alloc_fail(ca, bch2_alloc_reserves[reserve], avail, + trace_bucket_alloc_fail(ca, bch2_alloc_reserves[reserve], + usage.d[BCH_DATA_free].buckets, + avail, + bch2_copygc_wait_amount(c), + c->copygc_wait - atomic64_read(&c->io_clock[WRITE].now), buckets_seen, skipped_open, skipped_need_journal_commit, diff --git a/fs/bcachefs/movinggc.h b/fs/bcachefs/movinggc.h index 922738247d03..e85c8136a46e 100644 --- a/fs/bcachefs/movinggc.h +++ b/fs/bcachefs/movinggc.h @@ -2,6 +2,7 @@ #ifndef _BCACHEFS_MOVINGGC_H #define _BCACHEFS_MOVINGGC_H +unsigned long bch2_copygc_wait_amount(struct bch_fs *); void bch2_copygc_stop(struct bch_fs *); int bch2_copygc_start(struct bch_fs *); void bch2_fs_copygc_init(struct bch_fs *); diff --git a/include/trace/events/bcachefs.h b/include/trace/events/bcachefs.h index 66ad356e95bc..6d7076e79bf1 100644 --- a/include/trace/events/bcachefs.h +++ b/include/trace/events/bcachefs.h @@ -456,19 +456,26 @@ TRACE_EVENT(bucket_alloc, TRACE_EVENT(bucket_alloc_fail, TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, + u64 free, u64 avail, + u64 copygc_wait_amount, + s64 copygc_waiting_for, u64 seen, u64 open, u64 need_journal_commit, u64 nouse, bool nonblocking, int ret), - TP_ARGS(ca, alloc_reserve, avail, seen, open, need_journal_commit, nouse, nonblocking, ret), + TP_ARGS(ca, alloc_reserve, free, avail, copygc_wait_amount, copygc_waiting_for, + seen, open, need_journal_commit, nouse, nonblocking, ret), TP_STRUCT__entry( __field(dev_t, dev ) __array(char, reserve, 16 ) + __field(u64, free ) __field(u64, avail ) + __field(u64, copygc_wait_amount ) + __field(s64, copygc_waiting_for ) __field(u64, seen ) __field(u64, open ) __field(u64, need_journal_commit ) @@ -480,7 +487,10 @@ TRACE_EVENT(bucket_alloc_fail, TP_fast_assign( __entry->dev = ca->dev; strlcpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve)); + __entry->free = free; __entry->avail = avail; + __entry->copygc_wait_amount = copygc_wait_amount; + __entry->copygc_waiting_for = copygc_waiting_for; __entry->seen = seen; __entry->open = open; __entry->need_journal_commit = need_journal_commit; @@ -489,10 +499,13 @@ TRACE_EVENT(bucket_alloc_fail, __entry->ret = ret; ), - TP_printk("%d,%d reserve %s avail %llu seen %llu open %llu need_journal_commit %llu nouse %llu nonblocking %u ret %i", + TP_printk("%d,%d reserve %s free %llu avail %llu copygc_wait %llu/%lli seen %llu open %llu need_journal_commit %llu nouse %llu nonblocking %u ret %i", MAJOR(__entry->dev), MINOR(__entry->dev), __entry->reserve, + __entry->free, __entry->avail, + __entry->copygc_wait_amount, + __entry->copygc_waiting_for, __entry->seen, __entry->open, __entry->need_journal_commit, |