1 From: "Dan Langille" <dan@langille.org>
2 To: bacula-users@lists.sourceforge.net
3 Subject: [Bacula-users] FreeBSD - large backups to tape
4 Date: Mon, 20 Oct 2003 15:29:18 -0400
6 Kern and I have been working on a FreeBSD/Bacula problem.
7 He's asked me to post this to the list. The problem was within the
8 FreeBSD pthreads library. A solution has been found.
12 The FreeBSD pthreads library does not properly handle End Of Tape.
13 This problem will be fixed in FreeBSD 4.9. The bug results in more
14 data being written to the tape than could be read. Any backup which
15 involved more than one tape would be incomplete.
19 To demonstrate the problem, tapetest.c can be obtained from
20 http://www.freebsd.org/cgi/query-pr.cgi?pr=56274
22 This tests without pthreads:
24 * If you build this program with:
26 * c++ -g -O2 -Wall -c tapetest.c
27 * c++ -g -O2 -Wall tapetest.o -o tapetest
29 * Procedure for testing tape
30 * ./tapetest /dev/your-tape-device
36 * The output will be something like:
40 * *Begin writing blocks of 64512 bytes.
41 * ++++++++++++++++++++ ...
42 * Write failed. Last block written=17294. stat=0 ERR=Unknown
45 * Wrote EOF to /dev/nsa0
47 * *Starting scan at file 0
48 * 17294 blocks of 64512 bytes in file 0
52 * Total files=1, blocks=17294, bytes = 1115670528
55 * which is correct. Notice that the return status is
56 * 0, while in the example below, which fails, the return
59 This tests with pthreads:
61 * If you build this program with:
63 * c++ -g -O2 -Wall -pthread -c tapetest.c
64 * c++ -g -O2 -Wall -pthread tapetest.o -o tapetest
65 * Note, we simply added -pthread compared to the
68 * Procedure for testing tape
69 * ./tapetest /dev/your-tape-device
75 * The output will be something like:
79 * *Begin writing blocks of 64512 bytes.
80 * +++++++++++++++++++++++++++++ ...
81 * Write failed. Last block written=17926. stat=-1 ERR=No space left on device
83 * Wrote EOF to /dev/nsa0
85 * *Starting scan at file 0
86 * 17913 blocks of 64512 bytes in file 0
90 * Total files=1, blocks=17913, bytes = 1155603456
93 * which is incroorect because it wrote 17,926 blocks but read
94 * back only 17,913 blocks
96 If you get the same number of blocks written and read WHEN using
97 pthreads, then you've been correctly patched.
101 For FreeBSD prior to and including 4.9, you have two choices to ensure proper
102 backups. These instructions assume you are familiar with patching
103 FreeBSD and already have the FreeBSD source code installed on your
106 Do one of the following:
108 - cvsup and build your system to FreeBSD 4.x-STABLE after the
109 date Mon Dec 29 15:18:01 2003 UTC
113 http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc_r/uthread/uthread_write.c.diff?r1=1.16.2.6&r2=1.16.2.8
115 To apply the patch, follow these instructions as root.
117 fetch -o pthread.diff http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc_r/uthread/uthread_write.c.diff?r1=1.16.2.6\&r2=1.16.2.8
119 cd /usr/src/lib/libc_r/uthread/
120 patch < /path/to/pthread.diff
124 I recommend restarting Bacula.
129 I suggest running tapetest on your patched system and then
130 conducting a backup which spans two tapes. Restore the data
131 and compare to the original. If not identical, please let us know.