Received: by 10.223.185.116 with SMTP id b49csp1032668wrg; Wed, 21 Feb 2018 10:54:46 -0800 (PST) X-Google-Smtp-Source: AH8x22550OyXXhivloplHbNwmCbskuPOygJlo5q4wbkEaclSaqBD9QpTqdcU2hC072IA7m2UVFVj X-Received: by 2002:a17:902:8604:: with SMTP id f4-v6mr3188106plo.380.1519239286611; Wed, 21 Feb 2018 10:54:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519239286; cv=none; d=google.com; s=arc-20160816; b=c4BYheNNlK+y2X/0F5TBw92Z0qgTovs7HPhp2UnAnRcKPtYOuW4YwCXTrUaqSigvPt Cp3nAorAJwNGWkATRHIre/f/CFfLhv8HnMRIDppPwcf9pr/nhJ0KX5a1R0R6Eax+89w3 DS1a73lr8qVQuN1ZYiKSCU79L0k9bXKnOc9Wvx3bVI2w55ck5CM82V36AmpZhv1ju6PY 1cJoThcjWhpSNy04069aIol04YpkL+yYOKpBipuvP6v5CYqi5P+3obSFsGkuLQVEtAe9 8TbARvQnpDX3izoJNiQagjTCTmZDsbzD9D3kRF43WNWaBXOZ5qLxC0YNrgiDHN0Y1Wi1 I6ig== 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=5apjAbXwDBR79CGRv0uuAgxM6nOl/NiOHfT/zZxTca8=; b=X+4t4HdP3GH/0fTou5tHGooZXjaBovc4tct6t1eYgzjnbCWJSEq1MxUB8+OU2j/JPw JJZncB8gN3Pi9Id1OFPibFXn32roSptd44sgBlQVzLOfFAi5hE6M72kD7hw5jYOTA0Tj SI4p5qwEl4vIaya9UC6Fc/xwZGdge7rGuKtyZG3xsa5QgEFM/y65mNzla1KN6imkMw/q Jtt9iJiASe8CPZ0EQF/+iTsDrnrfSSjOhCM/iVkwAlXQRkf9ziUUyy0qp6oVBeixDA+f xlhho7Urdtein8riI+lQkS4MPOXjy/YueBdkB2NJumF3nvtAkR5hcGgqojeOkPWFB1aW Eg6g== 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 l62si10012134pfl.160.2018.02.21.10.54.32; Wed, 21 Feb 2018 10:54:46 -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 S937916AbeBUOlb (ORCPT + 99 others); Wed, 21 Feb 2018 09:41:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34162 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934084AbeBUMym (ORCPT ); Wed, 21 Feb 2018 07:54:42 -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 069811130; Wed, 21 Feb 2018 12:54:41 +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.9 18/77] Btrfs: fix deadlock in run_delalloc_nocow Date: Wed, 21 Feb 2018 13:48:27 +0100 Message-Id: <20180221124432.950380626@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124432.172390020@linuxfoundation.org> References: <20180221124432.172390020@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.9-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 @@ -1320,8 +1320,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];