Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2974745imu; Mon, 19 Nov 2018 08:51:19 -0800 (PST) X-Google-Smtp-Source: AJdET5fll9AwmocUSsf9qIyk1iUmy/jIy7dcdFlEJkCb37o7GiTtyn5b+i5ZpJoyAhCpbk9EGTwV X-Received: by 2002:a63:a064:: with SMTP id u36mr20904514pgn.145.1542646279562; Mon, 19 Nov 2018 08:51:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542646279; cv=none; d=google.com; s=arc-20160816; b=T32qFNtI8WFu6Zt4tlrcpa4F1LFAjbpo6ndhR6fKJT9SioQTCgSdTOMO4lKh8B/GmS iMOamwdDl3+UyJigPiSl2rEjoMQwvMufM+wa42S331C7ycIiHfg00sukqiu1oRHDXfzA B5EzVpt9q6uCv59CiKHNg6/80rKYWIix991pdp/M/BGO1Fbj7GOV3NrqPIBWq7G+81o8 eSp61+az4EdYFyLld5N9EZoJn1idHu9NYTcf9Z5nDGLlDi5GQW9c0OXPAGr9ReK2dUuk uMr84nEDpP8zyKwLHIi3Fv8IGAzCaRgrlcZzc0HX5vZuloigNnq8UVT9hbW6txeZuueA zGVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=byK1f0Bw7v2aZbRiF358Ma3mDuUR1hO0QzCdTdI3zig=; b=gqyAHSNOcYn7SowSnKDWseB72TUQKGCNNsIvGc+zkOrGrMGwzgFjWw0v4PzfAnvap+ 65NYrYXI/IbLZ8yEDQwWkjBzqzAvKbHuiTtddrnb7x89SO4j05SZyf+/lfrgtm/jt6cU sDXD1R78WwMDvxVOTRcGJEI3XdyiNF4hLbo+QzEVuHSy+zqsCUQOZyFft9qnh0CLOutV g80vIjk509BHfAS7TALvPJgh6w5f6O7pHVTcSflBIKFanEuY7095sLMxE4q5xeh1chO4 j08VZHLJllTLMHGZPIkjnAU6AGLCj4PMXEPJJ4ioC1VPAmSXix/YCHC2H2+NZdxVblYI epgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vzXGqi8J; 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 p19-v6si40104625plr.124.2018.11.19.08.51.04; Mon, 19 Nov 2018 08:51:19 -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; dkim=pass header.i=@kernel.org header.s=default header.b=vzXGqi8J; 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 S2389977AbeKTDO2 (ORCPT + 99 others); Mon, 19 Nov 2018 22:14:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:51766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388976AbeKTDO1 (ORCPT ); Mon, 19 Nov 2018 22:14:27 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 E0F2E206BA; Mon, 19 Nov 2018 16:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646214; bh=uj6pLK1qYw7JPUtti5S2gFliIK+lGbEuwDEG/MFbkBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vzXGqi8JETqr0nM6obcgWp4XvVovHdX+j2APezqnrHh7Q66Fr6Hr2EDOd9m3aJLpo PcqIayvUjcE9AWm6zlbj5Yz9HLb3qhl0E7Vwc3i2t+6JM1gCaeTqIFGAORJrpN3YT2 Gw6YekA6hWo35hqWK0KF23vQz8I8fKEcXJZxHbgo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi Subject: [PATCH 4.14 032/124] fuse: fix blocked_waitq wakeup Date: Mon, 19 Nov 2018 17:28:06 +0100 Message-Id: <20181119162619.815851268@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162612.951907286@linuxfoundation.org> References: <20181119162612.951907286@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Miklos Szeredi commit 908a572b80f6e9577b45e81b3dfe2e22111286b8 upstream. Using waitqueue_active() is racy. Make sure we issue a wake_up() unconditionally after storing into fc->blocked. After that it's okay to optimize with waitqueue_active() since the first wake up provides the necessary barrier for all waiters, not the just the woken one. Signed-off-by: Miklos Szeredi Fixes: 3c18ef8117f0 ("fuse: optimize wake_up") Cc: # v3.10 Signed-off-by: Greg Kroah-Hartman --- fs/fuse/dev.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -384,12 +384,19 @@ static void request_end(struct fuse_conn if (test_bit(FR_BACKGROUND, &req->flags)) { spin_lock(&fc->lock); clear_bit(FR_BACKGROUND, &req->flags); - if (fc->num_background == fc->max_background) + if (fc->num_background == fc->max_background) { fc->blocked = 0; - - /* Wake up next waiter, if any */ - if (!fc->blocked && waitqueue_active(&fc->blocked_waitq)) wake_up(&fc->blocked_waitq); + } else if (!fc->blocked) { + /* + * Wake up next waiter, if any. It's okay to use + * waitqueue_active(), as we've already synced up + * fc->blocked with waiters with the wake_up() call + * above. + */ + if (waitqueue_active(&fc->blocked_waitq)) + wake_up(&fc->blocked_waitq); + } if (fc->num_background == fc->congestion_threshold && fc->sb) { clear_bdi_congested(fc->sb->s_bdi, BLK_RW_SYNC);