Whamcloud - gitweb
LU-1842 quota: tunefs.lustre --quota
[fs/lustre-release.git] / lustre / utils / mkfs_lustre.c
index 22bf661..45ad45f 100644 (file)
@@ -88,8 +88,12 @@ int verbose = 1;
 static int print_only = 0;
 static int upgrade_to_18 = 0;
 
+#ifdef HAVE_LDISKFS_OSD
 #define FSLIST_LDISKFS "ldiskfs"
 #define HAVE_FSLIST
+#else
+ #define FSLIST_LDISKFS ""
+#endif /* HAVE_LDISKFS_OSD */
 #ifdef HAVE_ZFS_OSD
  #ifdef HAVE_FSLIST
    #define FSLIST_ZFS "|zfs"
@@ -162,6 +166,7 @@ void usage(FILE *out)
                "\t\t--erase-params: erase all old parameter settings\n"
                "\t\t--nomgs: turn off MGS service on this MDT\n"
                "\t\t--writeconf: erase all config logs for this fs.\n"
+               "\t\t--quota: enable space accounting on old 2.x device.\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"
@@ -209,7 +214,11 @@ void set_defaults(struct mkfs_opts *mop)
        mop->mo_ldd.ldd_magic = LDD_MAGIC;
        mop->mo_ldd.ldd_config_ver = 1;
        mop->mo_ldd.ldd_flags = LDD_F_NEED_INDEX | LDD_F_UPDATE | LDD_F_VIRGIN;
+#ifdef HAVE_LDISKFS_OSD
        mop->mo_ldd.ldd_mount_type = LDD_MT_LDISKFS;
+#else
+       mop->mo_ldd.ldd_mount_type = LDD_MT_ZFS;
+#endif
        mop->mo_ldd.ldd_svindex = INDEX_UNASSIGNED;
        mop->mo_mgs_failnodes = 0;
        mop->mo_stripe_count = 1;
@@ -306,6 +315,7 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
                 {"writeconf", 0, 0, 'w'},
                 {"upgrade_to_18", 0, 0, 'U'},
                 {"network", 1, 0, 't'},
+               {"quota", 0, 0, 'Q'},
                 {0, 0, 0, 0}
         };
         char *optstring = "b:c:C:d:ef:Ghi:k:L:m:MnNo:Op:Pqrs:t:Uu:vw";
@@ -513,6 +523,9 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
                 case 'U':
                         upgrade_to_18 = 1;
                         break;
+               case 'Q':
+                       mop->mo_flags |= MO_QUOTA;
+                       break;
                 default:
                         if (opt != '?') {
                                 fatal();
@@ -761,6 +774,13 @@ int main(int argc, char *const argv[])
                opts.mo_source = mop.mo_device;
                (void) osd_label_lustre(&opts);
        }
+
+       /* Enable quota accounting */
+       if (mop.mo_flags & MO_QUOTA) {
+               ret = osd_enable_quota(&mop);
+               goto out;
+       }
+
 #endif
 
         /* Write our config files */