diff options
author | mm <mm@FreeBSD.org> | 2010-05-04 17:30:07 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2010-05-04 17:30:07 +0000 |
commit | a0d55d935c4651b24a66107dc58763618df5172a (patch) | |
tree | 87ae8baac7c8a14b4a82ca3a0aa85fe8419a61b7 /sys/cddl | |
parent | 44093d908838f41371b4160ac664abdab7dd5f97 (diff) | |
download | FreeBSD-src-a0d55d935c4651b24a66107dc58763618df5172a.zip FreeBSD-src-a0d55d935c4651b24a66107dc58763618df5172a.tar.gz |
Fix deadlock during zfs receive.
OpenSolaris onnv revision: 9299:8809e849f63e
PR: kern/146296
Submitted by: myself
Approved by: pjd, delphij (mentor)
Obtained from: OpenSolaris (Bug ID 6783818, 6826836)
MFC after: 1 week
Diffstat (limited to 'sys/cddl')
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c | 6 | ||||
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c | 28 |
2 files changed, 18 insertions, 16 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c index 3bf0939..053c1e1 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c @@ -464,15 +464,15 @@ dbuf_read_impl(dmu_buf_impl_t *db, zio_t *zio, uint32_t *flags) ASSERT(db->db_buf == NULL); if (db->db_blkid == DB_BONUS_BLKID) { - int bonuslen = dn->dn_bonuslen; + int bonuslen = MIN(dn->dn_bonuslen, dn->dn_phys->dn_bonuslen); ASSERT3U(bonuslen, <=, db->db.db_size); db->db.db_data = zio_buf_alloc(DN_MAX_BONUSLEN); arc_space_consume(DN_MAX_BONUSLEN); if (bonuslen < DN_MAX_BONUSLEN) bzero(db->db.db_data, DN_MAX_BONUSLEN); - bcopy(DN_BONUS(dn->dn_phys), db->db.db_data, - bonuslen); + if (bonuslen) + bcopy(DN_BONUS(dn->dn_phys), db->db.db_data, bonuslen); dbuf_update_data(db); db->db_state = DB_CACHED; mutex_exit(&db->db_mtx); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c index 25dfafd..1f91fc1 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c @@ -128,15 +128,6 @@ dmu_object_reclaim(objset_t *os, uint64_t object, dmu_object_type_t ot, return (0); } - tx = dmu_tx_create(os); - dmu_tx_hold_bonus(tx, object); - err = dmu_tx_assign(tx, TXG_WAIT); - if (err) { - dmu_tx_abort(tx); - dnode_rele(dn, FTAG); - return (err); - } - nblkptr = 1 + ((DN_MAX_BONUSLEN - bonuslen) >> SPA_BLKPTRSHIFT); /* @@ -144,16 +135,27 @@ dmu_object_reclaim(objset_t *os, uint64_t object, dmu_object_type_t ot, * be a new file instance. We must clear out the previous file * contents before we can change this type of metadata in the dnode. */ - if (dn->dn_nblkptr > nblkptr || dn->dn_datablksz != blocksize) - dmu_free_long_range(os, object, 0, DMU_OBJECT_END); + if (dn->dn_nblkptr > nblkptr || dn->dn_datablksz != blocksize) { + err = dmu_free_long_range(os, object, 0, DMU_OBJECT_END); + if (err) + goto out; + } + + tx = dmu_tx_create(os); + dmu_tx_hold_bonus(tx, object); + err = dmu_tx_assign(tx, TXG_WAIT); + if (err) { + dmu_tx_abort(tx); + goto out; + } dnode_reallocate(dn, ot, blocksize, bonustype, bonuslen, tx); dmu_tx_commit(tx); - +out: dnode_rele(dn, FTAG); - return (0); + return (err); } int |