Skip to content

Commit e14575b

Browse files
committed
block: convert REQ_ATOM_COMPLETE to stealing rq->__deadline bit
We only have one atomic flag left. Instead of using an entire unsigned long for that, steal the bottom bit of the deadline field that we already reserved. Remove ->atomic_flags, since it's now unused. Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Omar Sandoval <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 0a72e7f commit e14575b

File tree

5 files changed

+12
-22
lines changed

5 files changed

+12
-22
lines changed

block/blk-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2853,7 +2853,7 @@ void blk_start_request(struct request *req)
28532853
wbt_issue(req->q->rq_wb, &req->issue_stat);
28542854
}
28552855

2856-
BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags));
2856+
BUG_ON(blk_rq_is_complete(req));
28572857
blk_add_timer(req);
28582858
}
28592859
EXPORT_SYMBOL(blk_start_request);

block/blk-mq-debugfs.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,6 @@ static const char *const rqf_name[] = {
294294
};
295295
#undef RQF_NAME
296296

297-
#define RQAF_NAME(name) [REQ_ATOM_##name] = #name
298-
static const char *const rqaf_name[] = {
299-
RQAF_NAME(COMPLETE),
300-
};
301-
#undef RQAF_NAME
302-
303297
int __blk_mq_debugfs_rq_show(struct seq_file *m, struct request *rq)
304298
{
305299
const struct blk_mq_ops *const mq_ops = rq->q->mq_ops;
@@ -316,8 +310,7 @@ int __blk_mq_debugfs_rq_show(struct seq_file *m, struct request *rq)
316310
seq_puts(m, ", .rq_flags=");
317311
blk_flags_show(m, (__force unsigned int)rq->rq_flags, rqf_name,
318312
ARRAY_SIZE(rqf_name));
319-
seq_puts(m, ", .atomic_flags=");
320-
blk_flags_show(m, rq->atomic_flags, rqaf_name, ARRAY_SIZE(rqaf_name));
313+
seq_printf(m, ", complete=%d", blk_rq_is_complete(rq));
321314
seq_printf(m, ", .tag=%d, .internal_tag=%d", rq->tag,
322315
rq->internal_tag);
323316
if (mq_ops->show_rq)

block/blk-mq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
294294
rq->rq_flags |= RQF_PREEMPT;
295295
if (blk_queue_io_stat(data->q))
296296
rq->rq_flags |= RQF_IO_STAT;
297-
/* do not touch atomic flags, it needs atomic ops against the timer */
298297
rq->cpu = -1;
299298
INIT_HLIST_NODE(&rq->hash);
300299
RB_CLEAR_NODE(&rq->rb_node);
@@ -313,6 +312,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
313312
rq->special = NULL;
314313
/* tag was already set */
315314
rq->extra_len = 0;
315+
rq->__deadline = 0;
316316

317317
INIT_LIST_HEAD(&rq->timeout_list);
318318
rq->timeout = 0;

block/blk.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,24 @@ void blk_account_io_start(struct request *req, bool new_io);
119119
void blk_account_io_completion(struct request *req, unsigned int bytes);
120120
void blk_account_io_done(struct request *req);
121121

122-
/*
123-
* Internal atomic flags for request handling
124-
*/
125-
enum rq_atomic_flags {
126-
REQ_ATOM_COMPLETE = 0,
127-
};
128-
129122
/*
130123
* EH timer and IO completion will both attempt to 'grab' the request, make
131-
* sure that only one of them succeeds
124+
* sure that only one of them succeeds. Steal the bottom bit of the
125+
* __deadline field for this.
132126
*/
133127
static inline int blk_mark_rq_complete(struct request *rq)
134128
{
135-
return test_and_set_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags);
129+
return test_and_set_bit(0, &rq->__deadline);
136130
}
137131

138132
static inline void blk_clear_rq_complete(struct request *rq)
139133
{
140-
clear_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags);
134+
clear_bit(0, &rq->__deadline);
135+
}
136+
137+
static inline bool blk_rq_is_complete(struct request *rq)
138+
{
139+
return test_bit(0, &rq->__deadline);
141140
}
142141

143142
/*

include/linux/blkdev.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ struct request {
156156

157157
int internal_tag;
158158

159-
unsigned long atomic_flags;
160-
161159
/* the following two fields are internal, NEVER access directly */
162160
unsigned int __data_len; /* total data len */
163161
int tag;

0 commit comments

Comments
 (0)