Skip to content

Commit 5404bc7

Browse files
Jens AxboeJens Axboe
authored andcommitted
[PATCH] Allow file systems to differentiate between data and meta reads
We can use this information for making more intelligent priority decisions, and it will also be useful for blktrace. Signed-off-by: Jens Axboe <[email protected]>
1 parent da20a20 commit 5404bc7

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

block/ll_rw_blk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,8 @@ static void init_request_from_bio(struct request *req, struct bio *bio)
28842884

28852885
if (bio_sync(bio))
28862886
req->cmd_flags |= REQ_RW_SYNC;
2887+
if (bio_rw_meta(bio))
2888+
req->cmd_flags |= REQ_RW_META;
28872889

28882890
req->errors = 0;
28892891
req->hard_sector = req->sector = bio->bi_sector;

include/linux/bio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ struct bio {
148148
#define BIO_RW_BARRIER 2
149149
#define BIO_RW_FAILFAST 3
150150
#define BIO_RW_SYNC 4
151+
#define BIO_RW_META 5
151152

152153
/*
153154
* upper 16 bits of bi_rw define the io priority of this bio
@@ -178,6 +179,7 @@ struct bio {
178179
#define bio_sync(bio) ((bio)->bi_rw & (1 << BIO_RW_SYNC))
179180
#define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST))
180181
#define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD))
182+
#define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META))
181183

182184
/*
183185
* will die

include/linux/blkdev.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ enum rq_flag_bits {
180180
__REQ_ORDERED_COLOR, /* is before or after barrier */
181181
__REQ_RW_SYNC, /* request is sync (O_DIRECT) */
182182
__REQ_ALLOCED, /* request came from our alloc pool */
183+
__REQ_RW_META, /* metadata io request */
183184
__REQ_NR_BITS, /* stops here */
184185
};
185186

@@ -200,6 +201,7 @@ enum rq_flag_bits {
200201
#define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR)
201202
#define REQ_RW_SYNC (1 << __REQ_RW_SYNC)
202203
#define REQ_ALLOCED (1 << __REQ_ALLOCED)
204+
#define REQ_RW_META (1 << __REQ_RW_META)
203205

204206
#define BLK_MAX_CDB 16
205207

@@ -543,6 +545,7 @@ enum {
543545
* We regard a request as sync, if it's a READ or a SYNC write.
544546
*/
545547
#define rq_is_sync(rq) (rq_data_dir((rq)) == READ || (rq)->cmd_flags & REQ_RW_SYNC)
548+
#define rq_is_meta(rq) ((rq)->cmd_flags & REQ_RW_META)
546549

547550
static inline int blk_queue_full(struct request_queue *q, int rw)
548551
{

include/linux/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ extern int dir_notify_enable;
8080
#define READA 2 /* read-ahead - don't block if no resources */
8181
#define SWRITE 3 /* for ll_rw_block() - wait for buffer lock */
8282
#define READ_SYNC (READ | (1 << BIO_RW_SYNC))
83+
#define READ_META (READ | (1 << BIO_RW_META))
8384
#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC))
8485
#define WRITE_BARRIER ((1 << BIO_RW) | (1 << BIO_RW_BARRIER))
8586

0 commit comments

Comments
 (0)