From patchwork Wed Sep 21 06:59:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoguang Wang X-Patchwork-Id: 9342893 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 34EF3607D4 for ; Wed, 21 Sep 2016 07:06:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 218A22A11A for ; Wed, 21 Sep 2016 07:06:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 162772A11D; Wed, 21 Sep 2016 07:06:30 +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 1DAC92A11A for ; Wed, 21 Sep 2016 07:06:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752733AbcIUHGW (ORCPT ); Wed, 21 Sep 2016 03:06:22 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:36126 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752139AbcIUHGW (ORCPT ); Wed, 21 Sep 2016 03:06:22 -0400 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="853825" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 21 Sep 2016 15:05:10 +0800 Received: from localhost.localdomain (unknown [10.167.226.107]) by cn.fujitsu.com (Postfix) with ESMTP id 924D44043CE5; Wed, 21 Sep 2016 15:05:07 +0800 (CST) From: Wang Xiaoguang To: linux-btrfs@vger.kernel.org Cc: jbacik@fb.com, dsterba@suse.cz Subject: [PATCH 2/2] btrfs: try to write enough delalloc bytes when reclaiming metadata space Date: Wed, 21 Sep 2016 14:59:33 +0800 Message-Id: <1474441173-31049-2-git-send-email-wangxg.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1474441173-31049-1-git-send-email-wangxg.fnst@cn.fujitsu.com> References: <1474441173-31049-1-git-send-email-wangxg.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 924D44043CE5.A1D20 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 Indeed as long as we have delalloc bytes and if we fail to reclaim requested metadata space, we should write these delalloc bytes and have one more try, this can fix some false enospc errors in some extreme cases. Signed-off-by: Wang Xiaoguang --- fs/btrfs/extent-tree.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index fdfc97f..46c2a37 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4794,6 +4794,15 @@ static int may_commit_transaction(struct btrfs_root *root, { struct btrfs_block_rsv *delayed_rsv = &root->fs_info->delayed_block_rsv; struct btrfs_trans_handle *trans; + struct btrfs_fs_info *fs_info = root->fs_info; + + /* + * shrink_delalloc() may not write enough delalloc bytes, so here we + * have a last try. Please don't remove these, because these can fix + * some false enospc error in some extreme cases. + */ + btrfs_start_delalloc_roots(fs_info, 0, -1); + btrfs_wait_ordered_roots(fs_info, -1, 0, (u64)-1); trans = (struct btrfs_trans_handle *)current->journal_info; if (trans)