Whamcloud - gitweb
LU-1842 quota: tunefs.lustre --quota
[fs/lustre-release.git] / lustre / utils / mkfs_lustre.c
index 483f512..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();
@@ -587,6 +600,8 @@ int main(int argc, char *const argv[])
                         "(%d)\n", mop.mo_device, ret);
                 goto out;
         }
+       mop.mo_ldd.ldd_flags &= ~(LDD_F_WRITECONF | LDD_F_VIRGIN);
+
         if (strstr(mop.mo_ldd.ldd_params, PARAM_MGSNODE))
             mop.mo_mgs_failnodes++;
 
@@ -618,6 +633,10 @@ int main(int argc, char *const argv[])
                 goto out;
         }
 
+       /* Stand alone MGS doesn't need a index */
+       if (!IS_MDT(ldd) && IS_MGS(ldd))
+               mop.mo_ldd.ldd_flags &= ~LDD_F_NEED_INDEX;
+
         if ((mop.mo_ldd.ldd_flags & (LDD_F_NEED_INDEX | LDD_F_UPGRADE14)) ==
             (LDD_F_NEED_INDEX | LDD_F_UPGRADE14)) {
                 fatal();
@@ -747,6 +766,21 @@ int main(int argc, char *const argv[])
                 fprintf(stderr, "mkfs failed %d\n", ret);
                 goto out;
         }
+#else
+       /* update svname with '=' to refresh config */
+       if (mop.mo_ldd.ldd_flags & LDD_F_WRITECONF) {
+               struct mount_opts opts;
+               opts.mo_ldd = mop.mo_ldd;
+               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 */