]> git.proxmox.com Git - mirror_zfs.git/commit
Handle compressed buffers in __dbuf_hold_impl()
authorTim Chase <tim@chase2k.com>
Wed, 8 Nov 2017 21:32:15 +0000 (15:32 -0600)
committerTony Hutter <hutter2@llnl.gov>
Tue, 21 Nov 2017 19:01:30 +0000 (13:01 -0600)
commitd7881a6dca4f2863f04324c3a15248796aa14cf9
tree4fbfa262d75fdda59a97df52672c34226c0b8aed
parent951e62169eed7b94769f844f92a29e877101f25f
Handle compressed buffers in __dbuf_hold_impl()

In __dbuf_hold_impl(), if a buffer is currently syncing and is still
referenced from db_data, a copy is made in case it is dirtied again in
the txg.  Previously, the buffer for the copy was simply allocated with
arc_alloc_buf() which doesn't handle compressed or encrypted buffers
(which are a special case of a compressed buffer).  The result was
typically an invalid memory access because the newly-allocated buffer
was of the uncompressed size.

This commit fixes the problem by handling the 2 compressed cases,
encrypted and unencrypted, respectively, with arc_alloc_raw_buf() and
arc_alloc_compressed_buf().

Although using the proper allocation functions fixes the invalid memory
access by allocating a buffer of the compressed size, another unrelated
issue made it impossible to properly detect compressed buffers in the
first place.  The header's compression flag was set to ZIO_COMPRESS_OFF
in arc_write() when it was possible that an attached buffer was actually
compressed.  This commit adds logic to only set ZIO_COMPRESS_OFF in
the non-ZIO_RAW case which wil handle both cases of compressed buffers
(encrypted or unencrypted).

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Closes #5742
Closes #6797
module/zfs/arc.c
module/zfs/dbuf.c