Commit 8ef98313 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent f501ad2b
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "error.h" #include "error.h"
#include "io.h" #include "io.h"
#include "journal.h" #include "journal.h"
#include "movinggc.h"
#include "trace.h" #include "trace.h"
#include <linux/math64.h> #include <linux/math64.h>
...@@ -526,7 +527,7 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans, ...@@ -526,7 +527,7 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans,
bool waiting = false; bool waiting = false;
again: again:
usage = bch2_dev_usage_read(ca); 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) if (usage.d[BCH_DATA_need_discard].buckets > avail)
bch2_do_discards(c); bch2_do_discards(c);
...@@ -581,14 +582,22 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans, ...@@ -581,14 +582,22 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans,
ob = ERR_PTR(-FREELIST_EMPTY); ob = ERR_PTR(-FREELIST_EMPTY);
if (!IS_ERR(ob)) { if (!IS_ERR(ob)) {
trace_bucket_alloc(ca, bch2_alloc_reserves[reserve], avail, trace_bucket_alloc(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, buckets_seen,
skipped_open, skipped_open,
skipped_need_journal_commit, skipped_need_journal_commit,
skipped_nouse, skipped_nouse,
cl == NULL, PTR_ERR_OR_ZERO(ob)); cl == NULL, PTR_ERR_OR_ZERO(ob));
} else { } else {
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, buckets_seen,
skipped_open, skipped_open,
skipped_need_journal_commit, skipped_need_journal_commit,
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#ifndef _BCACHEFS_MOVINGGC_H #ifndef _BCACHEFS_MOVINGGC_H
#define _BCACHEFS_MOVINGGC_H #define _BCACHEFS_MOVINGGC_H
unsigned long bch2_copygc_wait_amount(struct bch_fs *);
void bch2_copygc_stop(struct bch_fs *); void bch2_copygc_stop(struct bch_fs *);
int bch2_copygc_start(struct bch_fs *); int bch2_copygc_start(struct bch_fs *);
void bch2_fs_copygc_init(struct bch_fs *); void bch2_fs_copygc_init(struct bch_fs *);
......
...@@ -440,19 +440,26 @@ DEFINE_EVENT(bch_fs, gc_gens_end, ...@@ -440,19 +440,26 @@ DEFINE_EVENT(bch_fs, gc_gens_end,
DECLARE_EVENT_CLASS(bucket_alloc, DECLARE_EVENT_CLASS(bucket_alloc,
TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, TP_PROTO(struct bch_dev *ca, const char *alloc_reserve,
u64 free,
u64 avail, u64 avail,
u64 copygc_wait_amount,
s64 copygc_waiting_for,
u64 seen, u64 seen,
u64 open, u64 open,
u64 need_journal_commit, u64 need_journal_commit,
u64 nouse, u64 nouse,
bool nonblocking, bool nonblocking,
int ret), 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( TP_STRUCT__entry(
__field(dev_t, dev ) __field(dev_t, dev )
__array(char, reserve, 16 ) __array(char, reserve, 16 )
__field(u64, free )
__field(u64, avail ) __field(u64, avail )
__field(u64, copygc_wait_amount )
__field(s64, copygc_waiting_for )
__field(u64, seen ) __field(u64, seen )
__field(u64, open ) __field(u64, open )
__field(u64, need_journal_commit ) __field(u64, need_journal_commit )
...@@ -464,7 +471,10 @@ DECLARE_EVENT_CLASS(bucket_alloc, ...@@ -464,7 +471,10 @@ DECLARE_EVENT_CLASS(bucket_alloc,
TP_fast_assign( TP_fast_assign(
__entry->dev = ca->dev; __entry->dev = ca->dev;
strlcpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve)); strlcpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve));
__entry->free = free;
__entry->avail = avail; __entry->avail = avail;
__entry->copygc_wait_amount = copygc_wait_amount;
__entry->copygc_waiting_for = copygc_waiting_for;
__entry->seen = seen; __entry->seen = seen;
__entry->open = open; __entry->open = open;
__entry->need_journal_commit = need_journal_commit; __entry->need_journal_commit = need_journal_commit;
...@@ -473,10 +483,13 @@ DECLARE_EVENT_CLASS(bucket_alloc, ...@@ -473,10 +483,13 @@ DECLARE_EVENT_CLASS(bucket_alloc,
__entry->ret = ret; __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), MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->reserve, __entry->reserve,
__entry->free,
__entry->avail, __entry->avail,
__entry->copygc_wait_amount,
__entry->copygc_waiting_for,
__entry->seen, __entry->seen,
__entry->open, __entry->open,
__entry->need_journal_commit, __entry->need_journal_commit,
...@@ -487,26 +500,34 @@ DECLARE_EVENT_CLASS(bucket_alloc, ...@@ -487,26 +500,34 @@ DECLARE_EVENT_CLASS(bucket_alloc,
DEFINE_EVENT(bucket_alloc, bucket_alloc, DEFINE_EVENT(bucket_alloc, bucket_alloc,
TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, TP_PROTO(struct bch_dev *ca, const char *alloc_reserve,
u64 free,
u64 avail, u64 avail,
u64 copygc_wait_amount,
s64 copygc_waiting_for,
u64 seen, u64 seen,
u64 open, u64 open,
u64 need_journal_commit, u64 need_journal_commit,
u64 nouse, u64 nouse,
bool nonblocking, bool nonblocking,
int ret), 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)
); );
DEFINE_EVENT(bucket_alloc, bucket_alloc_fail, DEFINE_EVENT(bucket_alloc, bucket_alloc_fail,
TP_PROTO(struct bch_dev *ca, const char *alloc_reserve, TP_PROTO(struct bch_dev *ca, const char *alloc_reserve,
u64 free,
u64 avail, u64 avail,
u64 copygc_wait_amount,
s64 copygc_waiting_for,
u64 seen, u64 seen,
u64 open, u64 open,
u64 need_journal_commit, u64 need_journal_commit,
u64 nouse, u64 nouse,
bool nonblocking, bool nonblocking,
int ret), 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)
); );
TRACE_EVENT(discard_buckets, TRACE_EVENT(discard_buckets,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment