From owner-svn-src-all@freebsd.org Wed May 11 12:43:55 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9DB06B36301; Wed, 11 May 2016 12:43:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 56A6B1AD4; Wed, 11 May 2016 12:43:55 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4BChsLq057655; Wed, 11 May 2016 12:43:54 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4BChssG057654; Wed, 11 May 2016 12:43:54 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201605111243.u4BChssG057654@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 11 May 2016 12:43:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299437 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 May 2016 12:43:55 -0000 Author: mav Date: Wed May 11 12:43:54 2016 New Revision: 299437 URL: https://svnweb.freebsd.org/changeset/base/299437 Log: MFV r299436: 6843 Make xattr dir truncate and remove in one tx Reviewed by: Brian Behlendorf Reviewed by: Dan McDonald Reviewed by: Matthew Ahrens Approved by: Robert Mustacchi Author: Chunwei Chen openzfs/openzfs@399cc7d5d9aff97c714b708af3e3f0280ceab93f Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c Directory Properties: head/sys/cddl/contrib/opensolaris/ (props changed) Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c Wed May 11 12:39:53 2016 (r299436) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c Wed May 11 12:43:54 2016 (r299437) @@ -611,19 +611,25 @@ zfs_rmnode(znode_t *zp) zfs_znode_free(zp); return; } - } - - /* - * Free up all the data in the file. - */ - error = dmu_free_long_range(os, zp->z_id, 0, DMU_OBJECT_END); - if (error) { + } else { /* - * Not enough space. Leave the file in the unlinked set. + * Free up all the data in the file. We don't do this for + * XATTR directories because we need truncate and remove to be + * in the same tx, like in zfs_znode_delete(). Otherwise, if + * we crash here we'll end up with an inconsistent truncated + * zap object in the delete queue. Note a truncated file is + * harmless since it only contains user data. */ - zfs_znode_dmu_fini(zp); - zfs_znode_free(zp); - return; + error = dmu_free_long_range(os, zp->z_id, 0, DMU_OBJECT_END); + if (error) { + /* + * Not enough space. Leave the file in the unlinked + * set. + */ + zfs_znode_dmu_fini(zp); + zfs_znode_free(zp); + return; + } } /*