How to make a custom vdev module for FreeNAS 9.1?

Status
Not open for further replies.

Markj

Dabbler
Joined
Dec 20, 2013
Messages
11
I'm trying to fix a broken zpool due to losing the ZIL SSD device. I found this code fragment that looks like it would work around the problem and allow me to import the pool without the log device:
Code:
        /*
        * If this is a top-level vdev, initialize its metaslabs.
        */
        if (vd == vd->vdev_top && !vd->vdev_ishole &&
            (vd->vdev_ashift == 0 || vd->vdev_asize == 0 ||
-          vdev_metaslab_init(vd, 0) != 0))
-              vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
-                  VDEV_AUX_CORRUPT_DATA);
+            vdev_metaslab_init(vd, 0) != 0)) {
+        printf("\nFound corrupted top level vdev.");
+        //vdev_set_state(vd, B_FALSE, VDEV_STATE_CANT_OPEN,
+        //        VDEV_AUX_CORRUPT_DATA);
+      }
 
  Basically I commented out the location that marked the state of the
log vdev as broken. With that done, the pool will zpool import  -F
even without the log device, in an slightly odd state (missing was not
the name of the log device, this comes from VDEV_TYPE_MISSING):


Two questions:
1. How can I get access to the source repository so I can apply this change?
2. Can I make vdev as a standalone binary, or is FreeNAS monolithic requiring a full build?

Thanks in advance!
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
To be honest, before you go to this kind of extent I'd try to mount your pool with Solaris or ZFS on Linux before trying what you are doing. Of course, make it top priority to mount in readonly mode so you don't trash your pool and can get your data off. ;)

I'm pretty sure you'll need a full recompile. :( You can go in IRC and ask "wg" your question.
 

Markj

Dabbler
Joined
Dec 20, 2013
Messages
11
Cyberjock - thanks for the suggestions. I'm trying OpenIndiana live right now, but no joy so far.
 

Dusan

Guru
Joined
Jan 29, 2013
Messages
1,165
What you found is the illumos source code -- a fork of, the now dead, OpenSolaris.
To build FreeNAS with your changes you need to use the FreeNAS source code: https://github.com/freenas/freenas
This repo does not contain FreeBSD/ZFS source code, the build system pulls is from here: https://github.com/trueos/trueos (your file: https://github.com/trueos/trueos/bl...ib/opensolaris/uts/common/fs/zfs/vdev.c#L2141)
I did not study your proposed change, but for reference, this is what the -m option does:
https://github.com/trueos/trueos/bl...rib/opensolaris/uts/common/fs/zfs/spa.c#L1654
https://github.com/trueos/trueos/bl...rib/opensolaris/uts/common/fs/zfs/spa.c#L1703
 

Markj

Dabbler
Joined
Dec 20, 2013
Messages
11
Status
Not open for further replies.
Top