Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2508967imm; Mon, 28 May 2018 09:24:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrm71tUnVfc86LoHRPdIFaz4CaAqN3JKDDpkN0M3ScHigiCvGFp9eFt2HAB1FpQ/9A3YhyR X-Received: by 2002:a17:902:2702:: with SMTP id c2-v6mr14004525plb.297.1527524682905; Mon, 28 May 2018 09:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527524682; cv=none; d=google.com; s=arc-20160816; b=VDhNi7oye/zGCOJxxxmqrQVTwm2QxM+oHgnza6w6ed+DT9aefTavRYf21dPYzhz0// 0vV7I3ZSiLj0pEikBINIw+augRT7OdO6NrOwg/SeezLFXbaBQ0H3132islzT027AAlW0 IgugWupp3rIyPKrBJblSNBnCHPhv5vr3JCL1CYNNcxfe2E74XRAWs5gFXpj7paXKlHHW nbDTr50d6IKMv88gO1IWcwgfHynOfxTxjC3XkLlpRhWkCIMvVh8Hf+eQZfTEpyzte0Ky dcubHym6PkFo6m1dnhL1CctQBFiYU4fB+YtWp8VKZGCgh2MpoUkyF9HmDflGATFdTYxT wI5Q== 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=TwaOz3s0bgKykUw1YAQiu7PFXaeHyBxNKHEMWbgh2V4=; b=I0ys8Av6yRU4sR2DGlfFoyJQiNLezx1i2cO0gepeEyvLWyBMPAO8+gEts6QwxyD5QL 1IiRpM7xjZNXmS/txcmwLI1sSx8DrRZwj6Qjc703t++LiCXm91b6WsDQfo9qSdIr1vdA WT9eTWRJYPdClgz9kp1riuUB4J4zEXvdL4MZsV9wFkBsh86DmV5NKmgbP4XIPWrBj2EZ /hiY8TI9getdV/Vi2Dmul+nPBVw6lhLbjSWzH8Ibbyk7xYLEYHFTPeUlG350tjmqXBYu bkWEoqAgd9tzoWmfgoscwLWoIlhZSaQo/HJXni3M6Hv/EEyS1caxxG8R1UWY4y6S5P0h 9cRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oCeT0sQb; 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 c7-v6si29877564plr.145.2018.05.28.09.24.28; Mon, 28 May 2018 09:24:42 -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=oCeT0sQb; 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 S940005AbeE1QX6 (ORCPT + 99 others); Mon, 28 May 2018 12:23:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:59192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934591AbeE1KK7 (ORCPT ); Mon, 28 May 2018 06:10:59 -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 B1A56208AD; Mon, 28 May 2018 10:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502259; bh=Gwkz3lICZUwQi0J1lkzevjz0F4HXQrq+ArZifIYz2Qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oCeT0sQbYfH3nWTrBtaM43X04DxMsXWYuDhnAFbwBjNARFhyV/Lt1DtgGyz1utSO+ Mu/KtzwQjxEn1M++MPBgQlieISHDss/rlMp8ElwIteuqf+a/5QaVVhLcuV6oqiUrhm 1+ensEurMkvsCvwnbq4ohSKfl6VrwQgLz9NuB3iM= 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 3.18 120/185] btrfs: Fix possible softlock on single core machines Date: Mon, 28 May 2018 12:02:41 +0200 Message-Id: <20180528100102.394767341@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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 3.18-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 @@ -3946,6 +3946,7 @@ again: if (wait_for_alloc) { mutex_unlock(&fs_info->chunk_mutex); wait_for_alloc = 0; + cond_resched(); goto again; }