Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp266880ybi; Wed, 29 May 2019 21:00:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxq5jdHWbiCvqv/3nR3DQMoqkupq2a9vj/yRUI/zE+yg/mUaQfOyrAOa8Y9uJ21iYzaWkol X-Received: by 2002:a62:38d3:: with SMTP id f202mr1651966pfa.41.1559188859758; Wed, 29 May 2019 21:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559188859; cv=none; d=google.com; s=arc-20160816; b=lHhd+cW9Kzw5sPutahY9kZMYTsX6Iafb7R/g6hPpLd32dNqaaMKrvYttG5AOSE/wqi 1EKkvqOZGyR5N3Oy95HbjSvJsgOih1H+8bwJpTEzfFpaLWS4e7FIOUFllASO1963t8jU 2XYBVc7hPOomQZEdoy54PhH9YwOhJjwCCljeWBlLG0hc7Joxyo7VPfqNzhK4rgXQnK10 MDNBjvpDjnsg95Wr+rSM4b4nTu8Bd+uPHzKTSOJen64L27MvSRaedQGYaBeL5kFLq/ZT ghXJTaCSlYgGooTM0p0Kmn5Gwvf5oZaZ7zeaE7zTumHApLNfKuEH8abW/1jBbsT9mtql LhmQ== 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=W3z8ysDnFiw/S2s0V2lvuajV7Ktx8ZQ5jjsoqvDkCLQ=; b=wV/bk3fakb0Kzav5hgPwyOCXmg/37uCSTTy3zxvU38GZI05liTsf16ggK7ISrH0KgI 6BtSZ2KvCkvWJ2iEJA9QH2OgG3J5sNeuEwJ12+2RS+L0/XXN0C1t5v69gY0YGcwCrclz Asmnf6QmYM0GMQhCO87yBl3vTAuSyQl/c/ox9YEHPx+7ytVlHCtcSfWa7PA5KwebXdbB DXqngivRPPpnGN9OjkT+BpzC5XofD+LllGEpqOc3qEjmGEZxbRgZ1sc0X5LXRBT0xTy7 1xYUD6WIBOLjLYUVLfJzDF2yvK3Ebqm1l/tJvEPFmr3rMiaSk8F1pJrVDBBTxFnJ0Ux0 FEAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="vuDYpk/L"; 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 be3si1924689plb.127.2019.05.29.21.00.44; Wed, 29 May 2019 21:00:59 -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="vuDYpk/L"; 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 S1731909AbfE3D7m (ORCPT + 99 others); Wed, 29 May 2019 23:59:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:51776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731585AbfE3DSd (ORCPT ); Wed, 29 May 2019 23:18:33 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 E96C82475F; Thu, 30 May 2019 03:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186313; bh=Npxmw6nnvgD0ZjvtCKn1B+RkWhFeIgCUudF25HHwcB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vuDYpk/LUMqDsPLFXlQ4P45lDuzfzKIQfxAbuxTTyn5e2sqNB5ufhJZWDPLXqY7ng B2ajfskZAqL/h3ZpVyYKkzzjxej/JX9aIFztxoySOdU92JpphiSXfdDtx2rylM2q6F LlVcom8lFRD1mLjMo9EAzdh0JDG6zjoHMybYGpYk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Gruenbacher Subject: [PATCH 4.14 015/193] gfs2: Fix sign extension bug in gfs2_update_stats Date: Wed, 29 May 2019 20:04:29 -0700 Message-Id: <20190530030450.062891747@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030446.953835040@linuxfoundation.org> References: <20190530030446.953835040@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Andreas Gruenbacher commit 5a5ec83d6ac974b12085cd99b196795f14079037 upstream. Commit 4d207133e9c3 changed the types of the statistic values in struct gfs2_lkstats from s64 to u64. Because of that, what should be a signed value in gfs2_update_stats turned into an unsigned value. When shifted right, we end up with a large positive value instead of a small negative value, which results in an incorrect variance estimate. Fixes: 4d207133e9c3 ("gfs2: Make statistics unsigned, suitable for use with do_div()") Signed-off-by: Andreas Gruenbacher Cc: stable@vger.kernel.org # v4.4+ Signed-off-by: Greg Kroah-Hartman --- fs/gfs2/lock_dlm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/fs/gfs2/lock_dlm.c +++ b/fs/gfs2/lock_dlm.c @@ -31,9 +31,10 @@ * @delta is the difference between the current rtt sample and the * running average srtt. We add 1/8 of that to the srtt in order to * update the current srtt estimate. The variance estimate is a bit - * more complicated. We subtract the abs value of the @delta from - * the current variance estimate and add 1/4 of that to the running - * total. + * more complicated. We subtract the current variance estimate from + * the abs value of the @delta and add 1/4 of that to the running + * total. That's equivalent to 3/4 of the current variance + * estimate plus 1/4 of the abs of @delta. * * Note that the index points at the array entry containing the smoothed * mean value, and the variance is always in the following entry @@ -49,7 +50,7 @@ static inline void gfs2_update_stats(str s64 delta = sample - s->stats[index]; s->stats[index] += (delta >> 3); index++; - s->stats[index] += ((abs(delta) - s->stats[index]) >> 2); + s->stats[index] += (s64)(abs(delta) - s->stats[index]) >> 2; } /**