-}
-
-/* Build fs according to type */
-int make_lustre_backfs(struct mkfs_opts *mop)
-{
- __u64 device_sz = mop->mo_device_sz, block_count = 0;
- char mkfs_cmd[PATH_MAX];
- char buf[64];
- char *dev;
- int ret = 0;
-
- if (!(mop->mo_flags & MO_IS_LOOP)) {
- mop->mo_device_sz = get_device_size(mop->mo_device);
-
- if (mop->mo_device_sz == 0)
- return ENODEV;
-
- /* Compare to real size */
- if (device_sz == 0 || device_sz > mop->mo_device_sz)
- device_sz = mop->mo_device_sz;
- else
- mop->mo_device_sz = device_sz;
- }
-
- if (mop->mo_device_sz != 0) {
- if (mop->mo_device_sz < 8096){
- fprintf(stderr, "%s: size of filesystem must be larger "
- "than 8MB, but is set to %lldKB\n",
- progname, (long long)mop->mo_device_sz);
- return EINVAL;
- }
- block_count = mop->mo_device_sz / (L_BLOCK_SIZE >> 10);
- /* If the LUN size is just over 2^32 blocks, limit the
- * filesystem size to 2^32-1 blocks to avoid problems with
- * ldiskfs/mkfs not handling this size. Bug 22906 */
- if (block_count > 0xffffffffULL && block_count < 0x100002000ULL)
- block_count = 0xffffffffULL;
- }
-
- if ((mop->mo_ldd.ldd_mount_type == LDD_MT_EXT3) ||
- (mop->mo_ldd.ldd_mount_type == LDD_MT_LDISKFS) ||
- (mop->mo_ldd.ldd_mount_type == LDD_MT_LDISKFS2)) {
- long inode_size = 0;
-
- /* Journal size in MB */
- if (strstr(mop->mo_mkfsopts, "-J") == NULL) {
- /* Choose our own default journal size */
- long journal_sz = 0, max_sz;
- if (device_sz > 1024 * 1024) /* 1GB */
- journal_sz = (device_sz / 102400) * 4;
- /* cap journal size at 1GB */
- if (journal_sz > 1024L)
- journal_sz = 1024L;
- /* man mkfs.ext3 */
- max_sz = (102400 * L_BLOCK_SIZE) >> 20; /* 400MB */
- if (journal_sz > max_sz)
- journal_sz = max_sz;
- if (journal_sz) {
- sprintf(buf, " -J size=%ld", journal_sz);
- strscat(mop->mo_mkfsopts, buf,
- sizeof(mop->mo_mkfsopts));
- }
- }
-
- /* Inode size (for extended attributes). The LOV EA size is
- * 32 (EA hdr) + 32 (lov_mds_md) + stripes * 24 (lov_ost_data),
- * and we want some margin above that for ACLs, other EAs... */
- if (strstr(mop->mo_mkfsopts, "-I") == NULL) {
- if (IS_MDT(&mop->mo_ldd)) {
- if (mop->mo_stripe_count > 72)
- inode_size = 512; /* bz 7241 */
- /* see also "-i" below for EA blocks */
- else if (mop->mo_stripe_count > 32)
- inode_size = 2048;
- else if (mop->mo_stripe_count > 10)
- inode_size = 1024;
- else
- inode_size = 512;
- } else if (IS_OST(&mop->mo_ldd)) {
- /* We store MDS FID and OST objid in EA on OST
- * we need to make inode bigger as well. */
- inode_size = 256;
- }
-
- if (inode_size > 0) {
- sprintf(buf, " -I %ld", inode_size);
- strscat(mop->mo_mkfsopts, buf,
- sizeof(mop->mo_mkfsopts));
- }
- }
-
- /* Bytes_per_inode: disk size / num inodes */
- if (strstr(mop->mo_mkfsopts, "-i") == NULL &&
- strstr(mop->mo_mkfsopts, "-N") == NULL) {
- long bytes_per_inode = 0;
-
- /* Allocate more inodes on MDT devices. There is
- * no data stored on the MDT, and very little extra
- * metadata beyond the inode. It could go down as
- * low as 1024 bytes, but this is conservative.
- * Account for external EA blocks for wide striping. */
- if (IS_MDT(&mop->mo_ldd)) {
- bytes_per_inode = inode_size + 1536;
-
- if (mop->mo_stripe_count > 72) {
- int extra = mop->mo_stripe_count * 24;
- extra = ((extra - 1) | 4095) + 1;
- bytes_per_inode += extra;
- }
- }
-
- /* Allocate fewer inodes on large OST devices. Most
- * filesystems can be much more aggressive than even
- * this, but it is impossible to know in advance. */
- if (IS_OST(&mop->mo_ldd)) {
- /* OST > 8TB assume average file size 1MB */
- if (device_sz >= (8ULL << 30))
- bytes_per_inode = 1024 * 1024;
- /* OST > 1TB assume average file size 256kB */
- else if (device_sz >= (1ULL << 30))
- bytes_per_inode = 256 * 1024;
- /* OST > 100GB assume average file size 64kB,
- * plus a bit so that inodes will fit into a
- * 256x flex_bg without overflowing */
- else if (device_sz >= (10ULL << 20))
- bytes_per_inode = 69905;
- }
-
-
- if (bytes_per_inode > 0) {
- sprintf(buf, " -i %ld", bytes_per_inode);
- strscat(mop->mo_mkfsopts, buf,
- sizeof(mop->mo_mkfsopts));
- }
- }
-
- if (verbose < 2) {
- strscat(mop->mo_mkfsopts, " -q",
- sizeof(mop->mo_mkfsopts));
- }
-
- if (strstr(mop->mo_mkfsopts, "-O") == NULL)
- enable_default_ext4_features(mop);
-
- /* In order to align the filesystem metadata on 1MB boundaries,
- * give a resize value that will reserve a power-of-two group
- * descriptor blocks, but leave one block for the superblock.
- * Only useful for filesystems with < 2^32 blocks due to resize
- * limitations. */
- if (IS_OST(&mop->mo_ldd) && mop->mo_device_sz > 100 * 1024 &&
- mop->mo_device_sz * 1024 / L_BLOCK_SIZE <= 0xffffffffULL) {
- unsigned group_blocks = L_BLOCK_SIZE * 8;
- unsigned desc_per_block = L_BLOCK_SIZE / 32;
- unsigned resize_blks;
-
- resize_blks = (1ULL<<32) - desc_per_block*group_blocks;
- snprintf(buf, sizeof(buf)," -E resize=%u,",resize_blks);
- } else {
- strncpy(buf, " -E ", sizeof(buf));
- }
-
- /* Avoid zeroing out the full journal - speeds up mkfs */
- if (is_e2fsprogs_feature_supp("-E lazy_journal_init") == 0)
- strscat(buf, "lazy_journal_init,", sizeof(buf));
-
- if (strlen(buf) > strlen(" -E "))
- strscat(mop->mo_mkfsopts, buf,sizeof(mop->mo_mkfsopts));
-
- /* Allow reformat of full devices (as opposed to
- partitions.) We already checked for mounted dev. */
- strscat(mop->mo_mkfsopts, " -F", sizeof(mop->mo_mkfsopts));
-
- snprintf(mkfs_cmd, sizeof(mkfs_cmd),
- "%s -j -b %d -L %s ", MKE2FS, L_BLOCK_SIZE,
- mop->mo_ldd.ldd_svname);
- } else {
- fprintf(stderr,"%s: unsupported fs type: %d (%s)\n",
- progname, mop->mo_ldd.ldd_mount_type,
- MT_STR(&mop->mo_ldd));
- return EINVAL;
- }
-
- /* For loop device format the dev, not the filename */
- dev = mop->mo_device;
- if (mop->mo_flags & MO_IS_LOOP)
- dev = mop->mo_loopdev;
-
- vprint("formatting backing filesystem %s on %s\n",
- MT_STR(&mop->mo_ldd), dev);
- vprint("\ttarget name %s\n", mop->mo_ldd.ldd_svname);
- vprint("\t4k blocks "LPU64"\n", block_count);
- vprint("\toptions %s\n", mop->mo_mkfsopts);
-
- /* mkfs_cmd's trailing space is important! */
- strscat(mkfs_cmd, mop->mo_mkfsopts, sizeof(mkfs_cmd));
- strscat(mkfs_cmd, " ", sizeof(mkfs_cmd));
- strscat(mkfs_cmd, dev, sizeof(mkfs_cmd));
- if (block_count != 0) {
- sprintf(buf, " "LPU64, block_count);
- strscat(mkfs_cmd, buf, sizeof(mkfs_cmd));
- }
-
- vprint("mkfs_cmd = %s\n", mkfs_cmd);
- ret = run_command(mkfs_cmd, sizeof(mkfs_cmd));
- if (ret) {
- fatal();
- fprintf(stderr, "Unable to build fs %s (%d)\n", dev, ret);
- }
- return ret;
+ fprintf(out,
+ "\t<device>:block device or file (e.g /dev/sda or /tmp/ost1)\n"
+#ifdef HAVE_ZFS_OSD
+ "\t<pool name>: name of ZFS pool where target is created "
+ "(e.g. tank)\n"
+ "\t<dataset name>: name of new dataset, must be unique within "
+ "pool (e.g. ost1)\n"
+ "\t<vdev type>: type of vdev (mirror, raidz, raidz2, spare, "
+ "cache, log)\n"
+#endif
+ "\n"
+ "\ttarget types:\n"
+ "\t\t--mgs: configuration management service\n"
+ "\t\t--nomgs: turn off MGS service on this MDT\n"
+#ifndef TUNEFS
+ "\t\t--mdt: metadata storage, mutually exclusive with ost\n"
+ "\t\t--ost: object storage, mutually exclusive with mdt, mgs\n"
+#endif
+ "\toptions (in order of popularity):\n"
+ "\t\t--index=#N: numerical target index (0..N)\n"
+ "\t\t\trequired for all targets other than the MGS,\n"
+ "\t\t\ttarget index may either be a decimal number or\n"
+ "\t\t\thexadecimal number starting with '0x'\n"
+ "\t\t--fsname=<8_char_filesystem_name>: fs targets belong to\n"
+ "\t\t\trequired for all targets other than MGS\n"
+ "\t\t--mgsnode=<nid>[,<...>]: NID(s) of remote MGS\n"
+ "\t\t\trequired for all targets other than MGS\n"
+ "\t\t--mountfsoptions=<opts>: permanent Lustre mount options\n"
+ "\t\t--backfs-mount-opts=<opts>: backing fs mount options\n"
+ "\t\t--failnode=<nid>[,<...>]: NID(s) of backup failover node\n"
+ "\t\t\tmutually exclusive with --servicenode\n"
+ "\t\t--servicenode=<nid>[,<...>]: NID(s) of service partners\n"
+ "\t\t\ttreat nodes as equal service node, mutually exclusive "
+ "with --failnode\n"
+ "\t\t--param <key>=<value>: set a permanent parameter\n"
+ "\t\t\te.g. --param sys.timeout=40\n"
+ "\t\t\t --param lov.stripesize=2M\n"
+ "\t\t--network=<net>[,<...>]: restrict OST/MDT to network(s)\n"
+#ifndef TUNEFS
+ "\t\t--backfstype=<fstype>: backing fs type (ldiskfs, zfs)\n"
+ "\t\t--device-size=#N(KB): device size for loop devices\n"
+ "\t\t--mkfsoptions=<opts>: format options\n"
+ "\t\t--reformat: overwrite an existing disk\n"
+ "\t\t--replace: replace an old target with the same index\n"
+ "\t\t--stripe-count-hint=#N: for optimizing MDT inode size\n"
+#else
+ "\t\t--erase-param <key>: erase all instances of a parameter\n"
+ "\t\t--erase-params: erase all old parameter settings\n"
+ "\t\t--writeconf: erase all config logs for this fs.\n"
+ "\t\t--quota: enable space accounting on old 2.x device.\n"
+ "\t\t--rename: rename the filesystem name\n"
+#endif
+ "\t\t--comment=<user comment>: arbitrary string (%d bytes)\n"
+ "\t\t--dryrun: report what we would do; don't write to disk\n"
+ "\t\t--verbose: e.g. show mkfs progress\n"
+ "\t\t--force-nohostid: Ignore hostid requirement for ZFS "
+ "import\n"
+ "\t\t-V|--version: output build version of the utility and\n"
+ "\t\t\texit\n"
+ "\t\t--quiet\n",
+ (int)sizeof(((struct lustre_disk_data *)0)->ldd_userdata));