block, drivers, cgroup: use op_is_write helper instead of checking for REQ_WRITE
We currently set REQ_WRITE/WRITE for all non READ IOs like discard, flush, writesame, etc. In the next patches where we no longer set up the op as a bitmap, we will not be able to detect a operation direction like writesame by testing if REQ_WRITE is set. This patch converts the drivers and cgroup to use the op_is_write helper. This should just cover the simple cases. I did dm, md and bcache in their own patches because they were more involved. 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:

committed by
Jens Axboe

parent
dfec8a14fc
commit
a8ebb056a8
@@ -447,7 +447,7 @@ static int lo_req_flush(struct loop_device *lo, struct request *rq)
|
||||
|
||||
static inline void handle_partial_read(struct loop_cmd *cmd, long bytes)
|
||||
{
|
||||
if (bytes < 0 || (cmd->rq->cmd_flags & REQ_WRITE))
|
||||
if (bytes < 0 || op_is_write(req_op(cmd->rq)))
|
||||
return;
|
||||
|
||||
if (unlikely(bytes < blk_rq_bytes(cmd->rq))) {
|
||||
@@ -541,7 +541,7 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
|
||||
|
||||
pos = ((loff_t) blk_rq_pos(rq) << 9) + lo->lo_offset;
|
||||
|
||||
if (rq->cmd_flags & REQ_WRITE) {
|
||||
if (op_is_write(req_op(rq))) {
|
||||
if (rq->cmd_flags & REQ_FLUSH)
|
||||
ret = lo_req_flush(lo, rq);
|
||||
else if (rq->cmd_flags & REQ_DISCARD)
|
||||
@@ -1672,7 +1672,7 @@ static int loop_queue_rq(struct blk_mq_hw_ctx *hctx,
|
||||
|
||||
static void loop_handle_cmd(struct loop_cmd *cmd)
|
||||
{
|
||||
const bool write = cmd->rq->cmd_flags & REQ_WRITE;
|
||||
const bool write = op_is_write(req_op(cmd->rq));
|
||||
struct loop_device *lo = cmd->rq->q->queuedata;
|
||||
int ret = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user