From patchwork Thu Sep 28 11:03:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13402484 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 964F4E732D1 for ; Thu, 28 Sep 2023 11:03:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 294FC8D00A6; Thu, 28 Sep 2023 07:03:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 244E68D0038; Thu, 28 Sep 2023 07:03:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 049CD8D00A6; Thu, 28 Sep 2023 07:03:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E7F038D0038 for ; Thu, 28 Sep 2023 07:03:35 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BD0BE80D39 for ; Thu, 28 Sep 2023 11:03:35 +0000 (UTC) X-FDA: 81285720390.04.E764D8A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id EDF3D4000F for ; Thu, 28 Sep 2023 11:03:33 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cgJqBVdg; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695899014; 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:in-reply-to:references:references:dkim-signature; bh=4WjQgRNMdW3j3sfcIHlzIOpBIEpILEBwQl2Kii/SrPo=; b=a7YSG0ra5te5tVyB5TppfdL81II7NI4GQ8eL7xyKsdkEaOqrP6NhkzDg2jXngQ9MdnpYgM z/1y7JRftvYcUL1aNJffdqIlylyn6E3XLNxa8pjZQ35t2+yXatmjMUzUiDat8VoTrCKkqQ 5VjqHQ12hDYIFm8KU7RAWkGi+QDRwCs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cgJqBVdg; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695899014; a=rsa-sha256; cv=none; b=MkM6eIl4cwQFLMgoywRkJbsu3QBNWVneXA+J6YdtWGz2JULi9ky7XafYKOKr3EFjyAlRQZ aKzncrIoDeCvwQz6th/xP87wOt/vqZoVTZdoSqngLWcAFTMahG1py9xagCQEr4sBYZDDw0 wHi14FyBqnhx473pguypGF5Sm8Crzy0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C8B4E61348; Thu, 28 Sep 2023 11:03:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBF2CC433CD; Thu, 28 Sep 2023 11:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695899012; bh=2HU082C0O+wshN8razE9iX9Rxehg6mRJCvsU5n9rFmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgJqBVdgRTRGPcB9AYO9nuxbQNU/aRFlsoq2/9IfdhTUxto7jaIgTs2iK3Hh6VNmI PQNGXum64iBmE5gmxTB5fzhsNqjzKt2sLpABU1iY4QR3sLG/3TAi2tRkz3bK5NdR2Q 5J/x2S1ciuMIVP8CxOGFxyla+hxGROy5UoKNIuzR78QFdYK0UlmPcZ7xnSW65TY0z1 d09jqnFZdRWx08/ZfFzae3DcpVgwGYgcj94ylvD+5VeIqKKaZOw2/kkGfhLURz1SoJ LecijjrtKtsZor5I1BxBnr+8zBdASh0oRnrtfNreKI0opyGPJWi1hjF5WHyNrggNrR Xz99F3TmopI2w== From: Jeff Layton To: Alexander Viro , Christian Brauner , Linus Torvalds , David Sterba , Amir Goldstein , Theodore Ts'o , Eric Biederman , Kees Cook , Jeremy Kerr , Arnd Bergmann , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Greg Kroah-Hartman , =?utf-8?q?Arve_Hj=C3=B8nne?= =?utf-8?q?v=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Mattia Dongili , Dennis Dalessandro , Jason Gunthorpe , Leon Romanovsky , Brad Warrum , Ritu Agarwal , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mark Gross , Jiri Slaby , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Sterba , David Howells , Marc Dionne , Ian Kent , Luis de Bethencourt , Salah Triki , "Tigran A. Aivazian" , Chris Mason , Josef Bacik , Xiubo Li , Ilya Dryomov , Jan Harkes , coda@cs.cmu.edu, Joel Becker , Christoph Hellwig , Nicolas Pitre , "Rafael J. Wysocki" , Ard Biesheuvel , Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu , Namjae Jeon , Sungjong Seo , Jan Kara , Andreas Dilger , Jaegeuk Kim , OGAWA Hirofumi , Christoph Hellwig , Miklos Szeredi , Bob Peterson , Andreas Gruenbacher , Richard Weinberger , Anton Ivanov , Johannes Berg , Mikulas Patocka , Mike Kravetz , Muchun Song , Jan Kara , David Woodhouse , Dave Kleikamp , Tejun Heo , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Ryusuke Konishi , Anton Altaparmakov , Konstantin Komarov , Mark Fasheh , Joseph Qi , Bob Copeland , Mike Marshall , Martin Brandenburg , Luis Chamberlain , Iurii Zaikin , Tony Luck , "Guilherme G. Piccoli" , Anders Larsen , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Sergey Senozhatsky , Phillip Lougher , Steven Rostedt , Masami Hiramatsu , Evgeniy Dushistov , Chandan Babu R , "Darrick J. Wong" , Damien Le Moal , Naohiro Aota , Johannes Thumshirn , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Hugh Dickins , Andrew Morton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , John Johansen , Paul Moore , James Morris , "Serge E. Hallyn" , Stephen Smalley , Eric Paris Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-rdma@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, autofs@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-efi@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-mtd@lists.infradead.org, jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, ntfs3@lists.linux.dev, ocfs2-devel@lists.linux.dev, linux-karma-devel@lists.sourceforge.net, devel@lists.orangefs.org, linux-unionfs@vger.kernel.org, linux-hardening@vger.kernel.org, reiserfs-devel@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Subject: [PATCH 01/87] fs: new accessor methods for atime and mtime Date: Thu, 28 Sep 2023 07:03:00 -0400 Message-ID: <20230928110300.32891-2-jlayton@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230928110300.32891-1-jlayton@kernel.org> References: <20230928110300.32891-1-jlayton@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 5t8seqk76pebreshcu5rbtsm34uerh9b X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EDF3D4000F X-HE-Tag: 1695899013-48742 X-HE-Meta: U2FsdGVkX1+y4R3Uc3AH5O9P87x74KjbzP6IGtntD9PYmy5blXG0/wqjZyhkcsTYx3cMxkC6V74T9TR1iOQ1+RiuGMR6fcQhzbRNXpQtYrMRatl786bgkdxGKCu2ws+u70w2ZN0NA5QU+4PxixZnp3PM05en68GK8bDaqrcxS5vMzboM/4Zc3QwFB4oYgwRNXOB9R89Bl+Ry8cs+20FaVrYd2VxKzlDLfu75vcS/RvBabeSim5TbYTK3u1BSM7rbiwjDnmTe2Rj6NXcR3G1DSUoqhr/W0nyOL2yomc7ByNRmQleNMs8IYekLghfcX05hdTZLJH+U/G1qiodE1rORVcWCrOHHNmKuN785JlqXsbyMOErlYbYZO1GS4ylHqPzcvS5EDuzHn8PUTDM+vsDumHSa7A2mgGmBZoQzkxhVvKK1GPL+WV7b2W6HMSLnb3iEHHmDrtJ7YHParTpoB7/MkxyixmNoJzzvn7mTYY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Ue3XURHgCNJJIKT26EJXGGqR5b0G3mnNE+fJISBxo2DCvdjEOjVKvDyoue6z9JUEl+gRr44M4QhQ+jTzt0yLdjZLz3g8W0WsTqRwUxthDvJ7utu56Zqgcp6CFKmQDIgkuJPsKgltwc31FNwaKfVVs9yFyOjyLd4cWd9feGw/eTdyst4AmuirQnlpa/Zp7t+CITGvXe3bEacuYYxqn/C4EF8HgHUrQT7WWWFb1FiiDeA1fCY5LUrV7jbg0 zdaMaAwd rCYq6BkFjHn188wmBWqwUMpsjjdNwYrmBsquKEGfPZTC0ggM8nPgghaJ+DefJxuEGS6UqON96lOYZP9xYjJoI7Nausez3/OydbExzL6qQyRDvWmxfOzmCvc+4uoJhPwqJO+k5Jcdr7dGXpjpZF3hW497jNk1d4LOaVk6JL6SgBdfIbJt0F/VGHTAh9sRdCSXhOt9ala5CeyT+tivr7unyvR9r2Iy3NeHLjY1lZkNpO9HJDFZlPqXJgObnZP2xiePgXVZ1QfHzUndzkoKuf5bPS2hnLC5n6huorhWPlmL2BdQX0hh7ozTJuReGExBTh3GfFmmPh58VtaAzht9T4dMyR3fXG5v8SrIrY5YPD4e4BKg== 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: Recently, we converted the ctime accesses in the kernel to use new accessor functions. Linus recently pointed out though that if we add accessors for the atime and mtime, then that would allow us to seamlessly change how these timestamps are stored in the inode. Add new accessor functions for the atime and mtime that mirror the accessors for the ctime. Signed-off-by: Jeff Layton --- fs/libfs.c | 13 +++++++++++++ include/linux/fs.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 37f2d34ee090..f5cdc7f7f5b5 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1912,3 +1912,16 @@ ssize_t direct_write_fallback(struct kiocb *iocb, struct iov_iter *iter, return direct_written + buffered_written; } EXPORT_SYMBOL_GPL(direct_write_fallback); + +/** + * simple_inode_init_ts - initialize the timestamps for a new inode + * @inode: inode to be initialized + * + * When a new inode is created, most filesystems set the timestamps to the + * current time. Add a helper to do this. + */ +struct timespec64 simple_inode_init_ts(struct inode *inode); +{ + return inode->i_atime = inode->i_mtime = inode_set_ctime_current(inode); +} +EXPORT_SYMBOL(simple_inode_init_ts); diff --git a/include/linux/fs.h b/include/linux/fs.h index b528f063e8ff..12d247b82aa0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1553,6 +1553,48 @@ static inline struct timespec64 inode_set_ctime(struct inode *inode, return inode_set_ctime_to_ts(inode, ts); } +static inline struct timespec64 inode_get_atime(const struct inode *inode) +{ + return inode->i_atime; +} + +static inline struct timespec64 inode_set_atime_to_ts(struct inode *inode, + struct timespec64 ts) +{ + inode->i_atime = ts; + return ts; +} + +static inline struct timespec64 inode_set_atime(struct inode *inode, + time64_t sec, long nsec) +{ + struct timespec64 ts = { .tv_sec = sec, + .tv_nsec = nsec }; + return inode_set_atime_to_ts(inode, ts); +} + +static inline struct timespec64 inode_get_mtime(const struct inode *inode) +{ + return inode->i_mtime; +} + +static inline struct timespec64 inode_set_mtime_to_ts(struct inode *inode, + struct timespec64 ts) +{ + inode->i_mtime = ts; + return ts; +} + +static inline struct timespec64 inode_set_mtime(struct inode *inode, + time64_t sec, long nsec) +{ + struct timespec64 ts = { .tv_sec = sec, + .tv_nsec = nsec }; + return inode_set_mtime_to_ts(inode, ts); +} + +struct timespec64 simple_inode_init_ts(struct inode *inode); + /* * Snapshotting support. */