Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / quota / quota_master.c
index 7753bff..37739e8 100644 (file)
@@ -533,7 +533,7 @@ int mds_quota_adjust(struct obd_device *obd, const unsigned int qcids[],
         }
 
         if (rc2)
-                CDEBUG(rc2 == QUOTA_REQ_RETURNED ? D_QUOTA: D_ERROR,
+                CDEBUG(D_QUOTA,
                        "mds adjust qunit %ssuccessfully! (opc:%d rc:%d)\n",
                        rc2 == QUOTA_REQ_RETURNED ? "" : "un", opc, rc2);
         RETURN(0);
@@ -569,9 +569,9 @@ int filter_quota_adjust(struct obd_device *obd, const unsigned int qcids[],
         if (rc || rc2) {
                 if (!rc)
                         rc = rc2;
-                CDEBUG(rc == QUOTA_REQ_RETURNED ? D_QUOTA: D_ERROR,
+                CDEBUG(D_QUOTA,
                        "filter adjust qunit %ssuccessfully! (opc:%d rc%d)\n",
-                       QUOTA_REQ_RETURNED ? "" : "un", opc, rc);
+                       rc == QUOTA_REQ_RETURNED ? "" : "un", opc, rc);
         }
 
         RETURN(0);
@@ -583,20 +583,22 @@ int mds_quota_invalidate(struct obd_device *obd, struct obd_quotactl *oqctl)
 {
         struct mds_obd *mds = &obd->u.mds;
         struct lustre_quota_info *qinfo = &mds->mds_quota_info;
-        int rc = 0, i;
+        struct obd_device_target *obt = &obd->u.obt;
+        int rc = 0, i, rc1 = 0;
         char *quotafile[] = LUSTRE_ADMIN_QUOTAFILES_V2;
         char name[64];
         struct lvfs_run_ctxt saved;
+        ENTRY;
 
         LASSERT(qinfo->qi_version == LUSTRE_QUOTA_V2);
 
         if (oqctl->qc_type != USRQUOTA &&
             oqctl->qc_type != GRPQUOTA &&
             oqctl->qc_type != UGQUOTA)
-                return -EINVAL;
+                RETURN(-EINVAL);
 
+        down(&obt->obt_quotachecking);
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
         down(&mds->mds_qonoff_sem);
 
         for (i = 0; i < MAXQUOTAS; i++) {
@@ -607,8 +609,9 @@ int mds_quota_invalidate(struct obd_device *obd, struct obd_quotactl *oqctl)
 
                 /* quota file has been opened ? */
                 if (qinfo->qi_files[i]) {
-                        rc = -EBUSY;
-                        goto out;
+                        CWARN("quota[%d] is on yet\n", i);
+                        rc1 = -EBUSY;
+                        continue;
                 }
 
                 LASSERT(strlen(quotafile[i]) + sizeof(prefix) <= sizeof(name));
@@ -624,25 +627,26 @@ int mds_quota_invalidate(struct obd_device *obd, struct obd_quotactl *oqctl)
                         filp_close(fp, 0);
         }
 
-out:
         up(&mds->mds_qonoff_sem);
-
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
-        return rc;
+        up(&obt->obt_quotachecking);
+        RETURN(rc ? : rc1);
 }
 
 int mds_quota_finvalidate(struct obd_device *obd, struct obd_quotactl *oqctl)
 {
         struct mds_obd *mds = &obd->u.mds;
+        struct obd_device_target *obt = &obd->u.obt;
         int rc;
         struct lvfs_run_ctxt saved;
+        ENTRY;
 
         if (oqctl->qc_type != USRQUOTA &&
             oqctl->qc_type != GRPQUOTA &&
             oqctl->qc_type != UGQUOTA)
                 RETURN(-EINVAL);
 
+        down(&obt->obt_quotachecking);
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         down(&mds->mds_qonoff_sem);
 
@@ -653,8 +657,8 @@ int mds_quota_finvalidate(struct obd_device *obd, struct obd_quotactl *oqctl)
 
         up(&mds->mds_qonoff_sem);
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
-        return rc;
+        up(&obt->obt_quotachecking);
+        RETURN(rc);
 }
 
 int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl)
@@ -756,7 +760,8 @@ static int close_quota_files(struct obd_quotactl *oqctl,
                 if (!Q_TYPESET(oqctl, i))
                         continue;
                 if (qinfo->qi_files[i] == NULL) {
-                        rc = -ESRCH;
+                        CWARN("quota[%d] is off already\n", i);
+                        rc = -EALREADY;
                         continue;
                 }
                 filp_close(qinfo->qi_files[i], 0);
@@ -771,7 +776,7 @@ int mds_admin_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl)
         struct lustre_quota_info *qinfo = &mds->mds_quota_info;
         const char *quotafile[] = LUSTRE_ADMIN_QUOTAFILES_V2;
         char name[64];
-        int i, rc = 0;
+        int i, rc = 0, rc1 = 0;
         ENTRY;
 
         LASSERT(qinfo->qi_version == LUSTRE_QUOTA_V2);
@@ -788,8 +793,9 @@ int mds_admin_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl)
                 sprintf(name, "%s%s", prefix, quotafile[i]);
 
                 if (qinfo->qi_files[i] != NULL) {
-                        rc = -EBUSY;
-                        break;
+                        CWARN("quota[%d] is on already\n", i);
+                        rc1 = -EALREADY;
+                        continue;
                 }
 
                 fp = filp_open(name, O_RDWR, 0);
