Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp243219pxf; Wed, 10 Mar 2021 05:30:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3EGsysSsqwUiwUmtlB21ikGlvLHuBZYSCQgm1OpyUwveOuwQzGBVQwHi1YYZRr+/38hjd X-Received: by 2002:a05:6402:48c:: with SMTP id k12mr3257903edv.237.1615383039700; Wed, 10 Mar 2021 05:30:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383039; cv=none; d=google.com; s=arc-20160816; b=FiAjH8mHEV9hkHdxwSUtq5tJgKHHV/CjdT74CA56a3jIO9zBwsVPXYYoTbnz1JYDhL UG/fflr1W/qYHpLvUd4Ybeq+EhPYdMajuEVdxxRD6NVatHsePk+9dm7CVeJPe2QOonBS TQVuk/+lymReJdmkuRiUY+0X1iGW1bJrfsYeFiaCipahUUzsOigrfCrb/Aupsdu/Yum9 8dwalu6tT5sl1sr+cQ4rS0lIPTgGGk8I7jXvWrjQSoltZE4rGT3TYlAq9KELanB0YoSr +VMgipoLT7LmYF0mHqIYWcssb8HMNB6CueXtLuKsEGNunUHjOJ/KA23aW7YcrQykmAT1 v53g== 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=SHcwPzx9JHehEb8M+kHcJyYl43mPA4ZSpxmqKPAxvUE=; b=o5ioqH1FQMZWrG5qqYjw7yD3oo62NRRcsjXhKTOtnuXuupucyvAlpCMJxPmDFBsizd fSrbXxB97AnL+tpHtzjVjHhx49iEWSiqn8QlWdfvH/I3Zztiz9rEUmsYq3XPd4V81Ck8 auKvFgs64BN4QKuWcdn4SfGQ9TZwIFTqVNCBIDKFzz5WWzXwNxXmEkf1xndyF+87NFTY iCp/Ou9PLt9fBfFHvo5TauPQ1Gqk0oUkapkQzNqknaFpuGsVVtVUlV2paZGH0u/2RIyQ Zh27AYGfkobv/5no5pVDJX7bMzf5tdr5SphB+EWNEap+s7md2Jr+4uQ0Lk96NT//Wy6X BfPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T9TwrZqo; 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 hd42si12249377ejc.727.2021.03.10.05.30.15; Wed, 10 Mar 2021 05:30:39 -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=T9TwrZqo; 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 S233897AbhCJN12 (ORCPT + 99 others); Wed, 10 Mar 2021 08:27:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:46534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233170AbhCJNZB (ORCPT ); Wed, 10 Mar 2021 08:25:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 99E0A64FFC; Wed, 10 Mar 2021 13:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382700; bh=N3XFJuamEXjMY/iQLu9M4RuxbmpB/XKwAGTAVYdB3Hk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9TwrZqooJNceZl8rK/MbpCINoMLBMgxmprPyMBZZRUzANnrLsyFWiAc87IoGGn9Y pRr6AO13D/ty+N/Bis6Tk9AcZ6nk6GdZoJ9BG52Us2r0YiWdHpkLmGe0w9ZH7XGrzo LFRHwXltzk19NidD7Pz2nWrEBPRRQ7Bgy5tG44SI= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qu Wenruo , Nikolay Borisov , David Sterba Subject: [PATCH 4.19 05/39] btrfs: unlock extents in btrfs_zero_range in case of quota reservation errors Date: Wed, 10 Mar 2021 14:24:13 +0100 Message-Id: <20210310132319.897535962@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132319.708237392@linuxfoundation.org> References: <20210310132319.708237392@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: Greg Kroah-Hartman 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 @@ -3016,8 +3016,11 @@ reserve_space: goto out; ret = btrfs_qgroup_reserve_data(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),