Received: by 10.223.185.116 with SMTP id b49csp1020209wrg; Wed, 21 Feb 2018 10:41:07 -0800 (PST) X-Google-Smtp-Source: AH8x22458THK9PucU7dTz+9XjrP6iiBjk8K2lzYCt7SGuQCkwwtZm9cQGSx7eLf8iF19I4hc+5AF X-Received: by 2002:a17:902:22cc:: with SMTP id o12-v6mr4027200plg.280.1519238467145; Wed, 21 Feb 2018 10:41:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238467; cv=none; d=google.com; s=arc-20160816; b=cHae85XUCgm99/oodmyU4+uetTkMhXl8H++9erfSxSHzjcTxuDJg+zruHq1zmKMxL/ y6CGSlTxCQBsEIL8n0gEtM1EeONAy5H95OEUOjqe8wQXEW5Z6imUa6cbN0SLhxx8CeP/ vilpZ6BnkogsfYeFzuIvtKj7SBd5kJ7SCJFd/R74TdgZECvmMRv14bD8tJpXnOj0h8NM eo5muCqlwB5rK/qfqlEWMEhy8PqjM5/ghtPXOOMVPXRnl2IW/ntHPDvpIjXRU01Nq51A M271IgInT5R8U90Yk15AgVJXQttSTjtK9vKOerpLjLgppWCRFpSGc8EZjoauQIZrH2jh ZUaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=uMUmJZgjlFe9Xpa/GZ8XILGuWW6brjRNP+6JlSW3kdk=; b=drHsVco9pz2CjylxKQ8CxuYF489CxVIHRL8wkP+BIbqjMLoHhEj6TRmi77V4UP83yk IF6QdLWPOUD2vj6KEejZtsiiAn1e+2G1cZUgBoER0d/7wZ9hwzGijWHpowDooPbmtYhP xlwgeQBL6lbyvJlABxWoGprXQntXcX5ius1lAqmuXVCyb6JDOKAZX5xgRgf1YE4+4HTs JhVPg79eVzT1ZuOLLwWJan8hjage8ypgoWC0WlGfIRHbqV5eo6MRINjZWuInEx+bq9F7 jWs9ACLG+gQUa1Kv6rB1ATpQx4QY0A8gTBKhGEx/T63eK2Fe03ZyOgfadFlEvu/ebiBb yEHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si148248pgs.359.2018.02.21.10.40.53; Wed, 21 Feb 2018 10:41:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936481AbeBUNPJ (ORCPT + 99 others); Wed, 21 Feb 2018 08:15:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46008 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753648AbeBUNNT (ORCPT ); Wed, 21 Feb 2018 08:13:19 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9198710BA; Wed, 21 Feb 2018 13:13:18 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Bo , Josef Bacik , David Sterba Subject: [PATCH 4.15 135/163] Btrfs: fix deadlock in run_delalloc_nocow Date: Wed, 21 Feb 2018 13:49:24 +0100 Message-Id: <20180221124537.653207010@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Liu Bo commit e89166990f11c3f21e1649d760dd35f9e410321c upstream. @cur_offset is not set back to what it should be (@cow_start) if btrfs_next_leaf() returns something wrong, and the range [cow_start, cur_offset) remains locked forever. cc: Signed-off-by: Liu Bo Reviewed-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1330,8 +1330,11 @@ next_slot: leaf = path->nodes[0]; if (path->slots[0] >= btrfs_header_nritems(leaf)) { ret = btrfs_next_leaf(root, path); - if (ret < 0) + if (ret < 0) { + if (cow_start != (u64)-1) + cur_offset = cow_start; goto error; + } if (ret > 0) break; leaf = path->nodes[0];