Skip to content

Commit dc7292a

Browse files
Coly Liaxboe
authored andcommitted
bcache: use (REQ_META|REQ_PRIO) to indicate bio for metadata
In 'commit 752f66a ("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> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent a91fbda commit dc7292a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎drivers/md/bcache/request.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,11 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
392392

393393
/*
394394
* Flag for bypass if the IO is for read-ahead or background,
395-
* unless the read-ahead request is for metadata (eg, for gfs2).
395+
* unless the read-ahead request is for metadata
396+
* (eg, for gfs2 or xfs).
396397
*/
397398
if (bio->bi_opf & (REQ_RAHEAD|REQ_BACKGROUND) &&
398-
!(bio->bi_opf & REQ_PRIO))
399+
!(bio->bi_opf & (REQ_META|REQ_PRIO)))
399400
goto skip;
400401

401402
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,
877878
}
878879

879880
if (!(bio->bi_opf & REQ_RAHEAD) &&
880-
!(bio->bi_opf & REQ_PRIO) &&
881+
!(bio->bi_opf & (REQ_META|REQ_PRIO)) &&
881882
s->iop.c->gc_stats.in_use < CUTOFF_CACHE_READA)
882883
reada = min_t(sector_t, dc->readahead >> 9,
883884
get_capacity(bio->bi_disk) - bio_end_sector(bio));

0 commit comments

Comments
 (0)