Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / quota / quota_ctl.c
index cae30c4..75ab78d 100644 (file)
 #ifdef HAVE_QUOTA_SUPPORT
 #ifdef __KERNEL__
 
 #ifdef HAVE_QUOTA_SUPPORT
 #ifdef __KERNEL__
 
-/* When quotaon, build a lqs for every uid/gid who has been set limitation
- * for quota. After quota_search_lqs, it will hold one ref for the lqs.
- * It will be released when qctxt_cleanup() is executed b=18574 */
-void build_lqs(struct obd_device *obd)
-{
-        struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
-        struct list_head id_list;
-        int i, rc;
-
-        INIT_LIST_HEAD(&id_list);
-        for (i = 0; i < MAXQUOTAS; i++) {
-                struct dquot_id *dqid, *tmp;
-
-#ifndef KERNEL_SUPPORTS_QUOTA_READ
-                rc = fsfilt_qids(obd, sb_dqopt(qctxt->lqc_sb)->files[i], NULL,
-                                 i, &id_list);
-#else
-                rc = fsfilt_qids(obd, NULL, sb_dqopt(qctxt->lqc_sb)->files[i],
-                                 i, &id_list);
-#endif
-                if (rc) {
-                        CDEBUG(D_ERROR, "fail to get %s qids!\n",
-                               i ? "group" : "user");
-                        continue;
-                }
-
-                list_for_each_entry_safe(dqid, tmp, &id_list,
-                                         di_link) {
-                        struct lustre_qunit_size *lqs;
-
-                        list_del_init(&dqid->di_link);
-                        lqs = quota_search_lqs(LQS_KEY(i, dqid->di_id),
-                                               qctxt, 1);
-                        if (lqs && !IS_ERR(lqs)) {
-                                lqs->lqs_flags |= dqid->di_flag;
-                                lqs_putref(lqs);
-                        } else {
-                                CDEBUG(D_ERROR, "fail to create a lqs"
-                                       "(%s id: %u)!\n", i ? "group" : "user",
-                                       dqid->di_id);
-                        }
-
-                        OBD_FREE_PTR(dqid);
-                }
-        }
-}
-
 int mds_quota_ctl(struct obd_device *obd, struct obd_export *unused,
                   struct obd_quotactl *oqctl)
 {
 int mds_quota_ctl(struct obd_device *obd, struct obd_export *unused,
                   struct obd_quotactl *oqctl)
 {
@@ -128,8 +81,6 @@ int mds_quota_ctl(struct obd_device *obd, struct obd_export *unused,
         case Q_QUOTAON:
                 oqctl->qc_id = obt->obt_qfmt; /* override qfmt version */
                 rc = mds_quota_on(obd, oqctl);
         case Q_QUOTAON:
                 oqctl->qc_id = obt->obt_qfmt; /* override qfmt version */
                 rc = mds_quota_on(obd, oqctl);
-                /* when quotaon, create lqs for every quota uid/gid b=18574 */
-                build_lqs(obd);
                 break;
         case Q_QUOTAOFF:
                 oqctl->qc_id = obt->obt_qfmt; /* override qfmt version */
                 break;
         case Q_QUOTAOFF:
                 oqctl->qc_id = obt->obt_qfmt; /* override qfmt version */
@@ -181,7 +132,7 @@ int filter_quota_ctl(struct obd_device *unused, struct obd_export *exp,
         struct obd_device *obd = exp->exp_obd;
         struct obd_device_target *obt = &obd->u.obt;
         struct lvfs_run_ctxt saved;
         struct obd_device *obd = exp->exp_obd;
         struct obd_device_target *obt = &obd->u.obt;
         struct lvfs_run_ctxt saved;
-        struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
+        struct lustre_quota_ctxt *qctxt = &obt->obt_qctxt;
         struct lustre_qunit_size *lqs;
         void *handle = NULL;
         struct timeval work_start;
         struct lustre_qunit_size *lqs;
         void *handle = NULL;
         struct timeval work_start;
@@ -224,12 +175,16 @@ int filter_quota_ctl(struct obd_device *unused, struct obd_export *exp,
                 if (oqctl->qc_cmd == Q_QUOTAON || oqctl->qc_cmd == Q_QUOTAOFF ||
                     oqctl->qc_cmd == Q_FINVALIDATE) {
                         if (oqctl->qc_cmd == Q_QUOTAON) {
                 if (oqctl->qc_cmd == Q_QUOTAON || oqctl->qc_cmd == Q_QUOTAOFF ||
                     oqctl->qc_cmd == Q_FINVALIDATE) {
                         if (oqctl->qc_cmd == Q_QUOTAON) {
-                                if (!rc)
+                                if (!rc) {
                                         obt->obt_qctxt.lqc_flags |=
                                                 UGQUOTA2LQC(oqctl->qc_type);
                                         obt->obt_qctxt.lqc_flags |=
                                                 UGQUOTA2LQC(oqctl->qc_type);
-                                else if (rc == -EBUSY &&
-                                         quota_is_on(qctxt, oqctl))
+                                        /* when quotaon, create lqs for every
+                                         * quota uid/gid b=18574 */
+                                        build_lqs(obd);
+                                } else if (rc == -EBUSY &&
+                                         quota_is_on(qctxt, oqctl)) {
                                                 rc = -EALREADY;
                                                 rc = -EALREADY;
+                                }
                         } else if (oqctl->qc_cmd == Q_QUOTAOFF) {
                                 if (!rc)
                                         obt->obt_qctxt.lqc_flags &=
                         } else if (oqctl->qc_cmd == Q_QUOTAOFF) {
                                 if (!rc)
                                         obt->obt_qctxt.lqc_flags &=
@@ -240,9 +195,6 @@ int filter_quota_ctl(struct obd_device *unused, struct obd_export *exp,
                         up(&obt->obt_quotachecking);
                 }
 
                         up(&obt->obt_quotachecking);
                 }
 
-                /* when quotaon, create lqs for every quota uid/gid b=18574 */
-                if (oqctl->qc_cmd == Q_QUOTAON)
-                        build_lqs(obd);
                 break;
         case Q_SETQUOTA:
                 /* currently, it is only used for nullifying the quota */
                 break;
         case Q_SETQUOTA:
                 /* currently, it is only used for nullifying the quota */