mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
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 <alex@delphix.com>
Reviewed by: George Wilson <george@delphix.com>
Reviewed by: Richard Elling <richard.elling@richardelling.com>
Reviewed by: Steven Hartland <killing@multiplay.co.uk>
Approved by: Albert Lee <trisk@omniti.com>
References:
https://www.illumos.org/issues/5818
https://github.com/illumos/illumos-gate/commit/81cd5c5
Ported-by: Don Brady <don.brady@intel.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3432
This commit is contained in:
committed by
Brian Behlendorf
parent
9c43027b3f
commit
c3520e7f1f
@@ -2245,6 +2245,8 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
|
||||
return (error);
|
||||
|
||||
ASSERT(spa->spa_root_vdev == rvd);
|
||||
ASSERT3U(spa->spa_min_ashift, >=, SPA_MINBLOCKSHIFT);
|
||||
ASSERT3U(spa->spa_max_ashift, <=, SPA_MAXBLOCKSHIFT);
|
||||
|
||||
if (type != SPA_IMPORT_ASSEMBLE) {
|
||||
ASSERT(spa_guid(spa) == pool_guid);
|
||||
|
||||
@@ -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 2011 Nexenta Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
|
||||
*/
|
||||
@@ -623,6 +623,9 @@ spa_add(const char *name, nvlist_t *config, const char *altroot)
|
||||
|
||||
spa->spa_debug = ((zfs_flags & ZFS_DEBUG_SPA) != 0);
|
||||
|
||||
spa->spa_min_ashift = INT_MAX;
|
||||
spa->spa_max_ashift = 0;
|
||||
|
||||
/*
|
||||
* As a pool is being created, treat all features as disabled by
|
||||
* setting SPA_FEATURE_DISABLED for all entries in the feature
|
||||
|
||||
+14
-2
@@ -22,7 +22,7 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <sys/zfs_context.h>
|
||||
@@ -206,8 +206,9 @@ vdev_add_child(vdev_t *pvd, vdev_t *cvd)
|
||||
size_t oldsize, newsize;
|
||||
uint64_t id = cvd->vdev_id;
|
||||
vdev_t **newchild;
|
||||
spa_t *spa = cvd->vdev_spa;
|
||||
|
||||
ASSERT(spa_config_held(cvd->vdev_spa, SCL_ALL, RW_WRITER) == SCL_ALL);
|
||||
ASSERT(spa_config_held(spa, SCL_ALL, RW_WRITER) == SCL_ALL);
|
||||
ASSERT(cvd->vdev_parent == NULL);
|
||||
|
||||
cvd->vdev_parent = pvd;
|
||||
@@ -1336,6 +1337,17 @@ vdev_open(vdev_t *vd)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Track the min and max ashift values for normal data devices.
|
||||
*/
|
||||
if (vd->vdev_top == vd && vd->vdev_ashift != 0 &&
|
||||
!vd->vdev_islog && vd->vdev_aux == NULL) {
|
||||
if (vd->vdev_ashift > spa->spa_max_ashift)
|
||||
spa->spa_max_ashift = vd->vdev_ashift;
|
||||
if (vd->vdev_ashift < spa->spa_min_ashift)
|
||||
spa->spa_min_ashift = vd->vdev_ashift;
|
||||
}
|
||||
|
||||
/*
|
||||
* If a leaf vdev has a DTL, and seems healthy, then kick off a
|
||||
* resilver. But don't do this if we are doing a reopen for a scrub,
|
||||
|
||||
+17
-10
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user