From patchwork Mon Dec 13 07:22:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaohua Li X-Patchwork-Id: 405052 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBD7MfmT028607 for ; Mon, 13 Dec 2010 07:22:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932334Ab0LMHWY (ORCPT ); Mon, 13 Dec 2010 02:22:24 -0500 Received: from mga02.intel.com ([134.134.136.20]:30789 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932206Ab0LMHWW (ORCPT ); Mon, 13 Dec 2010 02:22:22 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 12 Dec 2010 23:22:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,335,1288594800"; d="scan'208";a="583119553" Received: from sli10-conroe.sh.intel.com (HELO [10.239.36.47]) ([10.239.36.47]) by orsmga002.jf.intel.com with ESMTP; 12 Dec 2010 23:22:20 -0800 Subject: [RFC 4/5] implement metadata_ra in btrfs From: Shaohua Li To: "linux-btrfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" Cc: Chris Mason , Christoph Hellwig , Arjan van de Ven , Andrew Morton Date: Mon, 13 Dec 2010 15:22:16 +0800 Message-ID: <1292224936.2323.453.camel@sli10-conroe> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 13 Dec 2010 07:22:41 +0000 (UTC) Index: linux/fs/btrfs/disk-io.c =================================================================== --- linux.orig/fs/btrfs/disk-io.c 2010-12-07 13:32:24.000000000 +0800 +++ linux/fs/btrfs/disk-io.c 2010-12-07 13:33:08.000000000 +0800 @@ -776,6 +776,15 @@ static int btree_readpage(struct file *f return extent_read_full_page(tree, page, btree_get_extent); } +static int btree_readpages(struct file *file, struct address_space *mapping, + struct list_head *pages, unsigned nr_pages) +{ + struct extent_io_tree *tree; + tree = &BTRFS_I(mapping->host)->io_tree; + return extent_readpages(tree, mapping, pages, nr_pages, + btree_get_extent); +} + static int btree_releasepage(struct page *page, gfp_t gfp_flags) { struct extent_io_tree *tree; @@ -819,6 +828,7 @@ static void btree_invalidatepage(struct static const struct address_space_operations btree_aops = { .readpage = btree_readpage, + .readpages = btree_readpages, .writepage = btree_writepage, .writepages = btree_writepages, .releasepage = btree_releasepage, Index: linux/fs/btrfs/super.c =================================================================== --- linux.orig/fs/btrfs/super.c 2010-12-07 13:32:24.000000000 +0800 +++ linux/fs/btrfs/super.c 2010-12-07 13:33:08.000000000 +0800 @@ -892,6 +892,18 @@ out: return -ENOENT; } +static int btrfs_metadata_readahead(struct super_block *sb, loff_t offset, + ssize_t size) +{ + struct btrfs_root *tree_root = btrfs_sb(sb); + struct inode *btree_inode = tree_root->fs_info->btree_inode; + struct address_space *mapping = btree_inode->i_mapping; + + force_page_cache_readahead(mapping, NULL, offset >> PAGE_CACHE_SHIFT, + size >> PAGE_CACHE_SHIFT); + return 0; +} + static const struct super_operations btrfs_super_ops = { .drop_inode = btrfs_drop_inode, .evict_inode = btrfs_evict_inode, @@ -907,6 +919,7 @@ static const struct super_operations btr .freeze_fs = btrfs_freeze, .unfreeze_fs = btrfs_unfreeze, .metadata_incore = btrfs_metadata_incore, + .metadata_readahead = btrfs_metadata_readahead, }; static const struct file_operations btrfs_ctl_fops = { Index: linux/mm/readahead.c =================================================================== --- linux.orig/mm/readahead.c 2010-12-07 13:32:24.000000000 +0800 +++ linux/mm/readahead.c 2010-12-07 13:33:08.000000000 +0800 @@ -228,6 +228,7 @@ int force_page_cache_readahead(struct ad } return ret; } +EXPORT_SYMBOL_GPL(force_page_cache_readahead); /* * Given a desired number of PAGE_CACHE_SIZE readahead pages, return a