Module Name:    src
Committed By:   hannken
Date:           Mon Apr  6 08:38:25 UTC 2015

Modified Files:
        src/sys/fs/udf: udf_vnops.c

Log Message:
Move the removal of unlinked nodes from udf_inactive() to udf_reclaim().


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/fs/udf/udf_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/udf/udf_vnops.c
diff -u src/sys/fs/udf/udf_vnops.c:1.98 src/sys/fs/udf/udf_vnops.c:1.99
--- src/sys/fs/udf/udf_vnops.c:1.98	Sat Apr  4 12:34:45 2015
+++ src/sys/fs/udf/udf_vnops.c	Mon Apr  6 08:38:25 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.98 2015/04/04 12:34:45 riastradh Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.99 2015/04/06 08:38:25 hannken Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.98 2015/04/04 12:34:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.99 2015/04/06 08:38:25 hannken Exp $");
 #endif /* not lint */
 
 
@@ -97,9 +97,7 @@ udf_inactive(void *v)
 	}
 
 	/*
-	 * Optionally flush metadata to disc. If the file has not been
-	 * referenced anymore in a directory we ought to free up the resources
-	 * on disc if applicable.
+	 * Optionally flush metadata to disc.
 	 */
 	if (udf_node->fe) {
 		refcnt = udf_rw16(udf_node->fe->link_cnt);
@@ -116,10 +114,7 @@ udf_inactive(void *v)
 
 	*ap->a_recycle = false;
 	if ((refcnt == 0) && ((vp->v_vflag & VV_SYSTEM) == 0)) {
-	 	/* remove this file's allocation */
-		DPRINTF(NODE, ("udf_inactive deleting unlinked file\n"));
 		*ap->a_recycle = true;
-		udf_delete_node(udf_node);
 		VOP_UNLOCK(vp);
 		return 0;
 	}
@@ -144,6 +139,7 @@ udf_reclaim(void *v)
 	} */ *ap = v;
 	struct vnode *vp = ap->a_vp;
 	struct udf_node *udf_node = VTOI(vp);
+	int refcnt;
 
 	DPRINTF(NODE, ("udf_reclaim called for node %p\n", udf_node));
 	if (prtactive && vp->v_usecount > 1)
@@ -154,6 +150,23 @@ udf_reclaim(void *v)
 		return 0;
 	}
 
+	/*
+	 * If the file has not been referenced anymore in a directory
+	 * we ought to free up the resources on disc if applicable.
+	 */
+	if (udf_node->fe) {
+		refcnt = udf_rw16(udf_node->fe->link_cnt);
+	} else {
+		assert(udf_node->efe);
+		refcnt = udf_rw16(udf_node->efe->link_cnt);
+	}
+
+	if ((refcnt == 0) && ((vp->v_vflag & VV_SYSTEM) == 0)) {
+	 	/* remove this file's allocation */
+		DPRINTF(NODE, ("udf_inactive deleting unlinked file\n"));
+		udf_delete_node(udf_node);
+	}
+
 	/* update note for closure */
 	udf_update(vp, NULL, NULL, NULL, UPDATE_CLOSE);
 

Reply via email to