-static int lfs_quotacheck(int argc, char **argv)
-{
- int c, check_type = 0;
- char *mnt;
- struct if_quotacheck qchk;
- struct if_quotactl qctl;
- char *obd_type = (char *)qchk.obd_type;
- int rc;
-
- memset(&qchk, 0, sizeof(qchk));
-
- while ((c = getopt(argc, argv, "gu")) != -1) {
- switch (c) {
- case 'u':
- check_type |= 0x01;
- break;
- case 'g':
- check_type |= 0x02;
- break;
- default:
- fprintf(stderr, "error: %s: option '-%c' "
- "unrecognized\n", argv[0], c);
- return CMD_HELP;
- }
- }
-
- if (check_type)
- check_type--;
- else /* do quotacheck for both user & group quota by default */
- check_type = 0x02;
-
- if (argc == optind)
- return CMD_HELP;
-
- mnt = argv[optind];
-
- rc = llapi_quotacheck(mnt, check_type);
- if (rc == -EOPNOTSUPP) {
- fprintf(stderr, "error: quotacheck not supported by the quota "
- "master.\nPlease note that quotacheck is deprecated as "
- "of lustre 2.4.0 since space accounting is always "
- "enabled.\nFilesystems not formatted with 2.4 utils or "
- "beyond can be upgraded with tunefs.lustre --quota.\n");
- return rc;
- } else if (rc) {
- fprintf(stderr, "quotacheck failed: %s\n", strerror(-rc));
- return rc;
- }
-
- rc = llapi_poll_quotacheck(mnt, &qchk);
- if (rc) {
- if (*obd_type)
- fprintf(stderr, "%s %s ", obd_type,
- obd_uuid2str(&qchk.obd_uuid));
- fprintf(stderr, "quota check failed: %s\n", strerror(-rc));
- return rc;
- }
-
- memset(&qctl, 0, sizeof(qctl));
- qctl.qc_cmd = LUSTRE_Q_QUOTAON;
- qctl.qc_type = check_type;
- rc = llapi_quotactl(mnt, &qctl);
- if (rc && rc != -EALREADY) {
- if (*obd_type)
- fprintf(stderr, "%s %s ", (char *)qctl.obd_type,
- obd_uuid2str(&qctl.obd_uuid));
- fprintf(stderr, "%s turn on quota failed: %s\n",
- argv[0], strerror(-rc));
- return rc;
- }
-
- return 0;
-}
-
-static int lfs_quotaon(int argc, char **argv)
-{
- int c;
- char *mnt;
- struct if_quotactl qctl;
- char *obd_type = (char *)qctl.obd_type;
- int rc;
-
- memset(&qctl, 0, sizeof(qctl));
- qctl.qc_cmd = LUSTRE_Q_QUOTAON;
-
- while ((c = getopt(argc, argv, "fgu")) != -1) {
- switch (c) {
- case 'u':
- qctl.qc_type |= 0x01;
- break;
- case 'g':
- qctl.qc_type |= 0x02;
- break;
- case 'f':
- qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
- break;
- default:
- fprintf(stderr, "error: %s: option '-%c' "
- "unrecognized\n", argv[0], c);
- return CMD_HELP;
- }
- }
-
- if (qctl.qc_type)
- qctl.qc_type--;
- else /* by default, enable quota for both user & group */
- qctl.qc_type = 0x02;
-
- if (argc == optind)
- return CMD_HELP;
-
- mnt = argv[optind];
-
- rc = llapi_quotactl(mnt, &qctl);
- if (rc) {
- if (rc == -EOPNOTSUPP) {
- fprintf(stderr, "error: quotaon not supported by the "
- "quota master.\nPlease note that quotaon/off is"
- " deprecated as of lustre 2.4.0.\nQuota "
- "enforcement should now be enabled on the MGS "
- "via:\nmgs# lctl conf_param ${FSNAME}.quota."
- "<ost|mdt>=<u|g|ug>\n(ost for block quota, mdt "
- "for inode quota, u for user and g for group"
- "\n");
- } else if (rc == -EALREADY) {
- rc = 0;
- } else if (rc == -ENOENT) {
- fprintf(stderr, "error: cannot find quota database, "
- "make sure you have run quotacheck\n");
- } else {
- if (*obd_type)
- fprintf(stderr, "%s %s ", obd_type,
- obd_uuid2str(&qctl.obd_uuid));
- fprintf(stderr, "%s failed: %s\n", argv[0],
- strerror(-rc));
- }
- }
-
- return rc;
-}
-
-static int lfs_quotaoff(int argc, char **argv)
-{
- int c;
- char *mnt;
- struct if_quotactl qctl;
- char *obd_type = (char *)qctl.obd_type;
- int rc;
-
- memset(&qctl, 0, sizeof(qctl));
- qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
-
- while ((c = getopt(argc, argv, "gu")) != -1) {
- switch (c) {
- case 'u':
- qctl.qc_type |= 0x01;
- break;
- case 'g':
- qctl.qc_type |= 0x02;
- break;
- default:
- fprintf(stderr, "error: %s: option '-%c' "
- "unrecognized\n", argv[0], c);
- return CMD_HELP;
- }
- }
-
- if (qctl.qc_type)
- qctl.qc_type--;
- else /* by default, disable quota for both user & group */
- qctl.qc_type = 0x02;
-
- if (argc == optind)
- return CMD_HELP;
-
- mnt = argv[optind];
-
- rc = llapi_quotactl(mnt, &qctl);
- if (rc) {
- if (rc == -EOPNOTSUPP) {
- fprintf(stderr, "error: quotaoff not supported by the "
- "quota master.\nPlease note that quotaon/off is"
- " deprecated as of lustre 2.4.0.\nQuota "
- "enforcement can be disabled on the MGS via:\n"
- "mgs# lctl conf_param ${FSNAME}.quota.<ost|mdt>"
- "=\"\"\n");
- } else if (rc == -EALREADY) {
- rc = 0;
- } else {
- if (*obd_type)
- fprintf(stderr, "%s %s ", obd_type,
- obd_uuid2str(&qctl.obd_uuid));
- fprintf(stderr, "quotaoff failed: %s\n",
- strerror(-rc));
- }
- }
-
- return rc;
-}
-