usr/src/uts/common/fs/zfs/bplist.c
author George Wilson <George.Wilson@Sun.COM>
Tue, 29 Sep 2009 07:29:35 -0700
changeset 10685 931790026ac6
parent 7390 6d408f0a5fbd
child 10922 e2081f502306
permissions -rw-r--r--
6846163 ZFS continues to use faulted logzilla, bringing system to a crawl 6872547 ztest LUN expansion test fails 6873635 zdb should be able to open a pool with a failed slog 6873654 system panics when a slog device is offlined 6875236 zdb should be able to dump the spa history
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     1
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     2
 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     3
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
     5
 * Common Development and Distribution License (the "License").
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
     6
 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
/*
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 5367
diff changeset
    22
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
#include <sys/bplist.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    29
static int
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
bplist_hold(bplist_t *bpl)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
	ASSERT(MUTEX_HELD(&bpl->bpl_lock));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
	if (bpl->bpl_dbuf == NULL) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    34
		int err = dmu_bonus_hold(bpl->bpl_mos,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    35
		    bpl->bpl_object, bpl, &bpl->bpl_dbuf);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    36
		if (err)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    37
			return (err);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
		bpl->bpl_phys = bpl->bpl_dbuf->db_data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
	}
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    40
	return (0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
uint64_t
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
bplist_create(objset_t *mos, int blocksize, dmu_tx_t *tx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
{
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    46
	int size;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 2082
diff changeset
    48
	size = spa_version(dmu_objset_spa(mos)) < SPA_VERSION_BPLIST_ACCOUNT ?
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    49
	    BPLIST_SIZE_V0 : sizeof (bplist_phys_t);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    51
	return (dmu_object_alloc(mos, DMU_OT_BPLIST, blocksize,
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    52
	    DMU_OT_BPLIST_HDR, size, tx));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
bplist_destroy(objset_t *mos, uint64_t object, dmu_tx_t *tx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
	VERIFY(dmu_object_free(mos, object, tx) == 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    61
int
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
bplist_open(bplist_t *bpl, objset_t *mos, uint64_t object)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
	dmu_object_info_t doi;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    65
	int err;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    67
	err = dmu_object_info(mos, object, &doi);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    68
	if (err)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    69
		return (err);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
	mutex_enter(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
	ASSERT(bpl->bpl_dbuf == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
	ASSERT(bpl->bpl_phys == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
	ASSERT(bpl->bpl_cached_dbuf == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
	ASSERT(bpl->bpl_queue == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
	ASSERT(object != 0);
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    78
	ASSERT3U(doi.doi_type, ==, DMU_OT_BPLIST);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    79
	ASSERT3U(doi.doi_bonus_type, ==, DMU_OT_BPLIST_HDR);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
	bpl->bpl_mos = mos;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
	bpl->bpl_object = object;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
	bpl->bpl_blockshift = highbit(doi.doi_data_block_size - 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
	bpl->bpl_bpshift = bpl->bpl_blockshift - SPA_BLKPTRSHIFT;
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
    85
	bpl->bpl_havecomp = (doi.doi_bonus_size == sizeof (bplist_phys_t));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
	mutex_exit(&bpl->bpl_lock);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    88
	return (0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
bplist_close(bplist_t *bpl)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
	mutex_enter(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
	ASSERT(bpl->bpl_queue == NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
	if (bpl->bpl_cached_dbuf) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
    99
		dmu_buf_rele(bpl->bpl_cached_dbuf, bpl);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
		bpl->bpl_cached_dbuf = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
	if (bpl->bpl_dbuf) {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   103
		dmu_buf_rele(bpl->bpl_dbuf, bpl);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
		bpl->bpl_dbuf = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
		bpl->bpl_phys = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
	mutex_exit(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
boolean_t
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
bplist_empty(bplist_t *bpl)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
	boolean_t rv;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
	if (bpl->bpl_object == 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
		return (B_TRUE);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
	mutex_enter(&bpl->bpl_lock);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   120
	VERIFY(0 == bplist_hold(bpl)); /* XXX */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
	rv = (bpl->bpl_phys->bpl_entries == 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
	mutex_exit(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   123
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   124
	return (rv);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   125
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   126
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   127
static int
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   128
bplist_cache(bplist_t *bpl, uint64_t blkid)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   129
{
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   130
	int err = 0;
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   131
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   132
	if (bpl->bpl_cached_dbuf == NULL ||
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   133
	    bpl->bpl_cached_dbuf->db_offset != (blkid << bpl->bpl_blockshift)) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   134
		if (bpl->bpl_cached_dbuf != NULL)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   135
			dmu_buf_rele(bpl->bpl_cached_dbuf, bpl);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   136
		err = dmu_buf_hold(bpl->bpl_mos,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   137
		    bpl->bpl_object, blkid << bpl->bpl_blockshift,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   138
		    bpl, &bpl->bpl_cached_dbuf);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   139
		ASSERT(err || bpl->bpl_cached_dbuf->db_size ==
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   140
		    1ULL << bpl->bpl_blockshift);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   141
	}
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   142
	return (err);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   143
}
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   144
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   145
int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   146
bplist_iterate(bplist_t *bpl, uint64_t *itorp, blkptr_t *bp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   147
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   148
	uint64_t blk, off;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   149
	blkptr_t *bparray;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   150
	int err;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   151
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   152
	mutex_enter(&bpl->bpl_lock);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   153
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   154
	err = bplist_hold(bpl);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   155
	if (err) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   156
		mutex_exit(&bpl->bpl_lock);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   157
		return (err);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   158
	}
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   159
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   160
	if (*itorp >= bpl->bpl_phys->bpl_entries) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   161
		mutex_exit(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   162
		return (ENOENT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   163
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   164
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   165
	blk = *itorp >> bpl->bpl_bpshift;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   166
	off = P2PHASE(*itorp, 1ULL << bpl->bpl_bpshift);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   167
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   168
	err = bplist_cache(bpl, blk);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   169
	if (err) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   170
		mutex_exit(&bpl->bpl_lock);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   171
		return (err);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   172
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   173
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   174
	bparray = bpl->bpl_cached_dbuf->db_data;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   175
	*bp = bparray[off];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   176
	(*itorp)++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   177
	mutex_exit(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   178
	return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   179
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   180
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   181
int
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 5367
diff changeset
   182
bplist_enqueue(bplist_t *bpl, const blkptr_t *bp, dmu_tx_t *tx)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   183
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   184
	uint64_t blk, off;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   185
	blkptr_t *bparray;
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   186
	int err;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   187
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   188
	ASSERT(!BP_IS_HOLE(bp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   189
	mutex_enter(&bpl->bpl_lock);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   190
	err = bplist_hold(bpl);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   191
	if (err)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   192
		return (err);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   193
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   194
	blk = bpl->bpl_phys->bpl_entries >> bpl->bpl_bpshift;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   195
	off = P2PHASE(bpl->bpl_phys->bpl_entries, 1ULL << bpl->bpl_bpshift);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   196
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   197
	err = bplist_cache(bpl, blk);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   198
	if (err) {
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   199
		mutex_exit(&bpl->bpl_lock);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   200
		return (err);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   201
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   202
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   203
	dmu_buf_will_dirty(bpl->bpl_cached_dbuf, tx);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   204
	bparray = bpl->bpl_cached_dbuf->db_data;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   205
	bparray[off] = *bp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   206
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   207
	/* We never need the fill count. */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   208
	bparray[off].blk_fill = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   210
	/* The bplist will compress better if we can leave off the checksum */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
	bzero(&bparray[off].blk_cksum, sizeof (bparray[off].blk_cksum));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   212
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   213
	dmu_buf_will_dirty(bpl->bpl_dbuf, tx);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   214
	bpl->bpl_phys->bpl_entries++;
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   215
	bpl->bpl_phys->bpl_bytes +=
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   216
	    bp_get_dasize(dmu_objset_spa(bpl->bpl_mos), bp);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   217
	if (bpl->bpl_havecomp) {
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   218
		bpl->bpl_phys->bpl_comp += BP_GET_PSIZE(bp);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   219
		bpl->bpl_phys->bpl_uncomp += BP_GET_UCSIZE(bp);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   220
	}
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
	mutex_exit(&bpl->bpl_lock);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   222
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   223
	return (0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   224
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   225
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   226
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   227
 * Deferred entry; will be written later by bplist_sync().
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   228
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   229
void
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 5367
diff changeset
   230
bplist_enqueue_deferred(bplist_t *bpl, const blkptr_t *bp)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   231
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   232
	bplist_q_t *bpq = kmem_alloc(sizeof (*bpq), KM_SLEEP);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   233
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   234
	ASSERT(!BP_IS_HOLE(bp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   235
	mutex_enter(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
	bpq->bpq_blk = *bp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   237
	bpq->bpq_next = bpl->bpl_queue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   238
	bpl->bpl_queue = bpq;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   239
	mutex_exit(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   240
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   241
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   242
void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   243
bplist_sync(bplist_t *bpl, dmu_tx_t *tx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   244
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   245
	bplist_q_t *bpq;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   246
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   247
	mutex_enter(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   248
	while ((bpq = bpl->bpl_queue) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   249
		bpl->bpl_queue = bpq->bpq_next;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   250
		mutex_exit(&bpl->bpl_lock);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   251
		VERIFY(0 == bplist_enqueue(bpl, &bpq->bpq_blk, tx));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   252
		kmem_free(bpq, sizeof (*bpq));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   253
		mutex_enter(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   254
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   255
	mutex_exit(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   256
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   257
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   258
void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   259
bplist_vacate(bplist_t *bpl, dmu_tx_t *tx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   260
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   261
	mutex_enter(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   262
	ASSERT3P(bpl->bpl_queue, ==, NULL);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   263
	VERIFY(0 == bplist_hold(bpl));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   264
	dmu_buf_will_dirty(bpl->bpl_dbuf, tx);
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   265
	VERIFY(0 == dmu_free_range(bpl->bpl_mos,
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 789
diff changeset
   266
	    bpl->bpl_object, 0, -1ULL, tx));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   267
	bpl->bpl_phys->bpl_entries = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   268
	bpl->bpl_phys->bpl_bytes = 0;
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   269
	if (bpl->bpl_havecomp) {
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   270
		bpl->bpl_phys->bpl_comp = 0;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   271
		bpl->bpl_phys->bpl_uncomp = 0;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   272
	}
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   273
	mutex_exit(&bpl->bpl_lock);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   274
}
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   275
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   276
int
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   277
bplist_space(bplist_t *bpl, uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   278
{
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   279
	int err;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   280
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   281
	mutex_enter(&bpl->bpl_lock);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   282
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   283
	err = bplist_hold(bpl);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   284
	if (err) {
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   285
		mutex_exit(&bpl->bpl_lock);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   286
		return (err);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   287
	}
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   288
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   289
	*usedp = bpl->bpl_phys->bpl_bytes;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   290
	if (bpl->bpl_havecomp) {
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   291
		*compp = bpl->bpl_phys->bpl_comp;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   292
		*uncompp = bpl->bpl_phys->bpl_uncomp;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   293
	}
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   294
	mutex_exit(&bpl->bpl_lock);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   295
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   296
	if (!bpl->bpl_havecomp) {
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 4577
diff changeset
   297
		uint64_t itor = 0, comp = 0, uncomp = 0;
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 4577
diff changeset
   298
		blkptr_t bp;
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 4577
diff changeset
   299
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   300
		while ((err = bplist_iterate(bpl, &itor, &bp)) == 0) {
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   301
			comp += BP_GET_PSIZE(&bp);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   302
			uncomp += BP_GET_UCSIZE(&bp);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   303
		}
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   304
		if (err == ENOENT)
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   305
			err = 0;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   306
		*compp = comp;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   307
		*uncompp = uncomp;
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   308
	}
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   309
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   310
	return (err);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1544
diff changeset
   311
}
7390
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   312
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   313
/*
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   314
 * Return (in *dasizep) the amount of space on the deadlist which is:
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   315
 * mintxg < blk_birth <= maxtxg
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   316
 */
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   317
int
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   318
bplist_space_birthrange(bplist_t *bpl, uint64_t mintxg, uint64_t maxtxg,
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   319
    uint64_t *dasizep)
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   320
{
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   321
	uint64_t size = 0;
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   322
	uint64_t itor = 0;
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   323
	blkptr_t bp;
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   324
	int err;
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   325
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   326
	/*
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   327
	 * As an optimization, if they want the whole txg range, just
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   328
	 * get bpl_bytes rather than iterating over the bps.
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   329
	 */
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   330
	if (mintxg < TXG_INITIAL && maxtxg == UINT64_MAX) {
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   331
		mutex_enter(&bpl->bpl_lock);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   332
		err = bplist_hold(bpl);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   333
		if (err == 0)
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   334
			*dasizep = bpl->bpl_phys->bpl_bytes;
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   335
		mutex_exit(&bpl->bpl_lock);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   336
		return (err);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   337
	}
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   338
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   339
	while ((err = bplist_iterate(bpl, &itor, &bp)) == 0) {
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   340
		if (bp.blk_birth > mintxg && bp.blk_birth <= maxtxg) {
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   341
			size +=
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   342
			    bp_get_dasize(dmu_objset_spa(bpl->bpl_mos), &bp);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   343
		}
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   344
	}
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   345
	if (err == ENOENT)
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   346
		err = 0;
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   347
	*dasizep = size;
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   348
	return (err);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7046
diff changeset
   349
}