@@ -814,10 +820,10 @@ int mds_admin_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl)
                 }
         }
 
-        if (rc && rc != -EBUSY)
+        if (rc && rc1 != -EALREADY)
                 close_quota_files(oqctl, qinfo);
 
-        RETURN(rc);
+        RETURN(rc ? : rc1);
 }
 
 int mds_admin_quota_off(struct obd_device *obd,
@@ -837,8 +843,9 @@ int mds_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl)
 {
         struct mds_obd *mds = &obd->u.mds;
         struct obd_device_target *obt = &obd->u.obt;
+        struct lustre_quota_ctxt *qctxt = &obt->obt_qctxt;
         struct lvfs_run_ctxt saved;
-        int rc;
+        int rc = 0, rc1 = 0, rc2 = 0;
         ENTRY;
 
         if (oqctl->qc_type != USRQUOTA &&
@@ -846,42 +853,76 @@ int mds_quota_on(struct obd_device *obd, struct obd_quotactl *oqctl)
             oqctl->qc_type != UGQUOTA)
                 RETURN(-EINVAL);
 
-        if (!atomic_dec_and_test(&obt->obt_quotachecking)) {
-                CDEBUG(D_INFO, "other people are doing quotacheck\n");
-                atomic_inc(&obt->obt_quotachecking);
-                RETURN(-EBUSY);
+        down(&obt->obt_quotachecking);
+        if (obt->obt_qctxt.lqc_immutable) {
+                LCONSOLE_ERROR("Failed to turn Quota on, immutable mode "
+                               "(is SOM enabled?)\n");
+                up(&obt->obt_quotachecking);
+                RETURN(-ECANCELED);
         }
 
-        LASSERT(!obt->obt_qctxt.lqc_immutable);
-        down(&mds->mds_qonoff_sem);
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        rc = mds_admin_quota_on(obd, oqctl);
-        if (rc)
-                GOTO(out, rc);
+        down(&mds->mds_qonoff_sem);
+        rc2 = mds_admin_quota_on(obd, oqctl);
+        if (rc2 && rc2 != -EALREADY) {
+                CWARN("mds quota[%d] is failed to be on for %d\n", oqctl->qc_type, rc2);
+                GOTO(out, rc2);
+        }
 
-        rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
-        if (!rc)
-                obt->obt_qctxt.lqc_flags |= UGQUOTA2LQC(oqctl->qc_type);
-        else
-                GOTO(out, rc);
+        rc1 = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
+        if (!rc1) {
+                qctxt->lqc_flags |= UGQUOTA2LQC(oqctl->qc_type);
+                /* when quotaon, create lqs for every quota uid/gid b=18574 */
+                build_lqs(obd);
+        } else if (rc1 == -EBUSY && quota_is_on(qctxt, oqctl)) {
+                CWARN("mds local quota[%d] is on already\n", oqctl->qc_type);
+                rc1 = -EALREADY;
+        } else {
+                if (rc2 != -EALREADY) {
+                        CWARN("mds local quota[%d] is failed to be on for %d\n",
+                              oqctl->qc_type, rc1);
+                        oqctl->qc_cmd = Q_QUOTAOFF;
+                        mds_admin_quota_off(obd, oqctl);
+                        oqctl->qc_cmd = Q_QUOTAON;
+                }
+                GOTO(out, rc1);
+        }
 
         rc = obd_quotactl(mds->mds_osc_exp, oqctl);
+        if (rc && rc != -EALREADY) {
+                CWARN("mds remote quota[%d] is failed to be on for %d\n",
+                      oqctl->qc_type, rc);
+                oqctl->qc_cmd = Q_QUOTAOFF;
+                if (rc2 != -EALREADY)
+                        mds_admin_quota_off(obd, oqctl);
+                if (rc1 != -EALREADY) {
+                        fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
+                        qctxt->lqc_flags &= ~UGQUOTA2LQC(oqctl->qc_type);
+                }
+                oqctl->qc_cmd = Q_QUOTAON;
+        }
+
+        EXIT;
 
 out:
-        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         up(&mds->mds_qonoff_sem);
-        atomic_inc(&obt->obt_quotachecking);
-        RETURN(rc);
+        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+        up(&obt->obt_quotachecking);
+        return rc ? : (rc1 ? : rc2);
 }
 
-int mds_quota_off(struct obd_device *obd, struct obd_quotactl *oqctl)
+/* with obt->obt_quotachecking held */
+int do_mds_quota_off(struct obd_device *obd, struct obd_quotactl *oqctl)
 {
         struct mds_obd *mds = &obd->u.mds;
         struct obd_device_target *obt = &obd->u.obt;
+        struct lustre_quota_ctxt *qctxt = &obt->obt_qctxt;
         struct lvfs_run_ctxt saved;
-        int rc, rc2, imm;
+        int rc = 0, rc1 = 0, rc2 = 0, imm;
         ENTRY;
 
+        LASSERT_SEM_LOCKED(&obt->obt_quotachecking);
+
         imm = oqctl->qc_type & IMMQUOTA;
         oqctl->qc_type &= ~IMMQUOTA;
 
@@ -890,29 +931,67 @@ int mds_quota_off(struct obd_device *obd, struct obd_quotactl *oqctl)
             oqctl->qc_type != UGQUOTA)
                 RETURN(-EINVAL);
 
-        if (!atomic_dec_and_test(&obt->obt_quotachecking)) {
-                CDEBUG(D_INFO, "other people are doing quotacheck\n");
-                atomic_inc(&obt->obt_quotachecking);
-                RETURN(-EBUSY);
-        }
-
+        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         down(&mds->mds_qonoff_sem);
         /* close admin quota files */
-        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        mds_admin_quota_off(obd, oqctl);
+        rc2 = mds_admin_quota_off(obd, oqctl);
+        if (rc2 && rc2 != -EALREADY) {
+                CWARN("mds quota[%d] is failed to be off for %d\n", oqctl->qc_type, rc2);
+                GOTO(out, rc2);
+        }
 
-        rc = obd_quotactl(mds->mds_osc_exp, oqctl);
-        rc2 = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
-        if (!rc2) {
+        rc1 = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
+        if (!rc1) {
                 if (imm)
                         obt->obt_qctxt.lqc_immutable = 1;
                 obt->obt_qctxt.lqc_flags &= ~UGQUOTA2LQC(oqctl->qc_type);
+        } else if (quota_is_off(qctxt, oqctl)) {
+                CWARN("mds local quota[%d] is off already\n", oqctl->qc_type);
+                rc1 = -EALREADY;
+        } else {
+                if (rc2 != -EALREADY) {
+                        CWARN("mds local quota[%d] is failed to be off for %d\n",
+                              oqctl->qc_type, rc1);
+                        oqctl->qc_cmd = Q_QUOTAON;
+                        mds_admin_quota_on(obd, oqctl);
+                        oqctl->qc_cmd = Q_QUOTAOFF;
+                }
+                GOTO(out, rc1);
         }
-        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+
+        rc = obd_quotactl(mds->mds_osc_exp, oqctl);
+        if (rc && rc != -EALREADY) {
+                CWARN("mds remote quota[%d] is failed to be off for %d\n",
+                      oqctl->qc_type, rc);
+                oqctl->qc_cmd = Q_QUOTAON;
+                if (rc2 != -EALREADY)
+                        mds_admin_quota_on(obd, oqctl);
+                if (rc1 != -EALREADY) {
+                        fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
+                        if (imm)
+                                obt->obt_qctxt.lqc_immutable = 0;
+                        qctxt->lqc_flags |= UGQUOTA2LQC(oqctl->qc_type);
+                }
+                oqctl->qc_cmd = Q_QUOTAOFF;
+        }
+        EXIT;
+
+out:
         up(&mds->mds_qonoff_sem);
-        atomic_inc(&obt->obt_quotachecking);
+        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+        return rc ? : (rc1 ? : rc2);
+}
 
-        RETURN(rc ?: rc2);
+int mds_quota_off(struct obd_device *obd, struct obd_quotactl *oqctl)
+{
+        struct obd_device_target *obt = &obd->u.obt;
+        int rc;
+        ENTRY;
+
+        down(&obt->obt_quotachecking);
+        rc = do_mds_quota_off(obd, oqctl);
+        up(&obt->obt_quotachecking);
+        RETURN(rc);
 }
 
 int mds_set_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl)
