Print this page
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>

@@ -604,24 +604,30 @@
                          */
                         zfs_znode_dmu_fini(zp);
                         zfs_znode_free(zp);
                         return;
                 }
-        }
-
+        } else {
         /*
-         * Free up all the data in the file.
+                 * 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.
          */
         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.
+                         * Not enough space.  Leave the file in the unlinked
+                         * set.
                  */
                 zfs_znode_dmu_fini(zp);
                 zfs_znode_free(zp);
                 return;
         }
+        }
 
         /*
          * If the file has extended attributes, we're going to unlink
          * the xattr dir.
          */