Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 May 2010 10:59:24 +0300
From:      Andriy Gapon <avg@freebsd.org>
To:        freebsd-fs@freebsd.org
Subject:   Re: few ideas for zfsloader ( bootfs -> vfs.root.mountfrom)
Message-ID:  <4BEBB15C.5000704@freebsd.org>
In-Reply-To: <4BD9B94F.7090709@icyb.net.ua>
References:  <4B9FD6E0.5000303@icyb.net.ua> <4BD9B94F.7090709@icyb.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
on 29/04/2010 19:52 Andriy Gapon said the following:
> I've made some progress on this, see the attached patch.
> The patch is not complete.
> 
> What it can do right now:
> 1. set vfs.zfs.bootfs to something like "zfs:tank:1111" where 'tank' is a pool
> name and '1111' is object id of dataset selected as boot filesystem (e.g. via bootfs).
> 2. set vfs.root.mountfrom to value of vfs.zfs.bootfs iff it was not set
> explicietly and '/' entry was not found in fstab.
> 
> But right now ZFS can not be mounted using a filesystem specification in the above
> format.
> 
> I see two ways forward:
> 1. Enhance ZFS mount kernel code, so that it accepts dataset id instead of its
> name.  This doesn't seem to be very hard.
> 2. Enhance zfs boot code (zfsloader) to map boot dataset id to its name.  I have
> prototype code (unfinished, non-working) for this that navigates from a dataset up
> the hierarchy (via dir_obj, parent_dir_obj) and does a reverse lookup in directory
> child map to find a name component.
> 
> While #2 seems nicer it also seems to be a waste, since the name will ultimately
> be mapped to object id by ZFS kernel code anyways.

OpenSolaris+GRUB do things the way described in #1.
ZFS v22 has code for mounting a (root) filesystem by its object id.
We probably will do the same when our ZFS gets updated to v22.

But right now I decided that it's easier for me to follow path #2 and hack on
boot code instead of ZFS code.

The result is here:
http://people.freebsd.org/~avg/zfsboot.diff
This patch is supposed to do the job.
Main routine is zfs_build_name.

Some things to consider/improve:

1. Currently loader sets
currdev="zfs0"
loaddev="disk0a:"
I changed it to
currdev="zfs0:"
loaddev="zfs0:"
Not sure which value in loaddev is more useful and whether it is used anywhere
at all.

2. Note amount of code duplication between *zap_lookup and *zap_rlookup.

3. Probably some functions should get better names, e.g. zfs_build_name =>
zfs_rloookup.

4. Probably there should be checks against buffer overflowing in zfs_build_name
and *_rlookup.

5. (zfs)boot2 should pass to loader not only boot pool id, but also boot
filesystem id, so that loader doesn't have to repeat bootfs or root dataset
lookup.  This should come handy when/if zfsboot provides ability to select
alternative boot filesystem.

6. spa_t should hold information about a pool, but information about currently
'mounted' filesystem/dataset should go into a separate structure.  zfsboot or
loader might want to read files from more than one filesystem of the pool.

-- 
Andriy Gapon



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