Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755899AbbGPQtQ (ORCPT ); Thu, 16 Jul 2015 12:49:16 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:50820 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752210AbbGPQtP (ORCPT ); Thu, 16 Jul 2015 12:49:15 -0400 Subject: Re: [PATCH v7 1/6] fs: direct-io: don't dirtying pages for ITER_BVEC/ITER_KVEC direct read To: Ming Lei , Jens Axboe , linux-kernel@vger.kernel.org References: <1437061068-26118-1-git-send-email-ming.lei@canonical.com> <1437061068-26118-2-git-send-email-ming.lei@canonical.com> Cc: "Justin M. Forbes" , Jeff Moyer , Tejun Heo , Christoph Hellwig From: Dave Kleikamp Message-ID: <55A7E063.20003@oracle.com> Date: Thu, 16 Jul 2015 11:48:35 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1437061068-26118-2-git-send-email-ming.lei@canonical.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2854 Lines: 74 On 07/16/2015 10:37 AM, Ming Lei wrote: > When direct read IO is submitted from kernel, it is often > unnecessary to dirty pages, for example of loop, dirtying pages > have been considered in the upper filesystem(over loop) side > already, and they don't need to be dirtied again. > > So this patch doesn't dirtying pages for ITER_BVEC/ITER_KVEC > direct read, and loop should be the 1st case to use ITER_BVEC/ITER_KVEC > for direct read I/O. > > The patch is based on previous Dave's patch. > > Cc: Dave Kleikamp > Reviewed-by: Christoph Hellwig > Signed-off-by: Ming Lei Reviewed-by: Dave Kleikamp > --- > 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 745d234..07e4b28 100644 > --- a/fs/direct-io.c > +++ b/fs/direct-io.c > @@ -120,6 +120,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 pages should be dirtied */ > 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 */ > @@ -393,7 +394,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) > @@ -464,13 +465,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(struct kiocb *iocb, struct inode *inode, > spin_lock_init(&dio->bio_lock); > dio->refcount = 1; > > + dio->should_dirty = (iter->type == ITER_IOVEC); > sdio.iter = iter; > sdio.final_block_in_request = > (offset + iov_iter_count(iter)) >> blkbits; > -- 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/