summaryrefslogtreecommitdiffstats
path: root/module/zfs/zio.c
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2015-05-19 22:14:01 -0600
committerBrian Behlendorf <[email protected]>2015-06-10 16:24:01 -0700
commitc3520e7f1f567bd4e6a28eff4867c70850e8a854 (patch)
treefa4841c8118ce6129ee4931d868dd015d60a7643 /module/zfs/zio.c
parent9c43027b3f18769f2ace16eaa222ac8b301501f4 (diff)
Illumos 5818 - zfs {ref}compressratio is incorrect with 4k sector size
5818 zfs {ref}compressratio is incorrect with 4k sector size Reviewed by: Alex Reece <[email protected]> Reviewed by: George Wilson <[email protected]> Reviewed by: Richard Elling <[email protected]> Reviewed by: Steven Hartland <[email protected]> Approved by: Albert Lee <[email protected]> References: https://www.illumos.org/issues/5818 https://github.com/illumos/illumos-gate/commit/81cd5c5 Ported-by: Don Brady <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #3432
Diffstat (limited to 'module/zfs/zio.c')
-rw-r--r--module/zfs/zio.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/module/zfs/zio.c b/module/zfs/zio.c
index 2b338f2a7..1e5be8bfc 100644
--- a/module/zfs/zio.c
+++ b/module/zfs/zio.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
*/
@@ -1195,19 +1195,26 @@ zio_write_bp_init(zio_t *zio)
return (ZIO_PIPELINE_CONTINUE);
} else {
/*
- * Round up compressed size to MINBLOCKSIZE and
- * zero the tail.
+ * Round up compressed size up to the ashift
+ * of the smallest-ashift device, and zero the tail.
+ * This ensures that the compressed size of the BP
+ * (and thus compressratio property) are correct,
+ * in that we charge for the padding used to fill out
+ * the last sector.
*/
- size_t rounded =
- P2ROUNDUP(psize, (size_t)SPA_MINBLOCKSIZE);
- if (rounded > psize) {
- bzero((char *)cbuf + psize, rounded - psize);
- psize = rounded;
- }
- if (psize == lsize) {
+ size_t rounded;
+
+ ASSERT3U(spa->spa_min_ashift, >=, SPA_MINBLOCKSHIFT);
+
+ rounded = (size_t)P2ROUNDUP(psize,
+ 1ULL << spa->spa_min_ashift);
+ if (rounded >= lsize) {
compress = ZIO_COMPRESS_OFF;
zio_buf_free(cbuf, lsize);
+ psize = lsize;
} else {
+ bzero((char *)cbuf + psize, rounded - psize);
+ psize = rounded;
zio_push_transform(zio, cbuf,
psize, lsize, NULL);
}