[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <175573714464.22854.6057932667823312007.stgit@frogsfrogsfrogs>
Date: Wed, 20 Aug 2025 18:22:13 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: John@...ves.net, bernd@...ernd.com, linux-fsdevel@...r.kernel.org,
linux-ext4@...r.kernel.org, miklos@...redi.hu, joannelkoong@...il.com,
neal@...pa.dev
Subject: [PATCH 4/8] fuse2fs: debug timestamp updates
From: Darrick J. Wong <djwong@...nel.org>
Add tracing for timestamp updates to files.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
misc/fuse2fs.c | 99 +++++++++++++++++++++++++++++++++++---------------------
1 file changed, 62 insertions(+), 37 deletions(-)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 44f76e9bed5f42..fe7d6a2568dcf0 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -693,7 +693,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;
@@ -703,11 +704,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;
@@ -718,6 +723,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;
}
@@ -729,6 +738,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);
@@ -736,8 +748,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;
@@ -756,6 +769,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
@@ -772,9 +789,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;
@@ -784,6 +802,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;
}
@@ -796,6 +818,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);
@@ -1860,7 +1885,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;
}
@@ -2134,7 +2159,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;
@@ -2157,7 +2182,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);
@@ -2243,7 +2268,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;
@@ -2270,7 +2295,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) {
@@ -2353,7 +2378,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;
@@ -2432,7 +2457,7 @@ static int remove_inode(struct fuse2fs *ff, ext2_ino_t ino)
inode.i_links_count--;
}
- ret = update_ctime(fs, ino, &inode);
+ ret = fuse2fs_update_ctime(ff, ino, &inode);
if (ret)
return ret;
@@ -2606,7 +2631,7 @@ static int __op_rmdir(struct fuse2fs *ff, const char *path)
}
if (inode.i_links_count > 1)
inode.i_links_count--;
- 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);
@@ -2699,7 +2724,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;
@@ -2723,7 +2748,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) {
@@ -2973,11 +2998,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;
@@ -3066,7 +3091,7 @@ static int op_link(const char *src, const char *dest)
goto out2;
inode.i_links_count++;
- ret = update_ctime(fs, ino, &inode);
+ ret = fuse2fs_update_ctime(ff, ino, &inode);
if (ret)
goto out2;
@@ -3085,7 +3110,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;
@@ -3241,7 +3266,7 @@ static int op_chmod(const char *path, mode_t mode
inode.i_mode = new_mode;
- ret = update_ctime(fs, ino, &inode);
+ ret = fuse2fs_update_ctime(ff, ino, &inode);
if (ret)
goto out;
@@ -3311,7 +3336,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;
@@ -3441,7 +3466,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;
@@ -3671,7 +3696,7 @@ static int op_read(const char *path EXT2FS_ATTR((unused)), char *buf,
}
if (fuse2fs_is_writeable(ff)) {
- ret = update_atime(fs, fh->ino);
+ ret = fuse2fs_update_atime(ff, fh->ino);
if (ret)
goto out;
}
@@ -3755,7 +3780,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;
@@ -4117,7 +4142,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)
@@ -4211,7 +4236,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)
@@ -4348,7 +4373,7 @@ static int op_readdir(const char *path EXT2FS_ATTR((unused)),
}
if (fuse2fs_is_writeable(ff)) {
- ret = update_atime(i.fs, fh->ino);
+ ret = fuse2fs_update_atime(ff, fh->ino);
if (ret)
goto out;
}
@@ -4453,7 +4478,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;
@@ -4484,7 +4509,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);
@@ -4555,7 +4580,7 @@ static int op_ftruncate(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;
@@ -4642,7 +4667,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;
@@ -4710,7 +4735,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;
@@ -4757,7 +4782,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;
@@ -4862,7 +4887,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;
@@ -5130,7 +5155,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;
@@ -5303,7 +5328,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;
Powered by blists - more mailing lists