add patch add-nombcache-mount-option
[ext4-patch-queue.git] / add-indirection-to-metadata-block-read-paths
blob49b933a3e6c21fd9dd06b6b24c74c3bcc38d68d6
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>
13 ---
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  7 files changed, 28 insertions(+), 12 deletions(-)
23 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
24 index 2a97dff87b96..342e4f0c23db 100644
25 --- a/fs/ext4/extents.c
26 +++ b/fs/ext4/extents.c
27 @@ -517,6 +517,7 @@ __read_extent_tree_block(const char *function, unsigned int line,
28  {
29         struct buffer_head              *bh;
30         int                             err;
31 +       journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
33         bh = sb_getblk_gfp(inode->i_sb, pblk, __GFP_MOVABLE | GFP_NOFS);
34         if (unlikely(!bh))
35 @@ -524,7 +525,7 @@ __read_extent_tree_block(const char *function, unsigned int line,
37         if (!bh_uptodate_or_lock(bh)) {
38                 trace_ext4_ext_load_extent(inode, pblk, _RET_IP_);
39 -               err = bh_submit_read(bh);
40 +               err = jbd2_bh_submit_read(journal, bh, __func__);
41                 if (err < 0)
42                         goto errout;
43         }
44 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
45 index b14bae2598bc..a095b8c1465a 100644
46 --- a/fs/ext4/ialloc.c
47 +++ b/fs/ext4/ialloc.c
48 @@ -14,6 +14,7 @@
50  #include <linux/time.h>
51  #include <linux/fs.h>
52 +#include <linux/jbd2.h>
53  #include <linux/stat.h>
54  #include <linux/string.h>
55  #include <linux/quotaops.h>
56 @@ -160,6 +161,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
57         struct buffer_head *bh = NULL;
58         ext4_fsblk_t bitmap_blk;
59         int err;
60 +       journal_t *journal = EXT4_SB(sb)->s_journal;
62         desc = ext4_get_group_desc(sb, block_group, NULL);
63         if (!desc)
64 @@ -214,7 +216,8 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
65         trace_ext4_load_inode_bitmap(sb, block_group);
66         bh->b_end_io = ext4_end_bitmap_read;
67         get_bh(bh);
68 -       submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
69 +       jbd2_submit_bh(journal, REQ_OP_READ, REQ_META | REQ_PRIO, bh, __func__);
71         wait_on_buffer(bh);
72         if (!buffer_uptodate(bh)) {
73                 put_bh(bh);
74 diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
75 index bc15c2c17633..21531ef4a182 100644
76 --- a/fs/ext4/indirect.c
77 +++ b/fs/ext4/indirect.c
78 @@ -145,6 +145,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
79                                  Indirect chain[4], int *err)
80  {
81         struct super_block *sb = inode->i_sb;
82 +       journal_t *journal = EXT4_SB(sb)->s_journal;
83         Indirect *p = chain;
84         struct buffer_head *bh;
85         int ret = -EIO;
86 @@ -162,7 +163,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
87                 }
89                 if (!bh_uptodate_or_lock(bh)) {
90 -                       if (bh_submit_read(bh) < 0) {
91 +                       if (jbd2_bh_submit_read(journal, bh, __func__) < 0) {
92                                 put_bh(bh);
93                                 goto failure;
94                         }
95 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
96 index 1908ac336ee5..374a9767a0ed 100644
97 --- a/fs/ext4/inode.c
98 +++ b/fs/ext4/inode.c
99 @@ -995,13 +995,15 @@ struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode,
100                                ext4_lblk_t block, int map_flags)
102         struct buffer_head *bh;
103 +       journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
105         bh = ext4_getblk(handle, inode, block, map_flags);
106         if (IS_ERR(bh))
107                 return bh;
108         if (!bh || buffer_uptodate(bh))
109                 return bh;
110 -       ll_rw_block(REQ_OP_READ, REQ_META | REQ_PRIO, 1, &bh);
111 +       jbd2_ll_rw_block(journal, REQ_OP_READ, REQ_META | REQ_PRIO, 1, &bh,
112 +                        __func__);
113         wait_on_buffer(bh);
114         if (buffer_uptodate(bh))
115                 return bh;
116 @@ -4343,6 +4345,7 @@ static int __ext4_get_inode_loc(struct inode *inode,
117         struct super_block      *sb = inode->i_sb;
118         ext4_fsblk_t            block;
119         int                     inodes_per_block, inode_offset;
120 +       journal_t               *journal = EXT4_SB(sb)->s_journal;
122         iloc->bh = NULL;
123         if (!ext4_valid_inum(sb, inode->i_ino))
124 @@ -4446,8 +4449,10 @@ static int __ext4_get_inode_loc(struct inode *inode,
125                         table += num / inodes_per_block;
126                         if (end > table)
127                                 end = table;
128 -                       while (b <= end)
129 -                               sb_breadahead(sb, b++);
130 +                       if (journal) {
131 +                               while (b <= end)
132 +                                       jbd2_sb_breadahead(journal, sb, b++);
133 +                       }
134                 }
136                 /*
137 @@ -4458,7 +4463,8 @@ static int __ext4_get_inode_loc(struct inode *inode,
138                 trace_ext4_load_inode(inode);
139                 get_bh(bh);
140                 bh->b_end_io = end_buffer_read_sync;
141 -               submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
142 +               jbd2_submit_bh(journal, REQ_OP_READ, REQ_META | REQ_PRIO, bh,
143 +                              __func__);
144                 wait_on_buffer(bh);
145                 if (!buffer_uptodate(bh)) {
146                         EXT4_ERROR_INODE_BLOCK(inode, block,
147 diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
148 index 6fc14def0c70..b6c25638f5f4 100644
149 --- a/fs/ext4/move_extent.c
150 +++ b/fs/ext4/move_extent.c
151 @@ -177,6 +177,7 @@ static int
152  mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
154         struct inode *inode = page->mapping->host;
155 +       journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
156         sector_t block;
157         struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE];
158         unsigned int blocksize, block_start, block_end;
159 @@ -225,7 +226,7 @@ mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
160         for (i = 0; i < nr; i++) {
161                 bh = arr[i];
162                 if (!bh_uptodate_or_lock(bh)) {
163 -                       err = bh_submit_read(bh);
164 +                       err = jbd2_bh_submit_read(journal, bh, __func__);
165                         if (err)
166                                 return err;
167                 }
168 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
169 index 6ad612c576fc..0812a692db0f 100644
170 --- a/fs/ext4/namei.c
171 +++ b/fs/ext4/namei.c
172 @@ -1361,6 +1361,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
173         struct buffer_head *bh_use[NAMEI_RA_SIZE];
174         struct buffer_head *bh, *ret = NULL;
175         ext4_lblk_t start, block, b;
176 +       journal_t *journal;
177         const u8 *name = d_name->name;
178         int ra_max = 0;         /* Number of bh's in the readahead
179                                    buffer, bh_use[] */
180 @@ -1373,6 +1374,7 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
182         *res_dir = NULL;
183         sb = dir->i_sb;
184 +       journal = EXT4_SB(sb)->s_journal;
185         namelen = d_name->len;
186         if (namelen > EXT4_NAME_LEN)
187                 return NULL;
188 @@ -1451,9 +1453,9 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
189                                 }
190                                 bh_use[ra_max] = bh;
191                                 if (bh)
192 -                                       ll_rw_block(REQ_OP_READ,
193 -                                                   REQ_META | REQ_PRIO,
194 -                                                   1, &bh);
195 +                                       jbd2_ll_rw_block(journal, REQ_OP_READ,
196 +                                                        REQ_META | REQ_PRIO,
197 +                                                        1, &bh, __func__);
198                         }
199                 }
200                 if ((bh = bh_use[ra_ptr++]) == NULL)
201 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
202 index c3ed9021b781..8406bca774c8 100644
203 --- a/fs/ext4/resize.c
204 +++ b/fs/ext4/resize.c
205 @@ -1193,10 +1193,12 @@ static int ext4_add_new_descs(handle_t *handle, struct super_block *sb,
206  static struct buffer_head *ext4_get_bitmap(struct super_block *sb, __u64 block)
208         struct buffer_head *bh = sb_getblk(sb, block);
209 +       journal_t *journal = EXT4_SB(sb)->s_journal;
211         if (unlikely(!bh))
212                 return NULL;
213         if (!bh_uptodate_or_lock(bh)) {
214 -               if (bh_submit_read(bh) < 0) {
215 +               if (jbd2_bh_submit_read(journal, bh, __func__) < 0) {
216                         brelse(bh);
217                         return NULL;
218                 }