Skip to content

Commit d384995

Browse files
Christoph Hellwigaxboe
authored andcommitted
fs: decouple READ and WRITE from the block layer ops
Move READ and WRITE to kernel.h and don't define them in terms of block layer ops; they are our generic data direction indicators these days and have no more resemblance with the block layer ops. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent 70fd761 commit d384995

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

‎include/linux/bio.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
#define bio_sectors(bio) ((bio)->bi_iter.bi_size >> 9)
6363
#define bio_end_sector(bio) ((bio)->bi_iter.bi_sector + bio_sectors((bio)))
6464

65+
/*
66+
* Return the data direction, READ or WRITE.
67+
*/
68+
#define bio_data_dir(bio) \
69+
(op_is_write(bio_op(bio)) ? WRITE : READ)
70+
6571
/*
6672
* Check whether this bio carries any data or not. A NULL bio is allowed.
6773
*/

‎include/linux/fs.h‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,6 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
151151
*/
152152
#define CHECK_IOVEC_ONLY -1
153153

154-
#define RW_MASK REQ_OP_WRITE
155-
156-
#define READ REQ_OP_READ
157-
#define WRITE REQ_OP_WRITE
158-
159154
/*
160155
* Attribute flags. These should be or-ed together to figure out what
161156
* has been changed!
@@ -2452,14 +2447,6 @@ extern void make_bad_inode(struct inode *);
24522447
extern bool is_bad_inode(struct inode *);
24532448

24542449
#ifdef CONFIG_BLOCK
2455-
/*
2456-
* return data direction, READ or WRITE
2457-
*/
2458-
static inline int bio_data_dir(struct bio *bio)
2459-
{
2460-
return op_is_write(bio_op(bio)) ? WRITE : READ;
2461-
}
2462-
24632450
extern void check_disk_size_change(struct gendisk *disk,
24642451
struct block_device *bdev);
24652452
extern int revalidate_disk(struct gendisk *);

‎include/linux/kernel.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
5151
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
5252

53+
/* generic data direction definitions */
54+
#define READ 0
55+
#define WRITE 1
56+
5357
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
5458

5559
#define u64_to_user_ptr(x) ( \

‎include/linux/uio.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static inline bool iter_is_iovec(const struct iov_iter *i)
125125
*
126126
* The ?: is just for type safety.
127127
*/
128-
#define iov_iter_rw(i) ((0 ? (struct iov_iter *)0 : (i))->type & RW_MASK)
128+
#define iov_iter_rw(i) ((0 ? (struct iov_iter *)0 : (i))->type & (READ | WRITE))
129129

130130
/*
131131
* Cap the iov_iter by given limit; note that the second argument is

0 commit comments

Comments
 (0)