Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 07 Oct 2001 21:52:52 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        =?iso-8859-1?Q?=C0=D3=C0=E7=B4=F6?= <jdscol92@hanmail.net>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: about vnode operations...
Message-ID:  <3BC13124.5655F3D7@mindspring.com>
References:  <20011008112943.HM.E0000000002RpGO@www15.hanmail.net>

next in thread | previous in thread | raw e-mail | index | archive | help
=C0=D3=C0=E7=B4=F6 wrote:
> =

> Hello, everyone..
> I have some questions with tracing the kernel source code about
> file system in FreeBSD 4.3.

OK.

> I read book, 'The Design and Inplementation of the 4.4BSD Operation
> System', but I can't underatand them.

The book is not entirely accurate, with regards to FreeBSD;
there is another book rumored to be in the works that is
specifically geared to FreeBSD.


> Please tell me the fellowing questions.
> =

> There are many operations starting with vn_*** and VOP_***.
> I don't know the the main difference between the two.
> What is the main difference between the two.

VOP operations are descriptor based argument list functions
which are generic, and are epxted to be implemented by each
VFS top operate on files within the file system.

The vn operations are implementations above the VFS layer,
but below the system call layer, for common operations at
the system call layer.  They can also be abused to do file
I/O within the kernel, if they are used exactly right.  A
better interface for this would pass a UIO_USRSPACE or a
UIO_SYSSPACE argument, and the code woul Just Work(tm) in
the kernel.

Reading the source code would probably be helpful for you.

In general, the VOP operations are not called until a file
system is mounted (via VFS operations).

If you consider this from the file descriptor perspective,
the VOP operations are those which are called as a result
of the struct fileops in a file descriptor pointing to the
vfsops version of the structure.


> And if i want to add new operations in the exist file system
> as a vnode operations, What can i do for it?

You define the operations in the vnode_if.src in /sys/kern,
and the vnode_if.c and vnode_if.h are created when you do
the kernel compilation.

In general, you will need to supply new system calls to call
the new VOP's to actually implement calls to your new code,
within a VFS.


> How are the vnode operations created and worked when system
> is started..??

You can't do this after the system is started.  The problem
is that the descriptor structure used for the lookups is
created at kernel compilation time, and can not be recreated;
there are three barries to adding new VOPs to the list of
allowable VOPs for all VFSs:

1)	The already instanced VFSs will not have these VOPs
	in their table, and the defaultops which things fall
	through to will cause this to break if you call the
	system call that calls the new VOP on an FS that was
	instanced before the VFS con taining the new VOP was
	loaded.

	The way to fix this is to refactor the VFS VOP vectors
	each time a new VOP is added to the system.  For this
	to work, the VOP vector list _must_ be sorted.  If it
	is sorted, you get the advantage of being able to use
	a direct index at instancing time, so that the reverse
	lookup for the vector is avoided.  This can also improve
	VFS interface speed significantly, so it's worthwhile to
	do in its own right.

2)	The new VOPs will not be in the global descriptor
	table from the vnode_if.c.

	The way to fix this is to change references to this to
	a pointer, allocate the data at runtime, and then do a
	reallocation each time a new VOP comes along.

3)	Collisions.  If you add VOPs by index, you rin the risk
	of using the same index as another VOP added by another
	VFS.

	The fix for this is to add a third field, a string name,
	and to use the string name to add the operation.  You
	will still run the (lesser) risk of having a namespace
	collision (e.g. if two FS's want to add an "abort", and
	each "abort" has differing semantics), but the alternative
	is a seperate system call per VFS per new VOP.

> I found 'vnode_if.src' file in /sys/kern/ directory.
> I think that this file is played a some role in vnode operations.
> Right..??

Yes.

> Please teach me above questions...

If you could tell us *why* you wanted to know, we could probably
give you more domain specific answers, which would cut the number
and generality of the questions you will have to ask to get your
code working.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-fs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3BC13124.5655F3D7>