From owner-freebsd-bugs@FreeBSD.ORG Tue May 4 10:50:02 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 67C8A106574D for ; Tue, 4 May 2010 10:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 2DA348FC17 for ; Tue, 4 May 2010 10:50:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o44Ao2lx041140 for ; Tue, 4 May 2010 10:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o44Ao2v0041139; Tue, 4 May 2010 10:50:02 GMT (envelope-from gnats) Resent-Date: Tue, 4 May 2010 10:50:02 GMT Resent-Message-Id: <201005041050.o44Ao2v0041139@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Martin Matuska Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3A65C106566C; Tue, 4 May 2010 10:42:52 +0000 (UTC) (envelope-from mm@mail.vx.sk) Received: from mail.vx.sk (core.vx.sk [188.40.32.143]) by mx1.freebsd.org (Postfix) with ESMTP id 847788FC08; Tue, 4 May 2010 10:42:51 +0000 (UTC) Received: from core.vx.sk (localhost [127.0.0.1]) by mail.vx.sk (Postfix) with ESMTP id 616BE8F579; Tue, 4 May 2010 12:42:49 +0200 (CEST) Received: from mail.vx.sk ([127.0.0.1]) by core.vx.sk (mail.vx.sk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id i-o+ksJnE8+v; Tue, 4 May 2010 12:42:47 +0200 (CEST) Received: by mail.vx.sk (Postfix, from userid 1001) id 198038F567; Tue, 4 May 2010 12:42:47 +0200 (CEST) Message-Id: <20100504104247.198038F567@mail.vx.sk> Date: Tue, 4 May 2010 12:42:47 +0200 (CEST) From: Martin Matuska To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: pjd@FreeBSD.org Subject: kern/146296: [zfs] [patch] fix deadlock during zfs receive (onnv 9299) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Martin Matuska List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2010 10:50:02 -0000 >Number: 146296 >Category: kern >Synopsis: [zfs] [patch] fix deadlock during zfs receive (onnv 9299) >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue May 04 10:50:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Martin Matuska >Release: FreeBSD 8.0-STABLE amd64 >Organization: >Environment: >Description: I have encountered a hanging zfs receive during receiving many incremental streams. This problem has been described in OpenSolaris mailing lists, it matches my symptoms and affects our ZFS port. OpenSolaris Bug IDs: 6783818 Incremental stream receive panics system 6826836 Deadlock possible in dmu_object_reclaim() Mailing list discussion: http://mail.opensolaris.org/pipermail/storage-discuss/2009-June/006171.html Fixed in onnv revision: 9299:8809e849f63e >How-To-Repeat: >Fix: Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c =================================================================== --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c (revision 207608) +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c (working copy) @@ -128,15 +128,6 @@ 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 @@ * 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 Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c =================================================================== --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c (revision 207608) +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c (working copy) @@ -464,15 +464,15 @@ 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); >Release-Note: >Audit-Trail: >Unformatted: