svn commit: r218949 - head/sys/fs/tmpfs

Alan Cox alc at FreeBSD.org
Tue Feb 22 14:47:11 UTC 2011


Author: alc
Date: Tue Feb 22 14:47:10 2011
New Revision: 218949
URL: http://svn.freebsd.org/changeset/base/218949

Log:
  Eliminate two dubious attempts at optimizing the implementation of a
  file's last accessed, modified, and changed times:
  
  TMPFS_NODE_ACCESSED and TMPFS_NODE_CHANGED should be set unconditionally
  in tmpfs_remove() without regard to the number of hard links to the file.
  Otherwise, after the last directory entry for a file has been removed, a
  process that still has the file open could read stale values for the last
  accessed and changed times with fstat(2).
  
  Similarly, tmpfs_close() should update the time-related fields even if all
  directory entries for a file have been removed.  In this case, the effect
  is that the time-related fields will have values that are later than
  expected.  They will correspond to the time at which fstat(2) is called.
  
  In collaboration with:	kib
  MFC after:	1 week

Modified:
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Feb 22 14:02:00 2011	(r218948)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Feb 22 14:47:10 2011	(r218949)
@@ -270,19 +270,12 @@ tmpfs_close(struct vop_close_args *v)
 {
 	struct vnode *vp = v->a_vp;
 
-	struct tmpfs_node *node;
-
 	MPASS(VOP_ISLOCKED(vp));
 
-	node = VP_TO_TMPFS_NODE(vp);
-
-	if (node->tn_links > 0) {
-		/* Update node times.  No need to do it if the node has
-		 * been deleted, because it will vanish after we return. */
-		tmpfs_update(vp);
-	}
+	/* Update node times. */
+	tmpfs_update(vp);
 
-	return 0;
+	return (0);
 }
 
 /* --------------------------------------------------------------------- */
@@ -852,8 +845,7 @@ tmpfs_remove(struct vop_remove_args *v)
 	 * reclaimed. */
 	tmpfs_free_dirent(tmp, de, TRUE);
 
-	if (node->tn_links > 0)
-		node->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED;
+	node->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED;
 	error = 0;
 
 out:


More information about the svn-src-head mailing list