* Mount MDT and OSTs
.br
* Mount clients
+.TP
+.BI \--quota
+Enable space accounting on old 2.x devices.
+
.SH EXAMPLES
.TP
.B tunefs.lustre --erase-param --mgsnode=<new_nid> --writeconf /dev/sda
"\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"
{"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";
case 'U':
upgrade_to_18 = 1;
break;
+ case 'Q':
+ mop->mo_flags |= MO_QUOTA;
+ break;
default:
if (opt != '?') {
fatal();
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 */
return ret;
}
+/* Enable quota accounting */
+int osd_enable_quota(struct mkfs_opts *mop)
+{
+ struct lustre_disk_data *ldd = &mop->mo_ldd;
+ int ret;
+
+ switch (ldd->ldd_mount_type) {
+#ifdef HAVE_LDISKFS_OSD
+ case LDD_MT_EXT3:
+ case LDD_MT_LDISKFS:
+ case LDD_MT_LDISKFS2:
+ ret = ldiskfs_enable_quota(mop);
+ break;
+#endif /* HAVE_LDISKFS_OSD */
+#ifdef HAVE_ZFS_OSD
+ case LDD_MT_ZFS:
+ fprintf(stderr, "this option is only valid for ldiskfs\n");
+ ret = EINVAL;
+ break;
+#endif /* HAVE_ZFS_OSD */
+ default:
+ fatal();
+ fprintf(stderr, "unknown fs type %d '%s'\n",
+ ldd->ldd_mount_type, MT_STR(ldd));
+ ret = EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
int osd_init(void)
{
int ret = 0;
#define MO_FORCEFORMAT 0x02
#define MO_FAILOVER 0x04
#define MO_DRYRUN 0x08
+#define MO_QUOTA 0x10
#define MAX_LOOP_DEVICES 16
#define INDEX_UNASSIGNED 0xFFFF
char *always_mountopts, int always_len);
int osd_tune_lustre(char *dev, struct mount_opts *mop);
int osd_label_lustre(struct mount_opts *mop);
+int osd_enable_quota(struct mkfs_opts *mop);
int osd_init(void);
void osd_fini(void);
char *always_mountopts, int always_len);
int ldiskfs_tune_lustre(char *dev, struct mount_opts *mop);
int ldiskfs_label_lustre(struct mount_opts *mop);
+int ldiskfs_enable_quota(struct mkfs_opts *mop);
int ldiskfs_init(void);
void ldiskfs_fini(void);
return ret;
}
+static int is_feature_enabled(const char *feature, const char *devpath)
+{
+ char cmd[PATH_MAX];
+ FILE *fp;
+ char enabled_features[4096] = "";
+
+ snprintf(cmd, sizeof(cmd), "%s -R features %s 2>&1",
+ DEBUGFS, devpath);
+
+ /* Using popen() instead of run_command() since debugfs does
+ * not return proper error code if command is not supported */
+ fp = popen(cmd, "r");
+ if (!fp) {
+ fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+ return 0;
+ }
+
+ fread(enabled_features, 1, sizeof(enabled_features), fp);
+ fclose(fp);
+
+ if (strstr(enabled_features, feature))
+ return 1;
+ return 0;
+}
+
+/* Enable quota accounting */
+int ldiskfs_enable_quota(struct mkfs_opts *mop)
+{
+ char *dev;
+ char cmd[512];
+ int cmdsz = sizeof(cmd), ret;
+
+ if (is_e2fsprogs_feature_supp("-O quota") != 0) {
+ fprintf(stderr, "%s: \"-O quota\" is is not supported by "
+ "current e2fsprogs\n", progname);
+ return EINVAL;
+ }
+
+ dev = mop->mo_device;
+ if (mop->mo_flags & MO_IS_LOOP)
+ dev = mop->mo_loopdev;
+
+ /* Quota feature is already enabled? */
+ if (is_feature_enabled("quota", dev)) {
+ vprint("Quota feature is already enabled.\n");
+ return 0;
+ }
+
+ /* Turn on quota feature by "tune2fs -O quota" */
+ snprintf(cmd, cmdsz, "%s -O quota %s", TUNE2FS, dev);
+ ret = run_command(cmd, cmdsz);
+ if (ret)
+ fprintf(stderr, "command:%s (%d)", cmd, ret);
+
+ return ret;
+}
+
int ldiskfs_init(void)
{
/* Required because full path to DEBUGFS is not specified */