From patchwork Sat Aug 6 09:37:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liubo X-Patchwork-Id: 1041272 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p769qqg1022469 for ; Sat, 6 Aug 2011 09:52:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754383Ab1HFJi4 (ORCPT ); Sat, 6 Aug 2011 05:38:56 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:55079 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752385Ab1HFJiv (ORCPT ); Sat, 6 Aug 2011 05:38:51 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id E4B05170129; Sat, 6 Aug 2011 17:38:44 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p769chDW005913; Sat, 6 Aug 2011 17:38:44 +0800 Received: from localhost.localdomain ([10.167.225.27]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011080617374355-63907 ; Sat, 6 Aug 2011 17:37:43 +0800 From: Liu Bo To: Cc: Subject: [PATCH 11/12 v5] Btrfs: do not iput inode when inode is still in log Date: Sat, 6 Aug 2011 17:37:46 +0800 Message-Id: <1312623467-31487-12-git-send-email-liubo2009@cn.fujitsu.com> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1312623467-31487-1-git-send-email-liubo2009@cn.fujitsu.com> References: <1312623467-31487-1-git-send-email-liubo2009@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-08-06 17:37:43, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-08-06 17:37:44, Serialize complete at 2011-08-06 17:37:44 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.6 (demeter2.kernel.org [140.211.167.43]); Sat, 06 Aug 2011 09:52:53 +0000 (UTC) We maintain the inode's logged_trans to avoid reloging it, but if we iput the inode and reread it, we'll get logged_trans to zero. So when an inode is still in log tree, and transaction is not committed yet, we do not iput the inode. Signed-off-by: Liu Bo --- fs/btrfs/inode.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a1f9155..10375fc 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6821,8 +6821,15 @@ int btrfs_drop_inode(struct inode *inode) { struct btrfs_root *root = BTRFS_I(inode)->root; - if (btrfs_root_refs(&root->root_item) == 0 && - !btrfs_is_free_space_inode(root, inode)) + /* + * If the inode has been in the log tree and the transaction is not + * committed yet, then we need to keep this inode in cache. + */ + if (BTRFS_I(inode)->last_trans >= root->fs_info->generation && + BTRFS_I(inode)->logged_trans >= BTRFS_I(inode)->last_trans) + return 0; + else if (btrfs_root_refs(&root->root_item) == 0 && + !btrfs_is_free_space_inode(root, inode)) return 1; else return generic_drop_inode(inode);