[Bug 262904] Write errors when writing to LTO tape with dd, tar, btape etc. after upgrade to 13.0-RELEASE

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 29 Mar 2022 13:47:11 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262904

            Bug ID: 262904
           Summary: Write errors when writing to LTO tape with dd, tar,
                    btape etc. after upgrade to 13.0-RELEASE
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: b.ecker@bitteeinbyte.de

I have a HP Storeworks Ultrium 960 LTO-3 drive, which is connected to a LSI
Logic Ultra320 SCSI Controller Card. I tested it a while ago, still running
FreeBSD 12.2-RELEASE, by writing a few peaces of data to tape with tar and dd
and it worked absolutely fine. That is not the case after upgrading to FreeBSD
13.0-RELEASE.

When something is about to be written to tape, that is at least a few MB in
size, the drive exits with errors. It tells the writing program, that it has
reached the end of medium or the end of device, which can't be the case after a
few megabytes. I tested it with three brand new tapes and I also used a
cleaning tape twice.

Upon invoking the mt-command for the first time after rebooting,
/var/log/messages says the following:
(sa0:mpt0:0:3:0): 64512-byte tape record bigger than supplied buffer
However positioning, rewinding and querying the status of the drive with mt is
all working fine.

I tried writing to the tape device with dd, tar, btape and piping the output to
the device. All yield similar results. I tried writing to /dev/nsa0 and
/dev/sa0. In every case the invoked command always fails. A few examples with
output:

Running dd:
dd if=/dev/urandom of=/dev/nsa0 bs=128k count=8192
dd: /dev/nsa0: end of device
2002+0 records in
2001+0 records out
262275072 bytes transferred in 5.069271 secs (51738220 bytes/sec)

Running tar:
tar cvf /dev/nsa0 /tmp/testfile
a tmp/testfile
tar: Write error

Running btape test
btape -v /dev/nsa0
Tape block granularity is 1024 bytes.
btape: stored/butil.cc:306-0 Using device: "/dev/nsa0" for writing.
btape: stored/btape.cc:490-0 open device "TapeDrive" (/dev/nsa0): OK
*test
=== Write, rewind, and re-read test ===
I'm going to write 10000 records and an EOF
then write 10000 records and an EOF, then rewind,
and re-read the data to verify that it is correct.
This is an *essential* feature ...
btape: stored/btape.cc:1119-0 Wrote 10000 blocks of 64412 bytes.
btape: stored/btape.cc:599-0 Wrote 1 EOF to "TapeDrive" (/dev/nsa0)
btape: stored/btape.cc:1133-0 Wrote 10000 blocks of 64412 bytes.
btape: stored/btape.cc:599-0 Wrote 1 EOF to "TapeDrive" (/dev/nsa0)
btape: stored/btape.cc:599-0 Wrote 1 EOF to "TapeDrive" (/dev/nsa0)
btape: stored/btape.cc:1169-0 Rewind OK.
10000 blocks re-read correctly.
Got EOF on tape.
Got EOF on tape.
btape: stored/btape.cc:1187-0 Read block 19123 failed! ERR=No error: 0

I also tried to reduce the size of kern.maxphys, because I got the impression,
that too much data is being send to the drive and overflows the buffer. But no
effect either.

I live-booted FreeBSD 12.3-RELEASE for diagnosing the problem further. Running
the same commands now yields perfect results out of the box. Everything works
as expected. I filled two tapes with over 200GB of data without a single
hickup.
I further confirmed this with a Debian live boot, with the same positive
results.

My guess is, that some change made in the process between 12.3 and 13.0 is
responsible. Thus I put the report in the bin category.

I am thankful for every insight.

Benedict

-- 
You are receiving this mail because:
You are the assignee for the bug.