Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5597439rwl; Tue, 11 Apr 2023 07:35:45 -0700 (PDT) X-Google-Smtp-Source: AKy350acQuKJ/2MTxBftERlIWLMCR1hVrsEfoMhO7dUuMwGIRu+nd+WRI1He6/r26ajoPXHIzqjC X-Received: by 2002:aa7:d483:0:b0:504:92aa:12ee with SMTP id b3-20020aa7d483000000b0050492aa12eemr8524007edr.15.1681223745217; Tue, 11 Apr 2023 07:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681223745; cv=none; d=google.com; s=arc-20160816; b=uIlPMXV3DimtUvKSPIcvq/UipeQ2cA+d7W9dyPLNWRfw6AZZWraj4GfBBg0E3/CQQK TrWp3eOGGfWQLjR/AEp+GNcUIuLAxShIuc/nWJ9GK1V4j0uypVBJt0GHpC48c6gPL04T cMnymkxvxwgJW2qJ9IFYfx1xS3NyM4SQF8jM5rPiS+93nsYZtCy7ukv6qyLCFl/e+WqD 0PdU/RGO4zcGEm0C4yXk2XKLYKxYQPuWeFa8PTlqGrXPltJEt0+uK6XWg3HeTdobW3C0 I5LXEGQxupDz4MTojDHcJraEg5sUk3aDjAbjBo0Mk34R0ZCTwuPZW7+JcHklJHPg8Adt EHhg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=VFub5OpzaPACr8vzw275dAO/o/fsMp3Ozg1Mskwvk04=; b=QhR4zuquQKsoabD0beXWMWOSg9b6yXJpzAALBmqSRkuJjVUK+QR2l0SwNIVSLuppha bU02uSnw/Z6xELD4HdqBWKKKyDgpvQoSoVVb39yrzlKJV+9HwiXnvQFIZZckm/4s26Y5 3h2i0aPxD981LcW31SLU+YVESJYrkHDioL17RJvDoJkq0JsedrtbhGdOWjQg5aCleEdi CjesmisNKXOfv7FxV+LlJ0OSrlJ9mS+EN+AC8I1Z/7S6J8l+5cG3tU9kgHqzRUmMtipt 1NSebQ0D5y6u/dc3PImkuEC8/KLvhKqvPm1AGCPKcxHQlYSAffOp97mpSm4x9GmtrdWT e5dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RSsigzCx; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a50ec8c000000b005048be8a371si797652edr.441.2023.04.11.07.35.20; Tue, 11 Apr 2023 07:35:45 -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=RSsigzCx; 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 S230410AbjDKO1s (ORCPT + 99 others); Tue, 11 Apr 2023 10:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbjDKO1f (ORCPT ); Tue, 11 Apr 2023 10:27:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE5D855BC; Tue, 11 Apr 2023 07:27:12 -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 508B862036; Tue, 11 Apr 2023 14:27:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8F35C433D2; Tue, 11 Apr 2023 14:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681223230; bh=zWD5OEjyLd2QTqKFMvAPrX2Tq24Vay8bPpirE1DcBnA=; h=From:To:Cc:Subject:Date:From; b=RSsigzCxO4uwigld6Th+McqIO8PLB6/6CvXf3HZDlQHmyJAYUtiyrAqYB3bmyVBZm Yr09wsZCpSY2l2twPoiWBpEIXcKkTZblQu2bd8CQ6HSMMzE+x0EJByQizYdcM+w56r Ka8h5x4IoZI41P4hUj57Heggj1NsnMYFy3GKY99TpawCxWCSvlVS2RZdWKBwVMOaqd r4IGVCLSdlwKb+E0uS2Zg+TFQnUegcj7NcWYaxr/MgOtWM7a+yrw3RcdtkpErmRGAc rPatFN6hxbtlB3YvnKAeRabYnusnqeTO6WbAZER+0RhwL0G/5SeGLMx0aIULT/2ZAB 5vvQtfrMG4O6Q== From: Jeff Layton To: Alexander Viro , Christian Brauner , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 0/3] fs: opportunistic high-res file timestamps Date: Tue, 11 Apr 2023 10:27:05 -0400 Message-Id: <20230411142708.62475-1-jlayton@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A few weeks ago, during one of the discussions around i_version, Dave Chinner wrote this: "You've missed the part where I suggested lifting the "nfsd sampled i_version" state into an inode state flag rather than hiding it in the i_version field. At that point, we could optimise away the secondary ctime updates just like you are proposing we do with the i_version updates. Further, we could also use that state it to decide whether we need to use high resolution timestamps when recording ctime updates - if the nfsd has not sampled the ctime/i_version, we don't need high res timestamps to be recorded for ctime...." While I don't think we can practically optimize away ctime updates like we do with i_version, I do like the idea of using this scheme to indicate when we need to use a high-res timestamp. This patchset is a first stab at a scheme to do this. It declares a new i_state flag for this purpose and adds two new vfs-layer functions to implement conditional high-res timestamp fetching. It then converts both tmpfs and xfs to use it. This seems to behave fine under xfstests, but I haven't yet done any performance testing with it. I wouldn't expect it to create huge regressions though since we're only grabbing high res timestamps after each query. I like this scheme because we can potentially convert any filesystem to use it. No special storage requirements like with i_version field. I think it'd potentially improve NFS cache coherency with a whole swath of exportable filesystems, and helps out NFSv3 too. This is really just a proof-of-concept. There are a number of things we could change: 1/ We could use the top bit in the tv_sec field as the flag. That'd give us different flags for ctime and mtime. We also wouldn't need to use a spinlock. 2/ We could probably optimize away the high-res timestamp fetch in more cases. Basically, always do a coarse-grained ts fetch and only fetch the high-res ts when the QUERIED flag is set and the existing time hasn't changed. If this approach looks reasonable, I'll plan to start working on converting more filesystems. One thing I'm not clear on is how widely available high res timestamps are. Is this something we need to gate on particular CONFIG_* options? Thoughts? Jeff Layton (3): fs: add infrastructure for opportunistic high-res ctime/mtime updates shmem: mark for high-res timestamps on next update after getattr xfs: mark the inode for high-res timestamp update in getattr fs/inode.c | 40 +++++++++++++++++++++++++++++++-- fs/stat.c | 10 +++++++++ fs/xfs/libxfs/xfs_trans_inode.c | 2 +- fs/xfs/xfs_acl.c | 2 +- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_iops.c | 15 ++++++++++--- include/linux/fs.h | 5 ++++- mm/shmem.c | 23 ++++++++++--------- 8 files changed, 80 insertions(+), 19 deletions(-) -- 2.39.2