Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2309189imm; Mon, 28 May 2018 05:50:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrHU8JdOuUDGiOGHBhKRoUBGJ6agyQPWN+ZTaHIdnXYOTmW9+GFmOJPkyxzSJzuyu29DHun X-Received: by 2002:a63:583:: with SMTP id 125-v6mr9030529pgf.385.1527511843428; Mon, 28 May 2018 05:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527511843; cv=none; d=google.com; s=arc-20160816; b=dmDcvUtkOzbyqqK+mdifpJjOysPlGfp2DPOf998NpaqLj1mifdxi66dknvCpop7AKC ewOEEU83CvorxAlEIo43ofSg6Jcow7IFm8tiA6z0VAUfvvmH3FKYyjjpYxk5gnlpdnBd DWVRnTxC7yXs55sDPXD+MFZ71HBW5yUI9yEUiUZI5lUThfOgQTArqyf8NzZiysCcmZAe D8TAK+c38nM8IsQ/G06pkukB5NBK91YUn86zZk+A8qkgiDClcIJz1aEerXRRyZH6Huhm k1KfqhFHQc2IwHIHhgt9Y4Pqs3lV81SpzW66K4MXcEIfoKHr+C/t7FEMVpZ2+6190pC1 PXKA== 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=JyOj0aPLDWL6VTMCDlEmcXVvqXVcWVBRzRP+PeJHpm0=; b=ExSJwqgpx78bsSwlqBJUwF6HOCxnBgAbp21CPd33sIsN/QVuXzU5NZ1ATCX9QJK01R YGDdiTTJKh5LSkA6wwzE/V3WTQBd9ASTvuzEFA+T/pljbQ2yDz4EXCGNoGab6irTZ17M F12XPfIT55MlAKT06RPIzFZU2itjFqLjvXLcplrLkq45sfPHMo37kvVqEHLdbMgtIpwu ckG4Ui67AFNdQtJ+HX/ESE+EX+rqD5MqrUV2lH6hCj7M/2Qo0vuAV1HP/0yzeOW/ySDs 8dEs7sdX/6ze7jGXO9zJnZBu0+NJx6SylNLTW6/dH42fjN1RYPsAY7IGDS41BWXbf/ul ClVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Uecg4GJi; 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 e1-v6si23811565pgr.167.2018.05.28.05.50.29; Mon, 28 May 2018 05:50:43 -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=Uecg4GJi; 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 S939011AbeE1Msg (ORCPT + 99 others); Mon, 28 May 2018 08:48:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:45026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164569AbeE1K4p (ORCPT ); Mon, 28 May 2018 06:56:45 -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 CCB73208A1; Mon, 28 May 2018 10:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505004; bh=HlwKpiz/pe8chpLqWa2/y8SjrnyEktaqeJaK7yZKXMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uecg4GJiSwdJY+v6iEfoXIRDypxPt4b3z0EOkSPnbb2adCRSMderE5kwrkLKxP3m8 X/Aw4TKDdt7fsnHoAJrfO+yZmhor6EmX3QfN/vjkIpgxHq05jj1gTHruSz+HYemR6f 8PUS+dnR3x2pKpe4cNxXL2zsP1rBO2R2RankYvYs= 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.14 340/496] btrfs: Fix possible softlock on single core machines Date: Mon, 28 May 2018 12:02:05 +0200 Message-Id: <20180528100334.149393345@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@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.14-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 @@ -4675,6 +4675,7 @@ again: if (wait_for_alloc) { mutex_unlock(&fs_info->chunk_mutex); wait_for_alloc = 0; + cond_resched(); goto again; }