From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC25636922A; Mon, 23 Feb 2026 23:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771890156; cv=none; b=gKiPFg5G9OXNfBCxVFmjesVB4stck7e3k1WNPfF2PVFEzw6L00yKRHPfpBVGBEPDECkZXqaJWHIKTy79F8G4gQe7Ss1rkfZ1mXupNtsvWIoSGBNSV30r3T0Rv6v0cbXOCesqKEIon6QqFKGMYtMielS6vN3HnMrNtSa6V+GTvBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771890156; c=relaxed/simple; bh=ngXUNB44NQuUbimKTCMUqixcZe9I6gp7J2um61W46qc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L5DVb87zmYUvGhvisGp0KhTKDK8qZn87cCzZ6U8rFhoR5lRvLbD3blfYqBcWYkpdTbmc5PvzBE+RS2OwPFiR7DZc5N9ypjTagI8mvKsn7mceTMzhVmiziT3pXA2k6xQ2hmLD97VF/pINDJ2tYDN+uyI+lid9dQph6sXdIEoqelU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ATE7Ayox; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ATE7Ayox" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1A7DC116C6; Mon, 23 Feb 2026 23:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771890155; bh=ngXUNB44NQuUbimKTCMUqixcZe9I6gp7J2um61W46qc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ATE7AyoxWsenO8nEPEPHI3Z80uzdwobl1rXLFZczNnc+kb8Juqk4IvRU0R/Sm8r5e w5Xd2snyUICSfHQ949Yl+4WUfJ++dpTR9LpKHhaWwlOg0OL+qOMrV7EPmUnhCNFtAU niyO2OYU/9npHUQd+LIrN63QUt5vtS5RHraUPrOCV2fsPCgqwvNmFEdyEEhl1g9t1+ C1lKejlzl2I9aGqxRiHzPkylzoDvOKGDotUgkjhfeFW6/U9iUX3pVdGH9Sh/aMIsUB 1YLbgtqHnUpHTAgxYw9xD9roTv3NLI3D4ntNa6ez+NhKWDsrAvqAFpeUa9ORk77Vb5 vg0c5B8myilgQ== Date: Mon, 23 Feb 2026 15:42:35 -0800 Subject: [PATCH 05/10] fuse2fs: debug timestamp updates From: "Darrick J. Wong" To: tytso@mit.edu Cc: bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, miklos@szeredi.hu, bernd@bsbernd.com, joannelkoong@gmail.com, neal@gompa.dev Message-ID: <177188745270.3944028.14444486216859288954.stgit@frogsfrogsfrogs> In-Reply-To: <177188745140.3944028.16289511572192714858.stgit@frogsfrogsfrogs> References: <177188745140.3944028.16289511572192714858.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit From: Darrick J. Wong Add tracing for timestamp updates to files. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 97 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 36 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 90f537efe525ce..21e27efb835659 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -864,7 +864,8 @@ static void increment_version(struct ext2_inode_large *inode) inode->i_version_hi = ver >> 32; } -static void init_times(struct ext2_inode_large *inode) +static void fuse2fs_init_timestamps(struct fuse2fs *ff, ext2_ino_t ino, + struct ext2_inode_large *inode) { struct timespec now; @@ -874,11 +875,15 @@ static void init_times(struct ext2_inode_large *inode) EXT4_INODE_SET_XTIME(i_mtime, &now, inode); EXT4_EINODE_SET_XTIME(i_crtime, &now, inode); increment_version(inode); + + dbg_printf(ff, "%s: ino=%u time %ld:%lu\n", __func__, ino, now.tv_sec, + now.tv_nsec); } -static int update_ctime(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode_large *pinode) +static int fuse2fs_update_ctime(struct fuse2fs *ff, ext2_ino_t ino, + struct ext2_inode_large *pinode) { + ext2_filsys fs = ff->fs; errcode_t err; struct timespec now; struct ext2_inode_large inode; @@ -889,6 +894,10 @@ static int update_ctime(ext2_filsys fs, ext2_ino_t ino, if (pinode) { increment_version(pinode); EXT4_INODE_SET_XTIME(i_ctime, &now, pinode); + + dbg_printf(ff, "%s: ino=%u ctime %ld:%lu\n", __func__, ino, + now.tv_sec, now.tv_nsec); + return 0; } @@ -900,6 +909,9 @@ static int update_ctime(ext2_filsys fs, ext2_ino_t ino, increment_version(&inode); EXT4_INODE_SET_XTIME(i_ctime, &now, &inode); + dbg_printf(ff, "%s: ino=%u ctime %ld:%lu\n", __func__, ino, + now.tv_sec, now.tv_nsec); + err = fuse2fs_write_inode(fs, ino, &inode); if (err) return translate_error(fs, ino, err); @@ -907,8 +919,9 @@ static int update_ctime(ext2_filsys fs, ext2_ino_t ino, return 0; } -static int update_atime(ext2_filsys fs, ext2_ino_t ino) +static int fuse2fs_update_atime(struct fuse2fs *ff, ext2_ino_t ino) { + ext2_filsys fs = ff->fs; errcode_t err; struct ext2_inode_large inode, *pinode; struct timespec atime, mtime, now; @@ -927,6 +940,10 @@ static int update_atime(ext2_filsys fs, ext2_ino_t ino) dmtime = mtime.tv_sec + ((double)mtime.tv_nsec / NSEC_PER_SEC); dnow = now.tv_sec + ((double)now.tv_nsec / NSEC_PER_SEC); + dbg_printf(ff, "%s: ino=%u atime %ld:%lu mtime %ld:%lu now %ld:%lu\n", + __func__, ino, atime.tv_sec, atime.tv_nsec, mtime.tv_sec, + mtime.tv_nsec, now.tv_sec, now.tv_nsec); + /* * If atime is newer than mtime and atime hasn't been updated in thirty * seconds, skip the atime update. Same idea as Linux "relatime". Use @@ -943,9 +960,10 @@ static int update_atime(ext2_filsys fs, ext2_ino_t ino) return 0; } -static int update_mtime(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode_large *pinode) +static int fuse2fs_update_mtime(struct fuse2fs *ff, ext2_ino_t ino, + struct ext2_inode_large *pinode) { + ext2_filsys fs = ff->fs; errcode_t err; struct ext2_inode_large inode; struct timespec now; @@ -955,6 +973,10 @@ static int update_mtime(ext2_filsys fs, ext2_ino_t ino, EXT4_INODE_SET_XTIME(i_mtime, &now, pinode); EXT4_INODE_SET_XTIME(i_ctime, &now, pinode); increment_version(pinode); + + dbg_printf(ff, "%s: ino=%u mtime/ctime %ld:%lu\n", + __func__, ino, now.tv_sec, now.tv_nsec); + return 0; } @@ -967,6 +989,9 @@ static int update_mtime(ext2_filsys fs, ext2_ino_t ino, EXT4_INODE_SET_XTIME(i_ctime, &now, &inode); increment_version(&inode); + dbg_printf(ff, "%s: ino=%u mtime/ctime %ld:%lu\n", + __func__, ino, now.tv_sec, now.tv_nsec); + err = fuse2fs_write_inode(fs, ino, &inode); if (err) return translate_error(fs, ino, err); @@ -2228,7 +2253,7 @@ static int op_readlink(const char *path, char *buf, size_t len) buf[len] = 0; if (fuse2fs_is_writeable(ff)) { - ret = update_atime(fs, ino); + ret = fuse2fs_update_atime(ff, ino); if (ret) goto out; } @@ -2502,7 +2527,7 @@ static int op_mknod(const char *path, mode_t mode, dev_t dev) goto out2; } - ret = update_mtime(fs, parent, NULL); + ret = fuse2fs_update_mtime(ff, parent, NULL); if (ret) goto out2; @@ -2525,7 +2550,7 @@ static int op_mknod(const char *path, mode_t mode, dev_t dev) } inode.i_generation = ff->next_generation++; - init_times(&inode); + fuse2fs_init_timestamps(ff, child, &inode); err = fuse2fs_write_inode(fs, child, &inode); if (err) { ret = translate_error(fs, child, err); @@ -2611,7 +2636,7 @@ static int op_mkdir(const char *path, mode_t mode) goto out2; } - ret = update_mtime(fs, parent, NULL); + ret = fuse2fs_update_mtime(ff, parent, NULL); if (ret) goto out2; @@ -2638,7 +2663,7 @@ static int op_mkdir(const char *path, mode_t mode) if (parent_sgid) inode.i_mode |= S_ISGID; inode.i_generation = ff->next_generation++; - init_times(&inode); + fuse2fs_init_timestamps(ff, child, &inode); err = fuse2fs_write_inode(fs, child, &inode); if (err) { @@ -2721,7 +2746,7 @@ static int fuse2fs_unlink(struct fuse2fs *ff, const char *path, if (err) return translate_error(fs, dir, err); - ret = update_mtime(fs, dir, NULL); + ret = fuse2fs_update_mtime(ff, dir, NULL); if (ret) return ret; @@ -2812,7 +2837,7 @@ static int remove_inode(struct fuse2fs *ff, ext2_ino_t ino) ext2fs_set_dtime(fs, EXT2_INODE(&inode)); } - ret = update_ctime(fs, ino, &inode); + ret = fuse2fs_update_ctime(ff, ino, &inode); if (ret) return ret; @@ -2982,7 +3007,7 @@ static int __op_rmdir(struct fuse2fs *ff, const char *path) goto out; } ext2fs_dec_nlink(EXT2_INODE(&inode)); - ret = update_mtime(fs, rds.parent, &inode); + ret = fuse2fs_update_mtime(ff, rds.parent, &inode); if (ret) goto out; err = fuse2fs_write_inode(fs, rds.parent, &inode); @@ -3079,7 +3104,7 @@ static int op_symlink(const char *src, const char *dest) } /* Update parent dir's mtime */ - ret = update_mtime(fs, parent, NULL); + ret = fuse2fs_update_mtime(ff, parent, NULL); if (ret) goto out2; @@ -3103,7 +3128,7 @@ static int op_symlink(const char *src, const char *dest) fuse2fs_set_uid(&inode, ctxt->uid); fuse2fs_set_gid(&inode, gid); inode.i_generation = ff->next_generation++; - init_times(&inode); + fuse2fs_init_timestamps(ff, child, &inode); err = fuse2fs_write_inode(fs, child, &inode); if (err) { @@ -3388,11 +3413,11 @@ static int op_rename(const char *from, const char *to, } /* Update timestamps */ - ret = update_ctime(fs, from_ino, NULL); + ret = fuse2fs_update_ctime(ff, from_ino, NULL); if (ret) goto out2; - ret = update_mtime(fs, to_dir_ino, NULL); + ret = fuse2fs_update_mtime(ff, to_dir_ino, NULL); if (ret) goto out2; @@ -3486,7 +3511,7 @@ static int op_link(const char *src, const char *dest) } ext2fs_inc_nlink(fs, EXT2_INODE(&inode)); - ret = update_ctime(fs, ino, &inode); + ret = fuse2fs_update_ctime(ff, ino, &inode); if (ret) goto out2; @@ -3505,7 +3530,7 @@ static int op_link(const char *src, const char *dest) goto out2; } - ret = update_mtime(fs, parent, NULL); + ret = fuse2fs_update_mtime(ff, parent, NULL); if (ret) goto out2; @@ -3653,7 +3678,7 @@ static int op_chmod(const char *path, mode_t mode, struct fuse_file_info *fi) inode.i_mode = new_mode; - ret = update_ctime(fs, ino, &inode); + ret = fuse2fs_update_ctime(ff, ino, &inode); if (ret) goto out; @@ -3720,7 +3745,7 @@ static int op_chown(const char *path, uid_t owner, gid_t group, fuse2fs_set_gid(&inode, group); } - ret = update_ctime(fs, ino, &inode); + ret = fuse2fs_update_ctime(ff, ino, &inode); if (ret) goto out; @@ -3850,7 +3875,7 @@ static int fuse2fs_truncate(struct fuse2fs *ff, ext2_ino_t ino, off_t new_size) if (err) return translate_error(fs, ino, err); - ret = update_mtime(fs, ino, NULL); + ret = fuse2fs_update_mtime(ff, ino, NULL); if (ret) return ret; @@ -4085,7 +4110,7 @@ static int op_read(const char *path EXT2FS_ATTR((unused)), char *buf, } if (fh->check_flags != X_OK && fuse2fs_is_writeable(ff)) { - ret = update_atime(fs, fh->ino); + ret = fuse2fs_update_atime(ff, fh->ino); if (ret) goto out; } @@ -4169,7 +4194,7 @@ static int op_write(const char *path EXT2FS_ATTR((unused)), goto out; } - ret = update_mtime(fs, fh->ino, NULL); + ret = fuse2fs_update_mtime(ff, fh->ino, NULL); if (ret) goto out; @@ -4531,7 +4556,7 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)), goto out2; } - ret = update_ctime(fs, ino, NULL); + ret = fuse2fs_update_ctime(ff, ino, NULL); out2: err = ext2fs_xattrs_close(&h); if (!ret && err) @@ -4625,7 +4650,7 @@ static int op_removexattr(const char *path, const char *key) goto out2; } - ret = update_ctime(fs, ino, NULL); + ret = fuse2fs_update_ctime(ff, ino, NULL); out2: err = ext2fs_xattrs_close(&h); if (err && !ret) @@ -4743,7 +4768,7 @@ static int op_readdir(const char *path EXT2FS_ATTR((unused)), void *buf, } if (fuse2fs_is_writeable(ff)) { - ret = update_atime(i.fs, fh->ino); + ret = fuse2fs_update_atime(ff, fh->ino); if (ret) goto out; } @@ -4848,7 +4873,7 @@ static int op_create(const char *path, mode_t mode, struct fuse_file_info *fp) goto out2; } - ret = update_mtime(fs, parent, NULL); + ret = fuse2fs_update_mtime(ff, parent, NULL); if (ret) goto out2; @@ -4879,7 +4904,7 @@ static int op_create(const char *path, mode_t mode, struct fuse_file_info *fp) } inode.i_generation = ff->next_generation++; - init_times(&inode); + fuse2fs_init_timestamps(ff, child, &inode); err = fuse2fs_write_inode(fs, child, &inode); if (err) { ret = translate_error(fs, child, err); @@ -4963,7 +4988,7 @@ static int op_utimens(const char *path, const struct timespec ctv[2], if (tv[1].tv_nsec != UTIME_OMIT) EXT4_INODE_SET_XTIME(i_mtime, &tv[1], &inode); #endif /* UTIME_OMIT */ - ret = update_ctime(fs, ino, &inode); + ret = fuse2fs_update_ctime(ff, ino, &inode); if (ret) goto out; @@ -5031,7 +5056,7 @@ static int ioctl_setflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, if (ret) return ret; - ret = update_ctime(fs, fh->ino, &inode); + ret = fuse2fs_update_ctime(ff, fh->ino, &inode); if (ret) return ret; @@ -5078,7 +5103,7 @@ static int ioctl_setversion(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, inode.i_generation = generation; - ret = update_ctime(fs, fh->ino, &inode); + ret = fuse2fs_update_ctime(ff, fh->ino, &inode); if (ret) return ret; @@ -5209,7 +5234,7 @@ static int ioctl_fssetxattr(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, if (ext2fs_inode_includes(inode_size, i_projid)) inode.i_projid = fsx->fsx_projid; - ret = update_ctime(fs, fh->ino, &inode); + ret = fuse2fs_update_ctime(ff, fh->ino, &inode); if (ret) return ret; @@ -5481,7 +5506,7 @@ static int fuse2fs_allocate_range(struct fuse2fs *ff, } } - err = update_mtime(fs, fh->ino, &inode); + err = fuse2fs_update_mtime(ff, fh->ino, &inode); if (err) return err; @@ -5654,7 +5679,7 @@ static int fuse2fs_punch_range(struct fuse2fs *ff, return translate_error(fs, fh->ino, err); } - err = update_mtime(fs, fh->ino, &inode); + err = fuse2fs_update_mtime(ff, fh->ino, &inode); if (err) return err;