From d11ea3ea8125ffb22ff77e6214da116f0454bf97 Mon Sep 17 00:00:00 2001 From: christos Date: Fri, 18 Nov 2011 21:18:50 +0000 Subject: [PATCH] Obey MNT_RELATIME, the only addition is that mkdir in ufs sets IN_ACCESS too. --- sys/fs/nilfs/nilfs_vnops.c | 6 ++++-- sys/fs/ptyfs/ptyfs_vnops.c | 9 ++++++--- sys/fs/puffs/puffs_vnops.c | 6 ++++-- sys/fs/tmpfs/tmpfs_vnops.c | 9 ++++++--- sys/fs/udf/udf_vnops.c | 17 ++++++++++++++--- sys/ufs/ext2fs/ext2fs_readwrite.c | 6 ++++-- sys/ufs/ext2fs/ext2fs_vnops.c | 11 ++++++++--- sys/ufs/ufs/ufs_readwrite.c | 6 ++++-- sys/ufs/ufs/ufs_vnops.c | 13 +++++++++---- 9 files changed, 59 insertions(+), 24 deletions(-) diff --git a/sys/fs/nilfs/nilfs_vnops.c b/sys/fs/nilfs/nilfs_vnops.c index 9aa4043e6ddc..84dc0cbe2298 100644 --- a/sys/fs/nilfs/nilfs_vnops.c +++ b/sys/fs/nilfs/nilfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: nilfs_vnops.c,v 1.15 2011/10/16 12:41:45 hannken Exp $ */ +/* $NetBSD: nilfs_vnops.c,v 1.16 2011/11/18 21:18:50 christos Exp $ */ /* * Copyright (c) 2008, 2009 Reinoud Zandijk @@ -28,7 +28,7 @@ #include #ifndef lint -__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.15 2011/10/16 12:41:45 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.16 2011/11/18 21:18:50 christos Exp $"); #endif /* not lint */ @@ -280,6 +280,8 @@ return EIO; /* mark node changed and request update */ nilfs_node->i_flags |= IN_CHANGE | IN_UPDATE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + nilfs_node->i_flags |= IN_ACCESS; /* * XXX TODO FFS has code here to reset setuid & setgid when we're not diff --git a/sys/fs/ptyfs/ptyfs_vnops.c b/sys/fs/ptyfs/ptyfs_vnops.c index 5664664e21c3..754fc377252c 100644 --- a/sys/fs/ptyfs/ptyfs_vnops.c +++ b/sys/fs/ptyfs/ptyfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ptyfs_vnops.c,v 1.36 2011/09/16 18:43:44 christos Exp $ */ +/* $NetBSD: ptyfs_vnops.c,v 1.37 2011/11/18 21:18:50 christos Exp $ */ /* * Copyright (c) 1993, 1995 @@ -76,7 +76,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.36 2011/09/16 18:43:44 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.37 2011/11/18 21:18:50 christos Exp $"); #include #include @@ -426,8 +426,11 @@ ptyfs_setattr(void *v) if (vap->va_atime.tv_sec != VNOVAL) if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) ptyfs->ptyfs_flag |= PTYFS_ACCESS; - if (vap->va_mtime.tv_sec != VNOVAL) + if (vap->va_mtime.tv_sec != VNOVAL) { ptyfs->ptyfs_flag |= PTYFS_CHANGE | PTYFS_MODIFY; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + ptyfs->ptyfs_flag |= PTYFS_ACCESS; + } if (vap->va_birthtime.tv_sec != VNOVAL) ptyfs->ptyfs_birthtime = vap->va_birthtime; ptyfs->ptyfs_flag |= PTYFS_CHANGE; diff --git a/sys/fs/puffs/puffs_vnops.c b/sys/fs/puffs/puffs_vnops.c index 721cd55b7f1e..d60a6c816c03 100644 --- a/sys/fs/puffs/puffs_vnops.c +++ b/sys/fs/puffs/puffs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.161 2011/10/30 13:24:13 hannken Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.162 2011/11/18 21:18:50 christos Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.161 2011/10/30 13:24:13 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.162 2011/11/18 21:18:50 christos Exp $"); #include #include @@ -1967,6 +1967,8 @@ puffs_vnop_write(void *v) origoff = uio->uio_offset; while (uio->uio_resid > 0) { + if (vp->v_mount->mnt_flag & MNT_RELATIME) + uflags |= PUFFS_UPDATEATIME; uflags |= PUFFS_UPDATECTIME; uflags |= PUFFS_UPDATEMTIME; oldoff = uio->uio_offset; diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 33851fb4bf05..97ef7ef8437c 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.92 2011/09/27 01:32:21 christos Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.93 2011/11/18 21:18:51 christos Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.92 2011/09/27 01:32:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.93 2011/11/18 21:18:51 christos Exp $"); #include #include @@ -2465,8 +2465,11 @@ tmpfs_getpages(void *v) if ((vp->v_mount->mnt_flag & MNT_NOATIME) == 0) node->tn_status |= TMPFS_NODE_ACCESSED; - if ((access_type & VM_PROT_WRITE) != 0) + if ((access_type & VM_PROT_WRITE) != 0) { node->tn_status |= TMPFS_NODE_MODIFIED; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + node->tn_status |= TMPFS_NODE_ACCESSED; + } } /* diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c index 36e87850612d..319b6890208f 100644 --- a/sys/fs/udf/udf_vnops.c +++ b/sys/fs/udf/udf_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: udf_vnops.c,v 1.68 2011/10/18 20:20:29 hannken Exp $ */ +/* $NetBSD: udf_vnops.c,v 1.69 2011/11/18 21:18:51 christos Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -32,7 +32,7 @@ #include #ifndef lint -__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.68 2011/10/18 20:20:29 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.69 2011/11/18 21:18:51 christos Exp $"); #endif /* not lint */ @@ -376,6 +376,8 @@ udf_write(void *v) /* mark node changed and request update */ udf_node->i_flags |= IN_CHANGE | IN_UPDATE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + udf_node->i_flags |= IN_ACCESS; /* * XXX TODO FFS has code here to reset setuid & setgid when we're not @@ -977,6 +979,8 @@ udf_chown(struct vnode *vp, uid_t new_uid, gid_t new_gid, /* mark node changed */ udf_node->i_flags |= IN_CHANGE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + udf_node->i_flags |= IN_ACCESS; return 0; } @@ -1013,6 +1017,8 @@ udf_chmod(struct vnode *vp, mode_t mode, kauth_cred_t cred) /* mark node changed */ udf_node->i_flags |= IN_CHANGE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + udf_node->i_flags |= IN_ACCESS; return 0; } @@ -1063,6 +1069,8 @@ udf_chsize(struct vnode *vp, u_quad_t newsize, kauth_cred_t cred) if (error == 0) { /* mark change */ udf_node->i_flags |= IN_CHANGE | IN_MODIFY; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + udf_node->i_flags |= IN_ACCESS; VN_KNOTE(vp, NOTE_ATTRIB | (extended ? NOTE_EXTEND : 0)); udf_update(vp, NULL, NULL, NULL, 0); } @@ -1116,8 +1124,11 @@ udf_chtimes(struct vnode *vp, if (atime->tv_sec != VNOVAL) if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) udf_node->i_flags |= IN_ACCESS; - if ((mtime->tv_sec != VNOVAL) || (birthtime->tv_sec != VNOVAL)) + if ((mtime->tv_sec != VNOVAL) || (birthtime->tv_sec != VNOVAL)) { udf_node->i_flags |= IN_CHANGE | IN_UPDATE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + udf_node->i_flags |= IN_ACCESS; + } return udf_update(vp, atime, mtime, birthtime, 0); } diff --git a/sys/ufs/ext2fs/ext2fs_readwrite.c b/sys/ufs/ext2fs/ext2fs_readwrite.c index 1e51fc87a9d6..0b6f8d617800 100644 --- a/sys/ufs/ext2fs/ext2fs_readwrite.c +++ b/sys/ufs/ext2fs/ext2fs_readwrite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_readwrite.c,v 1.57 2011/06/12 03:36:00 rmind Exp $ */ +/* $NetBSD: ext2fs_readwrite.c,v 1.58 2011/11/18 21:18:51 christos Exp $ */ /*- * Copyright (c) 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.57 2011/06/12 03:36:00 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.58 2011/11/18 21:18:51 christos Exp $"); #include #include @@ -374,6 +374,8 @@ ext2fs_write(void *v) out: ip->i_flag |= IN_CHANGE | IN_UPDATE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + ip->i_flag |= IN_ACCESS; if (resid > uio->uio_resid && ap->a_cred && kauth_authorize_generic(ap->a_cred, KAUTH_GENERIC_ISSUSER, NULL)) ip->i_e2fs_mode &= ~(ISUID | ISGID); diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c index 6042a6acea20..0ea5dd35ccbe 100644 --- a/sys/ufs/ext2fs/ext2fs_vnops.c +++ b/sys/ufs/ext2fs/ext2fs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vnops.c,v 1.100 2011/07/12 16:59:48 dholland Exp $ */ +/* $NetBSD: ext2fs_vnops.c,v 1.101 2011/11/18 21:18:51 christos Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.100 2011/07/12 16:59:48 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.101 2011/11/18 21:18:51 christos Exp $"); #include #include @@ -431,8 +431,11 @@ ext2fs_setattr(void *v) if (vap->va_atime.tv_sec != VNOVAL) if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) ip->i_flag |= IN_ACCESS; - if (vap->va_mtime.tv_sec != VNOVAL) + if (vap->va_mtime.tv_sec != VNOVAL) { ip->i_flag |= IN_CHANGE | IN_UPDATE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + ip->i_flag |= IN_ACCESS; + } error = ext2fs_update(vp, &vap->va_atime, &vap->va_mtime, UPDATE_WAIT); if (error) @@ -1282,6 +1285,8 @@ ext2fs_symlink(void *v) if (error) goto bad; ip->i_flag |= IN_CHANGE | IN_UPDATE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + ip->i_flag |= IN_ACCESS; uvm_vnp_setsize(vp, len); } else error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0, diff --git a/sys/ufs/ufs/ufs_readwrite.c b/sys/ufs/ufs/ufs_readwrite.c index 883f342ea655..4ab40c8c9a69 100644 --- a/sys/ufs/ufs/ufs_readwrite.c +++ b/sys/ufs/ufs/ufs_readwrite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_readwrite.c,v 1.99 2011/07/11 08:27:41 hannken Exp $ */ +/* $NetBSD: ufs_readwrite.c,v 1.100 2011/11/18 21:18:52 christos Exp $ */ /*- * Copyright (c) 1993 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.99 2011/07/11 08:27:41 hannken Exp $"); +__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.100 2011/11/18 21:18:52 christos Exp $"); #ifdef LFS_READWRITE #define FS struct lfs @@ -507,6 +507,8 @@ WRITE(void *v) */ out: ip->i_flag |= IN_CHANGE | IN_UPDATE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + ip->i_flag |= IN_ACCESS; if (resid > uio->uio_resid && ap->a_cred && kauth_authorize_generic(ap->a_cred, KAUTH_GENERIC_ISSUSER, NULL)) { ip->i_mode &= ~(ISUID | ISGID); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 359d5a0e0341..634f96694dd2 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.205 2011/09/27 02:10:32 christos Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.206 2011/11/18 21:18:52 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.205 2011/09/27 02:10:32 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.206 2011/11/18 21:18:52 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -638,8 +638,11 @@ ufs_setattr(void *v) if (vap->va_atime.tv_sec != VNOVAL) if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) ip->i_flag |= IN_ACCESS; - if (vap->va_mtime.tv_sec != VNOVAL) + if (vap->va_mtime.tv_sec != VNOVAL) { ip->i_flag |= IN_CHANGE | IN_UPDATE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + ip->i_flag |= IN_ACCESS; + } if (vap->va_birthtime.tv_sec != VNOVAL && ip->i_ump->um_fstype == UFS2) { ip->i_ffs2_birthtime = vap->va_birthtime.tv_sec; @@ -2092,7 +2095,7 @@ ufs_mkdir(void *v) goto bad; ip->i_size = dirblksiz; DIP_ASSIGN(ip, size, dirblksiz); - ip->i_flag |= IN_CHANGE | IN_UPDATE; + ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE; uvm_vnp_setsize(tvp, ip->i_size); memcpy((void *)bp->b_data, (void *)&dirtemplate, sizeof dirtemplate); @@ -2286,6 +2289,8 @@ ufs_symlink(void *v) DIP_ASSIGN(ip, size, len); uvm_vnp_setsize(vp, ip->i_size); ip->i_flag |= IN_CHANGE | IN_UPDATE; + if (vp->v_mount->mnt_flag & MNT_RELATIME) + ip->i_flag |= IN_ACCESS; UFS_WAPBL_UPDATE(vp, NULL, NULL, 0); } else error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,