g_vfs_open and bread(devvp, ...)

Andriy Gapon avg at freebsd.org
Fri Apr 9 14:26:03 UTC 2010


I came up with a small demonstration for why I bothered with this issue at all.
To reproduce the experiment you would need this image:
http://people.freebsd.org/~avg/test_img.gz
and avgfs:)
http://people.freebsd.org/~avg/avgfs/

The image needs to be gunzip-ed, of course.
avgfs:) needs to be compiled, avgfs.ko loaded.
The demonstration is to be executed on an unpatched system, e.g. head before
r205860, or a branch other than head, or recent head with r206097 and r205860
reverted.

Then do the following.
I. Inspect test image.
$ hd test_img.img | more

II. Test bread() through avgfs vnode.
1. Present the image as a disk with 2K sector size
mdconfig -a -t vnode -f test_img.img -S 2048 -u 0
2. Mount the image using avgfs:)
mount -t avg /dev/md0 /mnt
3. Read some data blocks in one go and examine the result.
dd if=/mnt/thefile bs=10k count=1 | hd
4. Re-read the same data using 2K blocks and examine the result.
dd if=/mnt/thefile bs=2k count=5 | hd
5. Cleanup.
umount /mnt

III. Test bread() through devvp.
1. Mount the image using avgfs:) with devvp option.
mount -t avg -o devvp /dev/md0 /mnt
2. Read some data blocks in one go and examine the result.
dd if=/mnt/thefile bs=10k count=1 | hd
3. Re-read the same data using 2K blocks and examine the result.
dd if=/mnt/thefile bs=2k count=5 | hd
4. Cleanup.
umount /mnt
mdconfig -d -u 0
kldunload avgfs


SPOILER.
In my testing only III.3 produces an unexpected result:
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000800  04 04 04 04 04 04 04 04  04 04 04 04 04 04 04 04  |................|
*
00001000  02 02 02 02 02 02 02 02  02 02 02 02 02 02 02 02  |................|
*
00001800  03 03 03 03 03 03 03 03  03 03 03 03 03 03 03 03  |................|
*
00002000  04 04 04 04 04 04 04 04  04 04 04 04 04 04 04 04  |................|
*

The result is explained here:
http://lists.freebsd.org/pipermail/freebsd-fs/2008-February/004268.html

Repeat the experiment on a patched system.
See if the change was worth bothering.

P.S. avgfs:) is explained here:
http://permalink.gmane.org/gmane.os.freebsd.devel.file-systems/8886

-- 
Andriy Gapon


More information about the freebsd-geom mailing list