LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Ming Lei <ming.lei@canonical.com> To: linux-kernel@vger.kernel.org, Dave Kleikamp <dave.kleikamp@oracle.com> Cc: Jens Axboe <axboe@kernel.dk>, Zach Brown <zab@zabbo.net>, Christoph Hellwig <hch@infradead.org>, Maxim Patlasov <mpatlasov@parallels.com>, Andrew Morton <akpm@linux-foundation.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Benjamin LaHaise <bcrl@kvack.org>, Ming Lei <ming.lei@canonical.com>, Omar Sandoval <osandov@osandov.com>, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 2/4] fd/direct-io: introduce should_dirty for kernel aio Date: Tue, 13 Jan 2015 23:44:46 +0800 [thread overview] Message-ID: <1421163888-21452-3-git-send-email-ming.lei@canonical.com> (raw) In-Reply-To: <1421163888-21452-1-git-send-email-ming.lei@canonical.com> For pages from kernel AIO, it is required to dirty them before direct IO. The idea is borrowd from Dave previous post. Also set ->should_dirty only for ITER_IOVEC pages based on recent discussion in following link: http://marc.info/?t=141904556800003&r=1&w=2 Cc: Maxim Patlasov <mpatlasov@parallels.com> Cc: Omar Sandoval <osandov@osandov.com> Cc: Zach Brown <zab@zabbo.net> Cc: Dave Kleikamp <dave.kleikamp@oracle.com> Cc: Benjamin LaHaise <bcrl@kvack.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Ming Lei <ming.lei@canonical.com> --- fs/direct-io.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index e181b6b..4dd6d14 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -121,6 +121,7 @@ struct dio { int page_errors; /* errno from get_user_pages() */ int is_async; /* is IO async ? */ bool defer_completion; /* defer AIO completion to workqueue? */ + bool should_dirty; /* if page should be dirty */ int io_error; /* IO error in completion path */ unsigned long refcount; /* direct_io_worker() and bios */ struct bio *bio_list; /* singly linked via bi_private */ @@ -392,7 +393,7 @@ 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) + if (dio->is_async && dio->rw == READ && dio->should_dirty) bio_set_pages_dirty(bio); if (sdio->submit_io) @@ -463,13 +464,14 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio) if (!uptodate) dio->io_error = -EIO; - if (dio->is_async && dio->rw == READ) { + if (dio->is_async && dio->rw == READ && dio->should_dirty) { bio_check_pages_dirty(bio); /* transfers ownership */ } else { bio_for_each_segment_all(bvec, bio, i) { struct page *page = bvec->bv_page; - if (dio->rw == READ && !PageCompound(page)) + if (dio->rw == READ && !PageCompound(page) && + dio->should_dirty) set_page_dirty_lock(page); page_cache_release(page); } @@ -1217,6 +1219,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, spin_lock_init(&dio->bio_lock); dio->refcount = 1; + dio->should_dirty = iter_is_iovec(iter); sdio.iter = iter; sdio.final_block_in_request = -- 1.7.9.5
next prev parent reply other threads:[~2015-01-13 15:45 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-01-13 15:44 [PATCH v2 0/4] block & aio: improve loop with kernel aio Ming Lei 2015-01-13 15:44 ` [PATCH v2 1/4] aio: add aio_kernel_() interface Ming Lei 2015-01-25 13:31 ` Christoph Hellwig 2015-01-26 16:18 ` Ming Lei 2015-01-26 17:00 ` Christoph Hellwig 2015-01-27 13:57 ` Ming Lei 2015-01-27 17:59 ` Christoph Hellwig 2015-01-13 15:44 ` Ming Lei [this message] 2015-01-25 13:34 ` [PATCH v2 2/4] fd/direct-io: introduce should_dirty for kernel aio Christoph Hellwig 2015-01-27 16:05 ` Ming Lei 2015-01-13 15:44 ` [PATCH v2 3/4] block: loop: introduce 'use_aio' sysfs file Ming Lei 2015-01-25 13:35 ` Christoph Hellwig 2015-01-27 5:26 ` Ming Lei 2015-01-26 17:57 ` Jeff Moyer 2015-01-13 15:44 ` [PATCH v2 4/4] block: loop: support to submit I/O via kernel aio based Ming Lei 2015-01-25 13:40 ` Christoph Hellwig 2015-03-18 18:28 ` Maxim Patlasov 2015-03-19 2:57 ` Ming Lei 2015-03-19 16:37 ` Maxim Patlasov 2015-03-20 5:27 ` Ming Lei 2015-01-13 16:23 ` [PATCH v2 0/4] block & aio: improve loop with kernel aio Christoph Hellwig 2015-01-14 10:17 ` Ming Lei
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1421163888-21452-3-git-send-email-ming.lei@canonical.com \ --to=ming.lei@canonical.com \ --cc=akpm@linux-foundation.org \ --cc=axboe@kernel.dk \ --cc=bcrl@kvack.org \ --cc=dave.kleikamp@oracle.com \ --cc=hch@infradead.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mpatlasov@parallels.com \ --cc=osandov@osandov.com \ --cc=viro@zeniv.linux.org.uk \ --cc=zab@zabbo.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).