[19/19] bcache: use (REQ_META|REQ_PRIO) to indicate bio for metadata
diff mbox series

Message ID 20190209045311.15677-20-colyli@suse.de
State New
Headers show
Series
  • bcache patches for Linux v5.1
Related show

Commit Message

Coly Li Feb. 9, 2019, 4:53 a.m. UTC
In 'commit 752f66a75aba ("bcache: use REQ_PRIO to indicate bio for
metadata")' REQ_META is replaced by REQ_PRIO to indicate metadata bio.
This assumption is not always correct, e.g. XFS uses REQ_META to mark
metadata bio other than REQ_PRIO. This is why Nix noticed that bcache
does not cache metadata for XFS after the above commit.

Thanks to Dave Chinner, he explains the difference between REQ_META and
REQ_PRIO from view of file system developer. Here I quote part of his
explanation from mailing list,
   REQ_META is used for metadata. REQ_PRIO is used to communicate to
   the lower layers that the submitter considers this IO to be more
   important that non REQ_PRIO IO and so dispatch should be expedited.

   IOWs, if the filesystem considers metadata IO to be more important
   that user data IO, then it will use REQ_PRIO | REQ_META rather than
   just REQ_META.

Then it seems bios with REQ_META or REQ_PRIO should both be cached for
performance optimation, because they are all probably low I/O latency
demand by upper layer (e.g. file system).

So in this patch, when we want to decide whether to bypass the cache,
REQ_META and REQ_PRIO are both checked. Then both metadata and
high priority I/O requests will be handled properly.

Reported-by: Nix <nix@esperi.org.uk>
Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Andre Noll <maan@tuebingen.mpg.de>
Tested-by: Nix <nix@esperi.org.uk>
Cc: stable@vger.kernel.org
Cc: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>
---
 drivers/md/bcache/request.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Coly Li Feb. 12, 2019, 4:48 p.m. UTC | #1
On 2019/2/12 9:28 下午, Sasha Levin wrote:
> Hi,
> 
> [This is an automated email]
> 
> This commit has been processed because it contains a -stable tag.
> The stable tag indicates that it's relevant for the following trees: all
> 
> The bot has tested the following trees: v4.20.7, v4.19.20, v4.14.98, v4.9.155, v4.4.173, v3.18.134.
> 
> v4.20.7: Build OK!
> v4.19.20: Failed to apply! Possible dependencies:
>     752f66a75aba ("bcache: use REQ_PRIO to indicate bio for metadata")
> 
> v4.14.98: Failed to apply! Possible dependencies:
>     752f66a75aba ("bcache: use REQ_PRIO to indicate bio for metadata")
>     b41c9b0266e8 ("bcache: update bio->bi_opf bypass/writeback REQ_ flag hints")
> 
> v4.9.155: Failed to apply! Possible dependencies:
>     752f66a75aba ("bcache: use REQ_PRIO to indicate bio for metadata")
>     83b5df67c509 ("bcache: use op_is_sync to check for synchronous requests")
>     b41c9b0266e8 ("bcache: update bio->bi_opf bypass/writeback REQ_ flag hints")
> 
> v4.4.173: Failed to apply! Possible dependencies:
>     09cbfeaf1a5a ("mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros")
>     1c2e54e1ed6f ("dm thin: bump thin and thin-pool target versions")
>     1eff9d322a44 ("block: rename bio bi_rw to bi_opf")
>     202bae52934d ("dm thin: unroll issue_discard() to create longer discard bio chains")
>     38f252553300 ("block: add __blkdev_issue_discard")
>     3dba53a958a7 ("dm thin: use __blkdev_issue_discard for async discard support")
>     4e49ea4a3d27 ("block/fs/drivers: remove rw argument from submit_bio")
>     83b5df67c509 ("bcache: use op_is_sync to check for synchronous requests")
>     9082e87bfbf8 ("block: remove struct bio_batch")
>     a6111d11b8b5 ("btrfs: raid56: Use raid_write_end_io for scrub")
>     b41c9b0266e8 ("bcache: update bio->bi_opf bypass/writeback REQ_ flag hints")
>     bbd848e0fade ("block: reinstate early return of -EOPNOTSUPP from blkdev_issue_discard")
>     c3667cc61904 ("dm thin: consistently return -ENOSPC if pool has run out of data space")
>     c8d93247f1d0 ("bcache: use op_is_write instead of checking for REQ_WRITE")
>     d57d611505d9 ("kernel/fs: fix I/O wait not accounted for RW O_DSYNC")
> 
> v3.18.134: Failed to apply! Possible dependencies:
>     1b94b5567e9c ("Btrfs, raid56: use a variant to record the operation type")
>     1eff9d322a44 ("block: rename bio bi_rw to bi_opf")
>     2c8cdd6ee4e7 ("Btrfs, replace: write dirty pages into the replace target device")
>     326e1dbb5736 ("block: remove management of bi_remaining when restoring original bi_end_io")
>     4245215d6a8d ("Btrfs, raid56: fix use-after-free problem in the final device replace procedure on raid56")
>     5a6ac9eacb49 ("Btrfs, raid56: support parity scrub on raid56")
>     6e9606d2a2dc ("Btrfs: add ref_count and free function for btrfs_bio")
>     83b5df67c509 ("bcache: use op_is_sync to check for synchronous requests")
>     8e5cfb55d3f7 ("Btrfs: Make raid_map array be inlined in btrfs_bio structure")
>     af8e2d1df984 ("Btrfs, scrub: repair the common data on RAID5/6 if it is corrupted")
>     b41c9b0266e8 ("bcache: update bio->bi_opf bypass/writeback REQ_ flag hints")
>     b7c44ed9d2fc ("block: manipulate bio->bi_flags through helpers")
>     b89e1b012c7f ("Btrfs, raid56: don't change bbio and raid_map")
>     c4cf5261f8bf ("bio: skip atomic inc/dec of ->bi_remaining for non-chains")
>     c8d93247f1d0 ("bcache: use op_is_write instead of checking for REQ_WRITE")
>     f90523d1aa3c ("Btrfs: remove noused bbio_ret in __btrfs_map_block in condition")
> 
> 
> How should we proceed with this patch?

Can I rebase this patch for each stable kernel, and send the patch to
stable@vger.kernel.org ?

Thanks.

Patch
diff mbox series

diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index 15070412a32e..f101bfe8657a 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -392,10 +392,11 @@  static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
 
 	/*
 	 * Flag for bypass if the IO is for read-ahead or background,
-	 * unless the read-ahead request is for metadata (eg, for gfs2).
+	 * unless the read-ahead request is for metadata
+	 * (eg, for gfs2 or xfs).
 	 */
 	if (bio->bi_opf & (REQ_RAHEAD|REQ_BACKGROUND) &&
-	    !(bio->bi_opf & REQ_PRIO))
+	    !(bio->bi_opf & (REQ_META|REQ_PRIO)))
 		goto skip;
 
 	if (bio->bi_iter.bi_sector & (c->sb.block_size - 1) ||
@@ -877,7 +878,7 @@  static int cached_dev_cache_miss(struct btree *b, struct search *s,
 	}
 
 	if (!(bio->bi_opf & REQ_RAHEAD) &&
-	    !(bio->bi_opf & REQ_PRIO) &&
+	    !(bio->bi_opf & (REQ_META|REQ_PRIO)) &&
 	    s->iop.c->gc_stats.in_use < CUTOFF_CACHE_READA)
 		reada = min_t(sector_t, dc->readahead >> 9,
 			      get_capacity(bio->bi_disk) - bio_end_sector(bio));