Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5601395rwl; Tue, 11 Apr 2023 07:38:52 -0700 (PDT) X-Google-Smtp-Source: AKy350bJoiRqbYUHzSGMQoWWyG3PWkoZQ9zimaPnDrRB4X2Mlz7E+Kv5+Si0Op8zT6aqaI2OiVRp X-Received: by 2002:aa7:d906:0:b0:504:6437:4369 with SMTP id a6-20020aa7d906000000b0050464374369mr11647314edr.40.1681223931911; Tue, 11 Apr 2023 07:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681223931; cv=none; d=google.com; s=arc-20160816; b=CnBlNWDNOebMEZZf85UJTJsBOg2hCdlX9XzXBBQgEfbU96ZJVQls55o4A5QDORfp5c KVO4gSx1+e/jS/aylakgJT6kmHmHKkXVowiostuWfbgqfUsGEN0keGw2ABH08zdiIF9Q 7LWL1kBIU91leOqEM9QAavFXt1obm8S2gpIAji4CL1zEXEYm2fdq8fvjMaDfg85dVxn7 Be+6t3Wajlw3KuZIfimRFa5ycgvTzHi6AxxT6F6e1kqdG2jPdbyN0U52UojLASSG2uxg 1rFTYn1z2JLiqoWCnrV6Wod8+3FgoCyJp574INHxRBhu3TkZ/2KGZr0dU/WMOQ7BIaZe GaTQ== 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=pwIqzlLgPxL9uHO3cMjsOKzk3pP9dtOVL/SY92iHXpU=; b=qfV0QpOWaJkO5j984kN40ZzMmfx8QVd38wcM3kFEkletOD/pumWcDac6kV1jZvHS5A Jnpu6n+AfeROBcavFFKF0JimzgEgFNcN6QGFo+MFHw3U6tBfXZCwnvqCdSI7Rka2yVzw 671nOMnDnu0xiaff6UYM/6RsIRF7QQwRJsxxxZd8YfABsILq4txdiWv1I1DKpI2c354v FKj4bgLRS0n3y3IxdQGhpvAJ+fks8XUH431VwR/405PAOGHaXl51r6ez52QJkaoe5CsT cMAUMB83PKm5WerGyOkTrOL1Jhq94KCP2hOQ6pCpBUjBCWD2IO6JNDCzgR/eF3/DHWnR Zpag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t4qT7x6t; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020aa7d54c000000b00504921b0826si350594edr.314.2023.04.11.07.38.17; Tue, 11 Apr 2023 07:38:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=t4qT7x6t; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230118AbjDKOhM (ORCPT + 99 others); Tue, 11 Apr 2023 10:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230163AbjDKOhI (ORCPT ); Tue, 11 Apr 2023 10:37:08 -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 8D69246AF; Tue, 11 Apr 2023 07:37:06 -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 02937627A7; Tue, 11 Apr 2023 14:37:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41813C433D2; Tue, 11 Apr 2023 14:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681223825; bh=IRCClithvgPTE04hKaJiM2EAL0BbX3ippre0W+x0FD4=; h=From:To:Cc:Subject:Date:From; b=t4qT7x6t2LTb4FTbywjpwvf4EZgxgoZDbquly4oCmuXuqeQHVn8s3QnZNlI8SwIt+ pjjvDJdWxP73tNqCgdJkKkph2o3QfeFww7QhfVDKoKt92Cgbu3ROm7x5RtpjebsiJT TTVr2x9eaw3xhwKJuT4FJbUWsqcNUK3AVcl7oSJoyNRESlqJvFls5gMWhdOXNdU1aa y/xNNgsCceoYVMtskUS+ytTRKik/3kWiXiYxZDIjWZLGkVgvXnr6g6zhIXyb2LkX3p dPVQMmiI2WSWyRm6wI+wARvMxps10ptSmgDmffgC65ZOuOJqIqsxQmI5ED1yYIPJA/ wYw7FCMju4k6Q== From: Jeff Layton To: Alexander Viro , Christian Brauner , "Darrick J. Wong" , Hugh Dickins , Andrew Morton , Dave Chinner , Chuck Lever Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Subject: [RFC PATCH 0/3][RESEND] fs: opportunistic high-res file timestamps Date: Tue, 11 Apr 2023 10:36:59 -0400 Message-Id: <20230411143702.64495-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-nfs@vger.kernel.org (Apologies for the resend, but I didn't send this with a wide enough distribution list originally). 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