Skip to content

Commit 4e1b2d5

Browse files
Mike Christieaxboe
authored andcommitted
block, fs, drivers: remove REQ_OP compat defs and related code
This patch drops the compat definition of req_op where it matches the rq_flag_bits definitions, and drops the related old and compat code that allowed users to set either the op or flags for the operation. We also then store the operation in the bi_rw/cmd_flags field similar to how we used to store the bio ioprio where it sat in the upper bits of the field. Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 6296b96 commit 4e1b2d5

File tree

6 files changed

+46
-63
lines changed

6 files changed

+46
-63
lines changed

drivers/scsi/sd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
10121012
} else if (rq_data_dir(rq) == READ) {
10131013
SCpnt->cmnd[0] = READ_6;
10141014
} else {
1015-
scmd_printk(KERN_ERR, SCpnt, "Unknown command %d,%llx\n",
1015+
scmd_printk(KERN_ERR, SCpnt, "Unknown command %llu,%llx\n",
10161016
req_op(rq), (unsigned long long) rq->cmd_flags);
10171017
goto out;
10181018
}

include/linux/bio.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@
4444
#define BIO_MAX_SIZE (BIO_MAX_PAGES << PAGE_SHIFT)
4545
#define BIO_MAX_SECTORS (BIO_MAX_SIZE >> 9)
4646

47-
#define bio_op(bio) (op_from_rq_bits((bio)->bi_rw))
48-
#define bio_set_op_attrs(bio, op, flags) ((bio)->bi_rw |= (op | flags))
49-
5047
#define bio_prio(bio) (bio)->bi_ioprio
5148
#define bio_set_prio(bio, prio) ((bio)->bi_ioprio = prio)
5249

include/linux/blk_types.h

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ struct bio {
4848
struct block_device *bi_bdev;
4949
unsigned int bi_flags; /* status, command, etc */
5050
int bi_error;
51-
unsigned int bi_rw; /* READ/WRITE */
51+
unsigned int bi_rw; /* bottom bits req flags,
52+
* top bits REQ_OP
53+
*/
5254
unsigned short bi_ioprio;
5355

5456
struct bvec_iter bi_iter;
@@ -106,6 +108,16 @@ struct bio {
106108
struct bio_vec bi_inline_vecs[0];
107109
};
108110

111+
#define BIO_OP_SHIFT (8 * sizeof(unsigned int) - REQ_OP_BITS)
112+
#define bio_op(bio) ((bio)->bi_rw >> BIO_OP_SHIFT)
113+
114+
#define bio_set_op_attrs(bio, op, op_flags) do { \
115+
WARN_ON(op >= (1 << REQ_OP_BITS)); \
116+
(bio)->bi_rw &= ((1 << BIO_OP_SHIFT) - 1); \
117+
(bio)->bi_rw |= ((unsigned int) (op) << BIO_OP_SHIFT); \
118+
(bio)->bi_rw |= op_flags; \
119+
} while (0)
120+
109121
#define BIO_RESET_BYTES offsetof(struct bio, bi_max_vecs)
110122

111123
/*
@@ -144,17 +156,14 @@ struct bio {
144156
*/
145157
enum rq_flag_bits {
146158
/* common flags */
147-
__REQ_WRITE, /* not set, read. set, write */
148159
__REQ_FAILFAST_DEV, /* no driver retries of device errors */
149160
__REQ_FAILFAST_TRANSPORT, /* no driver retries of transport errors */
150161
__REQ_FAILFAST_DRIVER, /* no driver retries of driver errors */
151162

152163
__REQ_SYNC, /* request is sync (sync write or read) */
153164
__REQ_META, /* metadata io request */
154165
__REQ_PRIO, /* boost priority in cfq */
155-
__REQ_DISCARD, /* request to discard sectors */
156-
__REQ_SECURE, /* secure discard (used with __REQ_DISCARD) */
157-
__REQ_WRITE_SAME, /* write same block many times */
166+
__REQ_SECURE, /* secure discard (used with REQ_OP_DISCARD) */
158167

159168
__REQ_NOIDLE, /* don't anticipate more IO after this one */
160169
__REQ_INTEGRITY, /* I/O includes block integrity payload */
@@ -190,28 +199,22 @@ enum rq_flag_bits {
190199
__REQ_NR_BITS, /* stops here */
191200
};
192201

193-
#define REQ_WRITE (1ULL << __REQ_WRITE)
194202
#define REQ_FAILFAST_DEV (1ULL << __REQ_FAILFAST_DEV)
195203
#define REQ_FAILFAST_TRANSPORT (1ULL << __REQ_FAILFAST_TRANSPORT)
196204
#define REQ_FAILFAST_DRIVER (1ULL << __REQ_FAILFAST_DRIVER)
197205
#define REQ_SYNC (1ULL << __REQ_SYNC)
198206
#define REQ_META (1ULL << __REQ_META)
199207
#define REQ_PRIO (1ULL << __REQ_PRIO)
200-
#define REQ_DISCARD (1ULL << __REQ_DISCARD)
201-
#define REQ_WRITE_SAME (1ULL << __REQ_WRITE_SAME)
202208
#define REQ_NOIDLE (1ULL << __REQ_NOIDLE)
203209
#define REQ_INTEGRITY (1ULL << __REQ_INTEGRITY)
204210

205211
#define REQ_FAILFAST_MASK \
206212
(REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
207213
#define REQ_COMMON_MASK \
208-
(REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_PRIO | \
209-
REQ_DISCARD | REQ_WRITE_SAME | REQ_NOIDLE | REQ_FLUSH | REQ_FUA | \
210-
REQ_SECURE | REQ_INTEGRITY | REQ_NOMERGE)
214+
(REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_PRIO | REQ_NOIDLE | \
215+
REQ_FLUSH | REQ_FUA | REQ_SECURE | REQ_INTEGRITY | REQ_NOMERGE)
211216
#define REQ_CLONE_MASK REQ_COMMON_MASK
212217

213-
#define BIO_NO_ADVANCE_ITER_MASK (REQ_DISCARD|REQ_WRITE_SAME)
214-
215218
/* This mask is used for both bio and request merge checking */
216219
#define REQ_NOMERGE_FLAGS \
217220
(REQ_NOMERGE | REQ_STARTED | REQ_SOFTBARRIER | REQ_FLUSH | REQ_FUA | REQ_FLUSH_SEQ)
@@ -243,27 +246,12 @@ enum rq_flag_bits {
243246

244247
enum req_op {
245248
REQ_OP_READ,
246-
REQ_OP_WRITE = REQ_WRITE,
247-
REQ_OP_DISCARD = REQ_DISCARD,
248-
REQ_OP_WRITE_SAME = REQ_WRITE_SAME,
249+
REQ_OP_WRITE,
250+
REQ_OP_DISCARD, /* request to discard sectors */
251+
REQ_OP_WRITE_SAME, /* write same block many times */
249252
};
250253

251-
/*
252-
* tmp cpmpat. Users used to set the write bit for all non reads, but
253-
* we will be dropping the bitmap use for ops. Support both until
254-
* the end of the patchset.
255-
*/
256-
static inline int op_from_rq_bits(u64 flags)
257-
{
258-
if (flags & REQ_OP_DISCARD)
259-
return REQ_OP_DISCARD;
260-
else if (flags & REQ_OP_WRITE_SAME)
261-
return REQ_OP_WRITE_SAME;
262-
else if (flags & REQ_OP_WRITE)
263-
return REQ_OP_WRITE;
264-
else
265-
return REQ_OP_READ;
266-
}
254+
#define REQ_OP_BITS 2
267255

268256
typedef unsigned int blk_qc_t;
269257
#define BLK_QC_T_NONE -1U

include/linux/blkdev.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,15 @@ struct request {
200200
struct request *next_rq;
201201
};
202202

203-
#define req_op(req) (op_from_rq_bits((req)->cmd_flags))
204-
#define req_set_op(req, op) ((req)->cmd_flags |= op)
203+
#define REQ_OP_SHIFT (8 * sizeof(u64) - REQ_OP_BITS)
204+
#define req_op(req) ((req)->cmd_flags >> REQ_OP_SHIFT)
205+
206+
#define req_set_op(req, op) do { \
207+
WARN_ON(op >= (1 << REQ_OP_BITS)); \
208+
(req)->cmd_flags &= ((1ULL << REQ_OP_SHIFT) - 1); \
209+
(req)->cmd_flags |= ((u64) (op) << REQ_OP_SHIFT); \
210+
} while (0)
211+
205212
#define req_set_op_attrs(req, op, flags) do { \
206213
req_set_op(req, op); \
207214
(req)->cmd_flags |= flags; \
@@ -604,8 +611,7 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
604611

605612
#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist)
606613

607-
#define rq_data_dir(rq) \
608-
(op_is_write(op_from_rq_bits(rq->cmd_flags)) ? WRITE : READ)
614+
#define rq_data_dir(rq) (op_is_write(req_op(rq)) ? WRITE : READ)
609615

610616
/*
611617
* Driver can handle struct request, if it either has an old style

include/linux/fs.h

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
152152
#define CHECK_IOVEC_ONLY -1
153153

154154
/*
155-
* The below are the various read and write types that we support. Some of
155+
* The below are the various read and write flags that we support. Some of
156156
* them include behavioral modifiers that send information down to the
157-
* block layer and IO scheduler. Terminology:
157+
* block layer and IO scheduler. They should be used along with a req_op.
158+
* Terminology:
158159
*
159160
* The block layer uses device plugging to defer IO a little bit, in
160161
* the hope that we will see more IO very shortly. This increases
@@ -193,19 +194,19 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
193194
* non-volatile media on completion.
194195
*
195196
*/
196-
#define RW_MASK REQ_WRITE
197+
#define RW_MASK REQ_OP_WRITE
197198
#define RWA_MASK REQ_RAHEAD
198199

199-
#define READ 0
200+
#define READ REQ_OP_READ
200201
#define WRITE RW_MASK
201202
#define READA RWA_MASK
202203

203-
#define READ_SYNC (READ | REQ_SYNC)
204-
#define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE)
205-
#define WRITE_ODIRECT (WRITE | REQ_SYNC)
206-
#define WRITE_FLUSH (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH)
207-
#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
208-
#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
204+
#define READ_SYNC REQ_SYNC
205+
#define WRITE_SYNC (REQ_SYNC | REQ_NOIDLE)
206+
#define WRITE_ODIRECT REQ_SYNC
207+
#define WRITE_FLUSH (REQ_SYNC | REQ_NOIDLE | REQ_FLUSH)
208+
#define WRITE_FUA (REQ_SYNC | REQ_NOIDLE | REQ_FUA)
209+
#define WRITE_FLUSH_FUA (REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
209210

210211
/*
211212
* Attribute flags. These should be or-ed together to figure out what
@@ -2464,25 +2465,17 @@ extern void make_bad_inode(struct inode *);
24642465
extern bool is_bad_inode(struct inode *);
24652466

24662467
#ifdef CONFIG_BLOCK
2467-
/*
2468-
* tmp cpmpat. Users used to set the write bit for all non reads, but
2469-
* we will be dropping the bitmap use for ops. Support both until
2470-
* the end of the patchset.
2471-
*/
2472-
static inline bool op_is_write(unsigned long flags)
2468+
static inline bool op_is_write(unsigned int op)
24732469
{
2474-
if (flags & (REQ_OP_WRITE | REQ_OP_WRITE_SAME | REQ_OP_DISCARD))
2475-
return true;
2476-
else
2477-
return false;
2470+
return op == REQ_OP_READ ? false : true;
24782471
}
24792472

24802473
/*
24812474
* return READ, READA, or WRITE
24822475
*/
24832476
static inline int bio_rw(struct bio *bio)
24842477
{
2485-
if (op_is_write(op_from_rq_bits(bio->bi_rw)))
2478+
if (op_is_write(bio_op(bio)))
24862479
return WRITE;
24872480

24882481
return bio->bi_rw & RWA_MASK;
@@ -2493,7 +2486,7 @@ static inline int bio_rw(struct bio *bio)
24932486
*/
24942487
static inline int bio_data_dir(struct bio *bio)
24952488
{
2496-
return op_is_write(op_from_rq_bits(bio->bi_rw)) ? WRITE : READ;
2489+
return op_is_write(bio_op(bio)) ? WRITE : READ;
24972490
}
24982491

24992492
extern void check_disk_size_change(struct gendisk *disk,

include/trace/events/f2fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ TRACE_DEFINE_ENUM(BG_GC);
3131
TRACE_DEFINE_ENUM(LFS);
3232
TRACE_DEFINE_ENUM(SSR);
3333
TRACE_DEFINE_ENUM(__REQ_RAHEAD);
34-
TRACE_DEFINE_ENUM(__REQ_WRITE);
3534
TRACE_DEFINE_ENUM(__REQ_SYNC);
3635
TRACE_DEFINE_ENUM(__REQ_NOIDLE);
3736
TRACE_DEFINE_ENUM(__REQ_FLUSH);

0 commit comments

Comments
 (0)