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 | 14 ++++++++++----
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, 38 insertions(+), 19 deletions(-)
24 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
25 index 2a97dff87b96..342e4f0c23db 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 b14bae2598bc..a095b8c1465a 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 831d025e59ad..f0a9f206c18f 100644
100 @@ -995,13 +995,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 @@ -4343,6 +4345,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 @@ -4446,8 +4449,10 @@ static int __ext4_get_inode_loc(struct inode *inode,
126 table += num / inodes_per_block;
130 - sb_breadahead(sb, b++);
133 + jbd2_sb_breadahead(journal, sb, b++);
138 @@ -4458,7 +4463,8 @@ static int __ext4_get_inode_loc(struct inode *inode,
139 trace_ext4_load_inode(inode);
141 bh->b_end_io = end_buffer_read_sync;
142 - submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
143 + jbd2_submit_bh(journal, REQ_OP_READ, REQ_META | REQ_PRIO, bh,
146 if (!buffer_uptodate(bh)) {
147 EXT4_ERROR_INODE_BLOCK(inode, block,
148 diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
149 index 6fc14def0c70..b6c25638f5f4 100644
150 --- a/fs/ext4/move_extent.c
151 +++ b/fs/ext4/move_extent.c
152 @@ -177,6 +177,7 @@ static int
153 mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
155 struct inode *inode = page->mapping->host;
156 + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
158 struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE];
159 unsigned int blocksize, block_start, block_end;
160 @@ -225,7 +226,7 @@ mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
161 for (i = 0; i < nr; i++) {
163 if (!bh_uptodate_or_lock(bh)) {
164 - err = bh_submit_read(bh);
165 + err = jbd2_bh_submit_read(journal, bh, __func__);
169 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
170 index 6ad612c576fc..0812a692db0f 100644
171 --- a/fs/ext4/namei.c
172 +++ b/fs/ext4/namei.c
173 @@ -1361,6 +1361,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
174 struct buffer_head *bh_use[NAMEI_RA_SIZE];
175 struct buffer_head *bh, *ret = NULL;
176 ext4_lblk_t start, block, b;
177 + journal_t *journal;
178 const u8 *name = d_name->name;
179 int ra_max = 0; /* Number of bh's in the readahead
181 @@ -1373,6 +1374,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
185 + journal = EXT4_SB(sb)->s_journal;
186 namelen = d_name->len;
187 if (namelen > EXT4_NAME_LEN)
189 @@ -1451,9 +1453,9 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
193 - ll_rw_block(REQ_OP_READ,
194 - REQ_META | REQ_PRIO,
196 + jbd2_ll_rw_block(journal, REQ_OP_READ,
197 + REQ_META | REQ_PRIO,
201 if ((bh = bh_use[ra_ptr++]) == NULL)
202 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
203 index c3ed9021b781..8406bca774c8 100644
204 --- a/fs/ext4/resize.c
205 +++ b/fs/ext4/resize.c
206 @@ -1193,10 +1193,12 @@ static int ext4_add_new_descs(handle_t *handle, struct super_block *sb,
207 static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block)
209 struct buffer_head *bh = sb_getblk(sb, block);
210 + journal_t *journal = EXT4_SB(sb)->s_journal;
214 if (!bh_uptodate_or_lock(bh)) {
215 - if (bh_submit_read(bh) < 0) {
216 + if (jbd2_bh_submit_read(journal, bh, __func__) < 0) {