From patchwork Mon Oct 17 10:57:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 3393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1380996wrs; Mon, 17 Oct 2022 04:00:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7tMExoIfilyLUNfkNQqr558E2p/xYAb4tXCBgE/6g7O7XCyoouCv1CxlO16J+kZvnDu2b6 X-Received: by 2002:a17:90a:d518:b0:20d:516d:67ee with SMTP id t24-20020a17090ad51800b0020d516d67eemr13214127pju.9.1666004405722; Mon, 17 Oct 2022 04:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666004405; cv=none; d=google.com; s=arc-20160816; b=V524Ig5bxlSAg0dA7J7VyItW7bnNiMqblj4KoUbU8wIIBbKftTTc879YrMrFmNcmFz u06E4mQ91VHQRLayAhOvMqBE5lG6L4id6X/G2grvC5rAtHJPUXBa1P27hMpENKCQ936t IKg8ekJNRpSGw/LdKSq+r/CvCiLflGvlZu+4EKNResVgCGo/BC6ZIKkqOLBgTxYnwvrI mDqVt8zz68CMdWIAAnvy6cMWEgdA3GoA83ODW8cZhiGdsG4W48TTAP7MDeGlZC9saa56 Bup6KwuZFmiMT4DH3jdYYR/A8n6cazw0Tt4a3izQpbMuA0nDQw7UGOO6f8A35qSUyERN Ic0A== 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:cc:to:from :dkim-signature; bh=KMRPUnRgQYJmghUIzLTcJ7lL8V9O58P6UhfIuR3wWsA=; b=BOHAxSlDVG/nHgNmpDle5kK0uyCiV6dyimXuqd+wT9aA/gEhmQFdsbaC4HUefFX3HI rYQuBu3ypocTjh+qT3hotDaT/7bsD+lrmSMa8Rb8V0X5PuupgcH4mjF/ZC5Hj11LPYT3 XsteBc5ChWSA4duW/ENOlBaAbVapdCyhmvqoIcpyUSKTWSWyeuaJbU8XdWbDm6Xp9vs4 BMdM12wWBVZN4LhhoYjQZsKVcC6CwDM5wBXmQBQUXMkkT/QmkpW+Uzhen8jvpLG9aQjS DHL1p5Owt8nKD394K2iBT/AquPihXUUBHkJNXAAUy4+vxklnARoX2pA6hhSGZAosNE3s q/+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MwUTTIfz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja21-20020a170902efd500b001751a9de12esi10333858plb.288.2022.10.17.03.59.51; Mon, 17 Oct 2022 04:00:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MwUTTIfz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S229779AbiJQK5c (ORCPT + 99 others); Mon, 17 Oct 2022 06:57:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbiJQK5U (ORCPT ); Mon, 17 Oct 2022 06:57:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFC155C95A; Mon, 17 Oct 2022 03:57:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83E3D6104E; Mon, 17 Oct 2022 10:57:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDF16C43150; Mon, 17 Oct 2022 10:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666004237; bh=3UkiypkQG9xLfg+hS+eOV/U1/Tn/AJ7lMyTpKN5KYY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MwUTTIfzRGKwnFgR9CHvcDGvrugB2kBLT3/HZViQOmOp7i4frDTUrsArcqbmeeT2M sTqJu3GIYqpuq4flLKcAZOZFnPFa7zPj7A3w5PltdPpt4g1ZzSk2WPonaGztX+OYfl s2ipV6sWJ6VMpoWn3SEs/Dv6B190JWr14RE6elpX9WGw03rwUK8saBdvkHEBdaLrCE Ay07oOffO0gqSfvow5iHwu6fqhlxBDabrcNW+ajL/uq9yLeRHETcYAgRGLAc+77frz jH8jsPYTVyyTxXoSYe3j6MKWOwEybrQ85JBygblbRW09TQLEz9WB87blZu3Ne2dAqa ylsTh8PecGdCw== From: Jeff Layton To: tytso@mit.edu, adilger.kernel@dilger.ca, djwong@kernel.org, david@fromorbit.com, trondmy@hammerspace.com, neilb@suse.de, viro@zeniv.linux.org.uk, zohar@linux.ibm.com, xiubli@redhat.com, chuck.lever@oracle.com, lczerner@redhat.com, jack@suse.cz, bfields@fieldses.org, brauner@kernel.org, fweimer@redhat.com Cc: linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, ceph-devel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, Colin Walters Subject: [PATCH v7 2/9] fs: clarify when the i_version counter must be updated Date: Mon, 17 Oct 2022 06:57:02 -0400 Message-Id: <20221017105709.10830-3-jlayton@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221017105709.10830-1-jlayton@kernel.org> References: <20221017105709.10830-1-jlayton@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746932235570592538?= X-GMAIL-MSGID: =?utf-8?q?1746932235570592538?= The i_version field in the kernel has had different semantics over the decades, but NFSv4 has certain expectations. Update the comments in iversion.h to describe when the i_version must change. Cc: Colin Walters Cc: NeilBrown Cc: Trond Myklebust Cc: Dave Chinner Signed-off-by: Jeff Layton --- include/linux/iversion.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/include/linux/iversion.h b/include/linux/iversion.h index 6755d8b4f20b..94f4dc620d01 100644 --- a/include/linux/iversion.h +++ b/include/linux/iversion.h @@ -9,8 +9,24 @@ * --------------------------- * The change attribute (i_version) is mandated by NFSv4 and is mostly for * knfsd, but is also used for other purposes (e.g. IMA). The i_version must - * appear different to observers if there was a change to the inode's data or - * metadata since it was last queried. + * appear larger to observers if there was an explicit change to the inode's + * data or metadata since it was last queried. + * + * An explicit change is one that would ordinarily result in a change to the + * inode status change time (aka ctime). i_version must appear to change, even + * if the ctime does not (since the whole point is to avoid missing updates due + * to timestamp granularity). If POSIX mandates that the ctime must change due + * to an operation, then the i_version counter must be incremented as well. + * + * Making the i_version update completely atomic with the operation itself would + * be prohibitively expensive. Traditionally the kernel has updated the times on + * directories after an operation that changes its contents. For regular files, + * the ctime is usually updated before the data is copied into the cache for a + * write. This means that there is a window of time when an observer can + * associate a new timestamp with old file contents. Since the purpose of the + * i_version is to allow for better cache coherency, the i_version must always + * be updated after the results of the operation are visible. Updating it before + * and after a change is also permitted. * * Observers see the i_version as a 64-bit number that never decreases. If it * remains the same since it was last checked, then nothing has changed in the