From patchwork Tue Apr 11 14:27:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13207677 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 02F26C77B70 for ; Tue, 11 Apr 2023 14:27:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96FFD280009; Tue, 11 Apr 2023 10:27:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92129280001; Tue, 11 Apr 2023 10:27:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E76A280009; Tue, 11 Apr 2023 10:27:14 -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 6B8AE280001 for ; Tue, 11 Apr 2023 10:27:14 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2DF451C6A24 for ; Tue, 11 Apr 2023 14:27:14 +0000 (UTC) X-FDA: 80669337588.23.623D223 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 7A5C640005 for ; Tue, 11 Apr 2023 14:27:12 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RSsigzCx; spf=pass (imf07.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=1681223232; a=rsa-sha256; cv=none; b=dsoCexg17SLzp76k39K8tHaqsQREWzAYTxSzqZVEaiMszcijgGgS18ECMR3YkmiTL0LLim kfnwKwI7MBW4vj8S6A0bqb19PschVIWx6F/KG2G6Me9FpUaMMyVlgNh/UhbREz6Z7uPNkm ZDoB5Rschxf/v2G9hOQOtZLjw7BBBQk= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RSsigzCx; spf=pass (imf07.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=1681223232; 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=VFub5OpzaPACr8vzw275dAO/o/fsMp3Ozg1Mskwvk04=; b=elHhvuvcgfpMaVIiyqqjnZVAWrzH2onYeHrIl90q7lRPuXj0LYi5OtRdO6ykfu4+kyuvHA MvrjqbBGGUKCf2lhY/SZMllPmRjUVBvV/Aj2bS7agKPwRStJFgLOhiACMueMddTD90K0qr hxRXNq/WOqhd3yOYP/km3lm2nxjiIKI= 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 57D326279F; 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 X-Rspam-User: X-Rspamd-Queue-Id: 7A5C640005 X-Rspamd-Server: rspam01 X-Stat-Signature: exzf8ea4cz9ywnpp7te9sp8yx8qs88gs X-HE-Tag: 1681223232-911180 X-HE-Meta: U2FsdGVkX19A6LkOPpGuqaUj02ZaUJVAJwMt+C6oRVk7AaoVjfXp0TzU7qb/9HRHoNavI+vFYVHJ3PFId7X7kn7LkdmtufXcTLE2k3ZR6l6FbERVDNy/QglMIu/Mb3gphFPtuhF2VifXzeJ36xOGAalZSsXaBcYgh8ACPB8XwhkL/yBkhDp/hNDfAcVCC/ILcU6tel6eW83JhF9R1vElM6cwpjAm0eZLYTsWmDgeUsSXV765sTmuA4VmcBiQbw86h58hhwiWFVjHCdlxCJw/AwKQr0P4fz04aUCCMicyr4O81YBErHecFi5/R4fVW0Y6ydsQHafD9AQxevOxN1+h7hei1URXwCwjhMdbZdVJ3rzs/eJMZWSv7pa4B2PmoNY0ufPDrzyA8/u7EzjvF+eYmZT0yz56jM65ajFrOkSD3OwJtjsvH3fCxTWcMtR3pXl09qXm4rDbdZPoOaNURlD4Gsx+OEh0c1GDpV9V6ejmI4KMW1oi4oYJbYZJZ6sa1G61KvKktCjBiIEy4VT0zEFMDCNEsqTUcx5V+YEtNBcgsTBcTM/onLrQwiRkHBFQHHP2dQ5Dw17jrwpwclVYwdO8xMMiMqt1fcrzfu+hbCDKGvqJdaugjuGUXBTjH9wkdLyWOCHdo9GxHTOdgVLyCFmcsUd2T13XC0+6x/luyoyScD4gFN+qL64wgpuu7kIEXc2X+uaoqIC/CB6Brkwa9xHeeQWuKUs7EfCKAd20iNFaaKc/SjasMiiYEm0vG6gcAgYE6g4L6X1TlQ0CJkbLHlY7pHTw7Izymeuj/9C3Qa1EbRepNExD7V/qtnXU2nmf+ETLpCWeRyEF0eKIYjEwv49yvm0rv+SIAxwJMKuXWxtdwXI9/VWGXXMDENuP+qKlDIFMlsa88I61vq1wmB/tXQViiUmCgI37wkQylsZ6Lm25eX+3Tuc/YnKWV/G8fjdsKgl3cDF/1Q1SXfWJ3jQbc7X QTT5aMKM hPQZmaVUBNk8GXqaXDJz8rpnZ39BBOahsN2kQAt5xS74TH8DzPI7n2gI+/vcUVk4p+LfIGdqxMmjjeIKWUWCDWj7MbvXqC/hyuyfwGn3vkUrcsDj5sGvF/u1iVQ1CaJIHcollbtMDDCUhgVjtmpiXg9NbnHGuPZamPZOpJDopgU8CsmRQDxZEwJuOsnw5dhYWOJKvMGP2eMiYC5arhiXz5aJ1TqEBa1q3VShAZ5DjcwsWpivmNHOSUfGoAQ/LLdNvMvKcwr0YqCIho04L+mHoSAzKvP9KDcggjd60ZxQDrNN7jDA= 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: 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(-)