LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Jeff Layton <jlayton@kernel.org>
Cc: lucho@ionkov.net, rafael@kernel.org, djwong@kernel.org,
	al@alarsen.net, cmllamas@google.com, andrii@kernel.org,
	hughd@google.com, john.johansen@canonical.com,
	agordeev@linux.ibm.com, hch@lst.de, hubcap@omnibond.com,
	pc@manguebit.com, linux-xfs@vger.kernel.org, bvanassche@acm.org,
	jeffxu@chromium.org, john@keeping.me.uk, yi.zhang@huawei.com,
	jmorris@namei.org, code@tyhicks.com, stern@rowland.harvard.edu,
	borntraeger@linux.ibm.com, devel@lists.orangefs.org,
	mirimmad17@gmail.com, sprasad@microsoft.com, jaharkes@cs.cmu.edu,
	linux-um@lists.infradead.org, npiggin@gmail.com,
	viro@zeniv.linux.org.uk, ericvh@kernel.org, surenb@google.com,
	trond.myklebust@hammerspace.com, anton@tuxera.com,
	brauner@kernel.org, wsa+renesas@sang-engineering.com,
	gregkh@linuxfoundation.org, stephen.smalley.work@gmail.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	lsahlber@redhat.com, senozhatsky@chromium.org, arve@android.com,
	chuck.lever@oracle.com, svens@linux.ibm.com, jolsa@kernel.org,
	jack@s use.com, tj@kernel.org, akpm@linux-foundation.org,
	linux-trace-kernel@vger.kernel.org, xu.xin16@zte.com.cn,
	shaggy@kernel.org, dhavale@google.com,
	penguin-kernel@I-love.SAKURA.ne.jp, zohar@linux.ibm.com,
	linux-mm@kvack.org, joel@joelfernandes.org, edumazet@google.com,
	sdf@google.com, jomajm@gmail.com, linux-s390@vger.kernel.org,
	linux-nilfs@vger.kernel.org, paul@paul-moore.com,
	leon@kernel.org, john.fastabend@gmail.com, mcgrof@kernel.org,
	chi.minghao@zte.com.cn, codalist@coda.cs.cmu.edu,
	selinux@vger.kernel.org, zhangpeng362@huawei.com,
	quic_ugoswami@quicinc.com, yhs@fb.com, yzaikin@google.com,
	linkinjeon@kernel.org, mhiramat@kernel.org,
	ecryptfs@vger.kernel.org, tkjos@android.com,
	madkar@cs.stonybrook.edu, gor@linux.ibm.com, yuzhe@nfschina.com,
	linuxppc-dev@lists.ozlabs.org, reiserfs-devel@vger.kernel.org,
	miklos@szeredi.hu, huyue2@coolpad.com, jaegeuk@kernel.org,
	gargaditya08@live.com, maco@android.com,
	hirofumi@mail.parknet.co.jp, haoluo@google.com,
	tony.luck@intel.com, tytso@mit .edu, nico@fluxnic.net,
	linux-ntfs-dev@lists.sourceforge.net, muchun.song@linux.dev,
	roberto.sassu@huawei.com, linux-f2fs-devel@lists.sourceforge.net,
	yang.yang29@zte.com.cn, gpiccoli@igalia.com,
	ebiederm@xmission.com, anna@kernel.org,
	quic_uaggarwa@quicinc.com, bwarrum@linux.ibm.com,
	mike.kravetz@oracle.com, jingyuwang_vip@163.com,
	linux-efi@vger.kernel.org, error27@gmail.com,
	martin@omnibond.com, trix@redhat.com,
	ocfs2-devel@lists.linux.dev, ast@kernel.org,
	sebastian.reichel@collabora.com, clm@fb.com,
	linux-mtd@lists.infradead.org, willy@infradead.org,
	marc.dionne@auristor.com, linux-afs@lists.infradead.org,
	raven@themaw.net, naohiro.aota@wdc.com, daniel@iogearbox.net,
	dennis.dalessandro@cornelisnetworks.com,
	linux-rdma@vger.kernel.org, quic_linyyuan@quicinc.com,
	coda@cs.cmu.edu, slava@dubeyko.com, idryomov@gmail.com,
	pabeni@redhat.com, adobriyan@gmail.com, serge@hallyn.com,
	chengzhihao1@huawei.com, axboe@kernel.dk, amir73il@gmail.com,
	linuszeng@tencent.com, keescook@chromium.org, arnd@arndb.de,
	autofs@vger.kernel.org, rostedt@goodmis.org,
	yifeliu@cs.stonybrook.edu, dlemoal@kernel.org,
	eparis@parisplace.org, ceph-devel@vger.kernel.org,
	xiang@kernel.org, yijiangshan@kylinos.cn, dhowells@redhat.com,
	linux-nfs@vger.kernel.org, linux-ext4@vger.kernel.org,
	kolga@netapp.com, song@kernel.org,
	samba-technical@lists.samba.org, sfrench@samba.org,
	jk@ozlabs.org, netdev@vger.kernel.org, rpeterso@redhat.com,
	linux-fsdevel@vger.kernel.org, bpf@vger.kernel.org,
	ntfs3@lists.linux.dev, linux-erofs@lists.ozlabs.org,
	davem@davemloft.net, jfs-discussion@lists.sourceforge.net,
	princekumarmaurya06@gmail.com, ebiggers@google.com,
	neilb@suse.de, asmadeus@codewreck.org, linux_oss@crudebyte.com,
	me@bobcopeland.com, kpsingh@kernel.org, okanatov@gmail.com,
	almaz.alexandrovich@paragon-software.com,
	joseph.qi@linux.alibaba.com, hayama@lineo.co.jp,
	adilger.kernel@dilger.ca, mikulas@artax.karlin.mff.cuni.cz,
	shaozhengchao@huawei.com, chenzhongjin@huawei.com,
	ardb@kernel.org, anton.ivanov@c ambridgegreys.com,
	agruenba@redhat.com, richard@nod.at, mark@fasheh.com,
	shr@devkernel.io, Dai.Ngo@oracle.com, cluster-devel@redhat.com,
	jgg@ziepe.ca, kuba@kernel.org, riel@surriel.com,
	salah.triki@gmail.com, dushistov@mail.ru,
	linux-cifs@vger.kernel.org, hca@linux.ibm.com, chao@kernel.org,
	apparmor@lists.ubuntu.com, josef@toxicpanda.com,
	Liam.Howlett@Oracle.com, tom@talpey.com, hdegoede@redhat.com,
	linux-hardening@vger.kernel.org, aivazian.tigran@gmail.com,
	dchinner@redhat.com, dsterba@suse.com, xiubli@redhat.com,
	konishi.ryusuke@gmail.com, jgross@suse.com, jth@kernel.org,
	rituagar@linux.ibm.com, luisbg@kernel.org, martin.lau@linux.dev,
	v9fs@lists.linux.dev, fmdefrancesco@gmail.com,
	linux-unionfs@vger.kernel.org, lrh2000@pku.edu.cn,
	linux-security-module@vger.kernel.org, ezk@cs.stonybrook.edu,
	jefflexu@linux.alibaba.com, linux@treblig.org,
	hannes@cmpxchg.org, phillip@squashfs.org.uk,
	johannes@sipsolutions.net, sj1557.seo@samsung.com,
	dwmw2@infradead.org, linux-karma-devel@lists.sou rceforge.net,
	linux-btrfs@vger.kernel.org, jlbec@evilplan.org
