From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6536129ED2; Mon, 18 Dec 2023 13:58:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="aNfjqvGz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A9D2C433C8; Mon, 18 Dec 2023 13:58:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1702907900; bh=SV0J3CCoA4Np0A6Hvy5ILqO+K4kvJEPVLZIwfWKuYWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aNfjqvGzT+sVehjGW1u4EsVmzZNF6XX6DBm58UGGDQKQXwqpemouNLLXMf1dCY/0n LU8tahFF6carPaWWmG/rpuKjmA2rhORvfSBWcY5+XwlsgITs9eV1qZKCFYTTxpimke 3/BI1Jefa/F889o0c8zv6M/WVxJtyZv2fU4QYCUQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qu Wenruo , Boris Burkov , David Sterba Subject: [PATCH 6.1 087/106] btrfs: free qgroup reserve when ORDERED_IOERR is set Date: Mon, 18 Dec 2023 14:51:41 +0100 Message-ID: <20231218135058.794976771@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218135055.005497074@linuxfoundation.org> References: <20231218135055.005497074@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Boris Burkov commit f63e1164b90b385cd832ff0fdfcfa76c3cc15436 upstream. An ordered extent completing is a critical moment in qgroup reserve handling, as the ownership of the reservation is handed off from the ordered extent to the delayed ref. In the happy path we release (unlock) but do not free (decrement counter) the reservation, and the delayed ref drives the free. However, on an error, we don't create a delayed ref, since there is no ref to add. Therefore, free on the error path. CC: stable@vger.kernel.org # 6.1+ Reviewed-by: Qu Wenruo Signed-off-by: Boris Burkov Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/ordered-data.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -544,7 +544,9 @@ void btrfs_remove_ordered_extent(struct release = entry->disk_num_bytes; else release = entry->num_bytes; - btrfs_delalloc_release_metadata(btrfs_inode, release, false); + btrfs_delalloc_release_metadata(btrfs_inode, release, + test_bit(BTRFS_ORDERED_IOERR, + &entry->flags)); } percpu_counter_add_batch(&fs_info->ordered_bytes, -entry->num_bytes,