]> git.proxmox.com Git - mirror_zfs.git/commit - module/zfs/arc.c
Handle compressed buffers in __dbuf_hold_impl()
authorTim Chase <tim@chase2k.com>
Wed, 8 Nov 2017 21:32:15 +0000 (15:32 -0600)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 8 Nov 2017 21:32:15 +0000 (13:32 -0800)
commit71a24c3c52f6223f54e6351b57e089791aa3b2f1
treeb0a33be5693236c9524b50b6ef4aa1b943a518ac
parenteef005d882dfaa2ffddfeea5d70ff27aadee344a
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