Make sure not to do I/O for more than MAXPHYS bytes. Doing so can cause
authormarcel <marcel@FreeBSD.org>
Tue, 15 Apr 2014 15:41:57 +0000 (15:41 +0000)
committermarcel <marcel@FreeBSD.org>
Tue, 15 Apr 2014 15:41:57 +0000 (15:41 +0000)
commit8dd37471400a14b39911e87f5306bd300fd567be
tree1e9c882bba953e1eb7dda3a4b046c97d1044ab2b
parent04f26f523588a7df586411bd86fde99acada76e1
Make sure not to do I/O for more than MAXPHYS bytes. Doing so can cause
problems in our providers, such as a KASSERT in md(4). We can initiate
I/O for more than MAXPHYS bytes if we've been given a BIO for MAXPHYS
bytes, the blocks from which we're reading couldn't be compressed and
we had compression in preceeding blocks resulting in misalignment of
the blocks we're trying to read relative to the sector. We're forced to
round up the I/O length to make it an multiple of the sector size.

When we detect the condition, we'll reduce the block count and perform
a "short" read. In g_uzip_done() we need to consider the original I/O
length and stop early if we're about to deflate a block that we didn't
read. By using bio_completed in the cloned BIO and not bio_length to
check for this, we automatically and gracefully handle short reads that
our providers may be doing on top of the short reads we may initiate
ourselves.

Obtained from: Juniper Networks, Inc.
sys/geom/uzip/g_uzip.c