1 Add support for tracking metadata blocks in the log.
3 From: Abutalib Aghayev <agayev@cs.cmu.edu>
5 This patch adds two important data structures, jmap and transaction_infos,
6 and supporting functions. Jmap is a map from a metadata block number to
7 the log block number. When a transaction commits, jmap is updated with new
8 mappings; when a block is revoked, the mapping for the block is removed
9 from the jmap. Transaction_infos is an array of transaction_info
10 structures that contain information about transactions currently present in
11 the log. It contains a linked list of live blocks in a transaction, and it
12 is updated after every commit to keep the list up-to-date.
13 Transaction_infos array will be used by the cleaner for identifying live
14 blocks and migrating them to appropriate location.
16 [ Modified by tytso to conditionalize changes on the JBD2_LAZY journal flag ]
18 Signed-off-by: Abutalib Aghayev <agayev@cs.cmu.edu>
19 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
21 fs/jbd2/Makefile | 3 +-
22 fs/jbd2/commit.c | 23 +++++
23 fs/jbd2/jmap.c | 458 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 fs/jbd2/journal.c | 17 +++-
25 include/linux/jbd2.h | 14 +++
26 include/linux/jmap.h | 131 +++++++++++++++++++++++++
27 include/trace/events/jbd2.h | 169 ++++++++++++++++++++++++++++++++
28 7 files changed, 810 insertions(+), 5 deletions(-)
30 diff --git a/fs/jbd2/Makefile b/fs/jbd2/Makefile
31 index 802a3413872a..a54f50b3a06e 100644
32 --- a/fs/jbd2/Makefile
33 +++ b/fs/jbd2/Makefile
36 obj-$(CONFIG_JBD2) += jbd2.o
38 -jbd2-objs := transaction.o commit.o recovery.o checkpoint.o revoke.o journal.o
39 +jbd2-objs := transaction.o commit.o recovery.o checkpoint.o revoke.o journal.o \
41 diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
42 index 8c514367ba5a..50e1a0b375c5 100644
43 --- a/fs/jbd2/commit.c
44 +++ b/fs/jbd2/commit.c
45 @@ -362,6 +362,8 @@ void jbd2_journal_commit_transaction(journal_t *journal)
48 unsigned long long blocknr;
49 + struct blk_mapping *mappings = NULL;
50 + struct blk_mapping *map_ptr = NULL;
54 @@ -563,6 +565,14 @@ void jbd2_journal_commit_transaction(journal_t *journal)
55 J_ASSERT(commit_transaction->t_nr_buffers <=
56 atomic_read(&commit_transaction->t_outstanding_credits));
58 + if (journal->j_flags & JBD2_LAZY) {
59 + int nr_mappings = commit_transaction->t_nr_buffers;
61 + map_ptr = mappings = kmalloc(sizeof(*mappings) * nr_mappings, GFP_NOFS);
63 + jbd2_journal_abort(journal, -ENOMEM);
69 @@ -661,6 +671,11 @@ void jbd2_journal_commit_transaction(journal_t *journal)
72 jbd2_file_log_bh(&io_bufs, wbuf[bufs]);
74 + map_ptr->fsblk = jh2bh(jh)->b_blocknr;
75 + map_ptr->logblk = blocknr;
79 /* Record the new block's tag in the current descriptor
81 @@ -895,6 +910,14 @@ void jbd2_journal_commit_transaction(journal_t *journal)
82 transaction can be removed from any checkpoint list it was on
86 + err = jbd2_transaction_infos_add(journal, commit_transaction,
87 + mappings, map_ptr - mappings);
89 + jbd2_journal_abort(journal, -ENOMEM);
93 jbd_debug(3, "JBD2: commit phase 6\n");
95 J_ASSERT(list_empty(&commit_transaction->t_inode_list));
96 diff --git a/fs/jbd2/jmap.c b/fs/jbd2/jmap.c
98 index 000000000000..d95346084aef
102 +#include <linux/blk_types.h>
103 +#include <linux/jbd2.h>
104 +#include <linux/jmap.h>
105 +#include <trace/events/jbd2.h>
107 +static struct kmem_cache *jbd2_jmap_cache;
109 +int jbd2_journal_init_jmap_cache(void)
111 + jbd2_jmap_cache = KMEM_CACHE(jmap_entry, SLAB_RECLAIM_ACCOUNT);
112 + if (!jbd2_jmap_cache)
117 +void jbd2_journal_destroy_jmap_cache(void)
119 + kmem_cache_destroy(jbd2_jmap_cache);
120 + jbd2_jmap_cache = NULL;
124 + * Allocate an array of transaction_info structures and initialize the list
125 + * heads inside them.
127 +int jbd2_init_transaction_infos(journal_t *journal)
130 + struct transaction_infos *tis = kzalloc(sizeof(*tis), GFP_KERNEL);
134 + tis->buf = kzalloc(sizeof(*tis->buf) * MAX_LIVE_TRANSACTIONS,
141 + for (i = 0; i < MAX_LIVE_TRANSACTIONS; ++i)
142 + INIT_LIST_HEAD(&tis->buf[i].live_logblks);
144 + journal->j_transaction_infos = tis;
149 + * Free the array of transaction_info structures.
151 +void jbd2_free_transaction_infos(journal_t *journal)
153 + struct transaction_infos *tis = journal->j_transaction_infos;
161 + * Fill an entry to be stored in jmap.
163 +static void fill_entry(struct jmap_entry *entry, struct blk_mapping *mapping,
164 + int t_idx, struct list_head *list)
166 + entry->mapping = *mapping;
167 + entry->fsblk_last_modified = jiffies;
168 + entry->t_idx = t_idx;
169 + list_add(&entry->list, list);
173 + * A helper function for jbd2_transaction_infos_add. Scans through the mappings
174 + * array, dropping revoked entries from jmap and updating existing entries.
175 + * Moves the new mappings to the beginning of the mappings array and returns the
176 + * number of new mappings. Should be called with a write lock on j_jmap_lock.
178 +static int process_existing_mappings(journal_t *journal,
179 + struct transaction_info *ti, int t_idx,
180 + struct blk_mapping *mappings, int nr_mappings)
182 + struct jmap_entry *je;
185 + for (i = 0; i < nr_mappings; ++i) {
186 + je = jbd2_jmap_lookup(journal, mappings[i].fsblk, __func__);
188 + mappings[nr_new++] = mappings[i];
192 + * We are either deleting the entry because it was revoked, or
193 + * we are moving it to the live blocks list of this transaction.
194 + * In either case, we remove it from its existing list.
196 + list_del(&je->list);
199 + rb_erase(&je->rb_node, &journal->j_jmap);
200 + kmem_cache_free(jbd2_jmap_cache, je);
202 + trace_jbd2_jmap_replace(je, &mappings[i], t_idx);
203 + fill_entry(je, &mappings[i], t_idx, &ti->live_logblks);
210 + * A helper function for jbd2_transaction_infos_add. Allocates an array of
211 + * jmap_entry structures and returns the pointer to array if successful.
212 + * Otherwise, returns NULL.
214 +static struct jmap_entry **alloc_jmap_entries(int nr_entries)
216 + struct jmap_entry **jmap_entries;
219 + jmap_entries = kmalloc(sizeof(struct jmap_entry *) * nr_entries,
224 + for (i = 0; i < nr_entries; i++) {
225 + jmap_entries[i] = kmem_cache_zalloc(jbd2_jmap_cache, GFP_NOFS);
226 + if (!jmap_entries[i])
229 + return jmap_entries;
232 + for (i = 0; i < nr_entries && jmap_entries[i]; ++i)
233 + kmem_cache_free(jbd2_jmap_cache, jmap_entries[i]);
234 + kfree(jmap_entries);
239 + * A helper function for jbd2_transaction_infos_add. Adds new mappings to jmap
240 + * and updates the linked list of live logblks of the new transaction. Should
241 + * be called with write lock on j_jmap_lock.
243 +static void add_new_mappings(journal_t *journal, struct transaction_info *ti,
244 + int t_idx, struct blk_mapping *mappings,
245 + struct jmap_entry **new_entries, int nr_new)
247 + struct rb_node **p;
248 + struct rb_node *parent = NULL;
249 + struct jmap_entry *je;
252 + for (i = 0; i < nr_new; ++i) {
253 + p = &journal->j_jmap.rb_node;
256 + je = rb_entry(parent, struct jmap_entry, rb_node);
258 + if (mappings[i].fsblk < je->mapping.fsblk)
259 + p = &(*p)->rb_left;
260 + else if (mappings[i].fsblk > je->mapping.fsblk)
261 + p = &(*p)->rb_right;
265 + fill_entry(new_entries[i], &mappings[i], t_idx,
266 + &ti->live_logblks);
267 + rb_link_node(&new_entries[i]->rb_node, parent, p);
268 + rb_insert_color(&new_entries[i]->rb_node, &journal->j_jmap);
269 + trace_jbd2_jmap_insert(&mappings[i], t_idx);
274 + * This function is called after a transaction commits. It adds new
275 + * transaction_info structure to transaction_infos and populates jmap map with
276 + * the new mappings that are part of the committed transaction. It also adds
277 + * all the mappings to the linked list that is part of the transaction_info
280 +int jbd2_transaction_infos_add(journal_t *journal, transaction_t *transaction,
281 + struct blk_mapping *mappings, int nr_mappings)
283 + struct transaction_infos *tis = journal->j_transaction_infos;
284 + int t_idx = tis->head;
285 + struct transaction_info *ti = &tis->buf[t_idx];
286 + struct jmap_entry **new_entries = NULL;
290 + * We are possibly reusing space of an old transaction_info. The old
291 + * transaction should not have any live blocks in it.
293 + BUG_ON(!list_empty(&ti->live_logblks));
295 + write_lock(&journal->j_jmap_lock);
296 + nr_new = process_existing_mappings(journal, ti, t_idx, mappings,
298 + write_unlock(&journal->j_jmap_lock);
303 + new_entries = alloc_jmap_entries(nr_new);
307 + write_lock(&journal->j_jmap_lock);
308 + add_new_mappings(journal, ti, t_idx, mappings, new_entries, nr_new);
309 + write_unlock(&journal->j_jmap_lock);
311 + kfree(new_entries);
314 + write_lock(&journal->j_jmap_lock);
315 + ti->tid = transaction->t_tid;
316 + ti->offset = transaction->t_log_start;
317 + tis->head = (tis->head + 1) & (MAX_LIVE_TRANSACTIONS - 1);
318 + write_unlock(&journal->j_jmap_lock);
320 + trace_jbd2_transaction_infos_add(t_idx, ti, nr_mappings);
325 + * Look up fsblk in the jmap and return the corresponding jmap entry if found.
326 + * Should be called with a read lock on j_jmap_lock.
328 +struct jmap_entry *jbd2_jmap_lookup(journal_t *journal, sector_t fsblk,
335 + for (p = journal->j_jmap.rb_node; p; ) {
336 + struct jmap_entry *je = rb_entry(p, struct jmap_entry, rb_node);
337 + if (je->mapping.fsblk > fsblk)
339 + else if (je->mapping.fsblk < fsblk)
342 + trace_jbd2_jmap_lookup(fsblk, je->mapping.logblk, func);
346 + trace_jbd2_jmap_lookup(fsblk, 0, func);
351 + * Revoke a mapping for the fsblk in the jmap. A lookup for fsblk will return
352 + * NULL and the mapping will be removed from the jmap during commit, unless
353 + * fsblk is reallocated as a metadata block.
355 +void jbd2_jmap_revoke(journal_t *journal, sector_t fsblk)
357 + struct jmap_entry *je;
359 + write_lock(&journal->j_jmap_lock);
360 + je = jbd2_jmap_lookup(journal, fsblk, __func__);
362 + * For now, since we do not construct jmap from the journal, it is
363 + * possible that a metadata block that was revoked is not in the jmap.
364 + * Eventually, this should not be the case and we should have a
365 + * BUG_ON(!je) here.
368 + BUG_ON(je->revoked);
369 + je->revoked = true;
371 + write_unlock(&journal->j_jmap_lock);
375 + * Cancel a revoke for the fsblk in the jmap.
377 +void jbd2_jmap_cancel_revoke(journal_t *journal, sector_t fsblk)
379 + struct jmap_entry *je;
381 + write_lock(&journal->j_jmap_lock);
382 + je = jbd2_jmap_lookup(journal, fsblk, __func__);
384 + BUG_ON(!je->revoked);
385 + je->revoked = false;
386 + write_unlock(&journal->j_jmap_lock);
390 + * Read bh from its most up-to-date location, either from the file system or
393 + * If there is no mapping for the bh in jmap, this function acts like submit_bh.
394 + * Otherwise, it submits a read for the block pointed by the mapping located in
395 + * the log. Upon completion, bh will be filled with the contents of the block
396 + * read from the log.
398 +void jbd2_submit_bh(journal_t *journal, int rw, int op_flags,
399 + struct buffer_head *bh, const char *func)
401 + sector_t fsblk = bh->b_blocknr;
403 + struct jmap_entry *je;
405 + BUG_ON(!buffer_locked(bh));
407 + if (!journal || !(journal->j_flags & JBD2_LAZY)) {
408 + submit_bh(rw, op_flags, bh);
412 + read_lock(&journal->j_jmap_lock);
413 + je = jbd2_jmap_lookup(journal, fsblk, func);
415 + read_unlock(&journal->j_jmap_lock);
416 + submit_bh(rw, op_flags, bh);
419 + logblk = je->mapping.logblk;
420 + read_unlock(&journal->j_jmap_lock);
422 + BUG_ON(rw == WRITE);
423 + read_block_from_log(journal, bh, op_flags, logblk);
425 +EXPORT_SYMBOL(jbd2_submit_bh);
428 + * End_io handler for read_block_from_log that copies the contents of
429 + * log_bh read from log to the embedded bh.
431 +static void jbd2_end_log_read(struct buffer_head *log_bh, int uptodate)
433 + struct buffer_head *bh = log_bh->b_private;
436 + trace_jbd2_jmap_printf1("read from log", bh->b_blocknr);
437 + memcpy(bh->b_data, log_bh->b_data, log_bh->b_size);
439 + trace_jbd2_jmap_printf1("failed to read from log", bh->b_blocknr);
442 + unlock_buffer(log_bh);
446 + bh->b_end_io(bh, uptodate);
450 + * This function fills |bh| with the contents of the |blk|. Assume
451 + * jmap maps metadata block 123 to log block 100123. To read the
452 + * metadata block 123, we obtain a buffer head for it and call
453 + * read_block_from_log passing the obtained buffer head as |bh| and
454 + * 100123 as |blk|. If block 100123 is cached, then we copy the
455 + * contents to |bh| and return. Otherwise, we submit a request and
456 + * end_io handler copies the contents of block 100123 to |bh|.
457 + * Returns -ENOMEM if getblk fails, 1 if block is not cached, 0 if
460 +int read_block_from_log(journal_t *journal, struct buffer_head *bh,
461 + int op_flags, sector_t blk)
463 + struct buffer_head *log_bh;
465 + BUG_ON(!buffer_locked(bh));
467 + log_bh = __getblk(journal->j_fs_dev, blk, bh->b_size);
468 + if (unlikely(!log_bh)) {
469 + bh->b_end_io(bh, 0);
473 + lock_buffer(log_bh);
474 + if (buffer_uptodate(log_bh)) {
475 + memcpy(bh->b_data, log_bh->b_data, bh->b_size);
476 + unlock_buffer(log_bh);
478 + bh->b_end_io(bh, 1);
482 + log_bh->b_end_io = jbd2_end_log_read;
483 + log_bh->b_private = bh;
485 + submit_bh(READ, op_flags, log_bh);
490 + * Copy of ll_rw_block that uses jbd2_submit_bh instead of submit_bh.
492 +void jbd2_ll_rw_block(journal_t *journal, int rw, int op_flags,
493 + int nr, struct buffer_head *bhs[], const char *func)
497 + for (i = 0; i < nr; i++) {
498 + struct buffer_head *bh = bhs[i];
500 + if (!trylock_buffer(bh))
502 + BUG_ON(rw == WRITE);
503 + if (!buffer_uptodate(bh)) {
504 + bh->b_end_io = end_buffer_read_sync;
506 + jbd2_submit_bh(journal, rw, op_flags, bh, func);
512 +EXPORT_SYMBOL(jbd2_ll_rw_block);
515 + * Copy of bh_submit_read that uses jbd2_submit_bh instead of submit_bh.
517 +int jbd2_bh_submit_read(journal_t *journal, struct buffer_head *bh,
520 + BUG_ON(!buffer_locked(bh));
522 + if (buffer_uptodate(bh)) {
528 + bh->b_end_io = end_buffer_read_sync;
529 + jbd2_submit_bh(journal, READ, 0, bh, func);
530 + wait_on_buffer(bh);
531 + if (buffer_uptodate(bh))
535 +EXPORT_SYMBOL(jbd2_bh_submit_read);
537 +int jbd2_smr_journal_init(journal_t *journal)
539 + journal->j_jmap = RB_ROOT;
540 + rwlock_init(&journal->j_jmap_lock);
541 + return jbd2_init_transaction_infos(journal);
544 +void jbd2_smr_journal_exit(journal_t *journal)
546 + jbd2_free_transaction_infos(journal);
549 +void jbd2_sb_breadahead(journal_t *journal, struct super_block *sb,
552 + struct buffer_head *bh = __getblk(sb->s_bdev, block, sb->s_blocksize);
554 + jbd2_ll_rw_block(journal, REQ_OP_READ, REQ_RAHEAD, 1,
559 +EXPORT_SYMBOL(jbd2_sb_breadahead);
560 diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
561 index eae93cdfbaa7..77a44c86ccc2 100644
562 --- a/fs/jbd2/journal.c
563 +++ b/fs/jbd2/journal.c
564 @@ -1120,15 +1120,17 @@ static journal_t *journal_init_common(struct block_device *bdev,
565 journal->j_max_batch_time = 15000; /* 15ms */
566 atomic_set(&journal->j_reserved_credits, 0);
568 + err = jbd2_smr_journal_init(journal);
572 /* The journal is marked for error until we succeed with recovery! */
573 journal->j_flags = JBD2_ABORT;
575 /* Set up a default-sized revoke table for the new mount. */
576 err = jbd2_journal_init_revoke(journal, JOURNAL_REVOKE_DEFAULT_HASH);
584 spin_lock_init(&journal->j_history_lock);
586 @@ -1162,6 +1164,9 @@ static journal_t *journal_init_common(struct block_device *bdev,
587 journal->j_superblock = (journal_superblock_t *)bh->b_data;
595 /* jbd2_journal_init_dev and jbd2_journal_init_inode:
596 @@ -1741,6 +1746,7 @@ int jbd2_journal_destroy(journal_t *journal)
597 jbd2_journal_destroy_revoke(journal);
598 if (journal->j_chksum_driver)
599 crypto_free_shash(journal->j_chksum_driver);
600 + jbd2_smr_journal_exit(journal);
601 kfree(journal->j_wbuf);
604 @@ -2641,6 +2647,8 @@ static int __init journal_init_caches(void)
605 ret = jbd2_journal_init_handle_cache();
607 ret = jbd2_journal_init_transaction_cache();
609 + ret = jbd2_journal_init_jmap_cache();
613 @@ -2650,6 +2658,7 @@ static void jbd2_journal_destroy_caches(void)
614 jbd2_journal_destroy_journal_head_cache();
615 jbd2_journal_destroy_handle_cache();
616 jbd2_journal_destroy_transaction_cache();
617 + jbd2_journal_destroy_jmap_cache();
618 jbd2_journal_destroy_slabs();
621 diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
622 index 9a07b0485784..771588026353 100644
623 --- a/include/linux/jbd2.h
624 +++ b/include/linux/jbd2.h
626 #include <linux/types.h>
627 #include <linux/buffer_head.h>
628 #include <linux/journal-head.h>
629 +#include <linux/jmap.h>
630 #include <linux/stddef.h>
631 #include <linux/mutex.h>
632 #include <linux/timer.h>
633 @@ -732,6 +733,9 @@ jbd2_time_diff(unsigned long start, unsigned long end)
635 * @j_sb_buffer: First part of superblock buffer
636 * @j_superblock: Second part of superblock buffer
637 + * @j_map: A map from file system blocks to log blocks
638 + * @j_transaction_infos: An array of information structures per live transaction
639 + * @j_map_lock: Protect j_jmap and j_transaction_infos
640 * @j_format_version: Version of the superblock format
641 * @j_state_lock: Protect the various scalars in the journal
642 * @j_barrier_count: Number of processes waiting to create a barrier lock
643 @@ -807,6 +811,15 @@ struct journal_s
644 struct buffer_head *j_sb_buffer;
645 journal_superblock_t *j_superblock;
647 + /* A map from file system blocks to journal blocks */
648 + struct rb_root j_jmap;
650 + /* An array of housekeeping information about live transactions */
651 + struct transaction_infos *j_transaction_infos;
653 + /* Protect j_jmap and j_transaction_infos */
654 + rwlock_t j_jmap_lock;
656 /* Version of the superblock format */
657 int j_format_version;
659 @@ -1129,6 +1142,7 @@ JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
661 #define JBD2_REC_ERR 0x080 /* The errno in the sb has been recorded */
662 #define JBD2_NO_CLEANUP 0x100 /* Don't flush empty the journal on shutdown */
663 +#define JBD2_LAZY 0x200 /* Do lazy journalling */
666 * Function declarations for the journaling transaction and buffer
667 diff --git a/include/linux/jmap.h b/include/linux/jmap.h
669 index 000000000000..a602ece7cc89
671 +++ b/include/linux/jmap.h
673 +#ifndef _LINUX_JMAP_H
674 +#define _LINUX_JMAP_H
676 +#include <linux/buffer_head.h>
677 +#include <linux/journal-head.h>
678 +#include <linux/list.h>
679 +#include <linux/circ_buf.h>
682 + * Maximum number of transactions. This guides the size of the circular buffer
683 + * in which we store housekeeping information per transaction. We start
684 + * cleaning either when the circular buffer is full or when we hit the free
685 + * space threshold, whichever happens first. For starters, we make this
686 + * constant large to make sure that we start cleaning only when we hit the free
687 + * space threshold. Later we can empirically determine a sensible value.
689 +#define MAX_LIVE_TRANSACTIONS 65536
692 + * Forward declaration for journal_t so that we don't get circular dependency
693 + * between jbd2.h and jmap.h
696 +typedef struct journal_s journal_t;
699 + * A mapping from file system block to log block.
701 +struct blk_mapping {
707 + * An RB-tree entry wrapper for blk_mapping with extra housekeeping information.
710 + struct rb_node rb_node;
712 + /* The actual mapping information. */
713 + struct blk_mapping mapping;
716 + * If a block that is mapped gets deleted, the revoked bit is set. A
717 + * lookup for a deleted block fails. If a deleted block gets
718 + * re-allocated as a metadata block, the mapping is updated and revoked
724 + * All log blocks that are part of the same transaction in the log are
725 + * chained with a linked list. The root of the list is stored in the
726 + * transaction_info structure described below.
728 + struct list_head list;
731 + * The last time when fsblk was written again to the journal and
732 + * therefore was remapped to a different log block.
734 + unsigned long fsblk_last_modified;
737 + * Index of the transaction in the transaction_info_buffer (described
738 + * below) of which the log block is part of.
744 + * Housekeeping information about committed transaction.
746 +struct transaction_info {
747 + /* Id of the transaction */
750 + /* Offset where the transaction starts in the log */
754 + * A list of live log blocks referenced in the RB-tree that belong to
755 + * this transaction. It is used during cleaning to locate live blocks
756 + * and migrate them to appropriate location. If this list is empty,
757 + * then the transaction does not contain any live blocks and we can
758 + * reuse its space. If this list is not empty, then we can quickly
759 + * locate all the live blocks in this transaction.
761 + struct list_head live_logblks;
765 + * An array of transaction_info structures about all the transactions in the
766 + * log. Since there can only be a limited number of transactions in the log, we
767 + * use a circular buffer to store housekeeping information about transactions.
769 +struct transaction_infos {
770 + struct transaction_info *buf;
775 +extern int jbd2_smr_journal_init(journal_t *journal);
776 +extern void jbd2_smr_journal_exit(journal_t *journal);
778 +extern int jbd2_journal_init_jmap_cache(void);
779 +extern void jbd2_journal_destroy_jmap_cache(void);
781 +extern int jbd2_init_transaction_infos(journal_t *journal);
782 +extern void jbd2_free_transaction_infos(journal_t *journal);
783 +extern int jbd2_transaction_infos_add(journal_t *journal,
784 + transaction_t *transaction,
785 + struct blk_mapping *mappings,
788 +extern struct jmap_entry *jbd2_jmap_lookup(journal_t *journal, sector_t fsblk,
790 +extern void jbd2_jmap_revoke(journal_t *journal, sector_t fsblk);
791 +extern void jbd2_jmap_cancel_revoke(journal_t *journal, sector_t fsblk);
792 +extern void jbd2_submit_bh(journal_t *journal, int rw, int op_flags,
793 + struct buffer_head *bh, const char *func);
794 +extern int read_block_from_log(journal_t *journal, struct buffer_head *bh,
795 + int op_flags, sector_t blk);
796 +extern void jbd2_ll_rw_block(journal_t *journal, int rw, int op_flags, int nr,
797 + struct buffer_head *bhs[], const char *func);
798 +extern int jbd2_bh_submit_read(journal_t *journal, struct buffer_head *bh,
800 +extern void jbd2_sb_breadahead(journal_t *journal, struct super_block *sb,
804 diff --git a/include/trace/events/jbd2.h b/include/trace/events/jbd2.h
805 index c1d1f3eb242d..bc1511a425ec 100644
806 --- a/include/trace/events/jbd2.h
807 +++ b/include/trace/events/jbd2.h
808 @@ -379,6 +379,175 @@ TRACE_EVENT(jbd2_lock_buffer_stall,
812 +TRACE_EVENT(jbd2_jmap_replace,
814 + TP_PROTO(struct jmap_entry *jentry, struct blk_mapping *mapping, \
817 + TP_ARGS(jentry, mapping, t_idx),
820 + __field(sector_t, fsblk )
821 + __field(sector_t, old_logblk )
822 + __field(sector_t, new_logblk )
823 + __field(int, old_t_idx )
824 + __field(int, new_t_idx )
828 + __entry->fsblk = mapping->fsblk;
829 + __entry->old_logblk = jentry->mapping.logblk;
830 + __entry->new_logblk = mapping->logblk;
831 + __entry->old_t_idx = jentry->t_idx;
832 + __entry->new_t_idx = t_idx;
835 + TP_printk("remap %llu from %llu to %llu, move from transaction at index %d to transaction at index %d",
836 + (unsigned long long) __entry->fsblk,
837 + (unsigned long long) __entry->old_logblk,
838 + (unsigned long long) __entry->new_logblk,
839 + __entry->old_t_idx,
840 + __entry->new_t_idx)
843 +TRACE_EVENT(jbd2_jmap_insert,
845 + TP_PROTO(struct blk_mapping *mapping, int t_idx),
847 + TP_ARGS(mapping, t_idx),
850 + __field(sector_t, fsblk )
851 + __field(sector_t, logblk)
852 + __field(int, t_idx)
856 + __entry->fsblk = mapping->fsblk;
857 + __entry->logblk = mapping->logblk;
858 + __entry->t_idx = t_idx;
861 + TP_printk("map %llu to %llu, insert to transaction %d",
862 + (unsigned long long) __entry->fsblk,
863 + (unsigned long long) __entry->logblk,
867 +TRACE_EVENT(jbd2_jmap_lookup,
869 + TP_PROTO(sector_t fsblk, sector_t logblk, const char *func),
871 + TP_ARGS(fsblk, logblk, func),
874 + __field(sector_t, fsblk )
875 + __field(sector_t, logblk)
876 + __string(func, func)
880 + __entry->fsblk = fsblk;
881 + __entry->logblk = logblk;
882 + __assign_str(func, func);
885 + TP_printk("%s: lookup %llu -> %llu",
887 + (unsigned long long) __entry->fsblk,
888 + (unsigned long long) __entry->logblk)
891 +TRACE_EVENT(jbd2_jmap_printf,
893 + TP_PROTO(const char *s),
902 + __assign_str(s, s);
909 +TRACE_EVENT(jbd2_jmap_printf1,
911 + TP_PROTO(const char *s, sector_t fsblk),
917 + __field(sector_t, fsblk )
921 + __assign_str(s, s);
922 + __entry->fsblk = fsblk;
925 + TP_printk("%s: %llu",
927 + (unsigned long long) __entry->fsblk)
930 +TRACE_EVENT(jbd2_jmap_printf2,
932 + TP_PROTO(const char *s, sector_t fsblk, sector_t logblk),
934 + TP_ARGS(s, fsblk, logblk),
938 + __field(sector_t, fsblk )
939 + __field(sector_t, logblk)
943 + __assign_str(s, s);
944 + __entry->fsblk = fsblk;
945 + __entry->logblk = logblk;
948 + TP_printk("%s: %llu:%llu",
950 + (unsigned long long) __entry->fsblk,
951 + (unsigned long long) __entry->logblk)
954 +TRACE_EVENT(jbd2_transaction_infos_add,
956 + TP_PROTO(int t_idx, struct transaction_info *ti, int nr_mappings),
958 + TP_ARGS(t_idx, ti, nr_mappings),
961 + __field(int, t_idx )
962 + __field(tid_t, tid )
963 + __field(sector_t, offset)
964 + __field(int, nr_mappings)
968 + __entry->t_idx = t_idx;
969 + __entry->tid = ti->tid;
970 + __entry->offset = ti->offset;
971 + __entry->nr_mappings = nr_mappings;
974 + TP_printk("inserted transaction %u (offset %llu) at index %d with %d mappings",
976 + (unsigned long long) __entry->offset,
978 + __entry->nr_mappings)
981 #endif /* _TRACE_JBD2_H */
983 /* This part must be outside protection */