summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/bcachefs/btree_journal_iter.h2
-rw-r--r--fs/bcachefs/io_read.c23
-rw-r--r--fs/bcachefs/journal_io.c20
-rw-r--r--fs/bcachefs/super.c14
-rw-r--r--fs/bcachefs/trace.h10
5 files changed, 55 insertions, 14 deletions
diff --git a/fs/bcachefs/btree_journal_iter.h b/fs/bcachefs/btree_journal_iter.h
index 8dc8e778be6c..85d6969fa9b1 100644
--- a/fs/bcachefs/btree_journal_iter.h
+++ b/fs/bcachefs/btree_journal_iter.h
@@ -31,7 +31,7 @@ struct btree_and_journal_iter {
static inline u32 journal_entry_radix_idx(struct bch_fs *c, u64 seq)
{
- return (seq - c->journal_entries_base_seq) & (~0U >> 1);
+ return seq - c->journal_entries_base_seq;
}
static inline struct bkey_i *journal_key_k(struct bch_fs *c,
diff --git a/fs/bcachefs/io_read.c b/fs/bcachefs/io_read.c
index e7d53ab1cf55..57bd52443f29 100644
--- a/fs/bcachefs/io_read.c
+++ b/fs/bcachefs/io_read.c
@@ -10,6 +10,7 @@
#include "alloc_background.h"
#include "alloc_foreground.h"
#include "async_objs.h"
+#include "btree_cache.h"
#include "btree_update.h"
#include "buckets.h"
#include "checksum.h"
@@ -1290,6 +1291,17 @@ retry_pick:
trace_and_count(c, io_read_split, &orig->bio);
}
+ if (trace_io_read_enabled()) {
+ CLASS(printbuf, buf)();
+ prt_str(&buf, "data_btree=");
+ prt_str(&buf, bch2_btree_id_str(data_btree));
+ prt_str(&buf, " read_pos=");
+ bch2_bpos_to_text(&buf, read_pos);
+ prt_printf(&buf, " offset_into_extent=%u\n", offset_into_extent);
+ bch2_bkey_val_to_text(&buf, c, k);
+ trace_io_read(c, buf.buf);
+ }
+
/*
* Unlock the iterator while the btree node's lock is still in
* cache, before doing the IO:
@@ -1428,6 +1440,17 @@ int __bch2_read(struct btree_trans *trans, struct bch_read_bio *rbio,
bkey_start_offset(k.k);
unsigned sectors = k.k->size - offset_into_extent;
+ if (trace_io_read_lookup_enabled()) {
+ CLASS(printbuf, buf)();
+ prt_str(&buf, "data_btree=");
+ prt_str(&buf, bch2_btree_id_str(data_btree));
+ prt_str(&buf, " read_pos=");
+ bch2_bpos_to_text(&buf, iter.pos);
+ prt_printf(&buf, " offset_into_extent=%llu\n", offset_into_extent);
+ bch2_bkey_val_to_text(&buf, c, k);
+ trace_io_read_lookup(c, buf.buf);
+ }
+
bch2_bkey_buf_reassemble(&sk, c, k);
ret = bch2_read_indirect_extent(trans, &data_btree,
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index 58c314a5cdac..a1feab88cc5e 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -152,6 +152,7 @@ static int journal_entry_add(struct bch_fs *c, struct bch_dev *ca,
struct journal_replay **_i, *i, *dup;
size_t bytes = vstruct_bytes(j);
u64 last_seq = !JSET_NO_FLUSH(j) ? le64_to_cpu(j->last_seq) : 0;
+ u64 seq = le64_to_cpu(j->seq);
CLASS(printbuf, buf)();
int ret = JOURNAL_ENTRY_ADD_OK;
@@ -159,12 +160,11 @@ static int journal_entry_add(struct bch_fs *c, struct bch_dev *ca,
last_seq = min(last_seq, c->opts.journal_rewind);
if (!c->journal.oldest_seq_found_ondisk ||
- le64_to_cpu(j->seq) < c->journal.oldest_seq_found_ondisk)
- c->journal.oldest_seq_found_ondisk = le64_to_cpu(j->seq);
+ seq < c->journal.oldest_seq_found_ondisk)
+ c->journal.oldest_seq_found_ondisk = seq;
/* Is this entry older than the range we need? */
- if (!c->opts.read_entire_journal &&
- le64_to_cpu(j->seq) < jlist->last_seq)
+ if (!c->opts.read_entire_journal && seq < jlist->last_seq)
return JOURNAL_ENTRY_ADD_OUT_OF_RANGE;
/*
@@ -173,7 +173,7 @@ static int journal_entry_add(struct bch_fs *c, struct bch_dev *ca,
* within the range of +-2billion of the filrst one we find.
*/
if (!c->journal_entries_base_seq)
- c->journal_entries_base_seq = max_t(s64, 1, le64_to_cpu(j->seq) - S32_MAX);
+ c->journal_entries_base_seq = max_t(s64, 1, seq - S32_MAX);
/* Drop entries we don't need anymore */
if (last_seq > jlist->last_seq && !c->opts.read_entire_journal) {
@@ -214,9 +214,13 @@ static int journal_entry_add(struct bch_fs *c, struct bch_dev *ca,
nocompact:
jlist->last_seq = max(jlist->last_seq, last_seq);
- _i = genradix_ptr_alloc(&c->journal_entries,
- journal_entry_radix_idx(c, le64_to_cpu(j->seq)),
- GFP_KERNEL);
+ if (seq < c->journal_entries_base_seq ||
+ seq >= c->journal_entries_base_seq + U32_MAX) {
+ bch_err(c, "journal entry sequence numbers span too large a range: cannot reply, contact developers");
+ return bch_err_throw(c, ENOMEM_journal_entry_add);
+ }
+
+ _i = genradix_ptr_alloc(&c->journal_entries, journal_entry_radix_idx(c, seq), GFP_KERNEL);
if (!_i)
return bch_err_throw(c, ENOMEM_journal_entry_add);
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index cc9d00e1afd5..6df782024052 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -988,11 +988,7 @@ static int bch2_fs_opt_version_init(struct bch_fs *c)
}
}
- if (c->cf_encoding)
- prt_printf(&p, "\nUsing encoding defined by superblock: utf8-%u.%u.%u",
- unicode_major(BCH_FS_DEFAULT_UTF8_ENCODING),
- unicode_minor(BCH_FS_DEFAULT_UTF8_ENCODING),
- unicode_rev(BCH_FS_DEFAULT_UTF8_ENCODING));
+ /* cf_encoding log message should be here, but it breaks xfstests - sigh */
if (c->opts.journal_rewind)
prt_printf(&p, "\nrewinding journal, fsck required");
@@ -1060,6 +1056,14 @@ static int bch2_fs_opt_version_init(struct bch_fs *c)
bch2_print_str(c, KERN_INFO, p.buf);
+ /* this really should be part of our one multi line mount message, but -
+ * xfstests... */
+ if (c->cf_encoding)
+ bch_info(c, "Using encoding defined by superblock: utf8-%u.%u.%u",
+ unicode_major(BCH_FS_DEFAULT_UTF8_ENCODING),
+ unicode_minor(BCH_FS_DEFAULT_UTF8_ENCODING),
+ unicode_rev(BCH_FS_DEFAULT_UTF8_ENCODING));
+
if (BCH_SB_INITIALIZED(c->disk_sb.sb)) {
if (!(c->sb.features & (1ULL << BCH_FEATURE_new_extent_overwrite))) {
bch_err(c, "feature new_extent_overwrite not set, filesystem no longer supported");
diff --git a/fs/bcachefs/trace.h b/fs/bcachefs/trace.h
index 269cdf1a87a4..788ab8f9fc1e 100644
--- a/fs/bcachefs/trace.h
+++ b/fs/bcachefs/trace.h
@@ -322,6 +322,16 @@ DEFINE_EVENT(bio, io_read_fail_and_poison,
TP_ARGS(bio)
);
+DEFINE_EVENT(fs_str, io_read_lookup,
+ TP_PROTO(struct bch_fs *c, const char *str),
+ TP_ARGS(c, str)
+);
+
+DEFINE_EVENT(fs_str, io_read,
+ TP_PROTO(struct bch_fs *c, const char *str),
+ TP_ARGS(c, str)
+);
+
/* ec.c */
TRACE_EVENT(stripe_create,