From owner-freebsd-hackers Thu Dec 5 23:19:33 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4358137B401 for ; Thu, 5 Dec 2002 23:19:32 -0800 (PST) Received: from canning.wemm.org (canning.wemm.org [192.203.228.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5C4EA43E4A for ; Thu, 5 Dec 2002 23:19:24 -0800 (PST) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by canning.wemm.org (Postfix) with ESMTP id 3BC1D2A7EA; Thu, 5 Dec 2002 23:19:24 -0800 (PST) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: "kai ouyang" Cc: hackers@FreeBSD.org Subject: Re: One Filesystem vnode operations declare problem. In-Reply-To: Content-Transfer-Encoding: 8bit Date: Thu, 05 Dec 2002 23:19:24 -0800 From: Peter Wemm Message-Id: <20021206071924.3BC1D2A7EA@canning.wemm.org> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG "kai ouyang" wrote: > Hi, everybody, > I have some questions about FS vnode operations. > I found the filesystems always declare vnode operations by "VNODEOP_SET" > more than once. > For example: > In DEVFS: > VNODEOP_SET(devfs_vnodeop_opv_desc); > VNODEOP_SET(devfs_specop_opv_desc); > In FFS: > VNODEOP_SET(ffs_vnodeop_opv_desc); > VNODEOP_SET(ffs_specop_opv_desc); > VNODEOP_SET(ffs_fifoop_opv_desc); > Why? Why can not the kerenel use only "devfs_vnodeop_opv_desc" or > "ffs_vnodeop_opv_desc"? > Another words, I want to know the difference among those "VNODEOP_SET" in > one filesystem. The name of the macro is a little strange, that is more of a historical relic where we used to declare these things in something called a 'linker set'. These days it is handled by a SYSINIT() function that registers the vnode ops. Our vnode op system is fully dynamic. We can create new VOP_xxx() functions on the fly. But for this to work, they need to be registered and assigned an index number in the system vectors. The act of referencing a "foo" vector in the xxx_opv_desc table adds support for a VOP_FOO(). For example, suppose we have some remote file system loadable module that supports remote file copies. That filesystem could introduce VOP_COPYFILE() that would cause the file to be copied on the server, rather than the source file being read by the client and then copied back to the new file. We could then load another module that adds a copyfile(2) syscall that calls VOP_COPYFILE(). And because of the vnode stacking system and the VOP_DEFAULT() vectors, we could even mount union fs's over the top of this hypothetical file system, even though at the time that unionfs was compiled there was no VOP_COPYFILE operation to pass down the stack. Quite a while ago, the kernel used to have a static list of supported VOP_* calls. This has not been the case for quite some time now. Any file system can create any VOP_* that it likes. Cheers, -Peter -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message