Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp48528pxb; Wed, 14 Apr 2021 09:08:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE8r4TIFL60N0+nJeD0cyO3lBOWqkOB63XFL9EpSWI+C4fMgMJhAxoXEJHvI8kwLjsaAup X-Received: by 2002:a17:90a:fc92:: with SMTP id ci18mr4292264pjb.130.1618416522323; Wed, 14 Apr 2021 09:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618416522; cv=none; d=google.com; s=arc-20160816; b=FkVwLzAOHEpbQxQPltfp1lnI+zXjCq7i/e8wCRI9STeHjCB8e4n3cKy+2ruEOQoKJ+ 7Y1L6QDkUCgxhtOmZWjUHZs2JdpMLwV1GZtscwZxGCsVv6lULC2Ihu7RglDwBzuQuWFv AkbxH2HxXCUJkswYbniECHp8Ehoi6fK020wJFWGxPgYbheTtxCCwZATbc4ZgLtiRbzsh CK4qnAZLIEtO+8HLqWTIEMHz9JV1kvGXOcQKvExzJ3Yeieblr/Ap8lkD0ZKrORnDqDE8 JwzMCEkE0m1oH9+SVhIgHQFXawxIeWe7vnvk/vtgSsh8r+sYVQMt/cUEPwpioEiX8xWy qQRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ZO/ISZMhynRZot3glda5jEURtX+T1xi9QosM2Jb996s=; b=shPku/+PjxxggzL7w+3+LpTAFWyrIkfsjuXHhLqRNbtj4AtjVH/7pxFh8iLwqC7gDl 8ixnK1igZVaXH0XqKWZrZAfLfmYhkH9+2B3AXLfTraXk2WisMzwjy6EQ3mHB34YzNASa JpTh6yD6fMQbUIhrtmo/h7Kpy8innvUpOFqtwGBg4L9cmkw0FfryCkNvBswKkiMWvbhb hASRWN/25esCzy+lVzAVQ4+qDZAVVVYFWfhlRsYlwdl5KIVfqpclWqX6wXCioGy61/p2 CNG9KCF/EEQl6CGZd6Wl3Y69abSSHJgu4/4knuoWXPa2zPcG8N9/6acx8lC0b+wXOhLM ok+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TjuBtKfF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m21si22616787pfa.124.2021.04.14.09.08.20; Wed, 14 Apr 2021 09:08:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TjuBtKfF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243282AbhDNNog (ORCPT + 99 others); Wed, 14 Apr 2021 09:44:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:52142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351583AbhDNNoQ (ORCPT ); Wed, 14 Apr 2021 09:44:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 743B3611AD for ; Wed, 14 Apr 2021 13:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618407835; bh=Av2mTAvTPBRR6n/iApvQ7Kz11QtjqJfgvAB+6CQmYVc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TjuBtKfF6UZmeYec22E+IRiwo+tLTZ4bHY1yZU81S/+aCdHSUb5GF3JfUPA4w9eri ljX+72EAmyyZpUPfBSn68Vx9Milia8afMA9tRGzOeh77nqYNDNEFYgREu6JThvxnYj WTV+3g+v5C3n6j1TbVVX6i+ATSfbM0gurQ6e6fwHcolrzRbS7vVKiNU+obtrL+uGvi LD3TIuZ3IukTvrvfh7orRzf/HBet5pECzJdkn+VhjnLMQpv2U12NjcEHS0Sm+4Dyj1 D1OvtSRxywDeR/pl6C29zfROUj1KbP46QwhXChK8x/nrQVFlK+ByrNMfFC+ro+IHVg bg6d9kZB3tYWA== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v2 01/26] NFS: Deal correctly with attribute generation counter overflow Date: Wed, 14 Apr 2021 09:43:28 -0400 Message-Id: <20210414134353.11860-2-trondmy@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210414134353.11860-1-trondmy@kernel.org> References: <20210414134353.11860-1-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust We need to use unsigned long subtraction and then convert to signed in order to deal correcly with C overflow rules. Fixes: f5062003465c ("NFS: Set an attribute barrier on all updates") Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index ff737be559dc..8de5b3b9da91 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1662,10 +1662,10 @@ EXPORT_SYMBOL_GPL(_nfs_display_fhandle); */ static int nfs_inode_attrs_need_update(const struct inode *inode, const struct nfs_fattr *fattr) { - const struct nfs_inode *nfsi = NFS_I(inode); + unsigned long attr_gencount = NFS_I(inode)->attr_gencount; - return ((long)fattr->gencount - (long)nfsi->attr_gencount) > 0 || - ((long)nfsi->attr_gencount - (long)nfs_read_attr_generation_counter() > 0); + return (long)(fattr->gencount - attr_gencount) > 0 || + (long)(attr_gencount - nfs_read_attr_generation_counter()) > 0; } static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr) @@ -2094,7 +2094,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->attrtimeo_timestamp = now; } /* Set the barrier to be more recent than this fattr */ - if ((long)fattr->gencount - (long)nfsi->attr_gencount > 0) + if ((long)(fattr->gencount - nfsi->attr_gencount) > 0) nfsi->attr_gencount = fattr->gencount; } -- 2.30.2