Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp4057115rwa; Tue, 23 Aug 2022 15:28:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR7GA4kv9eh2MsyRoiGOZlxijgwL/AH6qchrcrPu36oj0RrLFson7krXLFstHyPoi3B3aeRQ X-Received: by 2002:a63:5d4e:0:b0:41d:dcc3:aa85 with SMTP id o14-20020a635d4e000000b0041ddcc3aa85mr21981834pgm.324.1661293692601; Tue, 23 Aug 2022 15:28:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661293692; cv=none; d=google.com; s=arc-20160816; b=04KKsDKYq6FbycN4OavvXMsrNwzvXtiEXBOUau3kO7wQUdWZVotMAJrHxqUt1+JSKf rPIuoRrzvDrBykvJ+BlxKEq5h4M/4xVKnk7MMF22TdZQLGWFO9AW80CNuRCAdKb5urNO OXxZSxa8EF+5TEy92GJoTJTqpBGWE/TlARUx0ReX10ji4nyFW3SCaKLtpY+BMaecOyeS oC0aNlQEb403/OFkqKSWKhqJt2M9+R9oWajsWTPVIHq4S9WU70WRjYt/CjiE2N2U5Ne9 jDEiREroECR6UuQVOoxJJnpCzIMIXv/Mhgo8drD60E9wtO4XJFWiRRV5Do/m/duv6wKE XqgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=FE2Al3t7IgXV7i658F8wCx+Pqa+fMKLd8YrmqYyjo2c=; b=thevMabdevOBzhGlE3yWKKz7zJ9cjdENEqFQ8wEy6IYmVil5VzfU8K0gyMc8+wuZia MYnh65lEULX+rkzPeqtNJkqrz/V/idjgMMM8i3yhcNMS2qSDbCXqUUdurptvH40RVwDV wYJf/yCSAD7vRlKOs1/KEpYPfJkdCRv/RDmynieqhn2Z795L46TJhu1Z1YgA9rIyR75l qHNMvsFoPJAo/plk3XmjdIVrEeJcRRjQfMTHBjt4A07zVO0ZwLEqupOm0nL2ybjn7sGd ie916IILWEdz4hrWwogCFS+uIXftOvdC4cGm7Qe1DmvN7l23QG/NrkXAB8KE4qQIBJiC xBxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Q8gYMSsj; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 142-20020a630394000000b004298f3fdcb6si17713126pgd.353.2022.08.23.15.27.47; Tue, 23 Aug 2022 15:28:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@suse.de header.s=susede2_rsa header.b=Q8gYMSsj; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233734AbiHWW0D (ORCPT + 99 others); Tue, 23 Aug 2022 18:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233435AbiHWWZr (ORCPT ); Tue, 23 Aug 2022 18:25:47 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAC20870B0; Tue, 23 Aug 2022 15:25:42 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 907001F8A4; Tue, 23 Aug 2022 22:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661293540; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FE2Al3t7IgXV7i658F8wCx+Pqa+fMKLd8YrmqYyjo2c=; b=Q8gYMSsjemD43l+fHVukhYF+p5VRwHuwy5zy3Z1Y1vPTh5o6FIc+a/PSpQguOzy6uydL3h BBARFegh4V6Xpilsra7Mbe7ZJ28h0POtsHebNM1hpK1qKdeXl5Aq5vuoZEI49hixlX9usF 45/ruW2liXm17FeQdAvoqBLEwUwjr8M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661293540; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FE2Al3t7IgXV7i658F8wCx+Pqa+fMKLd8YrmqYyjo2c=; b=95Q12KkjJZdTEM7YMhnQyCV8dNijN9rMkjz2xVhuBNxLQruqJU6pchIWCDC9TliBDFTLzt ZqqcH6RHJETiDBDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7EBAF13A89; Tue, 23 Aug 2022 22:25:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id TMt4DuFTBWMmKAAAMHmgww (envelope-from ); Tue, 23 Aug 2022 22:25:37 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "Jeff Layton" Cc: "Dave Chinner" , "Mimi Zohar" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-nfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, "Trond Myklebust" Subject: Re: [PATCH] iversion: update comments with info about atime updates In-reply-to: References: <20220822133309.86005-1-jlayton@kernel.org>, , , <18827b350fbf6719733fda814255ec20d6dcf00f.camel@linux.ibm.com>, <4cc84440d954c022d0235bf407a60da66a6ccc39.camel@kernel.org>, <20220822233231.GJ3600936@dread.disaster.area>, <6cbcb33d33613f50dd5e485ecbf6ce7e305f3d6f.camel@kernel.org>, <166125468756.23264.2859374883806269821@noble.neil.brown.name>, Date: Wed, 24 Aug 2022 08:24:47 +1000 Message-id: <166129348704.23264.10381335282721356873@noble.neil.brown.name> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org On Tue, 23 Aug 2022, Jeff Layton wrote: > On Tue, 2022-08-23 at 21:38 +1000, NeilBrown wrote: > > On Tue, 23 Aug 2022, Jeff Layton wrote: > > > So, we can refer to that and simply say: > > > > > > "If the function updates the mtime or ctime on the inode, then the > > > i_version should be incremented. If only the atime is being updated, > > > then the i_version should not be incremented. The exception to this rule > > > is explicit atime updates via utimes() or similar mechanism, which > > > should result in the i_version being incremented." > > > > Is that exception needed? utimes() updates ctime. > > > > https://man7.org/linux/man-pages/man2/utimes.2.html > > > > doesn't say that, but > > > > https://pubs.opengroup.org/onlinepubs/007904875/functions/utimes.html > > > > does, as does the code. > > > > Oh, good point! I think we can leave that out. Even better! Further, implicit mtime updates (file_update_time()) also update ctime. So all you need is If the function updates the ctime, then i_version should be incremented. and I have to ask - why not just use the ctime? Why have another number that is parallel? Timestamps are updated at HZ (ktime_get_course) which is at most every millisecond. xfs stores nanosecond resolution, so about 20 bits are currently wasted. We could put a counter like i_version in there that only increments after it is viewed, then we can get all the precision we need but with exactly ctime semantics. The 64 change-id could comprise 35 bits of seconds (nearly a millenium) 16 bits of sub-seconds (just in case a higher precision time was wanted one day) 13 bits of counter. - 8192 changes per tick The value exposed in i_ctime would hide the counter and just show the timestamp portion of what the filesystem stores. This would ensure we never get changes on different files that happen in one order leaving timestamps with the reversed order (the timestamps could be the same, but that is expected). This scheme could be made to handle a sustained update rate of 1 increment every 8 nanoseconds (if the counter were allowed to overflow into unused bits of the sub-second field). This is one ever 24 CPU cycles. Incrementing a counter and making it visible to all CPUs can probably be done in 24 cycles. Accessing it and setting the "seen" flag as well might just fit with faster memory. Getting any other useful work done while maintaining that rate on a single file seems unlikely. NeilBrown