From patchwork Thu Sep 22 09:25:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoguang Wang X-Patchwork-Id: 9344851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A9EC601C2 for ; Thu, 22 Sep 2016 09:31:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B6982A91E for ; Thu, 22 Sep 2016 09:31:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1049D2A920; Thu, 22 Sep 2016 09:31:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEDF62A91E for ; Thu, 22 Sep 2016 09:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756655AbcIVJbC (ORCPT ); Thu, 22 Sep 2016 05:31:02 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:60251 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753183AbcIVJbB (ORCPT ); Thu, 22 Sep 2016 05:31:01 -0400 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="856365" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 22 Sep 2016 17:30:56 +0800 Received: from localhost.localdomain (unknown [10.167.226.107]) by cn.fujitsu.com (Postfix) with ESMTP id 2055F4026B46; Thu, 22 Sep 2016 17:30:55 +0800 (CST) From: Wang Xiaoguang To: linux-btrfs@vger.kernel.org Cc: jbacik@fb.com, dsterba@suse.cz Subject: [RFC 3/3] btrfs: make shrink_delalloc() try harder to reclaim metadata space Date: Thu, 22 Sep 2016 17:25:19 +0800 Message-Id: <1474536319-22659-1-git-send-email-wangxg.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1474441173-31049-2-git-send-email-wangxg.fnst@cn.fujitsu.com> References: <1474441173-31049-2-git-send-email-wangxg.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 2055F4026B46.A17E0 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: wangxg.fnst@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since commit b02441999efcc6152b87cd58e7970bb7843f76cf, we don't wait all ordered extents, but I run into some enospc errors when doing large file create and delete test, it's because shrink_delalloc() does not write enough delalloc bytes and wait them finished: From: Miao Xie Date: Mon, 4 Nov 2013 23:13:25 +0800 Subject: [PATCH] Btrfs: don't wait for the completion of all the ordered extents It is very likely that there are lots of ordered extents in the filesytem, if we wait for the completion of all of them when we want to reclaim some space for the metadata space reservation, we would be blocked for a long time. The performance would drop down suddenly for a long time. But since Josef introduced "Btrfs: introduce ticketed enospc infrastructure", shrink_delalloc() starts to be run asynchronously, then If we want to reclaim metadata space, we can try harder, after all, false enospc error is not acceptable. Signed-off-by: Wang Xiaoguang --- fs/btrfs/extent-tree.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 46c2a37..f7c420b 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4721,7 +4721,7 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig, if (trans) return; if (wait_ordered) - btrfs_wait_ordered_roots(root->fs_info, items, + btrfs_wait_ordered_roots(root->fs_info, -1, 0, (u64)-1); return; } @@ -4775,6 +4775,14 @@ skip_async: } delalloc_bytes = percpu_counter_sum_positive( &root->fs_info->delalloc_bytes); + if (loops == 2) { + /* + * Try to write all current delalloc bytes and wait all + * ordered extents to have a last try. + */ + to_reclaim = delalloc_bytes; + items = -1; + } } }