Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp4017527rdg; Wed, 18 Oct 2023 12:19:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrr2j1nFC+IBOlDpIQkrjpQX9OKp1YWx4QxAb1sr8Ko5AYlMRakFJcsNRW/z4zHR07aUt1 X-Received: by 2002:a17:902:ce8a:b0:1c7:4ab6:b3cc with SMTP id f10-20020a170902ce8a00b001c74ab6b3ccmr359117plg.54.1697656755370; Wed, 18 Oct 2023 12:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697656755; cv=none; d=google.com; s=arc-20160816; b=uYPYNH9xWhhcaSZJA0hPT5m707VrBW8obw9aUMqqe2ECgusbXk+CMiwXXuYvREDSVf 88yg9IBU+cGKrK0DQnlxV5eBVF5Tk9NixIm+zhCXIPaSn0VQHEO8BkuhhWjSF42N9eLu n4iC8P5Lh+mkaox6UAGlYXEizOH81Fhr7jsL3xq76niKePVEqlRXcEEEveul9+aAvJxK ajsFqC7WBusW+GrYNaOIxTyr3Pqm4IJLLiCqyXa0w1WRhu4d/DaswW+W/vNVbMfZU7Rd EtxbsoNIAZjKu2ec7jwfzQYfnibKTqHu5ykeZw+s+9kVpml1f5SAq7a3Tjsa1IryZvCW LAvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5Ne6XlZkvrqbgYXFwibkwS6QVtHojWCVkTUV60CnBXA=; fh=ISiDSzqmWaLh5iND+7SKGYwdebyc+vv4TxeeTTF5U/k=; b=MGMw3BHZljy8mZCMjlony/DhYxS8anUBcv5GhMFMTidvCyUphK8DiHAh9qIz86K7GU aI1ncu5g6nd1ykHMLg0HPRc0+bjBoe9P734L1YOueD/7okqdz+Hni425RwJ5eQpgpMhs j2ZRquuT4/ei8uF4ZDp9wzttWQkV64mPMKe7YNHbKKXPOgZ6r7YfPgS2SMOI+Tvf9vRZ hEXnul+eGcd0V7Jn1Fsn8rFi04rkrxg4iDzrCH2256RUU/5wAU8T8eQFGMvEHScDfc3p R1B+zOGoebpUXgLJ3Wb2TXJyefU35hdrvwWLLulBFkO7C9mO6OsRMjEB3GJ6BHfYQgFn +/yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=BunhL8vE; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id l4-20020a170902eb0400b001b7d2b55d8asi496181plb.626.2023.10.18.12.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 12:19:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=BunhL8vE; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A6E4A810FBDD; Wed, 18 Oct 2023 12:19:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231378AbjJRTTG (ORCPT + 99 others); Wed, 18 Oct 2023 15:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231284AbjJRTTF (ORCPT ); Wed, 18 Oct 2023 15:19:05 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43A1911F for ; Wed, 18 Oct 2023 12:19:03 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-507962561adso8700076e87.0 for ; Wed, 18 Oct 2023 12:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1697656741; x=1698261541; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5Ne6XlZkvrqbgYXFwibkwS6QVtHojWCVkTUV60CnBXA=; b=BunhL8vEinbtMzTobkYonStJky9F0F3H6gr/fGEhsF7xRMQV8NYr666XLtr22jPNbU J9pqRBLYmrFEs0bSbQfVJOe8VwBUFC676HMshHaKGBBNymcdZNEEuQwEN2R7+f51F3p9 fXevfbvD2dqSNXU6J0CS+IeTc7Z3zrrUh9kTY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697656741; x=1698261541; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5Ne6XlZkvrqbgYXFwibkwS6QVtHojWCVkTUV60CnBXA=; b=CWsgztw/rIbST2uS8ZNtgUAUqGHUMfWswQa8GqIPjdeomcloGxJ4P0gg1WHPBvyMtD kUMl+vUXGXypGBm/k0j4laiyuZMehor7vjszRZ1n6bagnhhd/acnHHFkLthD14k5b/B2 AKlFq1FOae0Li/Iyl1nYgqFA9rQy9pTia6xeVnJbaK79teLUF08evIz8Liwo8uPgajdK nQ/FiZ4v+QtXXBvPAAQs02lZIzNpTIRfW21omVXA7QiTaSiDZzJ7Pr6oRPcgHN8I9Ttp aMLolf+hUBPB/7v2AaZ5GUU2IBepHjTW1WJYYtUqmT4feynzhfeWpgCDmSggkokXQTTy na1g== X-Gm-Message-State: AOJu0YxiGk9Nqapx4VRAEgG5P5rMmCI6rpo7OABYel8MQLob3tuVFzpf 2/aVvOB51do8ztaqc00FfmInYlyAHViirvaKqBByFJjz X-Received: by 2002:a19:8c0d:0:b0:503:7be:c85d with SMTP id o13-20020a198c0d000000b0050307bec85dmr4336078lfd.35.1697656740878; Wed, 18 Oct 2023 12:19:00 -0700 (PDT) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com. [209.85.208.52]) by smtp.gmail.com with ESMTPSA id ch28-20020a0564021bdc00b0053e5a1bf77dsm3202317edb.88.2023.10.18.12.19.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Oct 2023 12:19:00 -0700 (PDT) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-523100882f2so11921331a12.2 for ; Wed, 18 Oct 2023 12:19:00 -0700 (PDT) X-Received: by 2002:a17:906:99c4:b0:9bd:a662:c066 with SMTP id s4-20020a17090699c400b009bda662c066mr149569ejn.76.1697656719721; Wed, 18 Oct 2023 12:18:39 -0700 (PDT) MIME-Version: 1.0 References: <20231018-mgtime-v1-0-4a7a97b1f482@kernel.org> <20231018-mgtime-v1-2-4a7a97b1f482@kernel.org> In-Reply-To: <20231018-mgtime-v1-2-4a7a97b1f482@kernel.org> From: Linus Torvalds Date: Wed, 18 Oct 2023 12:18:22 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC 2/9] timekeeping: new interfaces for multigrain timestamp handing To: Jeff Layton Cc: Alexander Viro , Christian Brauner , John Stultz , Thomas Gleixner , Stephen Boyd , Chandan Babu R , "Darrick J. Wong" , Dave Chinner , "Theodore Ts'o" , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Amir Goldstein , Jan Kara , David Howells , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 12:19:09 -0700 (PDT) On Wed, 18 Oct 2023 at 10:41, Jeff Layton wrote: > > One way to prevent this is to ensure that when we stamp a file with a > fine-grained timestamp, that we use that value to establish a floor for > any later timestamp update. I'm very leery of this. I don't like how it's using a global time - and a global fine-grained offset - when different filesystems will very naturally have different granularities. I also don't like how it's no using that global lock. Yes, yes, since the use of this all is then gated by the 'is_mgtime()' thing, any filesystem with big granularities will presumably never set FS_MGTIME in the first time, and that hides the worst pointless cases. But it still feels iffy to me. Also, the whole current_ctime() logic seems wrong. Later (in 4/9), you do this: static struct timespec64 current_ctime(struct inode *inode) { if (is_mgtime(inode)) return current_mgtime(inode); and current_mgtime() does if (nsec & I_CTIME_QUERIED) { ktime_get_real_ts64(&now); return timestamp_truncate(now, inode); } so once the code has set I_CTIME_QUERIED, it will now use the expensive fine-grained time - even when it makes no sense. As far as I can tell, there is *never* a reason to get the fine-grained time if the old inode ctime is already sufficiently far away. IOW, my gut feel is that all this logic should always not only be guarded by FS_MGTIME (like you do seem to do), *and* by "has anybody even queried this time" - it should *also* always be guarded by "if I get the coarse-grained time, is that sufficient?" So I think the current_ctime() logic should be something along the lines of static struct timespec64 current_ctime(struct inode *inode) { struct timespec64 ts64 = current_time(inode); unsigned long old_ctime_sec = inode->i_ctime_sec; unsigned int old_ctime_nsec = inode->i_ctime_nsec; if (ts64.tv_sec != old_ctime_sec) return ts64; /* * No need to check is_mgtime(inode) - the I_CTIME_QUERIED * flag is only set for mgtime filesystems */ if (!(old_ctime_nsec & I_CTIME_QUERIED)) return ts64; old_ctime_nsec &= ~I_CTIME_QUERIED; if (ts64.tv_nsec > old_ctime_nsec + inode->i_sb->s_time_gran) return ts64; /* Ok, only *now* do we do a finegrained value */ ktime_get_real_ts64(&ts64); return timestamp_truncate(ts64); } or whatever. Make it *very* clear that the finegrained timestamp is the absolute last option, after we have checked that the regular one isn't possible. I dunno. Linus