LE64_BITMASK(BCH_SB_JOURNAL_FLUSH_DELAY,struct bch_sb, flags[3], 30, 62);
LE64_BITMASK(BCH_SB_JOURNAL_FLUSH_DISABLED,struct bch_sb, flags[3], 62, 63);
LE64_BITMASK(BCH_SB_JOURNAL_RECLAIM_DELAY,struct bch_sb, flags[4], 0, 32);
+LE64_BITMASK(BCH_SB_JOURNAL_TRANSACTION_NAMES,struct bch_sb, flags[4], 32, 33);
/*
* Features:
x(usage, 5) \
x(data_usage, 6) \
x(clock, 7) \
- x(dev_usage, 8)
+ x(dev_usage, 8) \
+ x(log, 9)
enum {
#define x(f, nr) BCH_JSET_ENTRY_##f = nr,
struct jset_entry_dev_usage_type d[];
} __attribute__((packed));
+struct jset_entry_log {
+ struct jset_entry entry;
+ u8 d[];
+} __attribute__((packed));
+
/*
* On disk format for a journal entry:
* seq is monotonically increasing; every journal entry has its own unique
return ret == -EAGAIN ? BTREE_INSERT_NEED_JOURNAL_RES : ret;
}
+#define JSET_ENTRY_LOG_U64s 4
+
+static noinline void journal_transaction_name(struct btree_trans *trans)
+{
+ struct bch_fs *c = trans->c;
+ struct jset_entry *entry = journal_res_entry(&c->journal, &trans->journal_res);
+ struct jset_entry_log *l = container_of(entry, struct jset_entry_log, entry);
+ unsigned u64s = JSET_ENTRY_LOG_U64s - 1;
+ unsigned b, buflen = u64s * sizeof(u64);
+
+ l->entry.u64s = cpu_to_le16(u64s);
+ l->entry.btree_id = 0;
+ l->entry.level = 0;
+ l->entry.type = BCH_JSET_ENTRY_log;
+ l->entry.pad[0] = 0;
+ l->entry.pad[1] = 0;
+ l->entry.pad[2] = 0;
+ b = snprintf(l->d, buflen, "%ps", (void *) trans->ip);
+ while (b < buflen)
+ l->d[b++] = '\0';
+
+ trans->journal_res.offset += JSET_ENTRY_LOG_U64s;
+ trans->journal_res.u64s -= JSET_ENTRY_LOG_U64s;
+}
+
static inline enum btree_insert_ret
btree_key_can_insert(struct btree_trans *trans,
struct btree *b,
JOURNAL_RES_GET_NONBLOCK);
if (ret)
return ret;
+
+ if (unlikely(trans->journal_transaction_names))
+ journal_transaction_name(trans);
} else {
trans->journal_res.seq = c->journal.replay_journal_seq;
}
int __bch2_trans_commit(struct btree_trans *trans)
{
+ struct bch_fs *c = trans->c;
struct btree_insert_entry *i = NULL;
unsigned u64s;
int ret = 0;
goto out_reset;
if (trans->flags & BTREE_INSERT_GC_LOCK_HELD)
- lockdep_assert_held(&trans->c->gc_lock);
+ lockdep_assert_held(&c->gc_lock);
memset(&trans->journal_preres, 0, sizeof(trans->journal_preres));
trans->journal_u64s = trans->extra_journal_entry_u64s;
trans->journal_preres_u64s = 0;
+ trans->journal_transaction_names = READ_ONCE(c->opts.journal_transaction_names);
+
+ if (trans->journal_transaction_names)
+ trans->journal_u64s += JSET_ENTRY_LOG_U64s;
+
if (!(trans->flags & BTREE_INSERT_NOCHECK_RW) &&
- unlikely(!percpu_ref_tryget(&trans->c->writes))) {
+ unlikely(!percpu_ref_tryget(&c->writes))) {
ret = bch2_trans_commit_get_rw_cold(trans);
if (ret)
goto out_reset;
}
if (trans->extra_journal_res) {
- ret = bch2_disk_reservation_add(trans->c, trans->disk_res,
+ ret = bch2_disk_reservation_add(c, trans->disk_res,
trans->extra_journal_res,
(trans->flags & BTREE_INSERT_NOFAIL)
? BCH_DISK_RESERVATION_NOFAIL : 0);
if (ret)
goto err;
out:
- bch2_journal_preres_put(&trans->c->journal, &trans->journal_preres);
+ bch2_journal_preres_put(&c->journal, &trans->journal_preres);
if (likely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
- percpu_ref_put(&trans->c->writes);
+ percpu_ref_put(&c->writes);
out_reset:
trans_for_each_update(trans, i)
bch2_path_put(trans, i->path, true);