diff options
author | mav <mav@FreeBSD.org> | 2016-05-11 12:43:54 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2016-05-11 12:43:54 +0000 |
commit | 891d75bff2a12e626bd3fc7bf55acf9a26aa8b07 (patch) | |
tree | 4461e2dba73b45bf1b3e9d7a688a400f1ae38fcc | |
parent | b176e684164f76a8fb8e1015939986ea17963af2 (diff) | |
download | FreeBSD-src-891d75bff2a12e626bd3fc7bf55acf9a26aa8b07.zip FreeBSD-src-891d75bff2a12e626bd3fc7bf55acf9a26aa8b07.tar.gz |
MFV r299436: 6843 Make xattr dir truncate and remove in one tx
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Chunwei Chen <tuxoko@gmail.com>
openzfs/openzfs@399cc7d5d9aff97c714b708af3e3f0280ceab93f
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c index cf42ff6..12bd804 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c @@ -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; + } } /* |