gfs2: add flag REQ_PRIO for metadata I/O
authorColy Li <colyli@suse.de>
Fri, 21 Jul 2017 12:48:22 +0000 (07:48 -0500)
committerBob Peterson <rpeterso@redhat.com>
Fri, 21 Jul 2017 12:48:22 +0000 (07:48 -0500)
When gfs2 does metadata I/O, only REQ_META is used as a metadata hint of
the bio. But flag REQ_META is just a hint for block trace, not for block
layer code to handle a bio as metadata request.

For some of metadata I/Os of gfs2, A REQ_PRIO flag on the metadata bio
would be very informative to block layer code. For example, if bcache is
used as a I/O cache for gfs2, it will be possible for bcache code to get
the hint and cache the pre-fetched metadata blocks on cache device. This
behavior may be helpful to improve metadata I/O performance if the
following requests hit the cache.

Here are the locations in gfs2 code where a REQ_PRIO flag should be added,
- All places where REQ_READAHEAD is used, gfs2 code uses this flag for
  metadata read ahead.
- In gfs2_meta_rq() where the first metadata block is read in.
- In gfs2_write_buf_to_page(), read in quota metadata blocks to have them
  up to date.
These metadata blocks are probably to be accessed again in future, adding
a REQ_PRIO flag may have bcache to keep such metadata in fast cache
device. For system without a cache layer, REQ_PRIO can still provide hint
to block layer to handle metadata requests more properly.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/bmap.c
fs/gfs2/dir.c
fs/gfs2/meta_io.c
fs/gfs2/quota.c

index 9fa3aef9a5b358ec7f78fa6fd08f8c6d008611f6..fa3ea29f39cf8f743aec129ecf5469a5fa2d562b 100644 (file)
@@ -291,8 +291,9 @@ static void gfs2_metapath_ra(struct gfs2_glock *gl,
                if (trylock_buffer(rabh)) {
                        if (!buffer_uptodate(rabh)) {
                                rabh->b_end_io = end_buffer_read_sync;
-                               submit_bh(REQ_OP_READ, REQ_RAHEAD | REQ_META,
-                                               rabh);
+                               submit_bh(REQ_OP_READ,
+                                         REQ_RAHEAD | REQ_META | REQ_PRIO,
+                                         rabh);
                                continue;
                        }
                        unlock_buffer(rabh);
index db427658ccd9bc1e2a82030cf6cee6e097dd3fc3..0741e4018f8c0eef9e5dc164e56c730852fc22d2 100644 (file)
@@ -1514,7 +1514,9 @@ static void gfs2_dir_readahead(struct inode *inode, unsigned hsize, u32 index,
                                continue;
                        }
                        bh->b_end_io = end_buffer_read_sync;
-                       submit_bh(REQ_OP_READ, REQ_RAHEAD | REQ_META, bh);
+                       submit_bh(REQ_OP_READ,
+                                 REQ_RAHEAD | REQ_META | REQ_PRIO,
+                                 bh);
                        continue;
                }
                brelse(bh);
index 4da7745c890a1ef2e126a19c1d5399ab5fecf61b..61ef6c9be816f14a3c7242fd479f1acd1f373c46 100644 (file)
@@ -453,7 +453,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
        if (buffer_uptodate(first_bh))
                goto out;
        if (!buffer_locked(first_bh))
-               ll_rw_block(REQ_OP_READ, REQ_META, 1, &first_bh);
+               ll_rw_block(REQ_OP_READ, REQ_META | REQ_PRIO, 1, &first_bh);
 
        dblock++;
        extlen--;
@@ -462,7 +462,9 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
                bh = gfs2_getbuf(gl, dblock, CREATE);
 
                if (!buffer_uptodate(bh) && !buffer_locked(bh))
-                       ll_rw_block(REQ_OP_READ, REQ_RAHEAD | REQ_META, 1, &bh);
+                       ll_rw_block(REQ_OP_READ,
+                                   REQ_RAHEAD | REQ_META | REQ_PRIO,
+                                   1, &bh);
                brelse(bh);
                dblock++;
                extlen--;
index c2ca9566b7647e21adcf224af55172eb709221f5..739adf105d7f0409649c53bd2248dea5f907bf2d 100644 (file)
@@ -730,7 +730,7 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index,
                if (PageUptodate(page))
                        set_buffer_uptodate(bh);
                if (!buffer_uptodate(bh)) {
-                       ll_rw_block(REQ_OP_READ, REQ_META, 1, &bh);
+                       ll_rw_block(REQ_OP_READ, REQ_META | REQ_PRIO, 1, &bh);
                        wait_on_buffer(bh);
                        if (!buffer_uptodate(bh))
                                goto unlock_out;