OpenZFS 8155 - simplify dmu_write_policy handling of pre-compressed buffers

Authored by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: Giuseppe Di Natale <dinatale2@llnl.gov>

When writing pre-compressed buffers, arc_write() requires that
the compression algorithm used to compress the buffer matches
the compression algorithm requested by the zio_prop_t, which is
set by dmu_write_policy(). This makes dmu_write_policy() and its
callers a bit more complicated.

We simplify this by making arc_write() trust the caller to supply
the type of pre-compressed buffer that it wants to write,
and override the compression setting in the zio_prop_t.

OpenZFS-issue: https://www.illumos.org/issues/8155
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/b55ff58
Closes #6200
This commit is contained in:
Matthew Ahrens
2017-03-23 09:07:27 -07:00
committed by Brian Behlendorf
parent 4070bfd852
commit 82644107c4
5 changed files with 18 additions and 26 deletions
+9 -3
View File
@@ -5977,6 +5977,7 @@ arc_write(zio_t *pio, spa_t *spa, uint64_t txg,
arc_buf_hdr_t *hdr = buf->b_hdr;
arc_write_callback_t *callback;
zio_t *zio;
zio_prop_t localprop = *zp;
ASSERT3P(ready, !=, NULL);
ASSERT3P(done, !=, NULL);
@@ -5987,7 +5988,13 @@ arc_write(zio_t *pio, spa_t *spa, uint64_t txg,
if (l2arc)
arc_hdr_set_flags(hdr, ARC_FLAG_L2CACHE);
if (ARC_BUF_COMPRESSED(buf)) {
ASSERT3U(zp->zp_compress, !=, ZIO_COMPRESS_OFF);
/*
* We're writing a pre-compressed buffer. Make the
* compression algorithm requested by the zio_prop_t match
* the pre-compressed buffer's compression algorithm.
*/
localprop.zp_compress = HDR_GET_COMPRESS(hdr);
ASSERT3U(HDR_GET_LSIZE(hdr), !=, arc_buf_size(buf));
zio_flags |= ZIO_FLAG_RAW;
}
@@ -6023,8 +6030,7 @@ arc_write(zio_t *pio, spa_t *spa, uint64_t txg,
zio = zio_write(pio, spa, txg, bp,
abd_get_from_buf(buf->b_data, HDR_GET_LSIZE(hdr)),
HDR_GET_LSIZE(hdr), arc_buf_size(buf), zp,
arc_write_ready,
HDR_GET_LSIZE(hdr), arc_buf_size(buf), &localprop, arc_write_ready,
(children_ready != NULL) ? arc_write_children_ready : NULL,
arc_write_physdone, arc_write_done, callback,
priority, zio_flags, zb);