@@ -929,8 +1008,8 @@ int mds_set_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl)
 
         down(&mds->mds_qonoff_sem);
         if (qinfo->qi_files[oqctl->qc_type] == NULL) {
-                rc = -ESRCH;
-                goto out;
+                CWARN("quota[%u] is off\n", oqctl->qc_type);
+                GOTO(out, rc = -ESRCH);
         }
 
         qinfo->qi_info[oqctl->qc_type].dqi_bgrace = dqinfo->dqi_bgrace;
@@ -938,10 +1017,11 @@ int mds_set_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl)
         qinfo->qi_info[oqctl->qc_type].dqi_flags = dqinfo->dqi_flags;
 
         rc = fsfilt_quotainfo(obd, qinfo, oqctl->qc_type, QFILE_WR_INFO);
+        EXIT;
 
 out:
         up(&mds->mds_qonoff_sem);
-        RETURN(rc);
+        return rc;
 }
 
 int mds_get_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl)
@@ -958,17 +1038,18 @@ int mds_get_dqinfo(struct obd_device *obd, struct obd_quotactl *oqctl)
 
         down(&mds->mds_qonoff_sem);
         if (qinfo->qi_files[oqctl->qc_type] == NULL) {
-                rc = -ESRCH;
-                goto out;
+                CWARN("quota[%u] is off\n", oqctl->qc_type);
+                GOTO(out, rc = -ESRCH);
         }
 
         dqinfo->dqi_bgrace = qinfo->qi_info[oqctl->qc_type].dqi_bgrace;
         dqinfo->dqi_igrace = qinfo->qi_info[oqctl->qc_type].dqi_igrace;
         dqinfo->dqi_flags = qinfo->qi_info[oqctl->qc_type].dqi_flags;
