block: add REQ_OP definitions and helpers

The following patches separate the operation (WRITE, READ, DISCARD,
etc) from the rq_flag_bits flags. This patch adds definitions for
request/bio operations (REQ_OPs) and adds request/bio accessors to
get/set the op.

In this patch the REQ_OPs match the REQ rq_flag_bits ones
for compat reasons while all the code is converted to use the
op accessors in the set. In the last patches the op will become a
number and the accessors and helpers in this patch will be dropped
or updated.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
Mike Christie
2016-06-05 14:31:42 -05:00
committed by Jens Axboe
parent 4e49ea4a3d
commit f21508211d
4 changed files with 60 additions and 3 deletions

View File

@@ -2464,15 +2464,37 @@ extern void make_bad_inode(struct inode *);
extern bool is_bad_inode(struct inode *);
#ifdef CONFIG_BLOCK
/*
* tmp cpmpat. Users used to set the write bit for all non reads, but
* we will be dropping the bitmap use for ops. Support both until
* the end of the patchset.
*/
static inline bool op_is_write(unsigned long flags)
{
if (flags & (REQ_OP_WRITE | REQ_OP_WRITE_SAME | REQ_OP_DISCARD))
return true;
else
return false;
}
/*
* return READ, READA, or WRITE
*/
#define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK))
static inline int bio_rw(struct bio *bio)
{
if (op_is_write(op_from_rq_bits(bio->bi_rw)))
return WRITE;
return bio->bi_rw & RWA_MASK;
}
/*
* return data direction, READ or WRITE
*/
#define bio_data_dir(bio) ((bio)->bi_rw & 1)
static inline int bio_data_dir(struct bio *bio)
{
return op_is_write(op_from_rq_bits(bio->bi_rw)) ? WRITE : READ;
}
extern void check_disk_size_change(struct gendisk *disk,
struct block_device *bdev);