Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2957014imu; Mon, 19 Nov 2018 08:36:22 -0800 (PST) X-Google-Smtp-Source: AJdET5dLRiJcKbspzuC4Mfi5OldKlwI7eM2gtM9bJ9ps53X/IYEvQ1UQAp4PKLUjNj2T1UHZV41p X-Received: by 2002:a63:9041:: with SMTP id a62mr20361209pge.163.1542645382450; Mon, 19 Nov 2018 08:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542645382; cv=none; d=google.com; s=arc-20160816; b=1G49U5mkd2WDvMY5Tofp66AWtYUxVGtnkrMc72sb/8x3BjHNKs8fWYc78oYoIylBiW lM5ea2E89YR75+ecmcvCUo997VvqT4rU0M1PRYDtGJxp4zdRyihVxB882EAtx5+7aP0l 7K5/dF7vegtoRaFSM2DbxRf9GboXk/OCrP+gWz6wXsQC8nd/Ur4YwD9WSpUyv95f9n7a Qvz46hSvhcyg/JaXOvfYW1B3/fJuQPChq5tXhQM7j9j+jRPiobjCYENS9U1IMmzbom0M xvKSWmbVNJT0huOkoowGlP9FOX7SYtpJ4tARxld1viV3eworT6rF3NW3WBZBSBx5TFbR I82g== 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=9zpsi+HP70Bk6ITWCTRifPGRNuSnTfvv7BkKQSaNdmU=; b=C3E2sXdXepOkz7AyWont5otpzYCB0mZEXSECLTDxhdbxFLcUVnUClou2eSn2SkYaxA I8tAuQtCAk2FNL17p6D3YBjZUMY/Hh8g+yrV2xuxThRaa4H2GPsLpE6kkBGkcLhj7Qd8 UOjGcgU2hOQu6kUrD+mJ2iQ+SI5XL0WsSyx44FfdzsOU6RmauH9UXtea5Le1dFl3jNrJ P6DrY/hW7+qPvVVCabvgfYODFfwd6yfcqdEm2miISBPcds87elA67IK2E0g15MIGLXCk gRsws0fJ0tI5utC3qKEw+llKngH5eMxzOROi/TUp8n0vmw/ksXVBV8oE8l8T2+AuUe9c gX1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Hn5U/jkW"; 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 m10-v6si39630654plt.394.2018.11.19.08.36.06; Mon, 19 Nov 2018 08:36:22 -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="Hn5U/jkW"; 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 S1731442AbeKTC6r (ORCPT + 99 others); Mon, 19 Nov 2018 21:58:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:57886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730381AbeKTC6p (ORCPT ); Mon, 19 Nov 2018 21:58:45 -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 575B3208E3; Mon, 19 Nov 2018 16:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645277; bh=30x0Vp4v8JaUeA5I+J1LQNOT3Vjppw/bulE6/4yFzF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hn5U/jkWEcQ7CzUdxmptdm66XK/CjuAlTPFTw6IX+W0vLdmyP1JrqhrXXjKlpkMQh JFHpC+TI3yJ/5dMzE8bzKIWSflD1cqMFIoMcmRZIoYG6qY/LRek5c6Wqj8w+YrCSXI b+85MvQi5gjMja0Suw/SXEWBd3WhV+98u1Wbe2AU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi Subject: [PATCH 4.19 066/205] fuse: fix blocked_waitq wakeup Date: Mon, 19 Nov 2018 17:26:13 +0100 Message-Id: <20181119162628.901744978@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@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.19-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 @@ -391,12 +391,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);