git://git.camperquake.de
/
zfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Register correct handlers in nvlist_alloc()
[zfs.git]
/
module
/
zfs
/
dnode_sync.c
diff --git
a/module/zfs/dnode_sync.c
b/module/zfs/dnode_sync.c
index
f9ec9f6
..
76e6037
100644
(file)
--- a/
module/zfs/dnode_sync.c
+++ b/
module/zfs/dnode_sync.c
@@
-18,8
+18,10
@@
*
* CDDL HEADER END
*/
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
*/
#include <sys/zfs_context.h>
@@
-76,7
+78,11
@@
dnode_increase_indirection(dnode_t *dn, dmu_tx_t *tx)
if (child == NULL)
continue;
if (child == NULL)
continue;
- ASSERT3P(child->db_dnode, ==, dn);
+#ifdef DEBUG
+ DB_DNODE_ENTER(child);
+ ASSERT3P(DB_DNODE(child), ==, dn);
+ DB_DNODE_EXIT(child);
+#endif /* DEBUG */
if (child->db_parent && child->db_parent != dn->dn_dbuf) {
ASSERT(child->db_parent->db_level == db->db_level);
ASSERT(child->db_blkptr !=
if (child->db_parent && child->db_parent != dn->dn_dbuf) {
ASSERT(child->db_parent->db_level == db->db_level);
ASSERT(child->db_blkptr !=
@@
-135,15
+141,18
@@
free_verify(dmu_buf_impl_t *db, uint64_t start, uint64_t end, dmu_tx_t *tx)
int off, num;
int i, err, epbs;
uint64_t txg = tx->tx_txg;
int off, num;
int i, err, epbs;
uint64_t txg = tx->tx_txg;
+ dnode_t *dn;
- epbs = db->db_dnode->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
+ DB_DNODE_ENTER(db);
+ dn = DB_DNODE(db);
+ epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
off = start - (db->db_blkid * 1<<epbs);
num = end - start + 1;
ASSERT3U(off, >=, 0);
ASSERT3U(num, >=, 0);
ASSERT3U(db->db_level, >, 0);
off = start - (db->db_blkid * 1<<epbs);
num = end - start + 1;
ASSERT3U(off, >=, 0);
ASSERT3U(num, >=, 0);
ASSERT3U(db->db_level, >, 0);
- ASSERT3U(db->db.db_size, ==, 1
<<db->db_dnode
->dn_phys->dn_indblkshift);
+ ASSERT3U(db->db.db_size, ==, 1
<< dn
->dn_phys->dn_indblkshift);
ASSERT3U(off+num, <=, db->db.db_size >> SPA_BLKPTRSHIFT);
ASSERT(db->db_blkptr != NULL);
ASSERT3U(off+num, <=, db->db.db_size >> SPA_BLKPTRSHIFT);
ASSERT(db->db_blkptr != NULL);
@@
-155,10
+164,10
@@
free_verify(dmu_buf_impl_t *db, uint64_t start, uint64_t end, dmu_tx_t *tx)
ASSERT(db->db_level == 1);
ASSERT(db->db_level == 1);
- rw_enter(&d
b->db_dnode
->dn_struct_rwlock, RW_READER);
- err = dbuf_hold_impl(d
b->db_dnode
, db->db_level-1,
+ rw_enter(&d
n
->dn_struct_rwlock, RW_READER);
+ err = dbuf_hold_impl(d
n
, db->db_level-1,
(db->db_blkid << epbs) + i, TRUE, FTAG, &child);
(db->db_blkid << epbs) + i, TRUE, FTAG, &child);
- rw_exit(&d
b->db_dnode
->dn_struct_rwlock);
+ rw_exit(&d
n
->dn_struct_rwlock);
if (err == ENOENT)
continue;
ASSERT(err == 0);
if (err == ENOENT)
continue;
ASSERT(err == 0);
@@
-200,6
+209,7
@@
free_verify(dmu_buf_impl_t *db, uint64_t start, uint64_t end, dmu_tx_t *tx)
dbuf_rele(child, FTAG);
}
dbuf_rele(child, FTAG);
}
+ DB_DNODE_EXIT(db);
}
#endif
}
#endif
@@
-209,7
+219,7
@@
static int
free_children(dmu_buf_impl_t *db, uint64_t blkid, uint64_t nblks, int trunc,
dmu_tx_t *tx)
{
free_children(dmu_buf_impl_t *db, uint64_t blkid, uint64_t nblks, int trunc,
dmu_tx_t *tx)
{
- dnode_t *dn
= db->db_dnode
;
+ dnode_t *dn;
blkptr_t *bp;
dmu_buf_impl_t *subdb;
uint64_t start, end, dbstart, dbend, i;
blkptr_t *bp;
dmu_buf_impl_t *subdb;
uint64_t start, end, dbstart, dbend, i;
@@
-230,7
+240,9
@@
free_children(dmu_buf_impl_t *db, uint64_t blkid, uint64_t nblks, int trunc,
dbuf_release_bp(db);
bp = (blkptr_t *)db->db.db_data;
dbuf_release_bp(db);
bp = (blkptr_t *)db->db.db_data;
- epbs = db->db_dnode->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
+ DB_DNODE_ENTER(db);
+ dn = DB_DNODE(db);
+ epbs = dn->dn_phys->dn_indblkshift - SPA_BLKPTRSHIFT;
shift = (db->db_level - 1) * epbs;
dbstart = db->db_blkid << epbs;
start = blkid >> shift;
shift = (db->db_level - 1) * epbs;
dbstart = db->db_blkid << epbs;
start = blkid >> shift;
@@
-253,6
+265,7
@@
free_children(dmu_buf_impl_t *db, uint64_t blkid, uint64_t nblks, int trunc,
blocks_freed = free_blocks(dn, bp, end-start+1, tx);
arc_buf_freeze(db->db_buf);
ASSERT(all || blocks_freed == 0 || db->db_last_dirty);
blocks_freed = free_blocks(dn, bp, end-start+1, tx);
arc_buf_freeze(db->db_buf);
ASSERT(all || blocks_freed == 0 || db->db_last_dirty);
+ DB_DNODE_EXIT(db);
return (all ? ALL : blocks_freed);
}
return (all ? ALL : blocks_freed);
}
@@
-261,7
+274,7
@@
free_children(dmu_buf_impl_t *db, uint64_t blkid, uint64_t nblks, int trunc,
continue;
rw_enter(&dn->dn_struct_rwlock, RW_READER);
err = dbuf_hold_impl(dn, db->db_level-1, i, TRUE, FTAG, &subdb);
continue;
rw_enter(&dn->dn_struct_rwlock, RW_READER);
err = dbuf_hold_impl(dn, db->db_level-1, i, TRUE, FTAG, &subdb);
- ASSERT
3U(err, ==, 0
);
+ ASSERT
0(err
);
rw_exit(&dn->dn_struct_rwlock);
if (free_children(subdb, blkid, nblks, trunc, tx) == ALL) {
rw_exit(&dn->dn_struct_rwlock);
if (free_children(subdb, blkid, nblks, trunc, tx) == ALL) {
@@
-272,6
+285,7
@@
free_children(dmu_buf_impl_t *db, uint64_t blkid, uint64_t nblks, int trunc,
}
dbuf_rele(subdb, FTAG);
}
}
dbuf_rele(subdb, FTAG);
}
+ DB_DNODE_EXIT(db);
arc_buf_freeze(db->db_buf);
#ifdef ZFS_DEBUG
bp -= (end-start)+1;
arc_buf_freeze(db->db_buf);
#ifdef ZFS_DEBUG
bp -= (end-start)+1;
@@
-280,7
+294,7
@@
free_children(dmu_buf_impl_t *db, uint64_t blkid, uint64_t nblks, int trunc,
continue;
else if (i == end && !trunc)
continue;
continue;
else if (i == end && !trunc)
continue;
- ASSERT
3U(bp->blk_birth, ==, 0
);
+ ASSERT
0(bp->blk_birth
);
}
#endif
ASSERT(all || blocks_freed == 0 || db->db_last_dirty);
}
#endif
ASSERT(all || blocks_freed == 0 || db->db_last_dirty);
@@
-316,8
+330,8
@@
dnode_sync_free_range(dnode_t *dn, uint64_t blkid, uint64_t nblks, dmu_tx_t *tx)
ASSERT3U(blkid + nblks, <=, dn->dn_phys->dn_nblkptr);
(void) free_blocks(dn, bp + blkid, nblks, tx);
if (trunc) {
ASSERT3U(blkid + nblks, <=, dn->dn_phys->dn_nblkptr);
(void) free_blocks(dn, bp + blkid, nblks, tx);
if (trunc) {
- uint64_t off = (dn->dn_phys->dn_maxblkid + 1) *
- (dn->dn_phys->dn_datablkszsec
<< SPA_MINBLOCKSHIFT
);
+
ASSERTV(
uint64_t off = (dn->dn_phys->dn_maxblkid + 1) *
+ (dn->dn_phys->dn_datablkszsec
<<SPA_MINBLOCKSHIFT)
);
dn->dn_phys->dn_maxblkid = (blkid ? blkid - 1 : 0);
ASSERT(off < dn->dn_phys->dn_maxblkid ||
dn->dn_phys->dn_maxblkid == 0 ||
dn->dn_phys->dn_maxblkid = (blkid ? blkid - 1 : 0);
ASSERT(off < dn->dn_phys->dn_maxblkid ||
dn->dn_phys->dn_maxblkid == 0 ||
@@
-336,7
+350,7
@@
dnode_sync_free_range(dnode_t *dn, uint64_t blkid, uint64_t nblks, dmu_tx_t *tx)
continue;
rw_enter(&dn->dn_struct_rwlock, RW_READER);
err = dbuf_hold_impl(dn, dnlevel-1, i, TRUE, FTAG, &db);
continue;
rw_enter(&dn->dn_struct_rwlock, RW_READER);
err = dbuf_hold_impl(dn, dnlevel-1, i, TRUE, FTAG, &db);
- ASSERT
3U(err, ==, 0
);
+ ASSERT
0(err
);
rw_exit(&dn->dn_struct_rwlock);
if (free_children(db, blkid, nblks, trunc, tx) == ALL) {
rw_exit(&dn->dn_struct_rwlock);
if (free_children(db, blkid, nblks, trunc, tx) == ALL) {
@@
-346,8
+360,8
@@
dnode_sync_free_range(dnode_t *dn, uint64_t blkid, uint64_t nblks, dmu_tx_t *tx)
dbuf_rele(db, FTAG);
}
if (trunc) {
dbuf_rele(db, FTAG);
}
if (trunc) {
- uint64_t off = (dn->dn_phys->dn_maxblkid + 1) *
- (dn->dn_phys->dn_datablkszsec << SPA_MINBLOCKSHIFT);
+
ASSERTV(
uint64_t off = (dn->dn_phys->dn_maxblkid + 1) *
+ (dn->dn_phys->dn_datablkszsec << SPA_MINBLOCKSHIFT)
)
;
dn->dn_phys->dn_maxblkid = (blkid ? blkid - 1 : 0);
ASSERT(off < dn->dn_phys->dn_maxblkid ||
dn->dn_phys->dn_maxblkid == 0 ||
dn->dn_phys->dn_maxblkid = (blkid ? blkid - 1 : 0);
ASSERT(off < dn->dn_phys->dn_maxblkid ||
dn->dn_phys->dn_maxblkid == 0 ||
@@
-375,7
+389,11
@@
dnode_evict_dbufs(dnode_t *dn)
for (; db != ▮ db = list_head(&dn->dn_dbufs)) {
list_remove(&dn->dn_dbufs, db);
list_insert_tail(&dn->dn_dbufs, db);
for (; db != ▮ db = list_head(&dn->dn_dbufs)) {
list_remove(&dn->dn_dbufs, db);
list_insert_tail(&dn->dn_dbufs, db);
- ASSERT3P(db->db_dnode, ==, dn);
+#ifdef DEBUG
+ DB_DNODE_ENTER(db);
+ ASSERT3P(DB_DNODE(db), ==, dn);
+ DB_DNODE_EXIT(db);
+#endif /* DEBUG */
mutex_enter(&db->db_mtx);
if (db->db_state == DB_EVICTING) {
mutex_enter(&db->db_mtx);
if (db->db_state == DB_EVICTING) {
@@
-402,9
+420,13
@@
dnode_evict_dbufs(dnode_t *dn)
if (evicting)
delay(1);
pass++;
if (evicting)
delay(1);
pass++;
- ASSERT(pass < 100); /* sanity check */
+ if ((pass % 100) == 0)
+ dprintf("Exceeded %d passes evicting dbufs\n", pass);
} while (progress);
} while (progress);
+ if (pass >= 100)
+ dprintf("Required %d passes to evict dbufs\n", pass);
+
rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
if (dn->dn_bonus && refcount_is_zero(&dn->dn_bonus->db_holds)) {
mutex_enter(&dn->dn_bonus->db_mtx);
rw_enter(&dn->dn_struct_rwlock, RW_WRITER);
if (dn->dn_bonus && refcount_is_zero(&dn->dn_bonus->db_holds)) {
mutex_enter(&dn->dn_bonus->db_mtx);
@@
-419,7
+441,7
@@
dnode_undirty_dbufs(list_t *list)
{
dbuf_dirty_record_t *dr;
{
dbuf_dirty_record_t *dr;
- while (
dr = list_head(list
)) {
+ while (
(dr = list_head(list)
)) {
dmu_buf_impl_t *db = dr->dr_dbuf;
uint64_t txg = dr->dr_txg;
dmu_buf_impl_t *db = dr->dr_dbuf;
uint64_t txg = dr->dr_txg;
@@
-453,7
+475,7
@@
dnode_sync_free(dnode_t *dn, dmu_tx_t *tx)
* Our contents should have been freed in dnode_sync() by the
* free range record inserted by the caller of dnode_free().
*/
* Our contents should have been freed in dnode_sync() by the
* free range record inserted by the caller of dnode_free().
*/
- ASSERT
3U(DN_USED_BYTES(dn->dn_phys), ==, 0
);
+ ASSERT
0(DN_USED_BYTES(dn->dn_phys)
);
ASSERT(BP_IS_HOLE(dn->dn_phys->dn_blkptr));
dnode_undirty_dbufs(&dn->dn_dirty_records[txgoff]);
ASSERT(BP_IS_HOLE(dn->dn_phys->dn_blkptr));
dnode_undirty_dbufs(&dn->dn_dirty_records[txgoff]);
@@
-511,8
+533,8
@@
dnode_sync(dnode_t *dn, dmu_tx_t *tx)
dnode_phys_t *dnp = dn->dn_phys;
int txgoff = tx->tx_txg & TXG_MASK;
list_t *list = &dn->dn_dirty_records[txgoff];
dnode_phys_t *dnp = dn->dn_phys;
int txgoff = tx->tx_txg & TXG_MASK;
list_t *list = &dn->dn_dirty_records[txgoff];
- static const dnode_phys_t zerodn = { 0 };
boolean_t kill_spill = B_FALSE;
boolean_t kill_spill = B_FALSE;
+ ASSERTV(static const dnode_phys_t zerodn = { 0 });
ASSERT(dmu_tx_is_syncing(tx));
ASSERT(dnp->dn_type != DMU_OT_NONE || dn->dn_allocated_txg);
ASSERT(dmu_tx_is_syncing(tx));
ASSERT(dnp->dn_type != DMU_OT_NONE || dn->dn_allocated_txg);
@@
-578,7
+600,7
@@
dnode_sync(dnode_t *dn, dmu_tx_t *tx)
}
if (dn->dn_next_bonustype[txgoff]) {
}
if (dn->dn_next_bonustype[txgoff]) {
- ASSERT(
dn->dn_next_bonustype[txgoff] < DMU_OT_NUMTYPES
);
+ ASSERT(
DMU_OT_IS_VALID(dn->dn_next_bonustype[txgoff])
);
dnp->dn_bonustype = dn->dn_next_bonustype[txgoff];
dn->dn_next_bonustype[txgoff] = 0;
}
dnp->dn_bonustype = dn->dn_next_bonustype[txgoff];
dn->dn_next_bonustype[txgoff] = 0;
}
@@
-619,7
+641,7
@@
dnode_sync(dnode_t *dn, dmu_tx_t *tx)
}
/* process all the "freed" ranges in the file */
}
/* process all the "freed" ranges in the file */
- while (
rp = avl_last(&dn->dn_ranges[txgoff]
)) {
+ while (
(rp = avl_last(&dn->dn_ranges[txgoff])
)) {
dnode_sync_free_range(dn, rp->fr_blkid, rp->fr_nblks, tx);
/* grab the mutex so we don't race with dnode_block_freed() */
mutex_enter(&dn->dn_mtx);
dnode_sync_free_range(dn, rp->fr_blkid, rp->fr_nblks, tx);
/* grab the mutex so we don't race with dnode_block_freed() */
mutex_enter(&dn->dn_mtx);
@@
-646,9
+668,10
@@
dnode_sync(dnode_t *dn, dmu_tx_t *tx)
int i;
ASSERT(dn->dn_next_nblkptr[txgoff] < dnp->dn_nblkptr);
/* the blkptrs we are losing better be unallocated */
int i;
ASSERT(dn->dn_next_nblkptr[txgoff] < dnp->dn_nblkptr);
/* the blkptrs we are losing better be unallocated */
- for (i = dn->dn_next_nblkptr[txgoff];
- i < dnp->dn_nblkptr; i++)
- ASSERT(BP_IS_HOLE(&dnp->dn_blkptr[i]));
+ for (i = 0; i < dnp->dn_nblkptr; i++) {
+ if (i >= dn->dn_next_nblkptr[txgoff])
+ ASSERT(BP_IS_HOLE(&dnp->dn_blkptr[i]));
+ }
#endif
}
mutex_enter(&dn->dn_mtx);
#endif
}
mutex_enter(&dn->dn_mtx);