Whamcloud - gitweb
Branch b1_8
authorjohann <johann>
Thu, 15 Oct 2009 12:40:25 +0000 (12:40 +0000)
committerjohann <johann>
Thu, 15 Oct 2009 12:40:25 +0000 (12:40 +0000)
b=16890
i=adilger
i=tianzy
i=panda

CERROR cleanups in the quota code.

lustre/quota/lproc_quota.c
lustre/quota/quota_adjust_qunit.c
lustre/quota/quota_context.c
lustre/quota/quota_ctl.c
lustre/quota/quota_interface.c
lustre/quota/quota_master.c

index 52ddd1d..5a9c112 100644 (file)
@@ -276,20 +276,22 @@ static int auto_quota_on(struct obd_device *obd, int type,
                 down(&mds->mds_qonoff_sem);
                 /* turn on cluster wide quota */
                 rc = mds_admin_quota_on(obd, oqctl);
-                if (rc)
-                        CDEBUG(rc == -ENOENT ? D_QUOTA : D_ERROR,
-                               "auto-enable admin quota failed. rc=%d\n", rc);
+                if (rc && rc != -ENOENT)
+                        CERROR("%s: auto-enable admin quota failed. rc=%d\n",
+                               obd->obd_name, rc);
                 up(&mds->mds_qonoff_sem);
 
         }
         if (!rc) {
                 /* turn on local quota */
                 rc = fsfilt_quotactl(obd, sb, oqctl);
-                if (rc)
-                        CDEBUG(rc == -ENOENT ? D_QUOTA : D_ERROR,
-                               "auto-enable local quota failed. rc=%d\n", rc);
-                else
+                if (rc) {
+                        if (rc != -ENOENT)
+                                CERROR("%s: auto-enable local quota failed with"
+                                       " rc=%d\n", obd->obd_name, rc);
+                } else {
                         obt->obt_qctxt.lqc_flags |= UGQUOTA2LQC(type);
+                }
         }
 
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
@@ -695,8 +697,8 @@ int lquota_proc_setup(struct obd_device *obd, int is_master)
                                                lprocfs_quota_common_vars, obd);
         if (IS_ERR(qctxt->lqc_proc_dir)) {
                 rc = PTR_ERR(qctxt->lqc_proc_dir);
-                CERROR("error %d setting up lprocfs for %s\n", rc,
-                       obd->obd_name);
+                CERROR("%s: error %d setting up lprocfs\n",
+                       obd->obd_name, rc);
                 qctxt->lqc_proc_dir = NULL;
                 GOTO(out, rc);
         }
@@ -705,8 +707,8 @@ int lquota_proc_setup(struct obd_device *obd, int is_master)
                 rc = lprocfs_add_vars(qctxt->lqc_proc_dir,
                                       lprocfs_quota_master_vars, obd);
                 if (rc) {
-                        CERROR("error %d setting up lprocfs for %s"
-                               "(quota master)\n", rc, obd->obd_name);
+                        CERROR("%s: error %d setting up lprocfs for "
+                               "quota master\n", obd->obd_name, rc);
                         GOTO(out_free_proc, rc);
                 }
         }
index 49d487b..eeee71e 100644 (file)
@@ -175,7 +175,7 @@ struct lustre_qunit_size *quota_search_lqs(unsigned long long lqs_key,
         if (rc == 0) {
                 return lqs;
         } else {
-                CDEBUG(D_ERROR, "get lqs error(rc: %d)\n", rc);
+                CERROR("get lqs error(rc: %d)\n", rc);
                 return ERR_PTR(rc);
         }
 }
