Subject: Re: kern/25279: NFS read doesn't update atime
To: None <tech-kern@NetBSD.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 06/26/2005 21:08:19
--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Thu, Jun 23, 2005 at 12:23:29PM +0200, Manuel Bouyer wrote:
> Hi,
> quoting kern/25279:
> nfsd doesn't update atime of the file for READ RPCs
> because recently nfsd uses VOP_GETPAGES to serve them.
>
> This is hightly annoying in some environnement, and because of this
> I'm stuck with 1.6.x on my production NFS servers.
> It looks like it shoudln't be too hard to make VOP_GETPAGES update the
> atime at last for UFS-like filesystems (FFS and LFS already have their
> own getpage vnode operation, I can easily add one for ext2fs), but is it
> the right way to go ? would updating the atime from getpage have
> bad side effects, or break a traditionnal behavior ?
Here is a patch that makes VOP_GETPAGES update atime for UFS-like filesystems.
This fixes the mailbox issue for me.
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.getpage"
Index: ext2fs/ext2fs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_vnops.c,v
retrieving revision 1.59
diff -u -r1.59 ext2fs_vnops.c
--- ext2fs/ext2fs_vnops.c 26 Feb 2005 22:32:20 -0000 1.59
+++ ext2fs/ext2fs_vnops.c 26 Jun 2005 18:27:39 -0000
@@ -106,6 +106,7 @@
__P((struct vnode *, int, struct ucred *, struct proc *));
static int ext2fs_chown
__P((struct vnode *, uid_t, gid_t, struct ucred *, struct proc *));
+static int ext2fs_getpages __P((void *));
union _qcvt {
int64_t qcvt;
@@ -1475,6 +1476,27 @@
return (0);
}
+static int
+ext2fs_getpages(void *v)
+{
+ struct vop_getpages_args /* {
+ struct vnode *a_vp;
+ voff_t a_offset;
+ struct vm_page **a_m;
+ int *a_count;
+ int a_centeridx;
+ vm_prot_t a_access_type;
+ int a_advice;
+ int a_flags;
+ } */ *ap = v;
+ struct vnode *vp = ap->a_vp;
+ struct inode *ip = VTOI(vp);
+
+ if (!(vp->v_mount->mnt_flag & MNT_NOATIME))
+ ip->i_flag |= IN_ACCESS;
+ return genfs_getpages(v);
+}
+
/* Global vfs data structures for ext2fs. */
int (**ext2fs_vnodeop_p) __P((void *));
const struct vnodeopv_entry_desc ext2fs_vnodeop_entries[] = {
@@ -1523,7 +1545,7 @@
{ &vop_truncate_desc, ext2fs_truncate }, /* truncate */
{ &vop_update_desc, ext2fs_update }, /* update */
{ &vop_bwrite_desc, vn_bwrite }, /* bwrite */
- { &vop_getpages_desc, genfs_getpages }, /* getpages */
+ { &vop_getpages_desc, ext2fs_getpages }, /* getpages */
{ &vop_putpages_desc, genfs_putpages }, /* putpages */
{ NULL, NULL }
};
Index: ffs/ffs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/ffs/ffs_vnops.c,v
retrieving revision 1.69
diff -u -r1.69 ffs_vnops.c
--- ffs/ffs_vnops.c 26 Feb 2005 22:32:20 -0000 1.69
+++ ffs/ffs_vnops.c 26 Jun 2005 18:27:39 -0000
@@ -535,6 +535,8 @@
}
return EINVAL;
}
+ if (!(vp->v_mount->mnt_flag & MNT_NOATIME))
+ ip->i_flag |= IN_ACCESS;
return genfs_getpages(v);
}
Index: lfs/lfs_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/ufs/lfs/lfs_vnops.c,v
retrieving revision 1.152
diff -u -r1.152 lfs_vnops.c
--- lfs/lfs_vnops.c 29 May 2005 21:25:24 -0000 1.152
+++ lfs/lfs_vnops.c 26 Jun 2005 18:27:39 -0000
@@ -1424,6 +1424,8 @@
if ((ap->a_access_type & VM_PROT_WRITE) != 0) {
LFS_SET_UINO(VTOI(ap->a_vp), IN_MODIFIED);
}
+ if (!(ap->a_vp->v_mount->mnt_flag & MNT_NOATIME))
+ VTOI(ap->a_vp)->i_flag |= IN_ACCESS;
/*
* we're relying on the fact that genfs_getpages() always read in
--UlVJffcvxoiEqYs2--