+ /*
+ * Attempt to set dataset properties to reasonable defaults
+ * to optimize performance, unless the values were specified
+ * at the mkfs command line. Some ZFS pools or ZFS versions
+ * do not support these properties. We can safely ignore the
+ * errors and continue in those cases.
+ *
+ * zfs 0.6.1 - system attribute based xattrs
+ * zfs 0.6.5 - large block support
+ * zfs 0.7.0 - large dnode support
+ *
+ * Check if zhp is NULL as a defensive measure. Any dataset
+ * validation errors that would cause zfs_open() to fail
+ * should have been caught earlier.
+ */
+ zhp = zfs_open(g_zfs, ds, ZFS_TYPE_FILESYSTEM);
+ if (zhp) {
+ /* zfs 0.6.1 - system attribute based xattrs */
+ if (!strstr(mop->mo_mkfsopts, "xattr="))
+ zfs_set_prop_str(zhp, "xattr", "sa");
+
+ /* zfs 0.7.0 - large dnode support */
+ if (!strstr(mop->mo_mkfsopts, "dnodesize=") &&
+ !strstr(mop->mo_mkfsopts, "dnsize="))
+ zfs_set_prop_str(zhp, "dnodesize", "auto");
+
+ if (IS_OST(&mop->mo_ldd)) {
+ /* zfs 0.6.5 - large block support */
+ if (!strstr(mop->mo_mkfsopts, "recordsize=") &&
+ !strstr(mop->mo_mkfsopts, "recsize="))
+ zfs_set_prop_str(zhp, "recordsize", "1M");
+ }
+
+ zfs_close(zhp);
+ }
+