From patchwork Thu May 19 09:44:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoguang Wang X-Patchwork-Id: 9126081 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 53A8B9F1C3 for ; Thu, 19 May 2016 09:45:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FF962020F for ; Thu, 19 May 2016 09:45:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58DC120107 for ; Thu, 19 May 2016 09:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753595AbcESJpM (ORCPT ); Thu, 19 May 2016 05:45:12 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:16509 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753433AbcESJpL (ORCPT ); Thu, 19 May 2016 05:45:11 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="6703764" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 19 May 2016 17:45:02 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 128A8489F960 for ; Thu, 19 May 2016 17:44:57 +0800 (CST) Received: from localhost.localdomain (10.167.226.107) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.279.2; Thu, 19 May 2016 17:44:56 +0800 From: Wang Xiaoguang To: CC: Wang Xiaoguang Subject: [PATCH] btrfs: remove unnecessary btrfs_delalloc_release_metadata() call Date: Thu, 19 May 2016 17:44:10 +0800 Message-ID: <1463651050-6922-1-git-send-email-wangxg.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 X-Originating-IP: [10.167.226.107] X-yoursite-MailScanner-ID: 128A8489F960.A1B92 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: wangxg.fnst@cn.fujitsu.com X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In __btrfs_write_out_cache(), we don't call btrfs_delalloc_reserve_metadata() or btrfs_delalloc_reserve_space() to reserve metadata space, so we also should not call btrfs_delalloc_release_metadata(), in which BTRFS_I(inode)->outstanding_extents will be decreased, then WARN_ON(BTRFS_I(inode)->outstanding_extents) in btrfs_destroy_inode() will be triggered. To be honest, I do not see this WARNING in real, but I think we should fix it. Signed-off-by: Wang Xiaoguang --- fs/btrfs/free-space-cache.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 8f835bf..ababf56 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -3512,7 +3512,6 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root, struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; int ret; struct btrfs_io_ctl io_ctl; - bool release_metadata = true; if (!btrfs_test_opt(root, INODE_MAP_CACHE)) return 0; @@ -3520,26 +3519,16 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root, memset(&io_ctl, 0, sizeof(io_ctl)); ret = __btrfs_write_out_cache(root, inode, ctl, NULL, &io_ctl, trans, path, 0); - if (!ret) { - /* - * At this point writepages() didn't error out, so our metadata - * reservation is released when the writeback finishes, at - * inode.c:btrfs_finish_ordered_io(), regardless of it finishing - * with or without an error. - */ - release_metadata = false; + if (!ret) ret = btrfs_wait_cache_io(root, trans, NULL, &io_ctl, path, 0); - } - if (ret) { - if (release_metadata) - btrfs_delalloc_release_metadata(inode, inode->i_size); #ifdef DEBUG + if (ret) { btrfs_err(root->fs_info, "failed to write free ino cache for root %llu", root->root_key.objectid); -#endif } +#endif return ret; }