Re: [PATCH v2] ext4: fix the time handling macros when ext4 is using small inodes

From: Jeff Layton
Date: Thu Jul 20 2023 - 10:54:25 EST


On Thu, 2023-07-20 at 10:48 -0400, Theodore Ts'o wrote:
> On Wed, Jul 19, 2023 at 06:32:19AM -0400, Jeff Layton wrote:
> > If ext4 is using small on-disk inodes, then it may not be able to store
> > fine grained timestamps. It also can't store the i_crtime at all in that
> > case since that fully lives in the extended part of the inode.
> >
> > 979492850abd got the EXT4_EINODE_{GET,SET}_XTIME macros wrong, and would
> > still store the tv_sec field of the i_crtime into the raw_inode, even
> > when they were small, corrupting adjacent memory.
> >
> > This fixes those macros to skip setting anything in the raw_inode if the
> > tv_sec field doesn't fit, and to properly return a {0,0} timestamp when
> > the raw_inode doesn't support it.
> >
> > Also, fix a bug in ctime handling during rename. It was updating the
> > renamed inode's ctime twice rather than the old directory.
> >
> > Cc: Jan Kara <jack@xxxxxxx>
> > Fixes: 979492850abd ("ext4: convert to ctime accessor functions")
> > Reported-by: Hugh Dickins <hughd@xxxxxxxxxx>
> > Tested-by: Hugh Dickins <hughd@xxxxxxxxxx>
> > Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
>
> Acked-by: Theodore Ts'o <tytso@xxxxxxx>
>
> I assume this is will be applied to the vfs.ctime branch, yes?
>
> - Ted

Yes. Ideally it'll be folded into the ext4 patch there.
--
Jeff Layton <jlayton@xxxxxxxxxx>