Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp117840ybg; Mon, 8 Jun 2020 18:06:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzm2Az0u+by3A6OwQOwgJl92YaoHHxqQAY++6UvbzONEyouAdQhERCy1KubWc1d4KBzsZGt X-Received: by 2002:a17:906:4ecf:: with SMTP id i15mr24324964ejv.515.1591664778548; Mon, 08 Jun 2020 18:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664778; cv=none; d=google.com; s=arc-20160816; b=kMTRprsgOfJKZh24DbHQt2jj6xCF2+4HrE5uAqBaEtj92Ec0OvlXvbJSa80fT5EHSA JIt8UGKt5UE44cAkEwuGxngPLGeHhSDJ9hfLbWOc7aOJCeG8jk+Qvzs2pYuBNwS07Ghm cFZ+wN2SvAbZcq9TOb9o8QHn9nyXJDnsh6h5ho3WOitC02B7OB3P7PDjfnXvMyfqlXoe gU0woryVnnjXJUNELPad0c1zyVbVZSOy8IFBMdRCQWFfhHrxDgfxUZnyEJa7knGvSpLc FeQPxPyA2vC/4XrfErKKIYpLkLBoJK6u2nD59Q+6HA7hWDrI68HTgSTkcu9cGiRvNrpo j6bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/GYqU0DxMhdSzrlm1rEWK91OLOFY/HrFZjrEvRQ4aLc=; b=cKVRLYigYUNmhPRIfJnm3VAg073l26bOYB3/uG5EQWI7VCREsSZfgV89YAOqqnVnuw MHlXLNYTQe3qiEUp7rp3vgyk30Oaxf2JsU/iu9Tvf2d2WqhpuecE+BxzldotH0ovRtvC Do7oVu7QI6aTn1RB4TYqU3fq0xz2zVY9adAtOpRQu9vscaslO6GkeemPpQcDVucmAbx6 sXH17xUWWTf0PchdxNuu+t6Rr22/X4ZPqpGQTe+IKbvk56YqQg+8ajOTg4m/dkUV6EBy Vo81JQzaxlCEpmGJ/dz9f6QztnVT8ppFr5JVVmP0FO7OeTKTvaRFEVzYMhTAUmk2VwyC hnYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SZ3HKNaW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si8058447eje.542.2020.06.08.18.05.55; Mon, 08 Jun 2020 18:06:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SZ3HKNaW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731743AbgFIBED (ORCPT + 99 others); Mon, 8 Jun 2020 21:04:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:52002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727937AbgFHXHf (ORCPT ); Mon, 8 Jun 2020 19:07:35 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B391E20885; Mon, 8 Jun 2020 23:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657654; bh=P9JcKZNM/8l/scsQa6x9Ys0iK7XhzU3x66U2UwdZeQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SZ3HKNaWkgGU9iBOv0lhEAM32EnvC1FV529OMzedjSkyqOwPP0VjxQ3DNO5CM4wU+ Uh3BsOLaxwna/S8KF8EtyNmBOIhCUD9lMNBZtHFyn83IzUK12/TljrH2IQBT28MviZ YdGyg4/+1ot/bTpN7PkNksYAgNy6lWwckbVuNOeQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josef Bacik , Nikolay Borisov , David Sterba , Sasha Levin , linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 067/274] btrfs: account for trans_block_rsv in may_commit_transaction Date: Mon, 8 Jun 2020 19:02:40 -0400 Message-Id: <20200608230607.3361041-67-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik [ Upstream commit bb4f58a747f0421b10645fbf75a6acc88da0de50 ] On ppc64le with 64k page size (respectively 64k block size) generic/320 was failing and debug output showed we were getting a premature ENOSPC with a bunch of space in btrfs_fs_info::trans_block_rsv. This meant there were still open transaction handles holding space, yet the flusher didn't commit the transaction because it deemed the freed space won't be enough to satisfy the current reserve ticket. Fix this by accounting for space in trans_block_rsv when deciding whether the current transaction should be committed or not. Reviewed-by: Nikolay Borisov Tested-by: Nikolay Borisov Signed-off-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/space-info.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index ff17a4420358..3c0e9999bfd7 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -626,6 +626,7 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, struct reserve_ticket *ticket = NULL; struct btrfs_block_rsv *delayed_rsv = &fs_info->delayed_block_rsv; struct btrfs_block_rsv *delayed_refs_rsv = &fs_info->delayed_refs_rsv; + struct btrfs_block_rsv *trans_rsv = &fs_info->trans_block_rsv; struct btrfs_trans_handle *trans; u64 bytes_needed; u64 reclaim_bytes = 0; @@ -688,6 +689,11 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, spin_lock(&delayed_refs_rsv->lock); reclaim_bytes += delayed_refs_rsv->reserved; spin_unlock(&delayed_refs_rsv->lock); + + spin_lock(&trans_rsv->lock); + reclaim_bytes += trans_rsv->reserved; + spin_unlock(&trans_rsv->lock); + if (reclaim_bytes >= bytes_needed) goto commit; bytes_needed -= reclaim_bytes; -- 2.25.1