public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@linux.intel.com>
To: Jens Axboe <jaxboe@fusionio.com>,
	Al Viro <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@lst.de>,
	linux-kernel@vger.kernel.org
Cc: Shane Michael Matthews <shane.matthews@intel.com>,
	Matthew Wilcox <willy@linux.intel.com>
Subject: [PATCH] Add readpages support for block devices
Date: Fri, 17 Dec 2010 19:27:53 -0500	[thread overview]
Message-ID: <1292632073-6196-1-git-send-email-willy@linux.intel.com> (raw)

From: Shane Michael Matthews <shane.matthews@intel.com>

Using mpage_readpages instead of multiple calls to blkdev_readpage reduces
the CPU utilisation by 35% when using dd to clone a drive.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Shane Michael Matthews <shane.matthews@intel.com>
---
 fs/block_dev.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 4230252..55cf932 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -318,6 +318,12 @@ static int blkdev_readpage(struct file * file, struct page * page)
 	return block_read_full_page(page, blkdev_get_block);
 }
 
+static int blkdev_readpages(struct file *file, struct address_space *mapping,
+			struct list_head *pages, unsigned nr_pages)
+{
+	return mpage_readpages(mapping, pages, nr_pages, blkdev_get_block);
+}
+
 static int blkdev_write_begin(struct file *file, struct address_space *mapping,
 			loff_t pos, unsigned len, unsigned flags,
 			struct page **pagep, void **fsdata)
@@ -1634,6 +1640,7 @@ static int blkdev_releasepage(struct page *page, gfp_t wait)
 
 static const struct address_space_operations def_blk_aops = {
 	.readpage	= blkdev_readpage,
+	.readpages	= blkdev_readpages,
 	.writepage	= blkdev_writepage,
 	.sync_page	= block_sync_page,
 	.write_begin	= blkdev_write_begin,
-- 
1.7.2.3


             reply	other threads:[~2010-12-18  0:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-18  0:27 Matthew Wilcox [this message]
2010-12-18  9:20 ` [PATCH] Add readpages support for block devices Christoph Hellwig
2010-12-19  3:35   ` Wu Fengguang

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=1292632073-6196-1-git-send-email-willy@linux.intel.com \
    --to=willy@linux.intel.com \
    --cc=hch@lst.de \
    --cc=jaxboe@fusionio.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shane.matthews@intel.com \
    --cc=viro@zeniv.linux.org.uk \
    /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: link
Be 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