Subject: Re: [PATCH v2 08/92] fs: new helper: simple_rename_timestamp
Date: Thu, 6 Jul 2023 12:27:06 +0200	[thread overview]
Message-ID: <20230706102706.w7udmbmuwp7hhcry@quack3> (raw)
In-Reply-To: <20230705185812.579118-3-jlayton@kernel.org>

On Wed 05-07-23 14:58:11, Jeff Layton wrote:
> A rename potentially involves updating 4 different inode timestamps. Add
> a function that handles the details sanely, and convert the libfs.c
> callers to use it.
> 
> 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/libfs.c         | 36 +++++++++++++++++++++++++++---------
>  include/linux/fs.h |  2 ++
>  2 files changed, 29 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/libfs.c b/fs/libfs.c
> index a7e56baf8bbd..9ee79668c909 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -692,6 +692,31 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry)
>  }
>  EXPORT_SYMBOL(simple_rmdir);
>  
> +/**
> + * simple_rename_timestamp - update the various inode timestamps for rename
> + * @old_dir: old parent directory
> + * @old_dentry: dentry that is being renamed
> + * @new_dir: new parent directory
> + * @new_dentry: target for rename
> + *
> + * POSIX mandates that the old and new parent directories have their ctime and
> + * mtime updated, and that inodes of @old_dentry and @new_dentry (if any), have
> + * their ctime updated.
> + */
> +void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
> +			     struct inode *new_dir, struct dentry *new_dentry)
> +{
> +	struct inode *newino = d_inode(new_dentry);
> +
> +	old_dir->i_mtime = inode_set_ctime_current(old_dir);
> +	if (new_dir != old_dir)
> +		new_dir->i_mtime = inode_set_ctime_current(new_dir);
> +	inode_set_ctime_current(d_inode(old_dentry));
> +	if (newino)
> +		inode_set_ctime_current(newino);
> +}
> +EXPORT_SYMBOL_GPL(simple_rename_timestamp);
> +
>  int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
>  			   struct inode *new_dir, struct dentry *new_dentry)
>  {
> @@ -707,11 +732,7 @@ int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
>  			inc_nlink(old_dir);
>  		}
>  	}
> -	old_dir->i_ctime = old_dir->i_mtime =
> -	new_dir->i_ctime = new_dir->i_mtime =
> -	d_inode(old_dentry)->i_ctime =
> -	d_inode(new_dentry)->i_ctime = current_time(old_dir);
> -
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(simple_rename_exchange);
> @@ -720,7 +741,6 @@ int simple_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  		  struct dentry *old_dentry, struct inode *new_dir,
>  		  struct dentry *new_dentry, unsigned int flags)
>  {
> -	struct inode *inode = d_inode(old_dentry);
>  	int they_are_dirs = d_is_dir(old_dentry);
>  
>  	if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
> @@ -743,9 +763,7 @@ int simple_rename(struct mnt_idmap *idmap, struct inode *old_dir,
>  		inc_nlink(new_dir);
>  	}
>  
> -	old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
> -		new_dir->i_mtime = inode->i_ctime = current_time(old_dir);
> -
> +	simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry);
>  	return 0;
>  }
>  EXPORT_SYMBOL(simple_rename);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index bdfbd11a5811..14e38bd900f1 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2979,6 +2979,8 @@ extern int simple_open(struct inode *inode, struct file *file);
>  extern int simple_link(struct dentry *, struct inode *, struct dentry *);
>  extern int simple_unlink(struct inode *, struct dentry *);
>  extern int simple_rmdir(struct inode *, struct dentry *);
> +void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
> +			     struct inode *new_dir, struct dentry *new_dentry);
>  extern int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
>  				  struct inode *new_dir, struct dentry *new_dentry);
>  extern int simple_rename(struct mnt_idmap *, struct inode *,
> -- 
> 2.41.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  parent reply	other threads:[~2023-07-06 13:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 18:58 [PATCH v2 00/89] fs: new accessors for inode->i_ctime Jeff Layton
2023-07-05 18:58 ` [PATCH v2 07/92] fs: add ctime accessors infrastructure Jeff Layton
2023-07-05 23:12   ` Damien Le Moal
2023-07-05 18:58 ` [PATCH v2 08/92] fs: new helper: simple_rename_timestamp Jeff Layton
2023-07-05 23:19   ` Damien Le Moal
2023-07-06  0:04     ` Jeff Layton
2023-07-06 21:02       ` [apparmor] " Seth Arnold
2023-07-07 10:50         ` Jeff Layton
2023-07-06 10:27   ` Jan Kara [this message]
2023-08-30  0:19   ` Al Viro
2023-08-30  0:48     ` Jeff Layton
2023-07-05 18:58 ` [PATCH v2 92/92] fs: rename i_ctime field to __i_ctime Jeff Layton
2023-07-05 23:19   ` Damien Le Moal
2023-07-06 14:58   ` Jan Kara
2023-07-05 21:57 ` [PATCH v2 00/89] fs: new accessors for inode->i_ctime Jeff Layton
2023-07-06 15:16   ` Eric W. Biederman
2023-07-06 16:14     ` Jeff Layton
2023-07-07 12:42 ` Jeff Layton
2023-07-10 12:35   ` Christian Brauner
2023-07-10 13:32     ` Jeff Layton
2023-07-10 12:18 ` [PATCH v2 00/92] " Christian Brauner
2023-09-04 18:11 ` [f2fs-dev] [PATCH v2 00/89] " patchwork-bot+f2fs

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=20230706102706.w7udmbmuwp7hhcry@quack3 \
    --to=jack@suse.cz \
    --cc=agordeev@linux.ibm.com \
    --cc=al@alarsen.net \
    --cc=andrii@kernel.org \
    --cc=anton@tuxera.com \
    --cc=arve@android.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=brauner@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=chuck.lever@oracle.com \
    --cc=cmllamas@google.com \
    --cc=code@tyhicks.com \
    --cc=devel@lists.orangefs.org \
    --cc=djwong@kernel.org \
    --cc=ericvh@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=hubcap@omnibond.com \
    --cc=hughd@google.com \
    --cc=jack@s \
    --cc=jaharkes@cs.cmu.edu \
    --cc=jeffxu@chromium.org \
    --cc=jlayton@kernel.org \
    --cc=jmorris@namei.org \
    --cc=john.johansen@canonical.com \
    --cc=john@keeping.me.uk \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=lucho@ionkov.net \
    --cc=mirimmad17@gmail.com \
    --cc=npiggin@gmail.com \
    --cc=pc@manguebit.com \
    --cc=rafael@kernel.org \
    --cc=senozhatsky@chromium.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=trond.myklebust@hammerspace.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yi.zhang@huawei.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