Skip to content

Commit c2df40d

Browse files
Mike Christieaxboe
authored andcommitted
drivers: use req op accessor
The req operation REQ_OP is separated from the rq_flag_bits definition. This converts the block layer drivers to use req_op to get the op from the request struct. Signed-off-by: Mike Christie <mchristi@redhat.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent d9d8c5c commit c2df40d

14 files changed

Lines changed: 43 additions & 34 deletions

File tree

‎drivers/block/loop.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
544544
if (op_is_write(req_op(rq))) {
545545
if (rq->cmd_flags & REQ_FLUSH)
546546
ret = lo_req_flush(lo, rq);
547-
else if (rq->cmd_flags & REQ_DISCARD)
547+
else if (req_op(rq) == REQ_OP_DISCARD)
548548
ret = lo_discard(lo, rq, pos);
549549
else if (lo->transfer)
550550
ret = lo_write_transfer(lo, rq, pos);
@@ -1659,8 +1659,8 @@ static int loop_queue_rq(struct blk_mq_hw_ctx *hctx,
16591659
if (lo->lo_state != Lo_bound)
16601660
return -EIO;
16611661

1662-
if (lo->use_dio && !(cmd->rq->cmd_flags & (REQ_FLUSH |
1663-
REQ_DISCARD)))
1662+
if (lo->use_dio && (!(cmd->rq->cmd_flags & REQ_FLUSH) ||
1663+
req_op(cmd->rq) == REQ_OP_DISCARD))
16641664
cmd->use_aio = true;
16651665
else
16661666
cmd->use_aio = false;

‎drivers/block/mtip32xx/mtip32xx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3765,7 +3765,7 @@ static int mtip_submit_request(struct blk_mq_hw_ctx *hctx, struct request *rq)
37653765
return -ENODATA;
37663766
}
37673767

3768-
if (rq->cmd_flags & REQ_DISCARD) {
3768+
if (req_op(rq) == REQ_OP_DISCARD) {
37693769
int err;
37703770

37713771
err = mtip_send_trim(dd, blk_rq_pos(rq), blk_rq_sectors(rq));

‎drivers/block/nbd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req)
282282

283283
if (req->cmd_type == REQ_TYPE_DRV_PRIV)
284284
type = NBD_CMD_DISC;
285-
else if (req->cmd_flags & REQ_DISCARD)
285+
else if (req_op(req) == REQ_OP_DISCARD)
286286
type = NBD_CMD_TRIM;
287287
else if (req->cmd_flags & REQ_FLUSH)
288288
type = NBD_CMD_FLUSH;

‎drivers/block/rbd.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,9 +3286,9 @@ static void rbd_queue_workfn(struct work_struct *work)
32863286
goto err;
32873287
}
32883288

3289-
if (rq->cmd_flags & REQ_DISCARD)
3289+
if (req_op(rq) == REQ_OP_DISCARD)
32903290
op_type = OBJ_OP_DISCARD;
3291-
else if (rq->cmd_flags & REQ_WRITE)
3291+
else if (req_op(rq) == REQ_OP_WRITE)
32923292
op_type = OBJ_OP_WRITE;
32933293
else
32943294
op_type = OBJ_OP_READ;

‎drivers/block/xen-blkfront.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,8 @@ static int blkif_queue_request(struct request *req, struct blkfront_ring_info *r
844844
if (unlikely(rinfo->dev_info->connected != BLKIF_STATE_CONNECTED))
845845
return 1;
846846

847-
if (unlikely(req->cmd_flags & (REQ_DISCARD | REQ_SECURE)))
847+
if (unlikely(req_op(req) == REQ_OP_DISCARD ||
848+
req->cmd_flags & REQ_SECURE))
848849
return blkif_queue_discard_req(req, rinfo);
849850
else
850851
return blkif_queue_rw_req(req, rinfo);
@@ -2054,8 +2055,9 @@ static int blkif_recover(struct blkfront_info *info)
20542055
/*
20552056
* Get the bios in the request so we can re-queue them.
20562057
*/
2057-
if (copy[i].request->cmd_flags &
2058-
(REQ_FLUSH | REQ_FUA | REQ_DISCARD | REQ_SECURE)) {
2058+
if (copy[i].request->cmd_flags & REQ_FLUSH ||
2059+
req_op(copy[i].request) == REQ_OP_DISCARD ||
2060+
copy[i].request->cmd_flags & (REQ_FUA | REQ_SECURE)) {
20592061
/*
20602062
* Flush operations don't contain bios, so
20612063
* we need to requeue the whole request

‎drivers/ide/ide-floppy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
206206
memcpy(rq->cmd, pc->c, 12);
207207

208208
pc->rq = rq;
209-
if (rq->cmd_flags & REQ_WRITE)
209+
if (cmd == WRITE)
210210
pc->flags |= PC_FLAG_WRITING;
211211

212212
pc->flags |= PC_FLAG_DMA_OK;

‎drivers/md/dm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ static void dm_done(struct request *clone, int error, bool mapped)
13221322
r = rq_end_io(tio->ti, clone, error, &tio->info);
13231323
}
13241324

1325-
if (unlikely(r == -EREMOTEIO && (clone->cmd_flags & REQ_WRITE_SAME) &&
1325+
if (unlikely(r == -EREMOTEIO && (req_op(clone) == REQ_OP_WRITE_SAME) &&
13261326
!clone->q->limits.max_write_same_sectors))
13271327
disable_write_same(tio->md);
13281328

‎drivers/mmc/card/block.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,8 +1722,7 @@ static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request *req)
17221722
!IS_ALIGNED(blk_rq_sectors(next), 8))
17231723
break;
17241724

1725-
if (next->cmd_flags & REQ_DISCARD ||
1726-
next->cmd_flags & REQ_FLUSH)
1725+
if (req_op(next) == REQ_OP_DISCARD || next->cmd_flags & REQ_FLUSH)
17271726
break;
17281727

17291728
if (rq_data_dir(cur) != rq_data_dir(next))
@@ -2164,7 +2163,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
21642163
}
21652164

21662165
mq->flags &= ~MMC_QUEUE_NEW_REQUEST;
2167-
if (cmd_flags & REQ_DISCARD) {
2166+
if (req && req_op(req) == REQ_OP_DISCARD) {
21682167
/* complete ongoing async transfer before issuing discard */
21692168
if (card->host->areq)
21702169
mmc_blk_issue_rw_rq(mq, NULL);
@@ -2188,7 +2187,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
21882187

21892188
out:
21902189
if ((!req && !(mq->flags & MMC_QUEUE_NEW_REQUEST)) ||
2191-
(cmd_flags & MMC_REQ_SPECIAL_MASK))
2190+
mmc_req_is_special(req))
21922191
/*
21932192
* Release host when there are no more requests
21942193
* and after special request(discard, flush) is done.

‎drivers/mmc/card/queue.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int mmc_prep_request(struct request_queue *q, struct request *req)
3333
/*
3434
* We only like normal block requests and discards.
3535
*/
36-
if (req->cmd_type != REQ_TYPE_FS && !(req->cmd_flags & REQ_DISCARD)) {
36+
if (req->cmd_type != REQ_TYPE_FS && req_op(req) != REQ_OP_DISCARD) {
3737
blk_dump_rq_flags(req, "MMC bad request");
3838
return BLKPREP_KILL;
3939
}
@@ -56,7 +56,6 @@ static int mmc_queue_thread(void *d)
5656
down(&mq->thread_sem);
5757
do {
5858
struct request *req = NULL;
59-
unsigned int cmd_flags = 0;
6059

6160
spin_lock_irq(q->queue_lock);
6261
set_current_state(TASK_INTERRUPTIBLE);
@@ -66,7 +65,6 @@ static int mmc_queue_thread(void *d)
6665

6766
if (req || mq->mqrq_prev->req) {
6867
set_current_state(TASK_RUNNING);
69-
cmd_flags = req ? req->cmd_flags : 0;
7068
mq->issue_fn(mq, req);
7169
cond_resched();
7270
if (mq->flags & MMC_QUEUE_NEW_REQUEST) {
@@ -81,7 +79,7 @@ static int mmc_queue_thread(void *d)
8179
* has been finished. Do not assign it to previous
8280
* request.
8381
*/
84-
if (cmd_flags & MMC_REQ_SPECIAL_MASK)
82+
if (mmc_req_is_special(req))
8583
mq->mqrq_cur->req = NULL;
8684

8785
mq->mqrq_prev->brq.mrq.data = NULL;

‎drivers/mmc/card/queue.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#ifndef MMC_QUEUE_H
22
#define MMC_QUEUE_H
33

4-
#define MMC_REQ_SPECIAL_MASK (REQ_DISCARD | REQ_FLUSH)
4+
static inline bool mmc_req_is_special(struct request *req)
5+
{
6+
return req && (req->cmd_flags & REQ_FLUSH || req_op(req) == REQ_OP_DISCARD);
7+
}
58

69
struct request;
710
struct task_struct;

0 commit comments

Comments
 (0)