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
This commit is contained in:
parent
addc19a4f4
commit
4d2f3d2cde
@ -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);
|
||||
/* Update node times. */
|
||||
tmpfs_update(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);
|
||||
}
|
||||
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user