diff options
author | Jens Axboe <axboe@fb.com> | 2016-11-16 23:20:41 -0700 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-11-16 23:33:13 -0700 |
commit | 18eb8e94477813c190a2dfcd790c6707ab168377 (patch) | |
tree | 5d78618377bf5de8544596a422b73367342fac53 | |
parent | 3002cc26bfff9f6d62f3f6dc8ae49e087f289ad9 (diff) |
block: save 8 bytes of space in struct blkdev_diofor-4.10/hch-diofor-4.10/dio
The members 'waiter' and 'iocb' are mutually exclusive, since one
of them is for sync IO and the other for async. So put them in
a union.
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | fs/block_dev.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 1f7584d141f8..c642f04198b0 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -272,12 +272,15 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, } struct blkdev_dio { - struct kiocb *iocb; - struct task_struct *waiter; + union { + struct kiocb *iocb; + struct task_struct *waiter; + }; size_t size; atomic_t ref; bool multi_bio : 1; bool should_dirty : 1; + bool is_sync : 1; struct bio bio; }; @@ -286,13 +289,13 @@ static struct bio_set *blkdev_dio_pool __read_mostly; static void blkdev_bio_end_io(struct bio *bio) { struct blkdev_dio *dio = bio->bi_private; - struct kiocb *iocb = dio->iocb; if (dio->multi_bio && !atomic_dec_and_test(&dio->ref)) { if (bio->bi_error && !dio->bio.bi_error) dio->bio.bi_error = bio->bi_error; } else { - if (iocb) { + if (!dio->is_sync) { + struct kiocb *iocb = dio->iocb; ssize_t ret = dio->bio.bi_error; if (likely(!ret)) { @@ -332,7 +335,6 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) struct blkdev_dio *dio; struct bio *bio; bool is_read = (iov_iter_rw(iter) == READ); - bool is_sync = is_sync_kiocb(iocb); loff_t pos = iocb->ki_pos; blk_qc_t qc = BLK_QC_T_NONE; int ret; @@ -344,8 +346,12 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) bio_get(bio); /* extra ref for the completion handler */ dio = container_of(bio, struct blkdev_dio, bio); - dio->iocb = is_sync ? NULL : iocb; - dio->waiter = current; + dio->is_sync = is_sync_kiocb(iocb); + if (dio->is_sync) + dio->waiter = current; + else + dio->iocb = iocb; + dio->size = 0; dio->multi_bio = false; dio->should_dirty = is_read && (iter->type == ITER_IOVEC); @@ -392,7 +398,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) bio = bio_alloc(GFP_KERNEL, nr_pages); } - if (!is_sync) + if (!dio->is_sync) return -EIOCBQUEUED; for (;;) { |