From nobody@FreeBSD.org  Wed Oct 14 11:12:00 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 71BD4106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Oct 2009 11:12:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id F21C58FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Oct 2009 11:11:59 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n9EBBx4L045696
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 14 Oct 2009 11:11:59 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n9EBBxAH045695;
	Wed, 14 Oct 2009 11:11:59 GMT
	(envelope-from nobody)
Message-Id: <200910141111.n9EBBxAH045695@www.freebsd.org>
Date: Wed, 14 Oct 2009 11:11:59 GMT
From: Gleb Kurtsou <gk@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] [tmpfs] tmpfs initializes va_gen but doesn't update it on vnode change
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         139597
>Category:       kern
>Synopsis:       [patch] [tmpfs] tmpfs initializes va_gen but doesn't update it on vnode change
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-fs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 14 11:20:01 UTC 2009
>Closed-Date:    Sun May 20 13:27:58 UTC 2012
>Last-Modified:  Sun May 20 13:27:58 UTC 2012
>Originator:     Gleb Kurtsou
>Release:        
>Organization:
>Environment:
FreeBSD tops 9.0-CURRENT FreeBSD 9.0-CURRENT #10 r198029+5e4f6c4: Tue Oct 13 20:24:19 EEST 2009     root@tops:/usr/obj/usr/freebsd-src/local/sys/TOPS  amd64
>Description:
tmpfs initializes tn_gen (generation number) on node creation, but fails to update it on vnode change.
other filesystems set va_gen=0 or update it on changes (ufs, zfs)
>How-To-Repeat:
mount pefs or nfs (not tested) on top of tmpfs
>Fix:


Patch attached with submission follows:

diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 8dc8338..3df61f8 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1252,6 +1252,10 @@ tmpfs_itimes(struct vnode *vp, const struct timespec *acc,
 	if (node->tn_status & TMPFS_NODE_CHANGED) {
 		node->tn_ctime = now;
 	}
+	if (node->tn_status & (TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED)) {
+		if (++node->tn_gen == 0)
+			node->tn_gen = arc4random() / 2 + 1;
+	}
 	node->tn_status &=
 	    ~(TMPFS_NODE_ACCESSED | TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED);
 }


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Oct 14 20:10:47 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139597 
>Unformatted:
