From d4d1ad6628e89c32a56dd437daeea2cd3a84dd6a Mon Sep 17 00:00:00 2001 From: kib Date: Thu, 26 Jan 2017 10:15:41 +0000 Subject: MFC r311531 (by mjg): Perform a lockless check in tmpfs_itimes. --- sys/fs/tmpfs/tmpfs_subr.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index f1bf51c..ce54e7d 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -1743,19 +1743,22 @@ tmpfs_set_status(struct tmpfs_node *node, int status) } /* Sync timestamps */ -static void -tmpfs_itimes_locked(struct tmpfs_node *node, const struct timespec *acc, +void +tmpfs_itimes(struct vnode *vp, const struct timespec *acc, const struct timespec *mod) { + struct tmpfs_node *node; struct timespec now; - TMPFS_ASSERT_LOCKED(node); + ASSERT_VOP_LOCKED(vp, "tmpfs_itimes"); + node = VP_TO_TMPFS_NODE(vp); if ((node->tn_status & (TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED)) == 0) return; vfs_timestamp(&now); + TMPFS_NODE_LOCK(node); if (node->tn_status & TMPFS_NODE_ACCESSED) { if (acc == NULL) acc = &now; @@ -1770,19 +1773,6 @@ tmpfs_itimes_locked(struct tmpfs_node *node, const struct timespec *acc, node->tn_ctime = now; node->tn_status &= ~(TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED); -} - -void -tmpfs_itimes(struct vnode *vp, const struct timespec *acc, - const struct timespec *mod) -{ - struct tmpfs_node *node; - - ASSERT_VOP_LOCKED(vp, "tmpfs_itimes"); - node = VP_TO_TMPFS_NODE(vp); - - TMPFS_NODE_LOCK(node); - tmpfs_itimes_locked(node, acc, mod); TMPFS_NODE_UNLOCK(node); /* XXX: FIX? The entropy here is desirable, but the harvesting may be expensive */ -- cgit v1.1