|
20 | 20 | */
|
21 | 21 | /*
|
22 | 22 | * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
23 |
| - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. |
| 23 | + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. |
24 | 24 | * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
|
25 | 25 | */
|
26 | 26 |
|
@@ -1195,19 +1195,26 @@ zio_write_bp_init(zio_t *zio)
|
1195 | 1195 | return (ZIO_PIPELINE_CONTINUE);
|
1196 | 1196 | } else {
|
1197 | 1197 | /*
|
1198 |
| - * Round up compressed size to MINBLOCKSIZE and |
1199 |
| - * zero the tail. |
| 1198 | + * Round up compressed size up to the ashift |
| 1199 | + * of the smallest-ashift device, and zero the tail. |
| 1200 | + * This ensures that the compressed size of the BP |
| 1201 | + * (and thus compressratio property) are correct, |
| 1202 | + * in that we charge for the padding used to fill out |
| 1203 | + * the last sector. |
1200 | 1204 | */
|
1201 |
| - size_t rounded = |
1202 |
| - P2ROUNDUP(psize, (size_t)SPA_MINBLOCKSIZE); |
1203 |
| - if (rounded > psize) { |
1204 |
| - bzero((char *)cbuf + psize, rounded - psize); |
1205 |
| - psize = rounded; |
1206 |
| - } |
1207 |
| - if (psize == lsize) { |
| 1205 | + size_t rounded; |
| 1206 | + |
| 1207 | + ASSERT3U(spa->spa_min_ashift, >=, SPA_MINBLOCKSHIFT); |
| 1208 | + |
| 1209 | + rounded = (size_t)P2ROUNDUP(psize, |
| 1210 | + 1ULL << spa->spa_min_ashift); |
| 1211 | + if (rounded >= lsize) { |
1208 | 1212 | compress = ZIO_COMPRESS_OFF;
|
1209 | 1213 | zio_buf_free(cbuf, lsize);
|
| 1214 | + psize = lsize; |
1210 | 1215 | } else {
|
| 1216 | + bzero((char *)cbuf + psize, rounded - psize); |
| 1217 | + psize = rounded; |
1211 | 1218 | zio_push_transform(zio, cbuf,
|
1212 | 1219 | psize, lsize, NULL);
|
1213 | 1220 | }
|
|
0 commit comments