+        EXIT;
 
 out:
         up(&mds->mds_qonoff_sem);
-        RETURN(rc);
+        return rc;
 }
 
 int dquot_create_oqaq(struct lustre_quota_ctxt *qctxt,
@@ -1069,28 +1150,20 @@ int dquot_create_oqaq(struct lustre_quota_ctxt *qctxt,
 
         }
 
-        if (!dquot->dq_dqb.dqb_bhardlimit && !dquot->dq_dqb.dqb_bsoftlimit &&
-            !dquot->dq_dqb.dqb_ihardlimit && !dquot->dq_dqb.dqb_isoftlimit) {
-                oqaq->qaq_bunit_sz = 0;
-                oqaq->qaq_iunit_sz = 0;
-                QAQ_SET_ADJBLK(oqaq);
-                QAQ_SET_ADJINO(oqaq);
-        }
-
         QAQ_DEBUG(oqaq, "the oqaq computed\n");
 
         RETURN(rc);
 }
 
 static int mds_init_slave_ilimits(struct obd_device *obd,
-                                  struct obd_quotactl *oqctl, int set,
-                                  struct quota_adjust_qunit *oqaq)
+                                  struct obd_quotactl *oqctl, int set)
 {
         /* XXX: for file limits only adjust local now */
         struct obd_device_target *obt = &obd->u.obt;
         struct lustre_quota_ctxt *qctxt = &obt->obt_qctxt;
         unsigned int id[MAXQUOTAS] = { 0, 0 };
         struct obd_quotactl *ioqc = NULL;
+        struct lustre_qunit_size *lqs;
         int flag;
         int rc;
         ENTRY;
@@ -1112,12 +1185,21 @@ static int mds_init_slave_ilimits(struct obd_device *obd,
         ioqc->qc_dqblk.dqb_valid = QIF_ILIMITS;
         ioqc->qc_dqblk.dqb_ihardlimit = flag ? MIN_QLIMIT : 0;
 
-        if (QAQ_IS_ADJINO(oqaq)) {
-                /* adjust the mds slave's inode qunit size */
-                rc = quota_adjust_slave_lqs(oqaq, qctxt);
-                if (rc < 0)
-                        CDEBUG(D_ERROR, "adjust mds slave's inode qunit size \
-                               failed! (rc:%d)\n", rc);
+        /* build lqs for mds */
+        lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
+                               qctxt, flag ? 1 : 0);
+        if (lqs && !IS_ERR(lqs)) {
+                if (flag)
+                        lqs->lqs_flags |= QI_SET;
+                else
+                        lqs->lqs_flags &= ~QI_SET;
+                lqs_putref(lqs);
+        } else {
+                CERROR("fail to %s lqs for inode(%s id: %u)!\n",
+                       flag ? "create" : "search",
+                       oqctl->qc_type ? "group" : "user",
+                       oqctl->qc_id);
+                GOTO(out, rc = PTR_ERR(lqs));
         }
 
         /* set local limit to MIN_QLIMIT */
@@ -1150,15 +1232,15 @@ out:
 }
 
 static int mds_init_slave_blimits(struct obd_device *obd,
-                                  struct obd_quotactl *oqctl, int set,
-                                  struct quota_adjust_qunit *oqaq)
+                                  struct obd_quotactl *oqctl, int set)
 {
         struct obd_device_target *obt = &obd->u.obt;
         struct lustre_quota_ctxt *qctxt = &obt->obt_qctxt;
         struct mds_obd *mds = &obd->u.mds;
         struct obd_quotactl *ioqc;
+        struct lustre_qunit_size *lqs;
         unsigned int id[MAXQUOTAS] = { 0, 0 };
-        int rc, rc1 = 0;
+        int rc;
         int flag;
         ENTRY;
 
@@ -1178,12 +1260,22 @@ static int mds_init_slave_blimits(struct obd_device *obd,
         ioqc->qc_type = oqctl->qc_type;
         ioqc->qc_dqblk.dqb_valid = QIF_BLIMITS;
         ioqc->qc_dqblk.dqb_bhardlimit = flag ? MIN_QLIMIT : 0;
-        if (QAQ_IS_ADJBLK(oqaq)) {
-                /* adjust the mds slave's block qunit size */
-                rc1 = quota_adjust_slave_lqs(oqaq, qctxt);
-                if (rc1 < 0)
-                        CERROR("adjust mds slave's block qunit size failed!"
-                               "(rc:%d)\n", rc1);
+
+        /* build lqs for mds */
+        lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
+                               qctxt, flag ? 1 : 0);
+        if (lqs && !IS_ERR(lqs)) {
+                if (flag)
+                        lqs->lqs_flags |= QB_SET;
+                else
+                        lqs->lqs_flags &= ~QB_SET;
+                lqs_putref(lqs);
+        } else {
+                CERROR("fail to %s lqs for block(%s id: %u)!\n",
+                       flag ? "create" : "search",
+                       oqctl->qc_type ? "group" : "user",
+                       oqctl->qc_id);
+                GOTO(out, rc = PTR_ERR(lqs));
         }
 
         rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, ioqc);
@@ -1209,18 +1301,32 @@ static int mds_init_slave_blimits(struct obd_device *obd,
                 GOTO(out, rc);
         }
 
-        /* adjust all slave's qunit size when setting quota
-         * this is will create a lqs for every ost, which will present
-         * certain uid/gid is set quota or not */
-        QAQ_SET_ADJBLK(oqaq);
-        rc = obd_quota_adjust_qunit(mds->mds_osc_exp, oqaq, qctxt);
-
         EXIT;
 out:
         OBD_FREE_PTR(ioqc);
         return rc;
 }
 
