[review request] zfsboot/zfsloader: support accessing filesystems within a pool

Andriy Gapon avg at FreeBSD.org
Sat May 5 09:31:27 UTC 2012


on 04/05/2012 18:25 John Baldwin said the following:
> On Thursday, May 03, 2012 11:23:51 am Andriy Gapon wrote:
>> on 03/05/2012 18:02 Andriy Gapon said the following:
>>>
>>> Here's the latest version of the patches:
>>> http://people.freebsd.org/~avg/zfsboot.patches.4.diff
>>
>> I've found a couple of problems in the previous version, so here's another one:
>> http://people.freebsd.org/~avg/zfsboot.patches.5.diff
>> The important change is in the first patch (__exec args).
> 
> A few comments/suggestions on the args bits:

John,

these are excellent suggestions!  Thank you!
Some comments:

> - Please move the type of the 'kargs' struct into the new header and
>   give it a type name.  Don't add the LOADER_ZFS_SUPPORT #ifdef's
>   however or the new size field (see below).

Done. I've named the header and the struct "bootargs".

> - Add #ifndef LOCORE guards to the new header around the structure so
>   it can be used in assembly as well as C.

Done.  I have had to go into a few btx makefiles and add a necessary include
path and -DLOCORE to make the header usable from asm.

> - Move BI_SIZE and ARGOFF into the header as constants.

Done.

> - Add a CTASSERT() in loader/main.c that BI_SIZE == sizeof(struct bootinfo)

I have added a definition of CTASSERT to boostrap.h as it was not available for
sys/boot and there were two local definitions of the macro in individual files.

However the assertion would fail right now.
The backward-compatible value of BI_SIZE (72 == 0x48) covers only part of the
fields in struct bootinfo, those up to the following comment:
	/* Items below only from advanced bootloader */

I am a little bit hesitant: should I increase BI_SIZE to cover the whole struct
bootinfo or should I compare BI_SIZE to offsetof bi_kernend?

> - Add a KA_SIZE for sizeof(struct kargs) with a CTASSERT.  Use it in this
>   instruction:

Done.

> +		addl 0x1c(%esp),%ecx		# Add size of variable args
> 
>   in place of the 0x1c

Done.  Plus some more.

> - Don't add the new 'size' field to the end of the 'struct kargs'.  Instead
>   add a comment saying that if KARGS_FLAGS_EXT is set, then a structure will
>   be present at (kargs + 1) that has a int size as its first member.

Done.

> Maybe
>   create a 'struct kargs_ext' that looks like this:
> 
> struct kargs_ext {
> 	uint32_t size;
> 	char data[0];
> };

I've decided to skip on this.

> - Use 'zargs = (struct zfs_boot_args)(kargs + 1)' in loader/main.c.
> - Change the ARGADJ line in btxcsu to be this:
> 
> .set ARGADJ,0x1000 - ARGOFF

I've decided to define ARGADJ in the new common header, then I've had to rename
btxcsu.s to .S, so that the preprocessing is executed for it.

> - If you are adventurous, you could even add a new constant ARGSPACE or some
>   such with an appropriate comment in the new header that you use to replace
>   the 0x1000 in btx.S and in the definition of ARGADJ.

Done.

> Hope that isn't too much, but I do think this will help make things even more
> understandable.
> 

I will send the new patch shortly.

-- 
Andriy Gapon


More information about the freebsd-fs mailing list