Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1302220
| From | mchristi@redhat.com |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 06/35] direct-io: set bi_op to REQ_OP |
| Date | 2016-01-05 22:20 +0100 |
| Message-ID | <qNHbm-8sH-71@gated-at.bofh.it> (permalink) |
| References | <qNGRY-860-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Mike Christie <mchristi@redhat.com>
This patch has the dio code set the bio bi_op to a REQ_OP.
It also begins to convert btrfs's dio_submit_t related code,
because of the submit_io callout use. In the btrfs_submit_direct
change, I OR'd the op and flag back together. It is only temporary.
The next patch will completely convert all the btrfs code paths.
Signed-off-by: Mike Christie <mchristi@redhat.com>
---
fs/btrfs/inode.c | 9 +++++----
fs/direct-io.c | 35 +++++++++++++++++++++--------------
include/linux/fs.h | 2 +-
3 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 00f27eb..06f88bf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8300,14 +8300,14 @@ out_err:
return 0;
}
-static void btrfs_submit_direct(int rw, struct bio *dio_bio,
- struct inode *inode, loff_t file_offset)
+static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode,
+ loff_t file_offset)
{
struct btrfs_dio_private *dip = NULL;
struct bio *io_bio = NULL;
struct btrfs_io_bio *btrfs_bio;
int skip_sum;
- int write = rw & REQ_WRITE;
+ bool write = (dio_bio->bi_op == REQ_OP_WRITE);
int ret = 0;
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
@@ -8358,7 +8358,8 @@ static void btrfs_submit_direct(int rw, struct bio *dio_bio,
dio_data->unsubmitted_oe_range_end;
}
- ret = btrfs_submit_direct_hook(rw, dip, skip_sum);
+ ret = btrfs_submit_direct_hook(dio_bio->bi_op | dio_bio->bi_rw, dip,
+ skip_sum);
if (!ret)
return;
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 66b1d3eb..aa12742 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -108,7 +108,8 @@ struct dio_submit {
/* dio_state communicated between submission path and end_io */
struct dio {
int flags; /* doesn't change */
- int rw;
+ int op;
+ int op_flags;
blk_qc_t bio_cookie;
struct block_device *bio_bdev;
struct inode *inode;
@@ -163,7 +164,7 @@ static inline int dio_refill_pages(struct dio *dio, struct dio_submit *sdio)
ret = iov_iter_get_pages(sdio->iter, dio->pages, LONG_MAX, DIO_PAGES,
&sdio->from);
- if (ret < 0 && sdio->blocks_available && (dio->rw & WRITE)) {
+ if (ret < 0 && sdio->blocks_available && (dio->op == REQ_OP_WRITE)) {
struct page *page = ZERO_PAGE(0);
/*
* A memory fault, but the filesystem has some outstanding
@@ -242,7 +243,8 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret,
transferred = dio->result;
/* Check for short read case */
- if ((dio->rw == READ) && ((offset + transferred) > dio->i_size))
+ if ((dio->op == REQ_OP_READ) &&
+ ((offset + transferred) > dio->i_size))
transferred = dio->i_size - offset;
}
@@ -260,7 +262,7 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret,
inode_dio_end(dio->inode);
if (is_async) {
- if (dio->rw & WRITE) {
+ if (dio->op == REQ_OP_WRITE) {
int err;
err = generic_write_sync(dio->iocb->ki_filp, offset,
@@ -369,7 +371,8 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
bio->bi_bdev = bdev;
bio->bi_iter.bi_sector = first_sector;
- bio->bi_rw |= dio->rw;
+ bio->bi_op = dio->op;
+ bio->bi_rw |= dio->op_flags;
if (dio->is_async)
bio->bi_end_io = dio_bio_end_aio;
else
@@ -397,14 +400,13 @@ static inline void dio_bio_submit(struct dio *dio, struct dio_submit *sdio)
dio->refcount++;
spin_unlock_irqrestore(&dio->bio_lock, flags);
- if (dio->is_async && dio->rw == READ && dio->should_dirty)
+ if (dio->is_async && dio->op == REQ_OP_READ && dio->should_dirty)
bio_set_pages_dirty(bio);
dio->bio_bdev = bio->bi_bdev;
if (sdio->submit_io) {
- sdio->submit_io(dio->rw, bio, dio->inode,
- sdio->logical_offset_in_bio);
+ sdio->submit_io(bio, dio->inode, sdio->logical_offset_in_bio);
dio->bio_cookie = BLK_QC_T_NONE;
} else
dio->bio_cookie = submit_bio(bio);
@@ -472,14 +474,14 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio)
if (bio->bi_error)
dio->io_error = -EIO;
- if (dio->is_async && dio->rw == READ && dio->should_dirty) {
+ if (dio->is_async && dio->op == REQ_OP_READ && dio->should_dirty) {
bio_check_pages_dirty(bio); /* transfers ownership */
err = bio->bi_error;
} else {
bio_for_each_segment_all(bvec, bio, i) {
struct page *page = bvec->bv_page;
- if (dio->rw == READ && !PageCompound(page) &&
+ if (dio->op == REQ_OP_READ && !PageCompound(page) &&
dio->should_dirty)
set_page_dirty_lock(page);
page_cache_release(page);
@@ -632,7 +634,7 @@ static int get_more_blocks(struct dio *dio, struct dio_submit *sdio,
* which may decide to handle it or also return an unmapped
* buffer head.
*/
- create = dio->rw & WRITE;
+ create = dio->op == REQ_OP_WRITE;
if (dio->flags & DIO_SKIP_HOLES) {
if (sdio->block_in_file < (i_size_read(dio->inode) >>
sdio->blkbits))
@@ -782,7 +784,7 @@ submit_page_section(struct dio *dio, struct dio_submit *sdio, struct page *page,
{
int ret = 0;
- if (dio->rw & WRITE) {
+ if (dio->op == REQ_OP_WRITE) {
/*
* Read accounting is performed in submit_bio()
*/
@@ -982,7 +984,7 @@ do_holes:
loff_t i_size_aligned;
/* AKPM: eargh, -ENOTBLK is a hack */
- if (dio->rw & WRITE) {
+ if (dio->op == REQ_OP_WRITE) {
page_cache_release(page);
return -ENOTBLK;
}
@@ -1195,7 +1197,12 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
dio->is_async = true;
dio->inode = inode;
- dio->rw = iov_iter_rw(iter) == WRITE ? WRITE_ODIRECT : READ;
+ if (iov_iter_rw(iter) == WRITE) {
+ dio->op = REQ_OP_WRITE;
+ dio->op_flags = WRITE_ODIRECT;
+ } else {
+ dio->op = REQ_OP_READ;
+ }
/*
* For AIO O_(D)SYNC writes we need to defer completions to a workqueue
diff --git a/include/linux/fs.h b/include/linux/fs.h
index fb9e516..3ab5342 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2731,7 +2731,7 @@ extern int generic_file_open(struct inode * inode, struct file * filp);
extern int nonseekable_open(struct inode * inode, struct file * filp);
#ifdef CONFIG_BLOCK
-typedef void (dio_submit_t)(int rw, struct bio *bio, struct inode *inode,
+typedef void (dio_submit_t)(struct bio *bio, struct inode *inode,
loff_t file_offset);
enum {
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/35 v2] separate operations from flags in the bio/request structs mchristi@redhat.com - 2016-01-05 22:00 +0100
[PATCH 35/35] block, drivers, fs: rename REQ_FLUSH to REQ_PREFLUSH mchristi@redhat.com - 2016-01-05 22:00 +0100
Re: [PATCH 35/35] block, drivers, fs: rename REQ_FLUSH to REQ_PREFLUSH kbuild test robot <lkp@intel.com> - 2016-01-06 01:00 +0100
[PATCH 21/35] bcache: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields mchristi@redhat.com - 2016-01-05 22:10 +0100
Re: [PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields "Martin K. Petersen" <martin.petersen@oracle.com> - 2016-01-07 00:20 +0100
Re: [PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields Christoph Hellwig <hch@infradead.org> - 2016-01-09 14:40 +0100
Re: [dm-devel] [PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields Mike Christie <michaelc@cs.wisc.edu> - 2016-01-10 02:00 +0100
Re: [dm-devel] [PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields Mike Christie <michaelc@cs.wisc.edu> - 2016-01-10 02:30 +0100
Re: [dm-devel] [PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields Christoph Hellwig <hch@infradead.org> - 2016-01-10 08:20 +0100
Re: [dm-devel] [PATCH 02/35] block: add REQ_OP definitions and bi_op/op fields Christoph Hellwig <hch@infradead.org> - 2016-01-10 08:20 +0100
[PATCH 22/35] drbd: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 13/35] xfs: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
Re: [PATCH 13/35] xfs: set bi_op to REQ_OP Dave Chinner <david@fromorbit.com> - 2016-01-07 04:20 +0100
[PATCH 14/35] hfsplus: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 15/35] mpage: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 28/35] blktrace: get op from req->op/bio->bi_op mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 18/35] pm: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 12/35] gfs2: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 19/35] dm: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 24/35] xen: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 10/35] btrfs: don't pass rq_flag_bits if there is a bio mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 27/35] drivers: set request op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 23/35] md/raid: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 09/35] btrfs: update __btrfs_map_block for bi_op transition mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 16/35] nilfs: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 25/35] target: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
Re: [PATCH 25/35] target: set bi_op to REQ_OP "Nicholas A. Bellinger" <nab@linux-iscsi.org> - 2016-01-06 20:10 +0100
[PATCH 17/35] ocfs2: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:10 +0100
[PATCH 07/35] btrfs: have submit_one_bio users setup bio bi_op mchristi@redhat.com - 2016-01-05 22:20 +0100
[PATCH 06/35] direct-io: set bi_op to REQ_OP mchristi@redhat.com - 2016-01-05 22:20 +0100
[PATCH 08/35] btrfs: set bi_op tp REQ_OP mchristi@redhat.com - 2016-01-05 22:20 +0100
[PATCH 05/35] fs: have ll_rw_block users pass in op and flags separately mchristi@redhat.com - 2016-01-05 22:20 +0100
Re: [PATCH 05/35] fs: have ll_rw_block users pass in op and flags separately kbuild test robot <lkp@intel.com> - 2016-01-06 00:30 +0100
[PATCH 04/35] fs: have submit_bh users pass in op and flags separately mchristi@redhat.com - 2016-01-05 22:20 +0100
Re: [PATCH 00/35 v2] separate operations from flags in the bio/request structs "Martin K. Petersen" <martin.petersen@oracle.com> - 2016-01-07 02:50 +0100
Re: [PATCH 00/35 v2] separate operations from flags in the bio/request structs Dave Chinner <david@fromorbit.com> - 2016-01-07 04:20 +0100
Re: [PATCH 00/35 v2] separate operations from flags in the bio/request structs Christoph Hellwig <hch@infradead.org> - 2016-01-08 14:40 +0100
Re: [PATCH 00/35 v2] separate operations from flags in the bio/request structs Mike Christie <michaelc@cs.wisc.edu> - 2016-01-08 22:00 +0100
Re: [PATCH 00/35 v2] separate operations from flags in the bio/request structs Mike Snitzer <snitzer@redhat.com> - 2016-01-09 00:10 +0100
Re: [PATCH 01/35] block/fs/drivers: remove rw argument from submit_bio Christoph Hellwig <hch@infradead.org> - 2016-01-09 14:40 +0100
Re: [PATCH 01/35] block/fs/drivers: remove rw argument from submit_bio Mike Christie <michaelc@cs.wisc.edu> - 2016-01-10 01:50 +0100
csiph-web