-int generic_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl, int global)
-{
- struct obd_device_target *obt = &obd->u.obt;
- struct lvfs_run_ctxt saved;
- int id, is_master, rc = 0, local; /* means we need a local quotaon */
-
- cfs_down(&obt->obt_quotachecking);
- push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- id = UGQUOTA2LQC(oqctl->qc_type);
- local = (obt->obt_qctxt.lqc_flags & id) != id;
-
- oqctl->qc_cmd = Q_QUOTAON;
- oqctl->qc_id = obt->obt_qfmt;
-
- is_master = !strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME);
- if (is_master) {
- cfs_down_write(&obd->u.mds.mds_qonoff_sem);
- if (local) {
- /* turn on cluster wide quota */
- rc = mds_admin_quota_on(obd, oqctl);
- if (rc && rc != -ENOENT)
- CERROR("%s: %s admin quotaon failed. rc=%d\n",
- obd->obd_name, global ? "global":"local",
- rc);
- }
- }
-
- if (rc == 0) {
- if (local) {
- rc = fsfilt_quotactl(obd, obt->obt_sb, oqctl);
- if (rc) {
- if (rc != -ENOENT)
- CERROR("%s: %s quotaon failed with"
- " rc=%d\n", obd->obd_name,
- global ? "global" : "local", rc);
- } else {
- obt->obt_qctxt.lqc_flags |= UGQUOTA2LQC(oqctl->qc_type);
- build_lqs(obd);
- }
- }
-
- if (rc == 0 && global && is_master)
- rc = obd_quotactl(obd->u.mds.mds_lov_exp, oqctl);
- }
-
- if (is_master)
- cfs_up_write(&obd->u.mds.mds_qonoff_sem);
-
- pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- cfs_up(&obt->obt_quotachecking);
-
- CDEBUG(D_QUOTA, "%s: quotaon type:master:global:local:flags:rc "
- "%u:%d:%d:%d:%lu:%d\n",
- obd->obd_name, oqctl->qc_type, is_master, global, local,
- obt->obt_qctxt.lqc_flags, rc);
-
- return rc;
-}
-
-static int auto_quota_on(struct obd_device *obd, int type)
-{
- struct obd_quotactl *oqctl;
- int rc;
- ENTRY;
-
- LASSERT(type == USRQUOTA || type == GRPQUOTA || type == UGQUOTA);
-
- OBD_ALLOC_PTR(oqctl);
- if (!oqctl)
- RETURN(-ENOMEM);
-
- oqctl->qc_type = type;
-
- rc = generic_quota_on(obd, oqctl, 0);
-
- OBD_FREE_PTR(oqctl);
- RETURN(rc);
-}
-
-int lprocfs_quota_wr_type(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- int type = 0;
- unsigned long i;
- char stype[MAX_STYPE_SIZE + 1] = "";
-
- LASSERT(obd != NULL);
-
- if (count > MAX_STYPE_SIZE)
- return -EINVAL;
-
- if (cfs_copy_from_user(stype, buffer, count))
- return -EFAULT;
-
- for (i = 0 ; i < count ; i++) {
- switch (stype[i]) {
- case 'u' :
- type |= USER_QUOTA;
- break;
- case 'g' :
- type |= GROUP_QUOTA;
- break;
- case '1' :
- case '2' :
- CWARN("quota_type options 1 and 2 are obsolete, "
- "they will be ignored\n");
- break;
- case '3' : /* the only valid version spec, do nothing */
- default : /* just skip stray symbols like \n */
- break;
- }
- }
-
- if (type != 0) {
- int rc = auto_quota_on(obd, type - 1);
-
- if (rc && rc != -EALREADY && rc != -ENOENT)
- return rc;
- }
-
- return count;
-}
-EXPORT_SYMBOL(lprocfs_quota_wr_type);
-
-int lprocfs_quota_rd_switch_seconds(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- LASSERT(obd != NULL);
-
- return snprintf(page, count, "%d\n",
- obd->u.obt.obt_qctxt.lqc_switch_seconds);
-}
-EXPORT_SYMBOL(lprocfs_quota_rd_switch_seconds);
-
-int lprocfs_quota_wr_switch_seconds(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- int val, rc;
- LASSERT(obd != NULL);
-
- rc = lprocfs_write_helper(buffer, count, &val);
- if (rc)
- return rc;
-
- if (val <= 10)
- return -EINVAL;
-
- obd->u.obt.obt_qctxt.lqc_switch_seconds = val;
- return count;
-}
-EXPORT_SYMBOL(lprocfs_quota_wr_switch_seconds);
-
-int lprocfs_quota_rd_sync_blk(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- LASSERT(obd != NULL);
-
- return snprintf(page, count, "%d\n",
- obd->u.obt.obt_qctxt.lqc_sync_blk);
-}
-EXPORT_SYMBOL(lprocfs_quota_rd_sync_blk);
-
-int lprocfs_quota_wr_sync_blk(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- int val, rc;
- LASSERT(obd != NULL);
-
- rc = lprocfs_write_helper(buffer, count, &val);
- if (rc)
- return rc;
-
- if (val < 0)
- return -EINVAL;
-
- obd->u.obt.obt_qctxt.lqc_sync_blk = val;
- return count;
-}
-EXPORT_SYMBOL(lprocfs_quota_wr_sync_blk);
-
-int lprocfs_quota_rd_switch_qs(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- LASSERT(obd != NULL);
-
- return snprintf(page, count, "changing qunit size is %s\n",
- obd->u.obt.obt_qctxt.lqc_switch_qs ?
- "enabled" : "disabled");
-}
-EXPORT_SYMBOL(lprocfs_quota_rd_switch_qs);
-
-int lprocfs_quota_wr_switch_qs(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- int val, rc;
- LASSERT(obd != NULL);
-
- rc = lprocfs_write_helper(buffer, count, &val);
- if (rc)
- return rc;
-
- if (val)
- obd->u.obt.obt_qctxt.lqc_switch_qs = 1;
- else
- obd->u.obt.obt_qctxt.lqc_switch_qs = 0;
-
- return count;
-}
-EXPORT_SYMBOL(lprocfs_quota_wr_switch_qs);
-
-int lprocfs_quota_rd_boundary_factor(char *page, char **start, off_t off,
- int count, int *eof, void *data)