From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8359EB64D8 for ; Wed, 21 Jun 2023 18:48:44 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=sc9SdGkV; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=PrqwLsXY; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4QmXZz10vYz3cNH for ; Thu, 22 Jun 2023 04:48:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=sc9SdGkV; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=PrqwLsXY; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=suse.cz (client-ip=2001:67c:2178:6::1d; helo=smtp-out2.suse.de; envelope-from=jack@suse.cz; receiver=lists.ozlabs.org) X-Greylist: delayed 380 seconds by postgrey-1.37 at boromir; Thu, 22 Jun 2023 02:40:38 AEST Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4QmTlB0cYJz309J; Thu, 22 Jun 2023 02:40:37 +1000 (AEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0D47B1FF34; Wed, 21 Jun 2023 16:34:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1687365247; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=83XiFVWYz/09+oGN/3WNfR8rOmdHj8dhtkMP8AULWnA=; b=sc9SdGkVYpy6qJIOp94C8ZTK7+yexSuiuzBBQMmC044LdrYsGTTopVDpXJpirhT8YYUNwr EkZW+2bPiDoUHc1sENxt/GtvO8e+o5cGEB5/qIHjLNWUPiQKx/fex55iHFqqK+cK1B9O2I hTcjZhgE/PAahoI8Eyiz/fHdKLMV9RA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1687365247; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=83XiFVWYz/09+oGN/3WNfR8rOmdHj8dhtkMP8AULWnA=; b=PrqwLsXYpUHalqAYLIba6BTiYIYYM3iCNT6BT131aBHGuZlOrJnTQ+csCsqt6keBKu3RY2 7Ndse7BgJBjAHYAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E3BAB133E6; Wed, 21 Jun 2023 16:34:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YfCPN34mk2S4QgAAMHmgww (envelope-from ); Wed, 21 Jun 2023 16:34:06 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 74A08A075D; Wed, 21 Jun 2023 18:34:06 +0200 (CEST) Date: Wed, 21 Jun 2023 18:34:06 +0200 From: Jan Kara To: Jeff Layton Subject: Re: [PATCH 01/79] fs: add ctime accessors infrastructure Message-ID: <20230621163406.udwkxl6tteg6nlcn@quack3> References: <20230621144507.55591-1-jlayton@kernel.org> <20230621144507.55591-2-jlayton@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230621144507.55591-2-jlayton@kernel.org> X-Mailman-Approved-At: Thu, 22 Jun 2023 04:32:35 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Latchesar Ionkov , "Rafael J. Wysocki" , "Darrick J. Wong" , Anders Larsen , Carlos Llamas , Andrii Nakryiko , Hugh Dickins , John Johansen , Seth Forshee , Alexander Gordeev , Christoph Hellwig , Mike Marshall , Paulo Alcantara , linux-xfs@vger.kernel.org, Bart Van Assche , John Keeping , Zhang Yi , James Morris , Tyler Hicks , Alan Stern , Christian Borntraeger , devel@lists.orangefs.org, Shyam Prasad N , Jan Harkes , linux-um@lists.infradead.org, Nicholas Piggin , Alexander Viro , Eric Van Hensbergen , Suren Baghdasaryan , Trond Myklebust , Anton Altaparmakov , Christian Brauner , Wolfram Sang , Greg Kroah-Hartman , Stephen Smalley , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Ronnie Sahlberg , Sergey Senozhatsky , Luis Chamberlain , Chuck Lever , Sven Schnelle , Jiri Olsa , Jan Kara , Tejun Heo , Andrew Morton , linux-trace-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Dave Kleikamp , Sandeep Dhavale , Tetsuo Handa , Mimi Zohar , linux-mm@kvack.org, Joel Fernandes , Eric Dumazet , Stanislav Fomichev , Andrzej Pietrasiewicz , Hangyu Hua , linux-s390@vger.kernel.org, linux-nilfs@vger.kernel.org, Paul Moore , Leon Romanovsky , John Fastabend , Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= , Minghao Chi , codalist@coda.cs.cmu.edu, selinux@vger.kernel.org, ZhangPeng , Udipto Goswami , Yonghong Song , Iurii Zaikin , Namjae Jeon , Masami Hiramatsu , ecryptfs@vger.kernel.org, Todd Kjos , Vasily Gorbik , Yu Zhe , linuxppc-dev@lists.ozlabs.org, reiserfs-devel@vger.kernel.org, Miklos Szeredi , Yue Hu , Jaegeuk Kim , Aditya Garg , Martijn Coenen , OGAWA Hirofumi , Hao Luo , Tony Luck , Theodore Ts'o , Nicolas Pitre , linux-ntfs-dev@lists.sourceforge.net, Muchun Song , Roberto Sassu , linux-f2fs-devel@lists.sourceforge.net, "Guilherme G. Piccoli" , Jozef Martiniak , Eric Biederman , Anna Schumaker , xu xin , Brad Warrum , Mike Kravetz , Jingyu Wang , linux-efi@vger.kernel.org, Dan Carpenter , Martin Brandenburg , Tom Rix , Alexei Starovoitov , Chris Mason , linux-mtd@lists.infradead.org, "Matthew Wilcox \(Oracle\)" , Marc Dionne , linux-afs@lists.infradead.org, Ian Kent , Naohiro Aota , Daniel Borkmann , Dennis Dalessandro , linux-rdma@vger.kernel.org, Linyu Yuan , coda@cs.cmu.edu, Viacheslav Dubeyko , Ilya Dryomov , Paolo Abeni , Alexey Dobriyan , "Serge E. Hallyn" , Zhihao Cheng , Jens Axboe , Zeng Jingxiang , Kees Cook , Arnd Bergmann , autofs@vger.kernel.org, Steven Rostedt , Yifei Liu , Damien Le Moal , Eric Paris , ceph-devel@vger.kernel.org, Gao Xiang , Jiangshan Yi , David Howells , linux-nfs@vger.kernel.org, linux-ext4@vger.kernel.org, Song Liu , samba-technical@lists.samba.org, Steve French , Jeremy Kerr , netdev@vger.kernel.org, Bob Peterson , linux-fsdevel@vger.kernel.org, bpf@vger.kernel.org, ntfs3@lists.linux.dev, linux-erofs@lists.ozlabs.org, "David S. Miller" , ocfs2-devel@oss.oracle.com, jfs-discussion@lists.sourceforge.net, Dominique Martinet , Christian Schoenebeck , Bob Copeland , KP Singh , Oleg Kanatov , Konstantin Komarov , Joseph Qi , Yuta Hayama , Andreas Dilger , Mikulas Patocka , Zhengchao Shao , Chen Zhongjin , Ard Biesheuvel , Anton Ivanov , Laurent Pinchart , Andreas Gruenbacher , Richard Weinberger , Mark Fasheh , Stefan Roesch , cluster-devel@redhat.com, Jason Gunthorpe , Jakub Kicinski , Rik van Riel , Salah Triki , Evgeniy Dushistov , linux-cifs@vger.kernel.org, Heiko Carstens , Chao Yu , apparmor@lists.ubuntu.com, Josef Bacik , "Liam R. Howlett" , Tom Talpey , Hans de Goede , "Tigran A. Aivazian" , Dave Chinner , David Sterba , Xiubo Li , Ryusuke Konishi , Juergen Gross , Johannes Thumshirn , Ritu Agarwal , Luis de Bethencourt , Martin KaFai Lau , v9fs@lists.linux.dev, "Fabio M. De Francesco" , linux-unionfs@vger.kernel.org, Ruihan Li , linux-security-module@vger.kernel.org, Erez Zadok , Jeffle Xu , "Dr. David Alan Gilbert" , Johannes Weiner , Phillip Lougher , Johannes Berg , Sungjong Seo , David Woodhouse , linux-karma-devel@lists.sourceforge.net, linux-btrfs@vger.kernel.org, Joel Becker Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed 21-06-23 10:45:06, Jeff Layton wrote: > struct timespec64 has unused bits in the tv_nsec field that can be used > for other purposes. In future patches, we're going to change how the > inode->i_ctime is accessed in certain inodes in order to make use of > them. In order to do that safely though, we'll need to eradicate raw > accesses of the inode->i_ctime field from the kernel. > > Add new accessor functions for the ctime that we can use to replace them. > > Signed-off-by: Jeff Layton Looks good to me. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/inode.c | 16 ++++++++++++++ > include/linux/fs.h | 53 +++++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 68 insertions(+), 1 deletion(-) > > diff --git a/fs/inode.c b/fs/inode.c > index d37fad91c8da..c005e7328fbb 100644 > --- a/fs/inode.c > +++ b/fs/inode.c > @@ -2499,6 +2499,22 @@ struct timespec64 current_time(struct inode *inode) > } > EXPORT_SYMBOL(current_time); > > +/** > + * inode_ctime_set_current - set the ctime to current_time > + * @inode: inode > + * > + * Set the inode->i_ctime to the current value for the inode. Returns > + * the current value that was assigned to i_ctime. > + */ > +struct timespec64 inode_ctime_set_current(struct inode *inode) > +{ > + struct timespec64 now = current_time(inode); > + > + inode_set_ctime(inode, now); > + return now; > +} > +EXPORT_SYMBOL(inode_ctime_set_current); > + > /** > * in_group_or_capable - check whether caller is CAP_FSETID privileged > * @idmap: idmap of the mount @inode was found from > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 6867512907d6..9afb30606373 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1474,7 +1474,58 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb, > kgid_has_mapping(fs_userns, kgid); > } > > -extern struct timespec64 current_time(struct inode *inode); > +struct timespec64 current_time(struct inode *inode); > +struct timespec64 inode_ctime_set_current(struct inode *inode); > + > +/** > + * inode_ctime_peek - fetch the current ctime from the inode > + * @inode: inode from which to fetch ctime > + * > + * Grab the current ctime from the inode and return it. > + */ > +static inline struct timespec64 inode_ctime_peek(const struct inode *inode) > +{ > + return inode->i_ctime; > +} > + > +/** > + * inode_ctime_set - set the ctime in the inode to the given value > + * @inode: inode in which to set the ctime > + * @ts: timespec value to set the ctime > + * > + * Set the ctime in @inode to @ts. > + */ > +static inline struct timespec64 inode_ctime_set(struct inode *inode, struct timespec64 ts) > +{ > + inode->i_ctime = ts; > + return ts; > +} > + > +/** > + * inode_ctime_set_sec - set only the tv_sec field in the inode ctime > + * @inode: inode in which to set the ctime > + * @sec: value to set the tv_sec field > + * > + * Set the sec field in the ctime. Returns @sec. > + */ > +static inline time64_t inode_ctime_set_sec(struct inode *inode, time64_t sec) > +{ > + inode->i_ctime.tv_sec = sec; > + return sec; > +} > + > +/** > + * inode_ctime_set_nsec - set only the tv_nsec field in the inode ctime > + * @inode: inode in which to set the ctime > + * @nsec: value to set the tv_nsec field > + * > + * Set the nsec field in the ctime. Returns @nsec. > + */ > +static inline long inode_ctime_set_nsec(struct inode *inode, long nsec) > +{ > + inode->i_ctime.tv_nsec = nsec; > + return nsec; > +} > > /* > * Snapshotting support. > -- > 2.41.0 > -- Jan Kara SUSE Labs, CR