From: Jan Kara <jack@suse.cz>
To: Jeff Layton <jlayton@kernel.org>
Cc: "Latchesar Ionkov" <lucho@ionkov.net>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Darrick J. Wong" <djwong@kernel.org>,
"Anders Larsen" <al@alarsen.net>,
"Carlos Llamas" <cmllamas@google.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Hugh Dickins" <hughd@google.com>,
"John Johansen" <john.johansen@canonical.com>,
"Seth Forshee" <sforshee@digitalocean.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christoph Hellwig" <hch@lst.de>,
"Mike Marshall" <hubcap@omnibond.com>,
"Paulo Alcantara" <pc@manguebit.com>,
linux-xfs@vger.kernel.org, "Bart Van Assche" <bvanassche@acm.org>,
"John Keeping" <john@keeping.me.uk>,
"Zhang Yi" <yi.zhang@huawei.com>,
"James Morris" <jmorris@namei.org>,
"Tyler Hicks" <code@tyhicks.com>,
"Alan Stern" <stern@rowland.harvard.edu>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
devel@lists.orangefs.org,
"Shyam Prasad N" <sprasad@microsoft.com>,
"Jan Harkes" <jaharkes@cs.cmu.edu>,
linux-um@lists.infradead.org,
"Nicholas Piggin" <npiggin@gmail.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Eric Van Hensbergen" <ericvh@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Trond Myklebust" <trond.myklebust@hammerspace.com>,
"Anton Altaparmakov" <anton@tuxera.com>,
"Christian Brauner" <brauner@kernel.org>,
"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Stephen Smalley" <stephen.smalley.work@gmail.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
"Ronnie Sahlberg" <lsahlber@redhat.com>,
"Sergey Senozhatsky" <senozhatsky@chromium.org>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Chuck Lever" <chuck.lever@oracle.com>,
"Sven Schnelle" <svens@linux.ibm.com>,
"Jiri Olsa" <jolsa@kernel.org>, "Jan Kara" <jack@suse.com>,
"Tejun Heo" <tj@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
linux-trace-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org,
"Dave Kleikamp" <shaggy@kernel.org>,
"Sandeep Dhavale" <dhavale@google.com>,
"Tetsuo Handa" <penguin-kernel@I-love.SAKURA.ne.jp>,
"Mimi Zohar" <zohar@linux.ibm.com>,
linux-mm@kvack.org, "Joel Fernandes" <joel@joelfernandes.org>,
"Eric Dumazet" <edumazet@google.com>,
"Stanislav Fomichev" <sdf@google.com>,
"Andrzej Pietrasiewicz" <andrzej.p@collabora.com>,
"Hangyu Hua" <hbh25y@gmail.com>,
linux-s390@vger.kernel.org, linux-nilfs@vger.kernel.org,
"Paul Moore" <paul@paul-moore.com>,
"Leon Romanovsky" <leon@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
"Arve Hjønnevåg" <arve@android.com>,
"Minghao Chi" <chi.minghao@zte.com.cn>,
codalist@coda.cs.cmu.edu, selinux@vger.kernel.org,
ZhangPeng <zhangpeng362@huawei.com>,
"Udipto Goswami" <quic_ugoswami@quicinc.com>,
"Yonghong Song" <yhs@fb.com>, "Iurii Zaikin" <yzaikin@google.com>,
"Namjae Jeon" <linkinjeon@kernel.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
ecryptfs@vger.kernel.org, "Todd Kjos" <tkjos@android.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Yu Zhe" <yuzhe@nfschina.com>,
linuxppc-dev@lists.ozlabs.org, reiserfs-devel@vger.kernel.org,
"Miklos Szeredi" <miklos@szeredi.hu>,
"Yue Hu" <huyue2@coolpad.com>, "Jaegeuk Kim" <jaegeuk@kernel.org>,
"Aditya Garg" <gargaditya08@live.com>,
"Martijn Coenen" <maco@android.com>,
"OGAWA Hirofumi" <hirofumi@mail.parknet.co.jp>,
"Hao Luo" <haoluo@google.com>, "Tony Luck" <tony.luck@intel.com>,
"Theodore Ts'o" <tytso@mit.edu>,
"Nicolas Pitre" <nico@fluxnic.net>,
linux-ntfs-dev@lists.sourceforge.net,
"Muchun Song" <muchun.song@linux.dev>,
"Roberto Sassu" <roberto.sassu@huawei.com>,
linux-f2fs-devel@lists.sourceforge.net,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
"Jozef Martiniak" <jomajm@gmail.com>,
"Eric Biederman" <ebiederm@xmission.com>,
"Anna Schumaker" <anna@kernel.org>, "xu xin" <cgel.zte@gmail.com>,
"Brad Warrum" <bwarrum@linux.ibm.com>,
"Mike Kravetz" <mike.kravetz@oracle.com>,
"Jingyu Wang" <jingyuwang_vip@163.com>,
linux-efi@vger.kernel.org, "Dan Carpenter" <error27@gmail.com>,
"Martin Brandenburg" <martin@omnibond.com>,
"Tom Rix" <trix@redhat.com>,
"Alexei Starovoitov" <ast@kernel.org>, "Chris Mason" <clm@fb.com>,
linux-mtd@lists.infradead.org,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Marc Dionne" <marc.dionne@auristor.com>,
linux-afs@lists.infradead.org, "Ian Kent" <raven@themaw.net>,
"Naohiro Aota" <naohiro.aota@wdc.com>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Dennis Dalessandro" <dennis.dalessandro@cornelisnetworks.com>,
linux-rdma@vger.kernel.org,
"Linyu Yuan" <quic_linyyuan@quicinc.com>,
coda@cs.cmu.edu, "Viacheslav Dubeyko" <slava@dubeyko.com>,
"Ilya Dryomov" <idryomov@gmail.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Alexey Dobriyan" <adobriyan@gmail.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
"Zhihao Cheng" <chengzhihao1@huawei.com>,
"Jens Axboe" <axboe@kernel.dk>,
"Zeng Jingxiang" <linuszeng@tencent.com>,
"Kees Cook" <keescook@chromium.org>,
"Arnd Bergmann" <arnd@arndb.de>,
autofs@vger.kernel.org, "Steven Rostedt" <rostedt@goodmis.org>,
"Yifei Liu" <yifeliu@cs.stonybrook.edu>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Eric Paris" <eparis@parisplace.org>,
ceph-devel@vger.kernel.org, "Gao Xiang" <xiang@kernel.org>,
"Jiangshan Yi" <yijiangshan@kylinos.cn>,
"David Howells" <dhowells@redhat.com>,
linux-nfs@vger.kernel.org, linux-ext4@vger.kernel.org,
"Song Liu" <song@kernel.org>,
samba-technical@lists.samba.org,
"Steve French" <sfrench@samba.org>, "Jeremy Kerr" <jk@ozlabs.org>,
netdev@vger.kernel.org, "Bob Peterson" <rpeterso@redhat.com>,
linux-fsdevel@vger.kernel.org, bpf@vger.kernel.org,
ntfs3@lists.linux.dev, linux-erofs@lists.ozlabs.org,
"David S. Miller" <davem@davemloft.net>,
ocfs2-devel@oss.oracle.com, jfs-discussion@lists.sourceforge.net,
"Dominique Martinet" <asmadeus@codewreck.org>,
"Christian Schoenebeck" <linux_oss@crudebyte.com>,
"Bob Copeland" <me@bobcopeland.com>,
"KP Singh" <kpsingh@kernel.org>,
"Oleg Kanatov" <okanatov@gmail.com>,
"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
"Joseph Qi" <joseph.qi@linux.alibaba.com>,
"Yuta Hayama" <hayama@lineo.co.jp>,
"Andreas Dilger" <adilger.kernel@dilger.ca>,
"Mikulas Patocka" <mikulas@artax.karlin.mff.cuni.cz>,
"Zhengchao Shao" <shaozhengchao@huawei.com>,
"Chen Zhongjin" <chenzhongjin@huawei.com>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
"Laurent Pinchart" <laurent.pinchart+renesas@ideasonboard.com>,
"Andreas Gruenbacher" <agruenba@redhat.com>
Subject: Re: [PATCH 01/79] fs: add ctime accessors infrastructure
Date: Wed, 21 Jun 2023 18:34:06 +0200 [thread overview]
Message-ID: <20230621163406.udwkxl6tteg6nlcn@quack3> (raw)
In-Reply-To: <20230621144507.55591-2-jlayton@kernel.org>
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 <jlayton@kernel.org>
Looks good to me. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
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 <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-06-21 18:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-21 14:45 [PATCH 00/79] fs: new accessors for inode->i_ctime Jeff Layton
2023-06-21 14:45 ` [PATCH 01/79] fs: add ctime accessors infrastructure Jeff Layton
2023-06-21 16:34 ` Jan Kara [this message]
2023-06-21 17:29 ` Tom Talpey
2023-06-21 18:01 ` Jeff Layton
2023-06-21 18:19 ` Tom Talpey
2023-06-21 18:48 ` Jeff Layton
2023-06-22 0:46 ` Damien Le Moal
2023-06-22 10:14 ` Jeff Layton
2023-06-30 22:12 ` Luis Chamberlain
2023-07-12 15:31 ` Randy Dunlap
2023-06-21 14:45 ` [PATCH 02/79] spufs: switch to new ctime accessors Jeff Layton
2023-06-21 16:34 ` Jan Kara
2023-06-22 0:19 ` Jeremy Kerr
2023-06-21 14:49 ` [PATCH 79/79] fs: rename i_ctime field to __i_ctime Jeff Layton
2023-06-21 19:21 ` [PATCH 00/79] fs: new accessors for inode->i_ctime Steven Rostedt
2023-06-21 19:52 ` Jeff Layton
2023-06-23 12:41 ` Christian Brauner
2023-06-30 22:11 ` Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230621163406.udwkxl6tteg6nlcn@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=adobriyan@gmail.com \
--cc=agordeev@linux.ibm.com \
--cc=agruenba@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=al@alarsen.net \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=andrii@kernel.org \
--cc=andrzej.p@collabora.com \
--cc=anna@kernel.org \
--cc=anton.ivanov@cambridgegreys.com \
--cc=anton@tuxera.com \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=arve@android.com \
--cc=asmadeus@codewreck.org \
--cc=ast@kernel.org \
--cc=autofs@vger.kernel.org \
--cc=axboe@kernel.dk \
--cc=borntraeger@linux.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=bvanassche@acm.org \
--cc=bwarrum@linux.ibm.com \
--cc=ceph-devel@vger.kernel.org \
--cc=cgel.zte@gmail.com \
--cc=chengzhihao1@huawei.com \
--cc=chenzhongjin@huawei.com \
--cc=chi.minghao@zte.com.cn \
--cc=chuck.lever@oracle.com \
--cc=clm@fb.com \
--cc=cmllamas@google.com \
--cc=coda@cs.cmu.edu \
--cc=codalist@coda.cs.cmu.edu \
--cc=code@tyhicks.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dennis.dalessandro@cornelisnetworks.com \
--cc=devel@lists.orangefs.org \
--cc=dhavale@google.com \
--cc=dhowells@redhat.com \
--cc=djwong@kernel.org \
--cc=dlemoal@kernel.org \
--cc=ebiederm@xmission.com \
--cc=ecryptfs@vger.kernel.org \
--cc=edumazet@google.com \
--cc=eparis@parisplace.org \
--cc=ericvh@kernel.org \
--cc=error27@gmail.com \
--cc=gargaditya08@live.com \
--cc=gor@linux.ibm.com \
--cc=gpiccoli@igalia.com \
--cc=gregkh@linuxfoundation.org \
--cc=haoluo@google.com \
--cc=hayama@lineo.co.jp \
--cc=hbh25y@gmail.com \
--cc=hch@lst.de \
--cc=hirofumi@mail.parknet.co.jp \
--cc=hubcap@omnibond.com \
--cc=hughd@google.com \
--cc=huyue2@coolpad.com \
--cc=idryomov@gmail.com \
--cc=jack@suse.com \
--cc=jaegeuk@kernel.org \
--cc=jaharkes@cs.cmu.edu \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=jingyuwang_vip@163.com \
--cc=jk@ozlabs.org \
--cc=jlayton@kernel.org \
--cc=jmorris@namei.org \
--cc=joel@joelfernandes.org \
--cc=john.fastabend@gmail.com \
--cc=john.johansen@canonical.com \
--cc=john@keeping.me.uk \
--cc=jolsa@kernel.org \
--cc=jomajm@gmail.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=keescook@chromium.org \
--cc=kpsingh@kernel.org \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=leon@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linuszeng@tencent.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=linux-ntfs-dev@lists.sourceforge.net \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lsahlber@redhat.com \
--cc=lucho@ionkov.net \
--cc=maco@android.com \
--cc=marc.dionne@auristor.com \
--cc=martin@omnibond.com \
--cc=mcgrof@kernel.org \
--cc=me@bobcopeland.com \
--cc=mhiramat@kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=miklos@szeredi.hu \
--cc=mikulas@artax.karlin.mff.cuni.cz \
--cc=muchun.song@linux.dev \
--cc=naohiro.aota@wdc.com \
--cc=netdev@vger.kernel.org \
--cc=nico@fluxnic.net \
--cc=npiggin@gmail.com \
--cc=ntfs3@lists.linux.dev \
--cc=ocfs2-devel@oss.oracle.com \
--cc=okanatov@gmail.com \
--cc=pabeni@redhat.com \
--cc=paul@paul-moore.com \
--cc=pc@manguebit.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=quic_linyyuan@quicinc.com \
--cc=quic_ugoswami@quicinc.com \
--cc=rafael@kernel.org \
--cc=raven@themaw.net \
--cc=reiserfs-devel@vger.kernel.org \
--cc=roberto.sassu@huawei.com \
--cc=rostedt@goodmis.org \
--cc=rpeterso@redhat.com \
--cc=samba-technical@lists.samba.org \
--cc=sdf@google.com \
--cc=selinux@vger.kernel.org \
--cc=senozhatsky@chromium.org \
--cc=serge@hallyn.com \
--cc=sforshee@digitalocean.com \
--cc=sfrench@samba.org \
--cc=shaggy@kernel.org \
--cc=shaozhengchao@huawei.com \
--cc=slava@dubeyko.com \
--cc=song@kernel.org \
--cc=sprasad@microsoft.com \
--cc=stephen.smalley.work@gmail.com \
--cc=stern@rowland.harvard.edu \
--cc=surenb@google.com \
--cc=svens@linux.ibm.com \
--cc=tj@kernel.org \
--cc=tkjos@android.com \
--cc=tony.luck@intel.com \
--cc=trix@redhat.com \
--cc=trond.myklebust@hammerspace.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=wsa+renesas@sang-engineering.com \
--cc=xiang@kernel.org \
--cc=yhs@fb.com \
--cc=yi.zhang@huawei.com \
--cc=yifeliu@cs.stonybrook.edu \
--cc=yijiangshan@kylinos.cn \
--cc=yuzhe@nfschina.com \
--cc=yzaikin@google.com \
--cc=zhangpeng362@huawei.com \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox