# Applying .diff to fix ZFS bug



## deepdish (Dec 26, 2010)

Hello,

I am currently running FreeBSD 8.1 amd64 and I would like to apply a .diff patch to repair a ZFS bug. Basically, I'm trying to copy a bunch of files from a ZFS v3/Zpool v14 pool created in Solaris. Problem is that the FreeBSD box hangs when attempting to copy files, and outputs a " zfs_fuid_map_id " error on the console screen. Googling around has lead me to the following site:

http://www.freebsd.org/cgi/query-pr.cgi?pr=145778

The issue I am running into is that I never applied a .diff patch before and not sure where to begin. Searching around the Internet has given me a somewhat cloudy picture of what to do (during and after the patch).

Also, I have tried to manually set/unset the sharesmb feature for the ZFS pool, but the command is disallowed in FreeBSD. 

Would anyone be able to guide me?

Thanks!


----------



## graudeejs (Dec 26, 2010)

Hmm, interesting, I don't have problems copying...
anyway
To apply patch you cd to directory and run `# patch < some_patch.diff`
If you speak about last patch submitted, then you should apply it form /usr/src/ at least so it looks
If patch will fail, you will see messages about that, and patch will make reject (or something like that) files...., you you can check them and maybe fix un-applied chunks


----------



## deepdish (Dec 26, 2010)

I'm a little stuck:


```
plutonium# cd /usr/src
plutonium# patch < /root/patch-2.diff
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	Wed Sep 15 16:05:51 2010	(r212669)
|+++ stable/8/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	Wed Sep 15 16:10:38 2010	(r212670)
--------------------------
File to patch: libzfs_dataset.c
No file found--skip this patch? [n] ^Cplutonium# 
plutonium#
```


----------



## wblock@ (Dec 26, 2010)

See those first two lines of the patch?  Those are the file paths.  A normal /usr/src doesn't have a stable/8 subdir, it's just /usr/src/cddl.

So use the -p option to patch(1):
`# cd /usr/src`
`# patch -p2 < /root/patch-2.diff`

You'll still need to rebuild ZFS or maybe the whole kernel after that.  Hope you have an easily accessible backup, because if it goes wrong, you could find yourself without a way to read the old files.


----------



## deepdish (Dec 29, 2010)

Thanks for your suggestion, unfortunately I took a different path since I am quiet uneasy to make changes on the FreeBSD kernel. I have not sat played around with FreeBSD enough to go that far, and time for me is difficult to find unfortunately. 

Instead, what I have done is destroyed the Solaris-created ZFS pool on the USB drive and re-created it on my FreeBSD box. I'm waiting for the files to be copied over on the Solaris end and I will let everyone know how it goes (for Google's sake).


----------



## deepdish (Dec 31, 2010)

I am able to reproduce the problem, even if the ZFS partition/pool has been created under FreeBSD. It's a strange problem.
When I'm copying all of the contents on the USB drive (a ZFS pool) to my ZFS array on the same machine, it crashes.

For example, issuing this command gives the " zfs_fuid_map_id " error (this is not the exact command, DIR's are different):


```
cp -rvf /<USBDRIVE>/* /<ZFSPOOL>/
```

However, when performing the same action using rsync, it seems to be working fine (5 minutes, so far so good).

Would anyone have any hints or ideas?

UPDATE: I stand corrected, rsync has also produced the same error message. Now I'm really stuck. Is this specific to my system or are other people having issues with copying files from a USB drive, that is a ZFS partition/zpool, to your ZFS array?


----------

