Skip to content

Commit f14ccd7

Browse files
committed
hfs: disable the updating of file access times (atime)
The xfstests' test-case generic/003 fails with errors: sudo ./check generic/003 FSTYP -- hfs PLATFORM -- Linux/x86_64 hfsplus-testing-0001 7.0.0-rc1+ #18 SMP PREEMPT_DYNAMIC Fri Mar 13 17:54:19 PDT 2026 MKFS_OPTIONS -- /dev/loop51 MOUNT_OPTIONS -- /dev/loop51 /mnt/scratch output mismatch QA output created by 003 ERROR: access time has changed for file1 after remount ERROR: access time has changed after modifying file1 ERROR: change time has not been updated after changing file1 ERROR: access time has changed for file in read-only filesystem Silence is golden This patch fixes the issue with change time by adding inode_set_ctime_current() and mark_inode_dirty() in hfs_rename(). Also, it reworks hfs_inode_setattr() by changing simple_inode_init_ts() on inode_set_mtime_to_ts() and inode_set_ctime_current() calls. HFS hasn't any field in on-disk layout that can keep the file/folder access times (atime). It was added setting of SB_NOATIME in SB_NOATIME. Finally, we have only atime related errors in generic/003 output: sudo ./check generic/003 FSTYP -- hfs PLATFORM -- Linux/x86_64 hfsplus-testing-0001 7.1.0-rc1+ #52 SMP PREEMPT_DYNAMIC Wed May 13 15:04:37 PDT 2026 MKFS_OPTIONS -- /dev/loop51 MOUNT_OPTIONS -- /dev/loop51 /mnt/scratch QA output created by 003 ERROR: access time has not been updated after accessing file1 first time ERROR: access time has not been updated after accessing file2 ERROR: access time has not been updated after accessing file3 second time ERROR: access time has not been updated after accessing file3 third time Silence is golden The generic/003 test-case needs to be disabled for HFS case because it cannot support the file/folder access times (atime). Closes: hfs-linux-kernel#3 cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> cc: Yangtao Li <frank.li@vivo.com> cc: linux-fsdevel@vger.kernel.org Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com> Link: https://lore.kernel.org/r/20260514195630.354206-2-slava@dubeyko.com Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
1 parent 6592287 commit f14ccd7

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

fs/hfs/dir.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,15 @@ static int hfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
306306
res = hfs_cat_move(d_inode(old_dentry)->i_ino,
307307
old_dir, &old_dentry->d_name,
308308
new_dir, &new_dentry->d_name);
309-
if (!res)
309+
if (!res) {
310+
struct inode *inode = d_inode(old_dentry);
311+
310312
hfs_cat_build_key(old_dir->i_sb,
311-
(btree_key *)&HFS_I(d_inode(old_dentry))->cat_key,
313+
(btree_key *)&HFS_I(inode)->cat_key,
312314
new_dir->i_ino, &new_dentry->d_name);
315+
inode_set_ctime_current(inode);
316+
mark_inode_dirty(inode);
317+
}
313318
return res;
314319
}
315320

fs/hfs/inode.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ static int hfs_read_inode(struct inode *inode, void *data)
348348
struct hfs_iget_data *idata = data;
349349
struct hfs_sb_info *hsb = HFS_SB(inode->i_sb);
350350
hfs_cat_rec *rec;
351+
struct timespec64 mtime;
351352

352353
HFS_I(inode)->flags = 0;
353354
HFS_I(inode)->rsrc_inode = NULL;
@@ -383,8 +384,10 @@ static int hfs_read_inode(struct inode *inode, void *data)
383384
inode->i_mode |= S_IWUGO;
384385
inode->i_mode &= ~hsb->s_file_umask;
385386
inode->i_mode |= S_IFREG;
386-
inode_set_mtime_to_ts(inode,
387-
inode_set_atime_to_ts(inode, inode_set_ctime_to_ts(inode, hfs_m_to_utime(rec->file.MdDat))));
387+
mtime = hfs_m_to_utime(rec->file.MdDat);
388+
inode_set_ctime_to_ts(inode, mtime);
389+
inode_set_atime_to_ts(inode, mtime);
390+
inode_set_mtime_to_ts(inode, mtime);
388391
inode->i_op = &hfs_file_inode_operations;
389392
inode->i_fop = &hfs_file_operations;
390393
inode->i_mapping->a_ops = &hfs_aops;
@@ -394,8 +397,10 @@ static int hfs_read_inode(struct inode *inode, void *data)
394397
inode->i_size = be16_to_cpu(rec->dir.Val) + 2;
395398
HFS_I(inode)->fs_blocks = 0;
396399
inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask);
397-
inode_set_mtime_to_ts(inode,
398-
inode_set_atime_to_ts(inode, inode_set_ctime_to_ts(inode, hfs_m_to_utime(rec->dir.MdDat))));
400+
mtime = hfs_m_to_utime(rec->dir.MdDat);
401+
inode_set_ctime_to_ts(inode, mtime);
402+
inode_set_atime_to_ts(inode, mtime);
403+
inode_set_mtime_to_ts(inode, mtime);
399404
inode->i_op = &hfs_dir_inode_operations;
400405
inode->i_fop = &hfs_dir_operations;
401406
break;
@@ -665,7 +670,7 @@ int hfs_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
665670

666671
truncate_setsize(inode, attr->ia_size);
667672
hfs_file_truncate(inode);
668-
simple_inode_init_ts(inode);
673+
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
669674
}
670675

671676
setattr_copy(&nop_mnt_idmap, inode, attr);

fs/hfs/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static int hfs_fill_super(struct super_block *sb, struct fs_context *fc)
338338
sbi->sb = sb;
339339
sb->s_op = &hfs_super_operations;
340340
sb->s_xattr = hfs_xattr_handlers;
341-
sb->s_flags |= SB_NODIRATIME;
341+
sb->s_flags |= SB_NOATIME | SB_NODIRATIME;
342342
mutex_init(&sbi->bitmap_lock);
343343

344344
res = hfs_mdb_get(sb);

0 commit comments

Comments
 (0)