mbox series

[v2,0/8] fs: add some missing ctime updates

Message ID 20230612104524.17058-1-jlayton@kernel.org
Headers show
Series fs: add some missing ctime updates | expand

Message

Jeff Layton June 12, 2023, 10:45 a.m. UTC
v2:
- drop gfs2 patch as it involved (hidden) quota inode
- clarify patch descriptions to satisfy checkpatch.pl

While working on a patch series to change how we handle the ctime, I
found a number of places that update the mtime without a corresponding
ctime update.

While it's not spelled out explicitly in the POSIX spec, all of the
operations that update the mtime must also update the ctime. I've not
been able to find any counterexamples, in any case. Some of these
patches involve operations not covered by POSIX, but it's still a good
idea to update the ctime when updating the mtime.

Note that these are largely untested other than for compilation, so
please review carefully. These are a preliminary set for the upcoming
rework of how we handle the ctime.

None of these seem to be very crucial, but it would be nice if various
maintainers could pick these up for v6.5. Please let me know if you do,
or would rather I shepherd the patch upstream.

Jeff Layton (8):
  ibmvmc: update ctime in conjunction with mtime on write
  usb: update the ctime as well when updating mtime after an ioctl
  autofs: set ctime as well when mtime changes on a dir
  bfs: update ctime in addition to mtime when adding entries
  efivarfs: update ctime when mtime changes on a write
  exfat: ensure that ctime is updated whenever the mtime is
  apparmor: update ctime whenever the mtime changes on an inode
  cifs: update the ctime on a partial page write

 drivers/misc/ibmvmc.c             |  2 +-
 drivers/usb/core/devio.c          | 16 ++++++++--------
 fs/autofs/root.c                  |  6 +++---
 fs/bfs/dir.c                      |  2 +-
 fs/efivarfs/file.c                |  2 +-
 fs/exfat/namei.c                  |  8 ++++----
 fs/smb/client/file.c              |  2 +-
 security/apparmor/apparmorfs.c    |  7 +++++--
 security/apparmor/policy_unpack.c | 11 +++++++----
 9 files changed, 31 insertions(+), 25 deletions(-)

Comments

Ian Kent June 13, 2023, 7:16 a.m. UTC | #1
On 12/6/23 18:45, Jeff Layton wrote:
> When adding entries to a directory, POSIX generally requires that the
> ctime also be updated alongside the mtime.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Acked-by: Ian Kent <raven@themaw.net>


> ---
>   fs/autofs/root.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/autofs/root.c b/fs/autofs/root.c
> index 6baf90b08e0e..93046c9dc461 100644
> --- a/fs/autofs/root.c
> +++ b/fs/autofs/root.c
> @@ -600,7 +600,7 @@ static int autofs_dir_symlink(struct mnt_idmap *idmap,
>   	p_ino = autofs_dentry_ino(dentry->d_parent);
>   	p_ino->count++;
>   
> -	dir->i_mtime = current_time(dir);
> +	dir->i_mtime = dir->i_ctime = current_time(dir);
>   
>   	return 0;
>   }
> @@ -633,7 +633,7 @@ static int autofs_dir_unlink(struct inode *dir, struct dentry *dentry)
>   	d_inode(dentry)->i_size = 0;
>   	clear_nlink(d_inode(dentry));
>   
> -	dir->i_mtime = current_time(dir);
> +	dir->i_mtime = dir->i_ctime = current_time(dir);
>   
>   	spin_lock(&sbi->lookup_lock);
>   	__autofs_add_expiring(dentry);
> @@ -749,7 +749,7 @@ static int autofs_dir_mkdir(struct mnt_idmap *idmap,
>   	p_ino = autofs_dentry_ino(dentry->d_parent);
>   	p_ino->count++;
>   	inc_nlink(dir);
> -	dir->i_mtime = current_time(dir);
> +	dir->i_mtime = dir->i_ctime = current_time(dir);
>   
>   	return 0;
>   }
Christian Brauner June 14, 2023, 8:30 a.m. UTC | #2
On Mon, 12 Jun 2023 06:45:19 -0400, Jeff Layton wrote:
> When adding entries to a directory, POSIX generally requires that the
> ctime also be updated alongside the mtime.
> 
> 

Can't find a tree for this patch, so picking this patch up unless told otherwise.

---

Applied to the vfs.misc branch of the vfs/vfs.git tree.
Patches in the vfs.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.misc

[3/8] autofs: set ctime as well when mtime changes on a dir
      https://git.kernel.org/vfs/vfs/c/9b37b3342a98
Ian Kent June 15, 2023, 10:14 a.m. UTC | #3
On 14/6/23 16:30, Christian Brauner wrote:
> On Mon, 12 Jun 2023 06:45:19 -0400, Jeff Layton wrote:
>> When adding entries to a directory, POSIX generally requires that the
>> ctime also be updated alongside the mtime.
>>
>>
> Can't find a tree for this patch, so picking this patch up unless told otherwise.

There's relatively few changes to autofs and Linus asked me to send

changes via. Al or Andrew so there's no point in maintaining a tree

anyway.


Ian

>
> ---
>
> Applied to the vfs.misc branch of the vfs/vfs.git tree.
> Patches in the vfs.misc branch should appear in linux-next soon.
>
> Please report any outstanding bugs that were missed during review in a
> new review to the original patch series allowing us to drop it.
>
> It's encouraged to provide Acked-bys and Reviewed-bys even though the
> patch has now been applied. If possible patch trailers will be updated.
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
> branch: vfs.misc
>
> [3/8] autofs: set ctime as well when mtime changes on a dir
>        https://git.kernel.org/vfs/vfs/c/9b37b3342a98
Al Viro Aug. 30, 2023, 12:08 a.m. UTC | #4
On Mon, Jun 12, 2023 at 06:45:16AM -0400, Jeff Layton wrote:
> Jeff Layton (8):
>   ibmvmc: update ctime in conjunction with mtime on write
>   usb: update the ctime as well when updating mtime after an ioctl
>   autofs: set ctime as well when mtime changes on a dir
>   bfs: update ctime in addition to mtime when adding entries
>   efivarfs: update ctime when mtime changes on a write
>   exfat: ensure that ctime is updated whenever the mtime is
>   apparmor: update ctime whenever the mtime changes on an inode
>   cifs: update the ctime on a partial page write
> 
>  drivers/misc/ibmvmc.c             |  2 +-
>  drivers/usb/core/devio.c          | 16 ++++++++--------
>  fs/autofs/root.c                  |  6 +++---
>  fs/bfs/dir.c                      |  2 +-
>  fs/efivarfs/file.c                |  2 +-
>  fs/exfat/namei.c                  |  8 ++++----
>  fs/smb/client/file.c              |  2 +-
>  security/apparmor/apparmorfs.c    |  7 +++++--
>  security/apparmor/policy_unpack.c | 11 +++++++----
>  9 files changed, 31 insertions(+), 25 deletions(-)

As a possible followup (again, apologies for being MIA for months):
touch_cmtime(inode)...