Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2264032imm; Mon, 28 May 2018 05:02:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoNYoXrgCvuNn746FrmCGHiVz/VvmiLZf/bkFLpoCdOFVR95tMeX/RiLQqgMW7QXrv+MjSI X-Received: by 2002:a63:9a02:: with SMTP id o2-v6mr10312875pge.439.1527508976740; Mon, 28 May 2018 05:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527508976; cv=none; d=google.com; s=arc-20160816; b=O/PTmCu6xrsk21J9VOZdWVRAK5STTjzJ9YuEusBya77gzeAd3ka3Sq8/a5eq5E67ut /KBwjhJH8x0ak68MpU/cID4vqOwjQOK2M6CDqGDSJRnQ70GCY6i4W+tKdkzll3phhQtq gEmawide1pvgK1bARwvMt8lkpWqzAcbk0iv5zLGPcP8whkPsY8gGwwYo8eLXPiNo5MEJ tW4pWzZC62kYxM4OvoVt8AObiXQbvrsmTEqTBKgf1MV28FasD6Z+6KANwUE3RBdLxxbd 0CwL/sj69tZq7XDHmDa/VkahjUDSd8V/EMZMgggD0mHGnFZYF5XGT2oIs3qqjnE1BaMm DGhA== 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:dkim-signature :arc-authentication-results; bh=l/EIxhIQHAap2mzZkZcEzk+17+GutHQI6OD5TB/rpts=; b=YNWPWu2EXSUcqevfmDTet9t7da2yz5480OuYjPILw50sbH0tHdKSOCP7ppWK9YVAhk zZFP0x3FnFcqcMURbP5xr4weL7KN2G7IziL7E2JIqY6gHxpP2vlF6iVO4fHoJSF/uOpx 2Uktk/8CRvvF+cBx4CB+ix0UQnqRwYXaQ4A+OakEo7UFmCYn5M4H7qtFG0jqrlPhHE62 zRj0yJIB0f4XwsPnnmEC3BOzIdRpgn137s4x69RvaNb/qN+5a0RMaUjaHYBnugaCwsm/ XnqWGqQB5MGy1s1Ez/dyt2UMXYqXlTN89McsTI306I7iZvieBIRoaBhcW1iBkUWIc6dv 5muw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uR81kMVt; 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 a15-v6si8150750pfh.36.2018.05.28.05.02.41; Mon, 28 May 2018 05:02:56 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=uR81kMVt; 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 S1423418AbeE1LHZ (ORCPT + 99 others); Mon, 28 May 2018 07:07:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:53962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423391AbeE1LHO (ORCPT ); Mon, 28 May 2018 07:07:14 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F35C62087E; Mon, 28 May 2018 11:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505634; bh=pSeAQnt+MaH/nmH91q6pWwC0pW+we1ZehFKb7VEP4so=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uR81kMVtZ175bBTx/qEJbAg+ri9jFBxcUDmUdwVk1Oi3zUR5Ov2mw5w3wx4aLL0gh ucGdPT9mdVMnKDnBalDph/MzL/+dneKUXcrNLceAWJyOlU6ppOKPCRRDJOBASi2cVx LDV3sAifUxc25jB82vJ0IDI6QkLxcKBsGJaJ7QLI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , David Sterba , Sasha Levin Subject: [PATCH 4.16 073/272] btrfs: Fix possible softlock on single core machines Date: Mon, 28 May 2018 12:01:46 +0200 Message-Id: <20180528100247.088236797@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikolay Borisov [ Upstream commit 1e1c50a929bc9e49bc3f9935b92450d9e69f8158 ] do_chunk_alloc implements a loop checking whether there is a pending chunk allocation and if so causes the caller do loop. Generally this loop is executed only once, however testing with btrfs/072 on a single core vm machines uncovered an extreme case where the system could loop indefinitely. This is due to a missing cond_resched when loop which doesn't give a chance to the previous chunk allocator finish its job. The fix is to simply add the missing cond_resched. Fixes: 6d74119f1a3e ("Btrfs: avoid taking the chunk_mutex in do_chunk_alloc") Signed-off-by: Nikolay Borisov Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent-tree.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4657,6 +4657,7 @@ again: if (wait_for_alloc) { mutex_unlock(&fs_info->chunk_mutex); wait_for_alloc = 0; + cond_resched(); goto again; }