@@ -194,8 +194,8 @@ int quota_adjust_slave_lqs(struct quota_adjust_qunit *oqaq,
         lqs = quota_search_lqs(LQS_KEY(QAQ_IS_GRP(oqaq), oqaq->qaq_id),
                                qctxt, QAQ_IS_CREATE_LQS(oqaq) ? 1 : 0);
         if (lqs == NULL || IS_ERR(lqs)){
-                CDEBUG(D_ERROR, "fail to find a lqs(%s id: %u)!\n",
-                       QAQ_IS_GRP(oqaq) ? "group" : "user", oqaq->qaq_id);
+                CERROR("fail to find a lqs for %sid %u!\n",
+                       QAQ_IS_GRP(oqaq) ? "g" : "u", oqaq->qaq_id);
                 RETURN(PTR_ERR(lqs));
         }
 
index e011bf2..3f085fb 100644 (file)
@@ -277,8 +277,8 @@ check_cur_qunit(struct obd_device *obd,
         lqs = quota_search_lqs(LQS_KEY(QDATA_IS_GRP(qdata), qdata->qd_id),
                                qctxt, 0);
         if (IS_ERR(lqs) || lqs == NULL) {
-                CDEBUG(D_ERROR, "fail to find a lqs(%s id: %u)!\n",
-                       QDATA_IS_GRP(qdata) ? "group" : "user", qdata->qd_id);
+                CERROR("fail to find a lqs for %sid: %u)!\n",
+                       QDATA_IS_GRP(qdata) ? "g" : "u", qdata->qd_id);
                 GOTO (out, ret = 0);
         }
         spin_lock(&lqs->lqs_lock);
@@ -504,8 +504,9 @@ void* quota_barrier(struct lustre_quota_ctxt *qctxt,
 
         OBD_SLAB_ALLOC(qunit, qunit_cachep, CFS_ALLOC_IO, sizeof(*qunit));
         if (qunit == NULL) {
-                CERROR("locating qunit failed.(id=%u isblk=%d %s)\n",
-                       oqctl->qc_id, isblk, oqctl->qc_type ? "grp" : "usr");
+                CERROR("locating %sunit failed for %sid %u\n",
+                       isblk ? "b" : "i", oqctl->qc_type ? "g" : "u",
+                       oqctl->qc_id);
                 qctxt_wait_pending_dqacq(qctxt, oqctl->qc_id,
                                          oqctl->qc_type, isblk);
                 return NULL;
@@ -801,14 +802,14 @@ static int dqacq_interpret(struct ptlrpc_request *req, void *data, int rc)
 
         if (qdata->qd_id != qunit->lq_data.qd_id ||
             OBD_FAIL_CHECK_ONCE(OBD_FAIL_QUOTA_RET_QDATA)) {
-                CDEBUG(D_ERROR, "the returned qd_id isn't expected!"
+                CERROR("the returned qd_id isn't expected!"
                        "(qdata: %u, lq_data: %u)\n", qdata->qd_id,
                        qunit->lq_data.qd_id);
                 qdata->qd_id = qunit->lq_data.qd_id;
                 rc = -EPROTO;
         }
         if (QDATA_IS_GRP(qdata) != QDATA_IS_GRP(&qunit->lq_data)) {
-                CDEBUG(D_ERROR, "the returned grp/usr isn't expected!"
+                CERROR("the returned grp/usr isn't expected!"
                        "(qdata: %u, lq_data: %u)\n", qdata->qd_flags,
                        qunit->lq_data.qd_flags);
                 if (QDATA_IS_GRP(&qunit->lq_data))
@@ -818,7 +819,7 @@ static int dqacq_interpret(struct ptlrpc_request *req, void *data, int rc)
                 rc = -EPROTO;
         }
         if (qdata->qd_count > qunit->lq_data.qd_count) {
-                CDEBUG(D_ERROR, "the returned qd_count isn't expected!"
+                CERROR("the returned qd_count isn't expected!"
                        "(qdata: "LPU64", lq_data: "LPU64")\n", qdata->qd_count,
                        qunit->lq_data.qd_count);
                 rc = -EPROTO;
@@ -950,7 +951,7 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
                 /* this is for quota_search_lqs */
                 lqs_putref(lqs);
         } else {
-                CDEBUG(D_ERROR, "Can't find the lustre qunit size!\n");
+                CERROR("Can't find the lustre qunit size!\n");
         }
 
         QDATA_DEBUG(qdata, "obd(%s): send %s quota req\n",
@@ -1037,7 +1038,7 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
 
         rc = quota_copy_qdata(req, qdata, QUOTA_REQUEST, QUOTA_IMPORT);
         if (rc < 0) {
-                CDEBUG(D_ERROR, "Can't pack qunit_data(rc: %d)\n", rc);
+                CERROR("Can't pack qunit_data(rc: %d)\n", rc);
                 dqacq_completion(obd, qctxt, qdata, rc, opc);
                 class_import_put(imp);
                 /* this is for qunit_get() */
@@ -1234,11 +1235,11 @@ qctxt_init(struct obd_device *obd, dqacq_handler_t handler)
                                                HASH_LQS_MAX_BITS,
                                                &lqs_hash_ops, 0);
         if (!qctxt->lqc_lqs_hash)
-                CERROR("initialize hash lqs for %s error!\n", obd->obd_name);
+                CERROR("%s: initialize hash lqs failed\n", obd->obd_name);
 
 #ifdef LPROCFS
         if (lquota_proc_setup(obd, is_master(obd, qctxt, 0, 0)))
-                CERROR("initialize proc for %s error!\n", obd->obd_name);
+                CERROR("%s: initialize proc failed\n", obd->obd_name);
 #endif
 
         RETURN(rc);
@@ -1390,9 +1391,8 @@ static int qslave_recovery_main(void *arg)
                                 rc = 0;
                         }
 
-                        if (rc)
-                                CDEBUG(rc == -EBUSY ? D_QUOTA : D_ERROR,
-                                       "qslave recovery failed! (id:%d type:%d "
+                        if (rc && rc != -EBUSY)
+                                CERROR("qslave recovery failed! (id:%d type:%d "
                                        " rc:%d)\n", dqid->di_id, type, rc);
 free:
                         OBD_FREE_PTR(dqid);
index 4a4261c..d17b2d1 100644 (file)
@@ -88,7 +88,7 @@ void build_lqs(struct obd_device *obd)
                                  i, &id_list);
 #endif
                 if (rc) {
-                        CDEBUG(D_ERROR, "fail to get %s qids!\n",
+                        CERROR("%s: failed to get %s qids\n", obd->obd_name,
                                i ? "group" : "user");
                         continue;
                 }
@@ -104,8 +104,8 @@ void build_lqs(struct obd_device *obd)
                                 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",
+                                CERROR("%s: failed to create a lqs for %sid %u"
+                                       "\n", obd->obd_name, i ? "g" : "u",
                                        dqid->di_id);
                         }
 
@@ -257,7 +257,9 @@ int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                 lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
                                        qctxt, 0);
                 if (lqs == NULL || IS_ERR(lqs)){
-                        CDEBUG(D_ERROR, "fail to create lqs when setquota\n");
+                        CERROR("fail to create lqs during setquota operation "
+                               "for %sid %u\n", oqctl->qc_type ? "g" : "u",
+                               oqctl->qc_id);
                 } else {
                         lqs->lqs_flags &= ~QB_SET;
                         lqs_putref(lqs);
@@ -299,7 +301,9 @@ adjust:
                 lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
                                        qctxt, 1);
                 if (lqs == NULL || IS_ERR(lqs)){
-                        CDEBUG(D_ERROR, "fail to create lqs when setquota\n");
+                        CERROR("fail to create lqs during setquota operation "
+                               "for %sid %u\n", oqctl->qc_type ? "g" : "u",
+                               oqctl->qc_id);
                         break;
                 } else {
                         lqs->lqs_flags |= QB_SET;
index c941cee..3d48a02 100644 (file)
@@ -175,10 +175,8 @@ static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa)
                 RETURN(0);
 
         OBD_ALLOC_PTR(oqctl);
-        if (!oqctl) {
-                CERROR("Not enough memory!");
+        if (!oqctl)
                 RETURN(-ENOMEM);
-        }
 
         /* set over quota flags for a uid/gid */
         oa->o_valid |= OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA;
@@ -295,8 +293,8 @@ static int quota_check_common(struct obd_device *obd, unsigned int uid,
                                 LASSERT(inode && frags > 0);
                                 if (fsfilt_get_mblk(obd, qctxt->lqc_sb, &mb,
                                                     inode, frags) < 0)
-                                        CDEBUG(D_ERROR,
-                                               "can't get extra meta blocks.\n");
+                                        CERROR("%s: can't get extra meta "
+                                               "blocks\n", obd->obd_name);
                                 else
                                         pending[i] += mb;
                                 lqs->lqs_bwrite_pending += pending[i];
@@ -608,7 +606,8 @@ static int mds_quota_setup(struct obd_device *obd)
         sema_init(&mds->mds_qonoff_sem, 1);
         rc = qctxt_init(obd, dqacq_handler);
         if (rc) {
-                CERROR("initialize quota context failed! (rc:%d)\n", rc);
+                CERROR("%s: initialize quota context failed! (rc:%d)\n",
+                       obd->obd_name, rc);
                 RETURN(rc);
         }
         RETURN(rc);
@@ -786,26 +785,23 @@ int osc_quota_setdq(struct client_obd *cli, unsigned int uid, unsigned int gid,
                     (flags & OBD_FL_NO_USRQUOTA) : (flags & OBD_FL_NO_GRPQUOTA);
 
                 oqi = alloc_qinfo(cli, id, cnt);
-                if (oqi) {
-                        spin_lock(&qinfo_list_lock);
-
-                        old = find_qinfo(cli, id, cnt);
-                        if (old && !noquota)
-                                remove_qinfo_hash(old);
-                        else if (!old && noquota)
-                                insert_qinfo_hash(oqi);
-
-                        spin_unlock(&qinfo_list_lock);
-
-                        if (old || !noquota)
-                                free_qinfo(oqi);
-                        if (old && !noquota)
-                                free_qinfo(old);
-                } else {
-                        CERROR("not enough mem!\n");
+                if (!oqi) {
                         rc = -ENOMEM;
                         break;
                 }
+
+                spin_lock(&qinfo_list_lock);
+                old = find_qinfo(cli, id, cnt);
+                if (old && !noquota)
+                        remove_qinfo_hash(old);
+                else if (!old && noquota)
+                        insert_qinfo_hash(oqi);
+                spin_unlock(&qinfo_list_lock);
+
+                if (old || !noquota)
+                        free_qinfo(oqi);
+                if (old && !noquota)
+                        free_qinfo(old);
         }
 
         RETURN(rc);
index 6b5cede..3f617ab 100644 (file)
@@ -283,7 +283,7 @@ int dqacq_adjust_qunit_sz(struct obd_device *obd, qid_t id, int type,
                                LQUOTA_FLAGS_ADJINO, oqaq);
 
         if (rc < 0) {
-                CDEBUG(D_ERROR, "create oqaq failed! (rc:%d)\n", rc);
+                CERROR("create oqaq failed! (rc:%d)\n", rc);
                 GOTO(out_sem, rc);
         }
         QAQ_DEBUG(oqaq, "show oqaq.\n")
@@ -296,8 +296,8 @@ int dqacq_adjust_qunit_sz(struct obd_device *obd, qid_t id, int type,
         if (adjust_res <= 0) {
                 if (adjust_res < 0) {
                         rc = adjust_res;
-                        CDEBUG(D_ERROR, "adjust mds slave's qunit size failed! \
-                               (rc:%d)\n", rc);
+                        CERROR("adjust mds slave's qunit size failed! "
+                               "(rc:%d)\n", rc);
                 } else {
                         CDEBUG(D_QUOTA, "qunit doesn't need to be adjusted.\n");
                 }
@@ -317,8 +317,8 @@ int dqacq_adjust_qunit_sz(struct obd_device *obd, qid_t id, int type,
                 rc = 0;
         }
         if (rc) {
-                CDEBUG(D_ERROR, "mds fail to adjust file quota! \
-                               (rc:%d)\n", rc);
+                CERROR("%s: mds fail to adjust file quota! (rc:%d)\n",
+                       obd->obd_name, rc);
                 GOTO(out, rc);
         }
 
@@ -659,8 +659,8 @@ int mds_quota_invalidate(struct obd_device *obd, struct obd_quotactl *oqctl)
                 fp = filp_open(name, O_CREAT | O_TRUNC | O_RDWR, 0644);
                 if (IS_ERR(fp)) {
                         rc = PTR_ERR(fp);
-                        CERROR("error invalidating admin quotafile %s (rc:%d)\n",
-                               name, rc);
+                        CERROR("%s: error invalidating admin quotafile %s (rc:%d)\n",
+                               obd->obd_name, name, rc);
                 }
                 else
                         filp_close(fp, 0);
@@ -737,8 +737,8 @@ int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl)
                 if (!IS_ERR(fp)) {
                         /* irregular file is not the right place for quota */
                         if (!S_ISREG(fp->f_dentry->d_inode->i_mode)) {
-                                CERROR("admin quota file %s is not "
-                                       "regular!", quotafile);
+                                CERROR("%s: admin quota file %s is not "
+                                       "regular!", obd->obd_name, quotafile);
                                 filp_close(fp, 0);
                                 rc = -EINVAL;
                                 break;
@@ -756,8 +756,8 @@ int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl)
 
                 /* -EINVAL may be returned by quotainfo for bad quota file */
                 if (rc != -ENOENT && rc != -EINVAL) {
-                        CERROR("error opening old quota file %s (%d)\n",
-                               name, rc);
+                        CERROR("%s: error opening old quota file %s (%d)\n",
+                               obd->obd_name, name, rc);
                         break;
                 }
 
@@ -768,8 +768,8 @@ int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl)
                 fp = filp_open(name, O_CREAT | O_TRUNC | O_RDWR, 0644);
                 if (IS_ERR(fp)) {
                         rc = PTR_ERR(fp);
-                        CERROR("error creating admin quotafile %s (rc:%d)\n",
-                               name, rc);
+                        CERROR("%s: error creating admin quotafile %s (rc:%d)\n",
+                               obd->obd_name, name, rc);
                         break;
                 }
 
@@ -779,13 +779,15 @@ int init_admin_quotafiles(struct obd_device *obd, struct obd_quotactl *oqctl)
                 case LUSTRE_QUOTA_V1:
                         rc = fsfilt_quotainfo(obd, qinfo, i, QFILE_INIT_INFO);
                         if (rc)
-                                CERROR("error init %s admin quotafile! (rc:%d)\n",
+                                CERROR("%s: error init %s admin quotafile! "
+                                       "(rc:%d)\n", obd->obd_name,
                                        i == USRQUOTA ? "user" : "group", rc);
                         break;
                 case LUSTRE_QUOTA_V2:
                         rc = fsfilt_quotainfo(obd, qinfo, i, QFILE_CONVERT);
                         if (rc)
-                                CERROR("error convert %s admin quotafile! (rc:%d)\n",
+                                CERROR("%s: error convert %s admin quotafile! "
+                                       "(rc:%d)\n", obd->obd_name,
                                        i == USRQUOTA ? "user" : "group", rc);
                         break;
                 default:
@@ -1705,8 +1707,9 @@ static int qmaster_recovery_main(void *arg)
 
                         rc = dquot_recovery(obd, dqid->di_id, type);
                         if (rc)
-                                CERROR("qmaster recovery failed! (id:%d type:%d"
-                                       " rc:%d)\n", dqid->di_id, type, rc);
+                                CERROR("%s: qmaster recovery failed for %sid %d"
+                                       " rc:%d)\n", obd->obd_name,
+                                       type ? "g" : "u", dqid->di_id, rc);
 free:
                         OBD_FREE_PTR(dqid);
                 }
@@ -1737,7 +1740,8 @@ int mds_quota_recovery(struct obd_device *obd)
 
         rc = kernel_thread(qmaster_recovery_main, &data, CLONE_VM|CLONE_FILES);
         if (rc < 0)
-                CERROR("Cannot start quota recovery thread: rc %d\n", rc);
+                CERROR("%s: cannot start quota recovery thread: rc %d\n",
+                       obd->obd_name, rc);
 
         wait_for_completion(&data.comp);
         RETURN(rc);