Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/tmpfs convert to use it nanotime, but don't call it u...



details:   https://anonhg.NetBSD.org/src/rev/d6f5c1a9e9c7
branches:  trunk
changeset: 584295:d6f5c1a9e9c7
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Sep 12 16:55:01 2005 +0000

description:
convert to use it nanotime, but don't call it unless it is necessary.

diffstat:

 sys/fs/tmpfs/tmpfs_subr.c  |   8 +++-----
 sys/fs/tmpfs/tmpfs_vnops.c |  38 ++++++++++++++++++++------------------
 2 files changed, 23 insertions(+), 23 deletions(-)

diffs (104 lines):

diff -r 0ccd8cdc512c -r d6f5c1a9e9c7 sys/fs/tmpfs/tmpfs_subr.c
--- a/sys/fs/tmpfs/tmpfs_subr.c Mon Sep 12 16:54:35 2005 +0000
+++ b/sys/fs/tmpfs/tmpfs_subr.c Mon Sep 12 16:55:01 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_subr.c,v 1.2 2005/09/10 22:28:57 jmmv Exp $      */
+/*     $NetBSD: tmpfs_subr.c,v 1.3 2005/09/12 16:55:01 christos Exp $  */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.2 2005/09/10 22:28:57 jmmv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.3 2005/09/12 16:55:01 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -70,7 +70,6 @@
     uid_t uid, gid_t gid, mode_t mode, struct tmpfs_node *parent,
     char *target, dev_t rdev, struct proc *p, struct tmpfs_node **node)
 {
-       struct timeval tv;
        struct tmpfs_node *nnode;
 
        /* If the root directory of the 'tmp' file system is not yet
@@ -108,8 +107,7 @@
        nnode->tn_status = 0;
        nnode->tn_flags = 0;
        nnode->tn_links = 0;
-       microtime(&tv);
-       TIMEVAL_TO_TIMESPEC(&tv, &nnode->tn_atime);
+       (void)nanotime(&nnode->tn_atime);
        nnode->tn_birthtime = nnode->tn_ctime = nnode->tn_mtime =
            nnode->tn_atime;
        nnode->tn_uid = uid;
diff -r 0ccd8cdc512c -r d6f5c1a9e9c7 sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c        Mon Sep 12 16:54:35 2005 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c        Mon Sep 12 16:55:01 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_vnops.c,v 1.2 2005/09/10 22:28:57 jmmv Exp $     */
+/*     $NetBSD: tmpfs_vnops.c,v 1.3 2005/09/12 16:55:01 christos Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.2 2005/09/10 22:28:57 jmmv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.3 2005/09/12 16:55:01 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -1354,12 +1354,11 @@
 tmpfs_update(void *v)
 {
        struct vnode *vp = ((struct vop_update_args *)v)->a_vp;
-       struct timespec *access = ((struct vop_update_args *)v)->a_access;
-       struct timespec *modify = ((struct vop_update_args *)v)->a_modify;
+       struct timespec *acc = ((struct vop_update_args *)v)->a_access;
+       struct timespec *mod = ((struct vop_update_args *)v)->a_modify;
        int flags = ((struct vop_update_args *)v)->a_flags;
 
-       struct timespec ts;
-       struct timeval tv;
+       struct timespec *ts = NULL, tsb;
        struct tmpfs_node *node;
 
        KASSERT(VOP_ISLOCKED(vp));
@@ -1370,18 +1369,21 @@
                ; /* XXX Need to do anything special? */
 
        if (node->tn_status != 0) {
-               microtime(&tv);
-               TIMEVAL_TO_TIMESPEC(&tv, &ts);
-
-               if (node->tn_status & TMPFS_NODE_ACCESSED)
-                       node->tn_atime =
-                           (access != NULL ? *access : ts);
-               if (node->tn_status & TMPFS_NODE_MODIFIED)
-                       node->tn_mtime =
-                           (modify != NULL ? *modify : ts);
-               if (node->tn_status & TMPFS_NODE_CHANGED)
-                       node->tn_ctime = ts;
-
+               if (node->tn_status & TMPFS_NODE_ACCESSED) {
+                       if (acc == NULL)
+                               acc = ts == NULL ? (ts = nanotime(&tsb)) : ts;
+                       node->tn_atime = *acc;
+               }
+               if (node->tn_status & TMPFS_NODE_MODIFIED) {
+                       if (mod == NULL)
+                               mod = ts == NULL ? (ts = nanotime(&tsb)) : ts;
+                       node->tn_mtime = *mod;
+               }
+               if (node->tn_status & TMPFS_NODE_CHANGED) {
+                       if (ts == NULL)
+                               ts = nanotime(&tsb);
+                       node->tn_ctime = *ts;
+               }
                node->tn_status &=
                    ~(TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED |
                    TMPFS_NODE_CHANGED);



Home | Main Index | Thread Index | Old Index