+static void adjust_lqs(struct obd_device *obd, struct quota_adjust_qunit *qaq)
+{
+        struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
+        int rc = 0;
+
+        QAQ_SET_CREATE_LQS(qaq);
+        /* adjust local lqs */
+        rc = quota_adjust_slave_lqs(qaq, qctxt);
+        if (rc < 0)
+                CERROR("adjust master's qunit size failed!(rc=%d)\n", rc);
+
+        /* adjust remote lqs */
+        if (QAQ_IS_ADJBLK(qaq)) {
+                rc = obd_quota_adjust_qunit(obd->u.mds.mds_osc_exp, qaq, qctxt);
+                if (rc < 0)
+                        CERROR("adjust slaves' qunit size failed!(rc=%d)\n", rc);
+
+        }
+}
+
 int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl)
 {
         struct mds_obd *mds = &obd->u.mds;
@@ -1249,8 +1355,10 @@ int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl)
         down(&mds->mds_qonoff_sem);
         init_oqaq(oqaq, qctxt, oqctl->qc_id, oqctl->qc_type);
 
-        if (qinfo->qi_files[oqctl->qc_type] == NULL)
+        if (qinfo->qi_files[oqctl->qc_type] == NULL) {
+                CWARN("quota[%u] is off\n", oqctl->qc_type);
                 GOTO(out_sem, rc = -ESRCH);
+        }
 
         dquot = lustre_dqget(obd, qinfo, oqctl->qc_id, oqctl->qc_type);
         if (IS_ERR(dquot))
