Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Apr 1999 01:10:24 +0800
From:      Peter Wemm <peter@netplex.com.au>
To:        Zhihui Zhang <zzhang@cs.binghamton.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: VFS initialization in FreeBSD 3.1 
Message-ID:  <19990422171026.3E83F1F49@spinner.netplex.com.au>
In-Reply-To: Your message of "Thu, 22 Apr 1999 10:02:09 -0400." <Pine.GSO.3.96.990422095440.5541A-100000@sol.cs.binghamton.edu> 

next in thread | previous in thread | raw e-mail | index | archive | help
Zhihui Zhang wrote:
> 
> I am trying to understand how VFS gets initialized in FreeBSD 3.1.  In
> FreeBSD 2.2.8, the file vnode_if.c is created by vnode_if.sh.  At the end
> of vnode_if.c, there is the following array:
> 
>     struct vnodeop_desc *vfs_op_descs[] = {......}
> 
> This array will be traversed by vfs_op_init() (does not exist in FreeBSD
> 3.1) and the number of vnode operations is thus determined to be 44 in
> FreeBSD 2.2.8.
> 
> In FreeBSD 3.1, however, I can not find where the vfs_op_descs is
> initialized.  It seems to be initialized in vfs_add_vnodeops(), which is
> in turn called by some LKM routine. Is VFS initialized by LKM mechanism in
> FreeBSD 3.1.   I expect all system initialization is done by SYSINIT() or
> SYSINIT_KT() macros as in FreeBSD 2.2.8.  I hope some guru can give me
> some enlightment.

It's initiallized dynamically, via the VNODEOP_SET() macro:

/* Global vfs data structures for ufs. */
static vop_t **ufs_vnodeop_p;
static struct vnodeopv_entry_desc ufs_vnodeop_entries[] = {
        { &vop_default_desc,            (vop_t *) vop_defaultop },
        { &vop_fsync_desc,              (vop_t *) ufs_missingop },
        { &vop_read_desc,               (vop_t *) ufs_missingop },
[..]
        { &vop_whiteout_desc,           (vop_t *) ufs_whiteout },
        { NULL, NULL }
};
static struct vnodeopv_desc ufs_vnodeop_opv_desc =
        { &ufs_vnodeop_p, ufs_vnodeop_entries };
[..]
VNODEOP_SET(ufs_vnodeop_opv_desc);

VNODEOP_SET() arranges for a SYSINIT() to call the add/remove functions at
kernel boot and/or module load/unload times.

The VOP_*() vectors are 100% dynamic now - but there's a fair bit of
torture to get this to fly.  You can add *new* VOP's on the fly and they
will correctly pass through stacked layers, assuming the stacking works
right. :-)

VNODEOP_SET() is a legacy name from when this was all implemented with
linker sets.  This will go away and will get a proper name somewhere along
the line now that LKM mechanism has gone from 4.0-current and been replaced
with kld modules managed by the boot loader and the in-kernel linker.

Cheers,
-Peter




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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990422171026.3E83F1F49>