usr/src/uts/common/fs/zfs/bpobj.c
author George Wilson <George.Wilson@Sun.COM>
Tue, 08 Jun 2010 13:36:53 -0700
changeset 12587 16aef3d16470
parent 12538 bb02b9cd2b96
child 12593 3c3a4d3d1dda
permissions -rw-r--r--
6957090 ddt_zap_prefetch() induces deadlock, panic 6958874 bpobj_close() tries to dereference a NULL bpo_dbuf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
     1
/*
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
     2
 * CDDL HEADER START
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
     3
 *
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
     7
 *
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    11
 * and limitations under the License.
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    12
 *
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    18
 *
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    19
 * CDDL HEADER END
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    20
 */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    21
/*
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    22
 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    23
 */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    24
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    25
#include <sys/bpobj.h>
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    26
#include <sys/zfs_context.h>
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    27
#include <sys/refcount.h>
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    28
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    29
uint64_t
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    30
bpobj_alloc(objset_t *os, int blocksize, dmu_tx_t *tx)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    31
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    32
	int size;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    33
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    34
	if (spa_version(dmu_objset_spa(os)) < SPA_VERSION_BPOBJ_ACCOUNT)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    35
		size = BPOBJ_SIZE_V0;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    36
	else if (spa_version(dmu_objset_spa(os)) < SPA_VERSION_DEADLISTS)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    37
		size = BPOBJ_SIZE_V1;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    38
	else
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    39
		size = sizeof (bpobj_phys_t);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    40
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    41
	return (dmu_object_alloc(os, DMU_OT_BPOBJ, blocksize,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    42
	    DMU_OT_BPOBJ_HDR, size, tx));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    43
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    44
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    45
void
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    46
bpobj_free(objset_t *os, uint64_t obj, dmu_tx_t *tx)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    47
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    48
	int64_t i;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    49
	bpobj_t bpo;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    50
	dmu_object_info_t doi;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    51
	int epb;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    52
	dmu_buf_t *dbuf = NULL;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    53
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    54
	VERIFY3U(0, ==, bpobj_open(&bpo, os, obj));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    55
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    56
	mutex_enter(&bpo.bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    57
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    58
	if (!bpo.bpo_havesubobj || bpo.bpo_phys->bpo_subobjs == 0)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    59
		goto out;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    60
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    61
	VERIFY3U(0, ==, dmu_object_info(os, bpo.bpo_phys->bpo_subobjs, &doi));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    62
	epb = doi.doi_data_block_size / sizeof (uint64_t);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    63
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    64
	for (i = bpo.bpo_phys->bpo_num_subobjs - 1; i >= 0; i--) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    65
		uint64_t *objarray;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    66
		uint64_t offset, blkoff;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    67
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    68
		offset = i * sizeof (uint64_t);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    69
		blkoff = P2PHASE(i, epb);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    70
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    71
		if (dbuf == NULL || dbuf->db_offset > offset) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    72
			if (dbuf)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    73
				dmu_buf_rele(dbuf, FTAG);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    74
			VERIFY3U(0, ==, dmu_buf_hold(os,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    75
			    bpo.bpo_phys->bpo_subobjs, offset, FTAG, &dbuf, 0));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    76
		}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    77
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    78
		ASSERT3U(offset, >=, dbuf->db_offset);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    79
		ASSERT3U(offset, <, dbuf->db_offset + dbuf->db_size);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    80
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    81
		objarray = dbuf->db_data;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    82
		bpobj_free(os, objarray[blkoff], tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    83
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    84
	if (dbuf) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    85
		dmu_buf_rele(dbuf, FTAG);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    86
		dbuf = NULL;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    87
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    88
	VERIFY3U(0, ==, dmu_object_free(os, bpo.bpo_phys->bpo_subobjs, tx));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    89
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    90
out:
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    91
	mutex_exit(&bpo.bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    92
	bpobj_close(&bpo);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    93
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    94
	VERIFY3U(0, ==, dmu_object_free(os, obj, tx));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    95
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    96
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    97
int
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    98
bpobj_open(bpobj_t *bpo, objset_t *os, uint64_t object)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
    99
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   100
	dmu_object_info_t doi;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   101
	int err;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   102
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   103
	err = dmu_object_info(os, object, &doi);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   104
	if (err)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   105
		return (err);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   106
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   107
	bzero(bpo, sizeof (*bpo));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   108
	mutex_init(&bpo->bpo_lock, NULL, MUTEX_DEFAULT, NULL);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   109
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   110
	ASSERT(bpo->bpo_dbuf == NULL);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   111
	ASSERT(bpo->bpo_phys == NULL);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   112
	ASSERT(object != 0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   113
	ASSERT3U(doi.doi_type, ==, DMU_OT_BPOBJ);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   114
	ASSERT3U(doi.doi_bonus_type, ==, DMU_OT_BPOBJ_HDR);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   115
12587
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12538
diff changeset
   116
	err = dmu_bonus_hold(os, object, bpo, &bpo->bpo_dbuf);
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12538
diff changeset
   117
	if (err)
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12538
diff changeset
   118
		return (err);
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12538
diff changeset
   119
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   120
	bpo->bpo_os = os;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   121
	bpo->bpo_object = object;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   122
	bpo->bpo_epb = doi.doi_data_block_size >> SPA_BLKPTRSHIFT;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   123
	bpo->bpo_havecomp = (doi.doi_bonus_size > BPOBJ_SIZE_V0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   124
	bpo->bpo_havesubobj = (doi.doi_bonus_size > BPOBJ_SIZE_V1);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   125
	bpo->bpo_phys = bpo->bpo_dbuf->db_data;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   126
	return (0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   127
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   128
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   129
void
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   130
bpobj_close(bpobj_t *bpo)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   131
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   132
	/* Lame workaround for closing a bpobj that was never opened. */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   133
	if (bpo->bpo_object == 0)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   134
		return;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   135
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   136
	dmu_buf_rele(bpo->bpo_dbuf, bpo);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   137
	if (bpo->bpo_cached_dbuf != NULL)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   138
		dmu_buf_rele(bpo->bpo_cached_dbuf, bpo);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   139
	bpo->bpo_dbuf = NULL;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   140
	bpo->bpo_phys = NULL;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   141
	bpo->bpo_cached_dbuf = NULL;
12587
16aef3d16470 6957090 ddt_zap_prefetch() induces deadlock, panic
George Wilson <George.Wilson@Sun.COM>
parents: 12538
diff changeset
   142
	bpo->bpo_object = 0;
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   143
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   144
	mutex_destroy(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   145
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   146
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   147
static int
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   148
bpobj_iterate_impl(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   149
    boolean_t free)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   150
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   151
	dmu_object_info_t doi;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   152
	int epb;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   153
	int64_t i;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   154
	int err = 0;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   155
	dmu_buf_t *dbuf = NULL;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   156
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   157
	mutex_enter(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   158
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   159
	if (free)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   160
		dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   161
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   162
	for (i = bpo->bpo_phys->bpo_num_blkptrs - 1; i >= 0; i--) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   163
		blkptr_t *bparray;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   164
		blkptr_t *bp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   165
		uint64_t offset, blkoff;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   166
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   167
		offset = i * sizeof (blkptr_t);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   168
		blkoff = P2PHASE(i, bpo->bpo_epb);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   169
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   170
		if (dbuf == NULL || dbuf->db_offset > offset) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   171
			if (dbuf)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   172
				dmu_buf_rele(dbuf, FTAG);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   173
			err = dmu_buf_hold(bpo->bpo_os, bpo->bpo_object, offset,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   174
			    FTAG, &dbuf, 0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   175
			if (err)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   176
				break;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   177
		}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   178
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   179
		ASSERT3U(offset, >=, dbuf->db_offset);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   180
		ASSERT3U(offset, <, dbuf->db_offset + dbuf->db_size);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   181
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   182
		bparray = dbuf->db_data;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   183
		bp = &bparray[blkoff];
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   184
		err = func(arg, bp, tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   185
		if (err)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   186
			break;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   187
		if (free) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   188
			bpo->bpo_phys->bpo_bytes -=
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   189
			    bp_get_dsize_sync(dmu_objset_spa(bpo->bpo_os), bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   190
			ASSERT3S(bpo->bpo_phys->bpo_bytes, >=, 0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   191
			if (bpo->bpo_havecomp) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   192
				bpo->bpo_phys->bpo_comp -= BP_GET_PSIZE(bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   193
				bpo->bpo_phys->bpo_uncomp -= BP_GET_UCSIZE(bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   194
			}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   195
			bpo->bpo_phys->bpo_num_blkptrs--;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   196
			ASSERT3S(bpo->bpo_phys->bpo_num_blkptrs, >=, 0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   197
		}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   198
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   199
	if (dbuf) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   200
		dmu_buf_rele(dbuf, FTAG);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   201
		dbuf = NULL;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   202
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   203
	if (free) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   204
		i++;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   205
		VERIFY3U(0, ==, dmu_free_range(bpo->bpo_os, bpo->bpo_object,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   206
		    i * sizeof (blkptr_t), -1ULL, tx));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   207
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   208
	if (err || !bpo->bpo_havesubobj || bpo->bpo_phys->bpo_subobjs == 0)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   209
		goto out;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   210
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   211
	ASSERT(bpo->bpo_havecomp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   212
	err = dmu_object_info(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs, &doi);
12538
bb02b9cd2b96 6956280 mutex problem in bpobj_iterate_impl()
Lin Ling <Lin.Ling@Sun.COM>
parents: 12470
diff changeset
   213
	if (err) {
bb02b9cd2b96 6956280 mutex problem in bpobj_iterate_impl()
Lin Ling <Lin.Ling@Sun.COM>
parents: 12470
diff changeset
   214
		mutex_exit(&bpo->bpo_lock);
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   215
		return (err);
12538
bb02b9cd2b96 6956280 mutex problem in bpobj_iterate_impl()
Lin Ling <Lin.Ling@Sun.COM>
parents: 12470
diff changeset
   216
	}
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   217
	epb = doi.doi_data_block_size / sizeof (uint64_t);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   218
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   219
	for (i = bpo->bpo_phys->bpo_num_subobjs - 1; i >= 0; i--) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   220
		uint64_t *objarray;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   221
		uint64_t offset, blkoff;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   222
		bpobj_t sublist;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   223
		uint64_t used_before, comp_before, uncomp_before;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   224
		uint64_t used_after, comp_after, uncomp_after;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   225
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   226
		offset = i * sizeof (uint64_t);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   227
		blkoff = P2PHASE(i, epb);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   228
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   229
		if (dbuf == NULL || dbuf->db_offset > offset) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   230
			if (dbuf)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   231
				dmu_buf_rele(dbuf, FTAG);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   232
			err = dmu_buf_hold(bpo->bpo_os,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   233
			    bpo->bpo_phys->bpo_subobjs, offset, FTAG, &dbuf, 0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   234
			if (err)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   235
				break;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   236
		}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   237
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   238
		ASSERT3U(offset, >=, dbuf->db_offset);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   239
		ASSERT3U(offset, <, dbuf->db_offset + dbuf->db_size);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   240
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   241
		objarray = dbuf->db_data;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   242
		err = bpobj_open(&sublist, bpo->bpo_os, objarray[blkoff]);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   243
		if (err)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   244
			break;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   245
		if (free) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   246
			err = bpobj_space(&sublist,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   247
			    &used_before, &comp_before, &uncomp_before);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   248
			if (err)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   249
				break;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   250
		}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   251
		err = bpobj_iterate_impl(&sublist, func, arg, tx, free);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   252
		if (free) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   253
			VERIFY3U(0, ==, bpobj_space(&sublist,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   254
			    &used_after, &comp_after, &uncomp_after));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   255
			bpo->bpo_phys->bpo_bytes -= used_before - used_after;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   256
			ASSERT3S(bpo->bpo_phys->bpo_bytes, >=, 0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   257
			bpo->bpo_phys->bpo_comp -= comp_before - used_after;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   258
			bpo->bpo_phys->bpo_uncomp -=
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   259
			    uncomp_before - uncomp_after;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   260
		}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   261
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   262
		bpobj_close(&sublist);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   263
		if (err)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   264
			break;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   265
		if (free) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   266
			err = dmu_object_free(bpo->bpo_os,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   267
			    objarray[blkoff], tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   268
			if (err)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   269
				break;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   270
			bpo->bpo_phys->bpo_num_subobjs--;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   271
			ASSERT3S(bpo->bpo_phys->bpo_num_subobjs, >=, 0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   272
		}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   273
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   274
	if (dbuf) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   275
		dmu_buf_rele(dbuf, FTAG);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   276
		dbuf = NULL;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   277
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   278
	if (free) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   279
		VERIFY3U(0, ==, dmu_free_range(bpo->bpo_os,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   280
		    bpo->bpo_phys->bpo_subobjs,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   281
		    (i + 1) * sizeof (uint64_t), -1ULL, tx));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   282
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   283
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   284
out:
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   285
	/* If there are no entries, there should be no bytes. */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   286
	ASSERT(bpo->bpo_phys->bpo_num_blkptrs > 0 ||
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   287
	    (bpo->bpo_havesubobj && bpo->bpo_phys->bpo_num_subobjs > 0) ||
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   288
	    bpo->bpo_phys->bpo_bytes == 0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   289
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   290
	mutex_exit(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   291
	return (err);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   292
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   293
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   294
/*
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   295
 * Iterate and remove the entries.  If func returns nonzero, iteration
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   296
 * will stop and that entry will not be removed.
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   297
 */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   298
int
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   299
bpobj_iterate(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   300
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   301
	return (bpobj_iterate_impl(bpo, func, arg, tx, B_TRUE));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   302
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   303
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   304
/*
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   305
 * Iterate the entries.  If func returns nonzero, iteration will stop.
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   306
 */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   307
int
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   308
bpobj_iterate_nofree(bpobj_t *bpo, bpobj_itor_t func, void *arg, dmu_tx_t *tx)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   309
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   310
	return (bpobj_iterate_impl(bpo, func, arg, tx, B_FALSE));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   311
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   312
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   313
void
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   314
bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   315
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   316
	bpobj_t subbpo;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   317
	uint64_t used, comp, uncomp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   318
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   319
	ASSERT(bpo->bpo_havesubobj);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   320
	ASSERT(bpo->bpo_havecomp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   321
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   322
	VERIFY3U(0, ==, bpobj_open(&subbpo, bpo->bpo_os, subobj));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   323
	VERIFY3U(0, ==, bpobj_space(&subbpo, &used, &comp, &uncomp));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   324
	bpobj_close(&subbpo);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   325
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   326
	if (used == 0) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   327
		/* No point in having an empty subobj. */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   328
		bpobj_free(bpo->bpo_os, subobj, tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   329
		return;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   330
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   331
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   332
	dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   333
	if (bpo->bpo_phys->bpo_subobjs == 0) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   334
		bpo->bpo_phys->bpo_subobjs = dmu_object_alloc(bpo->bpo_os,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   335
		    DMU_OT_BPOBJ_SUBOBJ, SPA_MAXBLOCKSIZE, DMU_OT_NONE, 0, tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   336
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   337
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   338
	mutex_enter(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   339
	dmu_write(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   340
	    bpo->bpo_phys->bpo_num_subobjs * sizeof (subobj),
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   341
	    sizeof (subobj), &subobj, tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   342
	bpo->bpo_phys->bpo_num_subobjs++;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   343
	bpo->bpo_phys->bpo_bytes += used;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   344
	bpo->bpo_phys->bpo_comp += comp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   345
	bpo->bpo_phys->bpo_uncomp += uncomp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   346
	mutex_exit(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   347
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   348
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   349
void
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   350
bpobj_enqueue(bpobj_t *bpo, const blkptr_t *bp, dmu_tx_t *tx)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   351
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   352
	blkptr_t stored_bp = *bp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   353
	uint64_t offset;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   354
	int blkoff;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   355
	blkptr_t *bparray;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   356
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   357
	ASSERT(!BP_IS_HOLE(bp));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   358
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   359
	/* We never need the fill count. */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   360
	stored_bp.blk_fill = 0;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   361
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   362
	/* The bpobj will compress better if we can leave off the checksum */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   363
	if (!BP_GET_DEDUP(bp))
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   364
		bzero(&stored_bp.blk_cksum, sizeof (stored_bp.blk_cksum));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   365
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   366
	mutex_enter(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   367
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   368
	offset = bpo->bpo_phys->bpo_num_blkptrs * sizeof (stored_bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   369
	blkoff = P2PHASE(bpo->bpo_phys->bpo_num_blkptrs, bpo->bpo_epb);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   370
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   371
	if (bpo->bpo_cached_dbuf == NULL ||
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   372
	    offset < bpo->bpo_cached_dbuf->db_offset ||
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   373
	    offset >= bpo->bpo_cached_dbuf->db_offset +
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   374
	    bpo->bpo_cached_dbuf->db_size) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   375
		if (bpo->bpo_cached_dbuf)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   376
			dmu_buf_rele(bpo->bpo_cached_dbuf, bpo);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   377
		VERIFY3U(0, ==, dmu_buf_hold(bpo->bpo_os, bpo->bpo_object,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   378
		    offset, bpo, &bpo->bpo_cached_dbuf, 0));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   379
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   380
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   381
	dmu_buf_will_dirty(bpo->bpo_cached_dbuf, tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   382
	bparray = bpo->bpo_cached_dbuf->db_data;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   383
	bparray[blkoff] = stored_bp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   384
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   385
	dmu_buf_will_dirty(bpo->bpo_dbuf, tx);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   386
	bpo->bpo_phys->bpo_num_blkptrs++;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   387
	bpo->bpo_phys->bpo_bytes +=
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   388
	    bp_get_dsize_sync(dmu_objset_spa(bpo->bpo_os), bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   389
	if (bpo->bpo_havecomp) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   390
		bpo->bpo_phys->bpo_comp += BP_GET_PSIZE(bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   391
		bpo->bpo_phys->bpo_uncomp += BP_GET_UCSIZE(bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   392
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   393
	mutex_exit(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   394
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   395
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   396
struct space_range_arg {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   397
	spa_t *spa;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   398
	uint64_t mintxg;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   399
	uint64_t maxtxg;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   400
	uint64_t used;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   401
	uint64_t comp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   402
	uint64_t uncomp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   403
};
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   404
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   405
/* ARGSUSED */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   406
static int
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   407
space_range_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   408
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   409
	struct space_range_arg *sra = arg;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   410
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   411
	if (bp->blk_birth > sra->mintxg && bp->blk_birth <= sra->maxtxg) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   412
		sra->used += bp_get_dsize_sync(sra->spa, bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   413
		sra->comp += BP_GET_PSIZE(bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   414
		sra->uncomp += BP_GET_UCSIZE(bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   415
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   416
	return (0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   417
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   418
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   419
int
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   420
bpobj_space(bpobj_t *bpo, uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   421
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   422
	mutex_enter(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   423
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   424
	*usedp = bpo->bpo_phys->bpo_bytes;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   425
	if (bpo->bpo_havecomp) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   426
		*compp = bpo->bpo_phys->bpo_comp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   427
		*uncompp = bpo->bpo_phys->bpo_uncomp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   428
		mutex_exit(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   429
		return (0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   430
	} else {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   431
		mutex_exit(&bpo->bpo_lock);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   432
		return (bpobj_space_range(bpo, 0, UINT64_MAX,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   433
		    usedp, compp, uncompp));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   434
	}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   435
}
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   436
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   437
/*
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   438
 * Return the amount of space in the bpobj which is:
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   439
 * mintxg < blk_birth <= maxtxg
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   440
 */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   441
int
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   442
bpobj_space_range(bpobj_t *bpo, uint64_t mintxg, uint64_t maxtxg,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   443
    uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   444
{
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   445
	struct space_range_arg sra = { 0 };
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   446
	int err;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   447
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   448
	/*
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   449
	 * As an optimization, if they want the whole txg range, just
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   450
	 * get bpo_bytes rather than iterating over the bps.
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   451
	 */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   452
	if (mintxg < TXG_INITIAL && maxtxg == UINT64_MAX && bpo->bpo_havecomp)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   453
		return (bpobj_space(bpo, usedp, compp, uncompp));
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   454
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   455
	sra.spa = dmu_objset_spa(bpo->bpo_os);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   456
	sra.mintxg = mintxg;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   457
	sra.maxtxg = maxtxg;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   458
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   459
	err = bpobj_iterate_nofree(bpo, space_range_cb, &sra, NULL);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   460
	*usedp = sra.used;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   461
	*compp = sra.comp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   462
	*uncompp = sra.uncomp;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   463
	return (err);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
diff changeset
   464
}