From patchwork Wed Dec 1 08:09:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 370461 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 oB188DZV022479 for ; Wed, 1 Dec 2010 08:08:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754026Ab0LAIIF (ORCPT ); Wed, 1 Dec 2010 03:08:05 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:54236 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753588Ab0LAIIE (ORCPT ); Wed, 1 Dec 2010 03:08:04 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 76F58170E60 for ; Wed, 1 Dec 2010 16:08:03 +0800 (CST) Received: from mailserver.fnst.cn.fujitus.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id oB183QMM016843 for ; Wed, 1 Dec 2010 16:03:26 +0800 Received: from [10.167.225.64] ([10.167.225.64]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2010120116081459-135901 ; Wed, 1 Dec 2010 16:08:14 +0800 Message-ID: <4CF602BE.6090603@cn.fujitsu.com> Date: Wed, 01 Dec 2010 16:09:34 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: Linux Btrfs Subject: [RFC PATCH 3/4] btrfs: reduce the times of mmap() in fill_inode_item() X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-12-01 16:08:14, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-12-01 16:08:15, Serialize complete at 2010-12-01 16:08:15 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]); Wed, 01 Dec 2010 08:08:14 +0000 (UTC) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 46b9d1a..2f0c742 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2539,6 +2539,16 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, struct btrfs_inode_item *item, struct inode *inode) { + int unmap_on_exit; + + unmap_on_exit = (leaf->map_token == NULL); + if (unmap_on_exit) + map_extent_buffer(leaf, (unsigned long)item, + sizeof(*item), &leaf->map_token, + &leaf->kaddr, &leaf->map_start, + &leaf->map_len, KM_USER1); + + btrfs_set_inode_uid(leaf, item, inode->i_uid); btrfs_set_inode_gid(leaf, item, inode->i_gid); btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size); @@ -2567,6 +2577,11 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, btrfs_set_inode_rdev(leaf, item, inode->i_rdev); btrfs_set_inode_flags(leaf, item, BTRFS_I(inode)->flags); btrfs_set_inode_block_group(leaf, item, BTRFS_I(inode)->block_group); + + if (unmap_on_exit && leaf->map_token) { + unmap_extent_buffer(leaf, leaf->map_token, KM_USER1); + leaf->map_token = NULL; + } } /*