X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Flibmount_utils_zfs.c;h=148260c6c5784c5a1e1789ccae59be5c540b64be;hp=920682c30dd912b1964cf28b84444bb6632d6e58;hb=8d1639b5cf1edbc885876956dcd6189173c00955;hpb=d6f57eda898cc80a1cff49ad3875021749563dbf diff --git a/lustre/utils/libmount_utils_zfs.c b/lustre/utils/libmount_utils_zfs.c index 920682c..148260c 100644 --- a/lustre/utils/libmount_utils_zfs.c +++ b/lustre/utils/libmount_utils_zfs.c @@ -20,7 +20,7 @@ * GPL HEADER END */ /* - * Copyright (c) 2012, 2016, Intel Corporation. + * Copyright (c) 2012, 2017, Intel Corporation. * Use is subject to license terms. */ /* @@ -543,6 +543,9 @@ static char *zfs_mkfs_opts(struct mkfs_opts *mop, char *str, int len) if (strlen(mop->mo_mkfsopts) != 0) snprintf(str, len, " -o %s", mop->mo_mkfsopts); + if (mop->mo_device_kb) + snprintf(str, len, " -o quota=%llu", + mop->mo_device_kb * 1024); return str; } @@ -667,6 +670,7 @@ int zfs_make_lustre(struct mkfs_opts *mop) php = zpool_open(g_zfs, pool); if (php) { pool_exists = 1; + zpool_set_prop(php, "canmount", "off"); zpool_close(php); } @@ -701,15 +705,14 @@ int zfs_make_lustre(struct mkfs_opts *mop) /* * Set Options on ZPOOL * - * ALL - canmount=off + * ALL - canmount=off (set above) * 0.7.0 - multihost=on + * 0.7.0 - feature@userobj_accounting=enabled */ php = zpool_open(g_zfs, pool); if (php) { - if (pool_exists) - zpool_set_prop(php, "canmount", "off"); - zpool_set_prop(php, "multihost", "on"); + zpool_set_prop(php, "feature@userobj_accounting", "enabled"); zpool_close(php); } @@ -717,11 +720,10 @@ int zfs_make_lustre(struct mkfs_opts *mop) /* * Create the ZFS filesystem with any required mkfs options: * - canmount=off is set to prevent zfs automounting - * - xattr=sa is set to use system attribute based xattrs */ memset(mkfs_cmd, 0, PATH_MAX); snprintf(mkfs_cmd, PATH_MAX, - "zfs create -o canmount=off -o xattr=sa%s %s", + "zfs create -o canmount=off %s %s", zfs_mkfs_opts(mop, mkfs_tmp, PATH_MAX), ds); vprint("mkfs_cmd = %s\n", mkfs_cmd); @@ -733,6 +735,42 @@ int zfs_make_lustre(struct mkfs_opts *mop) goto out; } + /* + * 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); + } + out: if (pool != NULL) free(pool);