The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8177936ac293210251390e44d109ece0f3868df9
commit 8177936ac293210251390e44d109ece0f3868df9 Author: Konstantin Belousov <[email protected]> AuthorDate: 2026-06-19 19:52:45 +0000 Commit: Konstantin Belousov <[email protected]> CommitDate: 2026-06-23 22:11:55 +0000 vfs: rename vop_mmapped() to vop_update_atime() This reflects the actual functionality of the VOP. While there, add the explicit struct timespec argument for the VOP allowing the caller to set specific atime, not just request an update for it. Requested by: rmacklem Reviewed by: rmacklem Discussed with: jah Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D57681 --- sys/kern/kern_exec.c | 2 +- sys/kern/vnode_if.src | 3 ++- sys/ufs/ffs/ffs_inode.c | 2 +- sys/ufs/ffs/ffs_softdep.c | 2 +- sys/ufs/ufs/ufs_extern.h | 2 +- sys/ufs/ufs/ufs_vnops.c | 42 ++++++++++++++++++++++++++++-------------- sys/vm/vm_mmap.c | 2 +- 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index f19c62cd16e3..b6f2848f800c 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1036,7 +1036,7 @@ interpret: /* Set values passed into the program in registers. */ (*p->p_sysent->sv_setregs)(td, imgp, stack_base); - VOP_MMAPPED(imgp->vp); + VOP_UPDATE_ATIME(imgp->vp, NULL); SDT_PROBE1(proc, , , exec__success, args->fname); diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 78ba1aa7afda..d20ff39b314e 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -214,8 +214,9 @@ vop_setattr { %% mmapped vp L L L -vop_mmapped { +vop_update_atime { IN struct vnode *vp; + IN struct timespec *ts; }; diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index f47cfd08f75a..3b2e7846b085 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -100,7 +100,7 @@ ffs_update(struct vnode *vp, int waitfor) int flags, error; ASSERT_VOP_ELOCKED(vp, "ffs_update"); - ufs_itimes(vp); + ufs_itimes(vp, NULL); ip = VTOI(vp); if ((ip->i_flag & IN_MODIFIED) == 0 && waitfor == 0) return (0); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 297c8257bd22..00df2cd920d3 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -6896,7 +6896,7 @@ softdep_journal_freeblocks( * from reaching the disk while we are eliminating those that * have been truncated. This is a partially inlined ffs_update(). */ - ufs_itimes(vp); + ufs_itimes(vp, NULL); ip->i_flag &= ~(IN_LAZYACCESS | IN_LAZYMOD | IN_MODIFIED); dbn = fsbtodb(fs, ino_to_fsba(fs, ip->i_number)); error = ffs_breadz(ump, ump->um_devvp, dbn, dbn, (int)fs->fs_bsize, diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index 111fb1cb40b3..7b9215654e03 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -73,7 +73,7 @@ int ufs_lookup_ino(struct vnode *, struct vnode **, struct componentname *, int ufs_getlbns(struct vnode *, ufs2_daddr_t, struct indir *, int *); int ufs_inactive(struct vop_inactive_args *); int ufs_init(struct vfsconf *); -void ufs_itimes(struct vnode *vp); +void ufs_itimes(struct vnode *vp, struct timespec *tsa); int ufs_lookup(struct vop_cachedlookup_args *); int ufs_need_inactive(struct vop_need_inactive_args *); int ufs_readdir(struct vop_readdir_args *); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 4abbd4ee807f..1d04e1b2785f 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -111,7 +111,7 @@ static vop_ioctl_t ufs_ioctl; static vop_link_t ufs_link; static int ufs_makeinode(int mode, struct vnode *, struct vnode **, struct componentname *, const char *); -static vop_mmapped_t ufs_mmapped; +static vop_update_atime_t ufs_update_atime; static vop_mkdir_t ufs_mkdir; static vop_mknod_t ufs_mknod; static vop_open_t ufs_open; @@ -143,7 +143,7 @@ static struct odirtemplate omastertemplate = { }; static void -ufs_itimes_locked(struct vnode *vp) +ufs_itimes_locked(struct vnode *vp, struct timespec *tsa) { struct inode *ip; struct timespec ts; @@ -166,8 +166,13 @@ ufs_itimes_locked(struct vnode *vp) UFS_INODE_SET_FLAG(ip, IN_LAZYACCESS); vfs_timestamp(&ts); if ((ip->i_flag & IN_ACCESS) != 0) { - DIP_SET(ip, i_atime, ts.tv_sec); - DIP_SET(ip, i_atimensec, ts.tv_nsec); + if (tsa != NULL) { + DIP_SET(ip, i_atime, tsa->tv_sec); + DIP_SET(ip, i_atimensec, tsa->tv_nsec); + } else { + DIP_SET(ip, i_atime, ts.tv_sec); + DIP_SET(ip, i_atimensec, ts.tv_nsec); + } } if ((ip->i_flag & IN_UPDATE) != 0) { DIP_SET(ip, i_mtime, ts.tv_sec); @@ -184,7 +189,7 @@ out: } void -ufs_itimes(struct vnode *vp) +ufs_itimes(struct vnode *vp, struct timespec *tsa) { struct inode *ip; @@ -193,7 +198,7 @@ ufs_itimes(struct vnode *vp) return; VI_LOCK(vp); - ufs_itimes_locked(vp); + ufs_itimes_locked(vp, tsa); VI_UNLOCK(vp); } @@ -356,7 +361,7 @@ ufs_close( { struct vnode *vp = ap->a_vp; - ufs_itimes(vp); + ufs_itimes(vp, NULL); return (0); } @@ -523,7 +528,7 @@ ufs_stat(struct vop_stat_args *ap) return (error); VI_LOCK(vp); - ufs_itimes_locked(vp); + ufs_itimes_locked(vp, NULL); if (I_IS_UFS1(ip)) { sb->st_atim.tv_sec = ip->i_din1->di_atime; sb->st_atim.tv_nsec = ip->i_din1->di_atimensec; @@ -584,7 +589,7 @@ ufs_getattr( struct vattr *vap = ap->a_vap; VI_LOCK(vp); - ufs_itimes_locked(vp); + ufs_itimes_locked(vp, NULL); if (I_IS_UFS1(ip)) { vap->va_atime.tv_sec = ip->i_din1->di_atime; vap->va_atime.tv_nsec = ip->i_din1->di_atimensec; @@ -829,9 +834,10 @@ out: #endif /* UFS_ACL */ static int -ufs_mmapped( - struct vop_mmapped_args /* { +ufs_update_atime( + struct vop_update_atime_args /* { struct vnode *a_vp; + struct timespec *a_ts; } */ *ap) { struct vnode *vp; @@ -842,8 +848,16 @@ ufs_mmapped( ip = VTOI(vp); mp = vp->v_mount; - if ((mp->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0) - UFS_INODE_SET_FLAG_SHARED(ip, IN_ACCESS); + if ((mp->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0) { + VI_LOCK(vp); + if ((ip->i_flag & IN_ACCESS) == 0) { + ip->i_flag |= IN_ACCESS; + vlazy(vp); + } + if (ap->a_ts != NULL) + ufs_itimes_locked(vp, ap->a_ts); + VI_UNLOCK(vp); + } /* * XXXKIB No UFS_UPDATE(ap->a_vp, 0) there. */ @@ -3006,7 +3020,7 @@ struct vop_vector ufs_vnodeops = { .vop_ioctl = ufs_ioctl, .vop_link = ufs_link, .vop_lookup = vfs_cache_lookup, - .vop_mmapped = ufs_mmapped, + .vop_update_atime = ufs_update_atime, .vop_mkdir = ufs_mkdir, .vop_mknod = ufs_mknod, .vop_need_inactive = ufs_need_inactive, diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 8d71bce67d58..6ddfa02bda9e 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -1391,7 +1391,7 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize, *objp = obj; *flagsp = flags; - VOP_MMAPPED(vp); + VOP_UPDATE_ATIME(vp, NULL); done: if (error != 0 && *writecounted) {
