Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Apr 2001 20:58:10 +0700 (ALMST)
From:      Boris Popov <bp@butya.kz>
To:        freebsd-fs@freebsd.org
Subject:   An unlock VOP_CLOSE()
Message-ID:  <Pine.BSF.4.21.0104152045070.38342-200000@lion.butya.kz>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
	Hello,

	While working on various filesystems I've noticed that VOP_CLOSE()
vnode operation invoked on the non-locked vnode, and sometimes on the
locked (from vclean() notably). This may not cause any problems for local
fs'es like ufs and its family, but makes consistency problems for network
filesystems which may flush data and issue network calls inside of the
VOP_CLOSE operation.

	Of course, it is possible to create an additional lock in the
specific filesystem and track it across all VOPs, but probably use of
just VOP_LOCK()/VOP_UNLOCK() pair would be sufficient.

	Attached there is a patch which does this in the above way.

	Comments, suggestions ?

P.S. sometime read/write lock should be separated from the rest of
locks...
-- 
Boris Popov
http://www.butya.kz/~bp/

[-- Attachment #2 --]
Index: vnode_if.src
===================================================================
RCS file: /home/ncvs/src/sys/kern/vnode_if.src,v
retrieving revision 1.39
diff -u -r1.39 vnode_if.src
--- vnode_if.src	2001/03/19 05:44:14	1.39
+++ vnode_if.src	2001/04/15 12:53:37
@@ -130,7 +130,7 @@
 };
 
 #
-#% close	vp	U U U
+#% close	vp	L L L
 #
 vop_close {
 	IN struct vnode *vp;
Index: vfs_vnops.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/vfs_vnops.c,v
retrieving revision 1.113
diff -u -r1.113 vfs_vnops.c
--- vfs_vnops.c	2001/03/26 12:45:35	1.113
+++ vfs_vnops.c	2001/04/15 13:01:01
@@ -230,10 +230,11 @@
 {
 	int error;
 
+	vn_lock(vp, LK_EXCLUSIVE | LK_NOPAUSE | LK_RETRY, p);
 	if (flags & FWRITE)
 		vp->v_writecount--;
 	error = VOP_CLOSE(vp, flags, cred, p);
-	vrele(vp);
+	vput(vp);
 	return (error);
 }
 

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0104152045070.38342-200000>