Skip to content

Commit 33659eb

Browse files
Christoph HellwigJens Axboe
authored andcommitted
block: remove wrappers for request type/flags
Remove all the trivial wrappers for the cmd_type and cmd_flags fields in struct requests. This allows much easier grepping for different request types instead of unwinding through macros. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent 7e005f7 commit 33659eb

47 files changed

Lines changed: 236 additions & 198 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎block/blk-barrier.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ unsigned blk_ordered_req_seq(struct request *rq)
7979
*
8080
* http://thread.gmane.org/gmane.linux.kernel/537473
8181
*/
82-
if (!blk_fs_request(rq))
82+
if (rq->cmd_type != REQ_TYPE_FS)
8383
return QUEUE_ORDSEQ_DRAIN;
8484

8585
if ((rq->cmd_flags & REQ_ORDERED_COLOR) ==
@@ -236,7 +236,8 @@ static inline bool start_ordered(struct request_queue *q, struct request **rqp)
236236
bool blk_do_ordered(struct request_queue *q, struct request **rqp)
237237
{
238238
struct request *rq = *rqp;
239-
const int is_barrier = blk_fs_request(rq) && blk_barrier_rq(rq);
239+
const int is_barrier = rq->cmd_type == REQ_TYPE_FS &&
240+
(rq->cmd_flags & REQ_HARDBARRIER);
240241

241242
if (!q->ordseq) {
242243
if (!is_barrier)
@@ -261,7 +262,7 @@ bool blk_do_ordered(struct request_queue *q, struct request **rqp)
261262
*/
262263

263264
/* Special requests are not subject to ordering rules. */
264-
if (!blk_fs_request(rq) &&
265+
if (rq->cmd_type != REQ_TYPE_FS &&
265266
rq != &q->pre_flush_rq && rq != &q->post_flush_rq)
266267
return true;
267268

‎block/blk-core.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void blk_dump_rq_flags(struct request *rq, char *msg)
184184
printk(KERN_INFO " bio %p, biotail %p, buffer %p, len %u\n",
185185
rq->bio, rq->biotail, rq->buffer, blk_rq_bytes(rq));
186186

187-
if (blk_pc_request(rq)) {
187+
if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
188188
printk(KERN_INFO " cdb: ");
189189
for (bit = 0; bit < BLK_MAX_CDB; bit++)
190190
printk("%02x ", rq->cmd[bit]);
@@ -1796,7 +1796,7 @@ struct request *blk_peek_request(struct request_queue *q)
17961796
* sees this request (possibly after
17971797
* requeueing). Notify IO scheduler.
17981798
*/
1799-
if (blk_sorted_rq(rq))
1799+
if (rq->cmd_flags & REQ_SORTED)
18001800
elv_activate_rq(q, rq);
18011801

18021802
/*
@@ -1984,10 +1984,11 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
19841984
* TODO: tj: This is too subtle. It would be better to let
19851985
* low level drivers do what they see fit.
19861986
*/
1987-
if (blk_fs_request(req))
1987+
if (req->cmd_type == REQ_TYPE_FS)
19881988
req->errors = 0;
19891989

1990-
if (error && (blk_fs_request(req) && !(req->cmd_flags & REQ_QUIET))) {
1990+
if (error && req->cmd_type == REQ_TYPE_FS &&
1991+
!(req->cmd_flags & REQ_QUIET)) {
19911992
printk(KERN_ERR "end_request: I/O error, dev %s, sector %llu\n",
19921993
req->rq_disk ? req->rq_disk->disk_name : "?",
19931994
(unsigned long long)blk_rq_pos(req));
@@ -2074,7 +2075,7 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
20742075
req->buffer = bio_data(req->bio);
20752076

20762077
/* update sector only for requests with clear definition of sector */
2077-
if (blk_fs_request(req) || blk_discard_rq(req))
2078+
if (req->cmd_type == REQ_TYPE_FS || (req->cmd_flags & REQ_DISCARD))
20782079
req->__sector += total_bytes >> 9;
20792080

20802081
/* mixed attributes always follow the first bio */
@@ -2127,7 +2128,7 @@ static void blk_finish_request(struct request *req, int error)
21272128

21282129
BUG_ON(blk_queued_rq(req));
21292130

2130-
if (unlikely(laptop_mode) && blk_fs_request(req))
2131+
if (unlikely(laptop_mode) && req->cmd_type == REQ_TYPE_FS)
21312132
laptop_io_completion(&req->q->backing_dev_info);
21322133

21332134
blk_delete_timer(req);

‎block/blk-exec.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
5757
__elv_add_request(q, rq, where, 1);
5858
__generic_unplug_device(q);
5959
/* the queue is stopped so it won't be plugged+unplugged */
60-
if (blk_pm_resume_request(rq))
60+
if (rq->cmd_type == REQ_TYPE_PM_RESUME)
6161
q->request_fn(q);
6262
spin_unlock_irq(q->queue_lock);
6363
}

‎block/blk-merge.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req,
226226
{
227227
unsigned short max_sectors;
228228

229-
if (unlikely(blk_pc_request(req)))
229+
if (unlikely(req->cmd_type == REQ_TYPE_BLOCK_PC))
230230
max_sectors = queue_max_hw_sectors(q);
231231
else
232232
max_sectors = queue_max_sectors(q);
@@ -250,7 +250,7 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req,
250250
{
251251
unsigned short max_sectors;
252252

253-
if (unlikely(blk_pc_request(req)))
253+
if (unlikely(req->cmd_type == REQ_TYPE_BLOCK_PC))
254254
max_sectors = queue_max_hw_sectors(q);
255255
else
256256
max_sectors = queue_max_sectors(q);

‎block/blk.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ static inline int blk_cpu_to_group(int cpu)
161161
*/
162162
static inline int blk_do_io_stat(struct request *rq)
163163
{
164-
return rq->rq_disk && blk_rq_io_stat(rq) &&
165-
(blk_fs_request(rq) || blk_discard_rq(rq));
164+
return rq->rq_disk &&
165+
(rq->cmd_flags & REQ_IO_STAT) &&
166+
(rq->cmd_type == REQ_TYPE_FS ||
167+
(rq->cmd_flags & REQ_DISCARD));
166168
}
167169

168170
#endif

‎block/cfq-iosched.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,10 @@ cfq_choose_req(struct cfq_data *cfqd, struct request *rq1, struct request *rq2,
646646
return rq1;
647647
else if (rq_is_sync(rq2) && !rq_is_sync(rq1))
648648
return rq2;
649-
if (rq_is_meta(rq1) && !rq_is_meta(rq2))
649+
if ((rq1->cmd_flags & REQ_RW_META) && !(rq2->cmd_flags & REQ_RW_META))
650650
return rq1;
651-
else if (rq_is_meta(rq2) && !rq_is_meta(rq1))
651+
else if ((rq2->cmd_flags & REQ_RW_META) &&
652+
!(rq1->cmd_flags & REQ_RW_META))
652653
return rq2;
653654

654655
s1 = blk_rq_pos(rq1);
@@ -1484,7 +1485,7 @@ static void cfq_remove_request(struct request *rq)
14841485
cfqq->cfqd->rq_queued--;
14851486
cfq_blkiocg_update_io_remove_stats(&(RQ_CFQG(rq))->blkg,
14861487
rq_data_dir(rq), rq_is_sync(rq));
1487-
if (rq_is_meta(rq)) {
1488+
if (rq->cmd_flags & REQ_RW_META) {
14881489
WARN_ON(!cfqq->meta_pending);
14891490
cfqq->meta_pending--;
14901491
}
@@ -3176,7 +3177,7 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
31763177
* So both queues are sync. Let the new request get disk time if
31773178
* it's a metadata request and the current queue is doing regular IO.
31783179
*/
3179-
if (rq_is_meta(rq) && !cfqq->meta_pending)
3180+
if ((rq->cmd_flags & REQ_RW_META) && !cfqq->meta_pending)
31803181
return true;
31813182

31823183
/*
@@ -3230,7 +3231,7 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
32303231
struct cfq_io_context *cic = RQ_CIC(rq);
32313232

32323233
cfqd->rq_queued++;
3233-
if (rq_is_meta(rq))
3234+
if (rq->cmd_flags & REQ_RW_META)
32343235
cfqq->meta_pending++;
32353236

32363237
cfq_update_io_thinktime(cfqd, cic);
@@ -3365,7 +3366,8 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
33653366
unsigned long now;
33663367

33673368
now = jiffies;
3368-
cfq_log_cfqq(cfqd, cfqq, "complete rqnoidle %d", !!rq_noidle(rq));
3369+
cfq_log_cfqq(cfqd, cfqq, "complete rqnoidle %d",
3370+
!!(rq->cmd_flags & REQ_NOIDLE));
33693371

33703372
cfq_update_hw_tag(cfqd);
33713373

@@ -3419,11 +3421,12 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
34193421
cfq_slice_expired(cfqd, 1);
34203422
else if (sync && cfqq_empty &&
34213423
!cfq_close_cooperator(cfqd, cfqq)) {
3422-
cfqd->noidle_tree_requires_idle |= !rq_noidle(rq);
3424+
cfqd->noidle_tree_requires_idle |=
3425+
!(rq->cmd_flags & REQ_NOIDLE);
34233426
/*
34243427
* Idling is enabled for SYNC_WORKLOAD.
34253428
* SYNC_NOIDLE_WORKLOAD idles at the end of the tree
3426-
* only if we processed at least one !rq_noidle request
3429+
* only if we processed at least one !REQ_NOIDLE request
34273430
*/
34283431
if (cfqd->serving_type == SYNC_WORKLOAD
34293432
|| cfqd->noidle_tree_requires_idle

‎block/elevator.c‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ void elv_dispatch_sort(struct request_queue *q, struct request *rq)
428428
list_for_each_prev(entry, &q->queue_head) {
429429
struct request *pos = list_entry_rq(entry);
430430

431-
if (blk_discard_rq(rq) != blk_discard_rq(pos))
431+
if ((rq->cmd_flags & REQ_DISCARD) !=
432+
(pos->cmd_flags & REQ_DISCARD))
432433
break;
433434
if (rq_data_dir(rq) != rq_data_dir(pos))
434435
break;
@@ -558,7 +559,7 @@ void elv_requeue_request(struct request_queue *q, struct request *rq)
558559
*/
559560
if (blk_account_rq(rq)) {
560561
q->in_flight[rq_is_sync(rq)]--;
561-
if (blk_sorted_rq(rq))
562+
if (rq->cmd_flags & REQ_SORTED)
562563
elv_deactivate_rq(q, rq);
563564
}
564565

@@ -644,7 +645,8 @@ void elv_insert(struct request_queue *q, struct request *rq, int where)
644645
break;
645646

646647
case ELEVATOR_INSERT_SORT:
647-
BUG_ON(!blk_fs_request(rq) && !blk_discard_rq(rq));
648+
BUG_ON(rq->cmd_type != REQ_TYPE_FS &&
649+
!(rq->cmd_flags & REQ_DISCARD));
648650
rq->cmd_flags |= REQ_SORTED;
649651
q->nr_sorted++;
650652
if (rq_mergeable(rq)) {
@@ -716,7 +718,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where,
716718
/*
717719
* toggle ordered color
718720
*/
719-
if (blk_barrier_rq(rq))
721+
if (rq->cmd_flags & REQ_HARDBARRIER)
720722
q->ordcolor ^= 1;
721723

722724
/*
@@ -729,7 +731,8 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where,
729731
* this request is scheduling boundary, update
730732
* end_sector
731733
*/
732-
if (blk_fs_request(rq) || blk_discard_rq(rq)) {
734+
if (rq->cmd_type == REQ_TYPE_FS ||
735+
(rq->cmd_flags & REQ_DISCARD)) {
733736
q->end_sector = rq_end_sector(rq);
734737
q->boundary_rq = rq;
735738
}
@@ -843,7 +846,8 @@ void elv_completed_request(struct request_queue *q, struct request *rq)
843846
*/
844847
if (blk_account_rq(rq)) {
845848
q->in_flight[rq_is_sync(rq)]--;
846-
if (blk_sorted_rq(rq) && e->ops->elevator_completed_req_fn)
849+
if ((rq->cmd_flags & REQ_SORTED) &&
850+
e->ops->elevator_completed_req_fn)
847851
e->ops->elevator_completed_req_fn(q, rq);
848852
}
849853

‎drivers/ata/libata-scsi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
11111111
*/
11121112
static int atapi_drain_needed(struct request *rq)
11131113
{
1114-
if (likely(!blk_pc_request(rq)))
1114+
if (likely(rq->cmd_type != REQ_TYPE_BLOCK_PC))
11151115
return 0;
11161116

11171117
if (!blk_rq_bytes(rq) || (rq->cmd_flags & REQ_RW))

0 commit comments

Comments
 (0)