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>
12 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14 fs/ext4/extents.c | 3 ++-
15 fs/ext4/ialloc.c | 5 ++++-
16 fs/ext4/indirect.c | 3 ++-
17 fs/ext4/inode.c | 20 ++++++++++++++------
18 fs/ext4/move_extent.c | 3 ++-
19 fs/ext4/resize.c | 4 +++-
20 6 files changed, 27 insertions(+), 11 deletions(-)
22 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
23 index 97f0fd06728d..47914c6a2556 100644
24 --- a/fs/ext4/extents.c
25 +++ b/fs/ext4/extents.c
26 @@ -517,6 +517,7 @@ __read_extent_tree_block(const char *function, unsigned int line,
28 struct buffer_head *bh;
30 + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
32 bh = sb_getblk_gfp(inode->i_sb, pblk, __GFP_MOVABLE | GFP_NOFS);
34 @@ -524,7 +525,7 @@ __read_extent_tree_block(const char *function, unsigned int line,
36 if (!bh_uptodate_or_lock(bh)) {
37 trace_ext4_ext_load_extent(inode, pblk, _RET_IP_);
38 - err = bh_submit_read(bh);
39 + err = jbd2_bh_submit_read(journal, bh, __func__);
43 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
44 index 507bfb3344d4..1c3447629e76 100644
45 --- a/fs/ext4/ialloc.c
46 +++ b/fs/ext4/ialloc.c
49 #include <linux/time.h>
51 +#include <linux/jbd2.h>
52 #include <linux/stat.h>
53 #include <linux/string.h>
54 #include <linux/quotaops.h>
55 @@ -162,6 +163,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
56 struct buffer_head *bh = NULL;
57 ext4_fsblk_t bitmap_blk;
59 + journal_t *journal = EXT4_SB(sb)->s_journal;
61 desc = ext4_get_group_desc(sb, block_group, NULL);
63 @@ -216,7 +218,8 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
64 trace_ext4_load_inode_bitmap(sb, block_group);
65 bh->b_end_io = ext4_end_bitmap_read;
67 - submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
68 + jbd2_submit_bh(journal, REQ_OP_READ, REQ_META | REQ_PRIO, bh, __func__);
71 if (!buffer_uptodate(bh)) {
73 diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
74 index 7ffa290cbb8e..06a79f5e563e 100644
75 --- a/fs/ext4/indirect.c
76 +++ b/fs/ext4/indirect.c
77 @@ -145,6 +145,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
78 Indirect chain[4], int *err)
80 struct super_block *sb = inode->i_sb;
81 + journal_t *journal = EXT4_SB(sb)->s_journal;
83 struct buffer_head *bh;
85 @@ -162,7 +163,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
88 if (!bh_uptodate_or_lock(bh)) {
89 - if (bh_submit_read(bh) < 0) {
90 + if (jbd2_bh_submit_read(journal, bh, __func__) < 0) {
94 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
95 index c774bdc22759..a56e717b39be 100644
98 @@ -1001,13 +1001,15 @@ struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
99 ext4_lblk_t block, int map_flags)
101 struct buffer_head *bh;
102 + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
104 bh = ext4_getblk(handle, inode, block, map_flags);
107 if (!bh || buffer_uptodate(bh))
109 - ll_rw_block(REQ_OP_READ, REQ_META | REQ_PRIO, 1, &bh);
110 + jbd2_ll_rw_block(journal, REQ_OP_READ, REQ_META | REQ_PRIO, 1, &bh,
113 if (buffer_uptodate(bh))
115 @@ -1020,6 +1022,7 @@ int ext4_bread_batch(struct inode *inode, ext4_lblk_t block, int bh_count,
116 bool wait, struct buffer_head **bhs)
119 + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
121 for (i = 0; i < bh_count; i++) {
122 bhs[i] = ext4_getblk(NULL, inode, block + i, 0 /* map_flags */);
123 @@ -1033,8 +1036,9 @@ int ext4_bread_batch(struct inode *inode, ext4_lblk_t block, int bh_count,
124 for (i = 0; i < bh_count; i++)
125 /* Note that NULL bhs[i] is valid because of holes. */
126 if (bhs[i] && !buffer_uptodate(bhs[i]))
127 - ll_rw_block(REQ_OP_READ, REQ_META | REQ_PRIO, 1,
129 + jbd2_ll_rw_block(journal, REQ_OP_READ,
130 + REQ_META | REQ_PRIO, 1, &bhs[i],
135 @@ -4448,6 +4452,7 @@ static int __ext4_get_inode_loc(struct inode *inode,
136 struct super_block *sb = inode->i_sb;
138 int inodes_per_block, inode_offset;
139 + journal_t *journal = EXT4_SB(sb)->s_journal;
142 if (!ext4_valid_inum(sb, inode->i_ino))
143 @@ -4551,8 +4556,10 @@ static int __ext4_get_inode_loc(struct inode *inode,
144 table += num / inodes_per_block;
148 - sb_breadahead(sb, b++);
151 + jbd2_sb_breadahead(journal, sb, b++);
156 @@ -4563,7 +4570,8 @@ static int __ext4_get_inode_loc(struct inode *inode,
157 trace_ext4_load_inode(inode);
159 bh->b_end_io = end_buffer_read_sync;
160 - submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
161 + jbd2_submit_bh(journal, REQ_OP_READ, REQ_META | REQ_PRIO, bh,
164 if (!buffer_uptodate(bh)) {
165 EXT4_ERROR_INODE_BLOCK(inode, block,
166 diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
167 index 9bb36909ec92..0f6c00d0df17 100644
168 --- a/fs/ext4/move_extent.c
169 +++ b/fs/ext4/move_extent.c
170 @@ -177,6 +177,7 @@ static int
171 mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
173 struct inode *inode = page->mapping->host;
174 + journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
176 struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE];
177 unsigned int blocksize, block_start, block_end;
178 @@ -225,7 +226,7 @@ mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
179 for (i = 0; i < nr; i++) {
181 if (!bh_uptodate_or_lock(bh)) {
182 - err = bh_submit_read(bh);
183 + err = jbd2_bh_submit_read(journal, bh, __func__);
187 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
188 index 035cd3f4785e..5c817953053b 100644
189 --- a/fs/ext4/resize.c
190 +++ b/fs/ext4/resize.c
191 @@ -1193,10 +1193,12 @@ static int ext4_add_new_descs(handle_t *handle, struct super_block *sb,
192 static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block)
194 struct buffer_head *bh = sb_getblk(sb, block);
195 + journal_t *journal = EXT4_SB(sb)->s_journal;
199 if (!bh_uptodate_or_lock(bh)) {
200 - if (bh_submit_read(bh) < 0) {
201 + if (jbd2_bh_submit_read(journal, bh, __func__) < 0) {