From patchwork Tue Apr 11 14:36:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13207693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A81DCC76196 for ; Tue, 11 Apr 2023 14:37:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A015280009; Tue, 11 Apr 2023 10:37:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3502A280001; Tue, 11 Apr 2023 10:37:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23FBD280009; Tue, 11 Apr 2023 10:37:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 151EA280001 for ; Tue, 11 Apr 2023 10:37:09 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B8AB280D82 for ; Tue, 11 Apr 2023 14:37:08 +0000 (UTC) X-FDA: 80669362536.07.437EA63 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id F36D8180020 for ; Tue, 11 Apr 2023 14:37:06 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=t4qT7x6t; spf=pass (imf06.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681223827; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=pwIqzlLgPxL9uHO3cMjsOKzk3pP9dtOVL/SY92iHXpU=; b=Qt2UtqRZe/ujfFRZQ/JMyJgcRrGSn/lZg7CGE8G7HJB0/4XD6pLqk8G/Ke0y4c3XKlupJM qh+h/0YrqOz10dRqizChIyWPxX9mfO4wR4UlWWGlzftHH2sl9Iof6gf8Sz1V9mVdY8EUEC DuOASzIcYqKUquUO1i6ddlT6jscz6Mo= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=t4qT7x6t; spf=pass (imf06.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681223827; a=rsa-sha256; cv=none; b=m8Q/+iXPbXsg5KH8W4tX5FdnXHETNVhHZscDwpRDfgzenMrzaPVHECJSTUeu/Gg2Lba+nV SqC8OAiL5aOFvj6tRdirmOGa1z7RRKWhla1L3hYypI8ghPnZWBn69C2osB2Zri+fD/xZuU H7vlbF0q1SCB4b7U6LtvXvDwxlP5es8= 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 02D84627A9; 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 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: F36D8180020 X-Stat-Signature: zbas9eiwko3b7x98hx5qcos49tgjtfeb X-HE-Tag: 1681223826-404916 X-HE-Meta: U2FsdGVkX18exPC34RyfHhOawdevymvN+acDerw7lhxYv75gmvt+h0wUApv9u5kET3oYEnMf12JWZ2/tzwYszYxYFdB4UQz9ex8lRNVWZeJCnmzav+8QsUAftGsxfX1R7ZwfIcfoX1mGdh7Ru5Frw8Y6Q2jDzs0CmBBRU4YwEcTtF8AsrslxHl3DmPP+RKMo10UdJqm0214lRF471lXjrYAnA58kWRkjLVaGVV6WDS87rUtEQj5Lqo6uW8O3f8uwOqEgTaUrQf2Gbwl83L9kgUOkcoQNgs2ujOHiHzXziQoAnfgCpMUhz55FS8o49Rb8WWWfHhXK66tAk6Kc6YBWNqF7PWT4maVDZZhn2Wb0aZQqfSb8dGW6tAIW3YK5mXUOneX7wnJQmxN/6eblGBumvjs2J3CDj/meF2Uy/C0+KB9NNROlV93zcvNGcANTTMmzd3GRSqQA5TrdyOsXf3J8zXydUgMePJxSqno+advQNH2QmltnpMBCfC9qgG0sEP8mUMN4u4IEDo/R83aur/gP/OqGBCeVNGEVXz1RFowzkzOA4KHPMf3o9cgQ5ENeyWT2F7O50sPAG95tnp89u8WA88AEA0TWwyzviiZUJokTBKC1we2n1VDPZ8OXOZFze+Z6vwLWHU30SYn7FdDBKdXO8X7BXAn8TMCysLnP47Xtw8o0mcAsGGRdTgaPq2RzcQ21GoyHbWG2r9bSmQhUSr7svHLuVzDnVQMv7oRI/Gk+gBc93s/pqolru6BX6okZmWJh5B0mIYKOxGRsUazW9he0aheG0edQvH4LDOWmEu+sRg/yYq6+DQToBMeeuNJrUq04ShBg0UD1BJv59RAes08jpUbhv367sRdLr3Fy4HaBfBkWJSD6caAJ9yDi8EpqOhKc7Q/gAcUOQ6DmmRkZNg6wygcltjAKx5qQuFd5iKXtriv6GoMQcM/OcwFmlB42fIRiJXeJf1qSWmOWXGADSkr ept1+KWf 68l15wbbXdaNsmdYWfyZJvnjqF+Wr4D68KLyJaLjvFYw3DB9uZ+P6hKUXpMMcL4JbILYtHEQniLc8/2W2QVMh7/PJZ0n2Z4wgAIc9qlH0q6pWztOV94utuQvv7TGTrSEYUB0DM1DDTmdHeK3DFtpaW/e1h93p5EVqyeH5v6B+PoQBPXbSiGUTu/puu6RedYXx8pEx9GDUIgvyQPRVwHPFGPd/Y8bKvP8zTgoL9dARe4Slb0NHZ5iEiljVfR49T0T709kfEssyRufogeHj10Jw49muREuxiQ3mlcTrRGFjoMo0xTk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: (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(-)