Google Summer of Code zfs-port project

June 04, 2009 posted by Adam Hamsik

ZFS-port project introduction

ZFS is well known file system developed by Sun Microsystems, inc. for Solaris operating system. Its source code was released under the CDDL license. ZFS currently was ported to several other operating systems like Mac OS X and FreeBSD.

ZFS port to NetBSD was started in Summer of code 2007 by Oliver Gould. Later Andrew Doran (my mentor in this project) worked on zfs port and released several versions of his work Partial zfs port.

More about ZFS features and how it works can be found at presentation ZFS last word in file systems.

The ZFS file system contains two major modules ZVOL and ZPL.

The ZVOL is Logical Volume Manager module of the ZFS. It creates/manages Logical disk drives created from pools of disk space called ZPOOLS.

The ZPL is file system layer used for creating ZFS file system on a ZVOL volume.

ZFS source code tour


Mandatory (must-have) components:

  • Finish port of ZFS ZVOL layer to NetBSD
  • Implement device partition properties. Change newfs, dm(4) and other logical disk drivers.
  • Implement device disk(driver:model-revision-serial-etc) ids for identification of zfs disk.
  • Port vfsops and vnodeops. ignore getpages/putpages.

Optional (would-be-nice) components:

  • Implement getpages/putpages
  • Callbacks into arc, for reclaim of memory or kernel virual space.
  • Maybe changing the order of arguments for pool_cache constructors.
  • Implement nameiat and lookupnameat functions.

Progress zvol, modules, wedge like disks

ZFS and solaris modules can be loaded to NetBSD system.

Zvol is one of two basic parts of ZFS. This subsystem manages disk space added to ZFS pools. Administrator can create Logical Volumes/manage their size just like with LVM. Currently user can create zvols and use them as Logical Volumes for ffs file system.

I have written small patch to support wedge like devices in newfs and all utilities using getdiskinfo() from partiutil.c file. Commiting patch was discussed here.


# zpool create -f test /dev/wd1a
# zfs create -V 200M test/ufs
# /mod/newfs /dev/zvol/rdsk/test/ufs                                                                                                        
/dev/zvol/rdsk/test/ufs: 200.0MB (409600 sectors) block size 8192, fragment size 1024
        using 5 cylinder groups of 40.00MB, 5120 blks, 9920 inodes.
super-block backups (for fsck_ffs -b #) at:
32, 81952, 163872, 245792, 327712,

# zpool list NAME SIZE USED AVAIL CAP HEALTH ALTROOT test 260M 5.22M 255M 2% ONLINE -
# zfs list NAME USED AVAIL REFER MOUNTPOINT test 200M 27.9M 18K /test test/ufs 200M 223M 5.13M -
# mount /dev/zvol/dsk/test/ufs /mnt/ # mount /dev/wd0a on / type ffs (local) kernfs on /kern type kernfs (local) ptyfs on /dev/pts type ptyfs (local) /dev/zvol/dsk/test/ufs on /mnt type ffs (local)

In example zpool test is created from disk wd1a, later new zvol called ufs is created from it. newfs compiled with my getdiskinfo patch is later used to create file system on this zvol. File system is later mounted to /mnt.

Source code

Source code is managed in my own git repository at git:// This code should be only used for review, getting some panics :). Be aware that it is Work in progress code which can panics/deadlocks a lot.


Post a Comment:
Comments are closed for this entry.