Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1711167pxb; Mon, 8 Mar 2021 04:39:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzM5X+18S6d+lADPnBbkOw/MUM5tPR0LvJ65HqWfEFhcniRqYqkeMEnAiw/Z33OaJ7Osz9b X-Received: by 2002:aa7:d987:: with SMTP id u7mr21559580eds.326.1615207163677; Mon, 08 Mar 2021 04:39:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615207163; cv=none; d=google.com; s=arc-20160816; b=0zA05TahSIcW1X014gFy562cedrz2rNp83duVYG8WssxRQ/B/dzGwQjXT9a052felB u3HJoU2R3Q3VnQuGYRWjP05ArUiaLJPTFTcg7/vf43iIpePaap3qSrHKTme6DQ+sIJsH n0P/36wm8lvOQAtWyDuIUg1KxLfJKmx6qa2zJJ3Alrs0L9hL//UXmVJ3MnahQAMAgvAZ pyOQUdhT1g+b7hQP+62/F5FLHnRFOP/c2Nn5NWN7EKTmwcz7AVFF6/n/jpYd0YI+1HNg mLAGCGnQ0PMIdFtHVSYAZAE5W0T80tgGd5mHtbejo2JYy/wpbDuQqPPpTeG2tw8H69fH QvXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UG9H7U5xZtmm6PFvD/PYrabbZfWhAc9clYOOZqMHD3A=; b=XZ4Rae3pmKQHBkLCYkYYjw1ODnWXIigtz0Yvo2TQOvvwVSS4010Cu9WdiHngQ8Lsqf Ttxjf3CfoIWOtcIquPZPJqvkBlTluOIIwgbXS2OZaLuGY6bttbmSSBXF2t44RexzEitc +R3iJRNKCLMdrqOMGDfIzIi/WqZqoOhDWn3L5vLATTA/QSti6Sd08taGWVRJug2LrRL3 +N3CldUikLdl9IB4OZrqKZnafooV5Xuy8ldulkzVfqiKc9nMVh5eivbNtqNFZL0Vj3fn 6FGLC16SLijq6Vo5tLJqJRgSH4iBFB3CE743tswSn//7Trn1dKs3ztgzltCclZveZmsn cOFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wz1eu6sL; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si6656565edv.547.2021.03.08.04.39.01; Mon, 08 Mar 2021 04:39:23 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=Wz1eu6sL; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232276AbhCHMfs (ORCPT + 99 others); Mon, 8 Mar 2021 07:35:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:44252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232127AbhCHMfQ (ORCPT ); Mon, 8 Mar 2021 07:35:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 82EBF64EBC; Mon, 8 Mar 2021 12:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615206916; bh=/deGr9Mnn5LBqI2w/zNfMGMTuJ2ozKZpFlyPbvb7kqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wz1eu6sLLQDMdtOB4g43fxL+IuaXk+Nw8WYuFqAirB45XfDU6craEOEy+Dn5//ScL Cdc6dEF3tTjBiXFpw9ottf7izfOOXnO764vF0ICqQUAGrMvdAQ96w8sYSNlzlE1q4c DH08mBOvZnHLTmRM49ZyoAPuMMQrk19jemRsSdVc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qu Wenruo , Nikolay Borisov , David Sterba Subject: [PATCH 5.10 14/42] btrfs: unlock extents in btrfs_zero_range in case of quota reservation errors Date: Mon, 8 Mar 2021 13:30:40 +0100 Message-Id: <20210308122718.835648943@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308122718.120213856@linuxfoundation.org> References: <20210308122718.120213856@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikolay Borisov commit 4f6a49de64fd1b1dba5229c02047376da7cf24fd upstream. If btrfs_qgroup_reserve_data returns an error (i.e quota limit reached) the handling logic directly goes to the 'out' label without first unlocking the extent range between lockstart, lockend. This results in deadlocks as other processes try to lock the same extent. Fixes: a7f8b1c2ac21 ("btrfs: file: reserve qgroup space after the hole punch range is locked") CC: stable@vger.kernel.org # 5.10+ Reviewed-by: Qu Wenruo Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3236,8 +3236,11 @@ reserve_space: goto out; ret = btrfs_qgroup_reserve_data(BTRFS_I(inode), &data_reserved, alloc_start, bytes_to_reserve); - if (ret) + if (ret) { + unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, + lockend, &cached_state); goto out; + } ret = btrfs_prealloc_file_range(inode, mode, alloc_start, alloc_end - alloc_start, i_blocksize(inode),