1 Add indirection to metadata read paths
3 From: Abutalib Aghayev <agayev@cs.cmu.edu>
5 Change all metadata block reads to use jmap-aware function that first looks
6 up the metadata block in the jmap. If lookup is successful, the function
7 reads the corresponding log block from the journal and copies it to the
8 metadata block buffer head. Otherwise, it reads the metadata block from
9 the file system, just like standard jmap-unaware function.
11 Signed-off-by: Abutalib Aghayev <agayev@cs.cmu.edu>
14 fs/ext4/extents.c | 3 ++-
15 fs/ext4/ialloc.c | 5 ++++-
16 fs/ext4/indirect.c | 3 ++-
17 fs/ext4/inode.c | 8 ++++++--
18 fs/ext4/move_extent.c | 3 ++-
19 fs/ext4/namei.c | 8 +++++---
20 fs/ext4/resize.c | 4 +++-
21 fs/jbd2/jmap.c | 17 ++++++++++-------
22 8 files changed, 34 insertions(+), 17 deletions(-)
24 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
25 index c930a0110fb4..aea6e67d9037 100644
26 --- a/fs/ext4/extents.c
27 +++ b/fs/ext4/extents.c
28 @@ -517,6 +517,7 @@ __read_extent_tree_block(const char *function, unsigned int line,
30 struct buffer_head *bh;
32 + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
34 bh = sb_getblk_gfp(inode->i_sb, pblk, __GFP_MOVABLE | GFP_NOFS);
36 @@ -524,7 +525,7 @@ __read_extent_tree_block(const char *function, unsigned int line,
38 if (!bh_uptodate_or_lock(bh)) {
39 trace_ext4_ext_load_extent(inode, pblk, _RET_IP_);
40 - err = bh_submit_read(bh);
41 + err = jbd2_bh_submit_read(journal, bh, __func__);
45 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
46 index 170421edfdfe..919c2d114fb5 100644
47 --- a/fs/ext4/ialloc.c
48 +++ b/fs/ext4/ialloc.c
51 #include <linux/time.h>
53 +#include <linux/jbd2.h>
54 #include <linux/stat.h>
55 #include <linux/string.h>
56 #include <linux/quotaops.h>
57 @@ -160,6 +161,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
58 struct buffer_head *bh = NULL;
59 ext4_fsblk_t bitmap_blk;
61 + journal_t *journal = EXT4_SB(sb)->s_journal;
63 desc = ext4_get_group_desc(sb, block_group, NULL);
65 @@ -214,7 +216,8 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
66 trace_ext4_load_inode_bitmap(sb, block_group);
67 bh->b_end_io = ext4_end_bitmap_read;
69 - submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
70 + jbd2_submit_bh(journal, REQ_OP_READ, REQ_META | REQ_PRIO, bh, __func__);
73 if (!buffer_uptodate(bh)) {
75 diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
76 index bc15c2c17633..21531ef4a182 100644
77 --- a/fs/ext4/indirect.c
78 +++ b/fs/ext4/indirect.c
79 @@ -145,6 +145,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
80 Indirect chain[4], int *err)
82 struct super_block *sb = inode->i_sb;
83 + journal_t *journal = EXT4_SB(sb)->s_journal;
85 struct buffer_head *bh;
87 @@ -162,7 +163,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
90 if (!bh_uptodate_or_lock(bh)) {
91 - if (bh_submit_read(bh) < 0) {
92 + if (jbd2_bh_submit_read(journal, bh, __func__) < 0) {
96 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
97 index 9c064727ed62..0e2f7c3b499e 100644
100 @@ -989,13 +989,15 @@ struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
101 ext4_lblk_t block, int map_flags)
103 struct buffer_head *bh;
104 + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
106 bh = ext4_getblk(handle, inode, block, map_flags);
109 if (!bh || buffer_uptodate(bh))
111 - ll_rw_block(REQ_OP_READ, REQ_META | REQ_PRIO, 1, &bh);
112 + jbd2_ll_rw_block(journal, REQ_OP_READ, REQ_META | REQ_PRIO, 1, &bh,
115 if (buffer_uptodate(bh))
117 @@ -4201,6 +4203,7 @@ static int __ext4_get_inode_loc(struct inode *inode,
118 struct super_block *sb = inode->i_sb;
120 int inodes_per_block, inode_offset;
121 + journal_t *journal = EXT4_SB(sb)->s_journal;
124 if (!ext4_valid_inum(sb, inode->i_ino))
125 @@ -4316,7 +4319,8 @@ static int __ext4_get_inode_loc(struct inode *inode,
126 trace_ext4_load_inode(inode);
128 bh->b_end_io = end_buffer_read_sync;
129 - submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
130 + jbd2_submit_bh(journal, REQ_OP_READ, REQ_META | REQ_PRIO, bh,
133 if (!buffer_uptodate(bh)) {
134 EXT4_ERROR_INODE_BLOCK(inode, block,
135 diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
136 index 6fc14def0c70..b6c25638f5f4 100644
137 --- a/fs/ext4/move_extent.c
138 +++ b/fs/ext4/move_extent.c
139 @@ -177,6 +177,7 @@ static int
140 mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
142 struct inode *inode = page->mapping->host;
143 + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
145 struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE];
146 unsigned int blocksize, block_start, block_end;
147 @@ -225,7 +226,7 @@ mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
148 for (i = 0; i < nr; i++) {
150 if (!bh_uptodate_or_lock(bh)) {
151 - err = bh_submit_read(bh);
152 + err = jbd2_bh_submit_read(journal, bh, __func__);
156 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
157 index 104f8bfba718..9c23616e7702 100644
158 --- a/fs/ext4/namei.c
159 +++ b/fs/ext4/namei.c
160 @@ -1361,6 +1361,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
161 struct buffer_head *bh_use[NAMEI_RA_SIZE];
162 struct buffer_head *bh, *ret = NULL;
163 ext4_lblk_t start, block, b;
164 + journal_t *journal;
165 const u8 *name = d_name->name;
166 int ra_max = 0; /* Number of bh's in the readahead
168 @@ -1373,6 +1374,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
172 + journal = EXT4_SB(sb)->s_journal;
173 namelen = d_name->len;
174 if (namelen > EXT4_NAME_LEN)
176 @@ -1449,9 +1451,9 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
180 - ll_rw_block(REQ_OP_READ,
181 - REQ_META | REQ_PRIO,
183 + jbd2_ll_rw_block(journal, REQ_OP_READ,
184 + REQ_META | REQ_PRIO,
188 if ((bh = bh_use[ra_ptr++]) == NULL)
189 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
190 index cf681004b196..4e8711abc333 100644
191 --- a/fs/ext4/resize.c
192 +++ b/fs/ext4/resize.c
193 @@ -1192,10 +1192,12 @@ static int ext4_add_new_descs(handle_t *handle, struct super_block *sb,
194 static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block)
196 struct buffer_head *bh = sb_getblk(sb, block);
197 + journal_t *journal = EXT4_SB(sb)->s_journal;
201 if (!bh_uptodate_or_lock(bh)) {
202 - if (bh_submit_read(bh) < 0) {
203 + if (jbd2_bh_submit_read(journal, bh, __func__) < 0) {
207 diff --git a/fs/jbd2/jmap.c b/fs/jbd2/jmap.c
208 index 7d7b4eb389ed..8c844f65eeaa 100644
211 @@ -87,17 +87,19 @@ static int process_existing_mappings(journal_t *journal,
212 mappings[nr_new++] = mappings[i];
216 + * We are either deleting the entry because it was revoked, or
217 + * we are moving it to the live blocks list of this transaction.
218 + * In either case, we remove it from its existing list.
220 + list_del(&je->list);
223 rb_erase(&je->rb_node, &journal->j_jmap);
224 kmem_cache_free(jbd2_jmap_cache, je);
227 - * Delete jmap entry from the old transaction's list
228 - * before adding it to the new transaction's list.
230 - list_del(&je->list);
231 - fill_entry(je, &mappings[i], t_idx, &ti->live_logblks);
232 trace_jbd2_jmap_replace(je, &mappings[i], t_idx);
233 + fill_entry(je, &mappings[i], t_idx, &ti->live_logblks);
237 @@ -141,12 +143,13 @@ static void add_new_mappings(journal_t *journal, struct transaction_info *ti,
238 int t_idx, struct blk_mapping *mappings,
239 struct jmap_entry **new_entries, int nr_new)
241 - struct rb_node **p = &journal->j_jmap.rb_node;
242 + struct rb_node **p;
243 struct rb_node *parent = NULL;
244 struct jmap_entry *je;
247 for (i = 0; i < nr_new; ++i) {
248 + p = &journal->j_jmap.rb_node;
251 je = rb_entry(parent, struct jmap_entry, rb_node);