@@ -1334,13 +1442,16 @@ int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl)
         }
 
         up(&mds->mds_qonoff_sem);
+
+        adjust_lqs(obd, oqaq);
+
         orig_set = ihardlimit || isoftlimit;
         now_set  = dqblk->dqb_ihardlimit || dqblk->dqb_isoftlimit;
         if (dqblk->dqb_valid & QIF_ILIMITS && orig_set != now_set) {
                 down(&dquot->dq_sem);
                 dquot->dq_dqb.dqb_curinodes = 0;
                 up(&dquot->dq_sem);
-                rc = mds_init_slave_ilimits(obd, oqctl, orig_set, oqaq);
+                rc = mds_init_slave_ilimits(obd, oqctl, orig_set);
                 if (rc) {
                         CERROR("init slave ilimits failed! (rc:%d)\n", rc);
                         goto revoke_out;
@@ -1353,7 +1464,7 @@ int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl)
                 down(&dquot->dq_sem);
                 dquot->dq_dqb.dqb_curspace = 0;
                 up(&dquot->dq_sem);
-                rc = mds_init_slave_blimits(obd, oqctl, orig_set, oqaq);
+                rc = mds_init_slave_blimits(obd, oqctl, orig_set);
                 if (rc) {
                         CERROR("init slave blimits failed! (rc:%d)\n", rc);
                         goto revoke_out;
@@ -1445,8 +1556,10 @@ int mds_get_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl)
 
         down(&mds->mds_qonoff_sem);
         dqblk->dqb_valid = 0;
-        if (qinfo->qi_files[oqctl->qc_type] == NULL)
+        if (qinfo->qi_files[oqctl->qc_type] == NULL) {
+                CWARN("quota[%u] is off\n", oqctl->qc_type);
                 GOTO(out, rc = -ESRCH);
+        }
 
         dquot = lustre_dqget(obd, qinfo, oqctl->qc_id, oqctl->qc_type);
         if (IS_ERR(dquot))
@@ -1463,12 +1576,14 @@ int mds_get_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl)
         up(&dquot->dq_sem);
 
         lustre_dqput(dquot);
+        up(&mds->mds_qonoff_sem);
 
         /* the usages in admin quota file is inaccurate */
         dqblk->dqb_curinodes = 0;
         dqblk->dqb_curspace = 0;
         rc = mds_get_space(obd, oqctl);
         EXIT;
+        return rc;
 out:
         up(&mds->mds_qonoff_sem);
         return rc;
@@ -1577,7 +1692,7 @@ static int qmaster_recovery_main(void *arg)
         unsigned short type;
         ENTRY;
 
-        ptlrpc_daemonize("qmaster_recovd");
+        cfs_daemonize_ctxt("qmaster_recovd");
 
         /* for mds */
         class_incref(obd, "qmaster_recovd_mds", obd);
@@ -1613,7 +1728,7 @@ static int qmaster_recovery_main(void *arg)
                                 CERROR("qmaster recovery failed! (id:%d type:%d"
                                        " rc:%d)\n", dqid->di_id, type, rc);
 free:
-                        kfree(dqid);
+                        OBD_FREE_PTR(dqid);
                 }
         }
         class_decref(mds->mds_osc_obd, "qmaster_recovd_lov", mds->mds_osc_obd);