Whamcloud - gitweb
LU-2509 quota: various code cleanups
authorJohann Lombardi <johann.lombardi@intel.com>
Tue, 18 Dec 2012 21:54:54 +0000 (22:54 +0100)
committerOleg Drokin <green@whamcloud.com>
Fri, 18 Jan 2013 17:01:41 +0000 (12:01 -0500)
Address some cleanups that were mentioned during code inspection.

Signed-off-by: Johann Lombardi <johann.lombardi@intel.com>
Change-Id: I3cab9c0e6bfefef0d717e542f6620cc167075937
Reviewed-on: http://review.whamcloud.com/4855
Tested-by: Hudson
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdd/mdd_object.c
lustre/osd-zfs/osd_object.c
lustre/quota/lquota_disk.c
lustre/quota/lquota_lib.c
lustre/quota/qmt_lock.c
lustre/quota/qsd_lib.c
lustre/quota/qsd_lock.c
lustre/quota/qsd_request.c
lustre/quota/qsd_writeback.c

index a4d7e84..cb742d5 100644 (file)
@@ -2081,7 +2081,7 @@ out:
        if (result > 0)
                /* end of directory */
                dp->ldp_hash_end = cpu_to_le64(MDS_DIR_END_OFF);
        if (result > 0)
                /* end of directory */
                dp->ldp_hash_end = cpu_to_le64(MDS_DIR_END_OFF);
-       if (result < 0)
+       else if (result < 0)
                CWARN("build page failed: %d!\n", result);
         return result;
 }
                CWARN("build page failed: %d!\n", result);
         return result;
 }
index 86e9d87..96eca39 100644 (file)
@@ -782,8 +782,9 @@ static inline int qsd_transfer(const struct lu_env *env,
        /* and one less inode for the current id */
        qi->lqi_id.qid_uid = orig_id;;
        qi->lqi_space      = -1;
        /* and one less inode for the current id */
        qi->lqi_id.qid_uid = orig_id;;
        qi->lqi_space      = -1;
+       /* can't get EDQUOT when reducing usage */
        rc = qsd_op_begin(env, qsd, trans, qi, NULL);
        rc = qsd_op_begin(env, qsd, trans, qi, NULL);
-       if (rc == -EDQUOT || rc == -EINPROGRESS)
+       if (rc == -EINPROGRESS)
                rc = 0;
        if (rc)
                return rc;
                rc = 0;
        if (rc)
                return rc;
@@ -804,7 +805,8 @@ static inline int qsd_transfer(const struct lu_env *env,
        qi->lqi_id.qid_uid = orig_id;
        qi->lqi_space      = -bspace;
        rc = qsd_op_begin(env, qsd, trans, qi, NULL);
        qi->lqi_id.qid_uid = orig_id;
        qi->lqi_space      = -bspace;
        rc = qsd_op_begin(env, qsd, trans, qi, NULL);
-       if (rc == -EDQUOT || rc == -EINPROGRESS)
+       /* can't get EDQUOT when reducing usage */
+       if (rc == -EINPROGRESS)
                rc = 0;
        return rc;
 }
                rc = 0;
        return rc;
 }
@@ -1037,6 +1039,7 @@ static int osd_declare_object_create(const struct lu_env *env,
        struct osd_device       *osd = osd_obj2dev(obj);
        struct osd_thandle      *oh;
        uint64_t                 zapid;
        struct osd_device       *osd = osd_obj2dev(obj);
        struct osd_thandle      *oh;
        uint64_t                 zapid;
+       int                      rc;
        ENTRY;
 
        LASSERT(dof);
        ENTRY;
 
        LASSERT(dof);
@@ -1090,8 +1093,9 @@ static int osd_declare_object_create(const struct lu_env *env,
        __osd_xattr_declare_set(env, obj, sizeof(struct lustre_mdt_attrs),
                                XATTR_NAME_LMA, oh);
 
        __osd_xattr_declare_set(env, obj, sizeof(struct lustre_mdt_attrs),
                                XATTR_NAME_LMA, oh);
 
-       RETURN(osd_declare_quota(env, osd, attr->la_uid, attr->la_gid, 1, oh,
-                                false, NULL, false));
+       rc = osd_declare_quota(env, osd, attr->la_uid, attr->la_gid, 1, oh,
+                              false, NULL, false);
+       RETURN(rc);
 }
 
 int __osd_attr_init(const struct lu_env *env, udmu_objset_t *uos,
 }
 
 int __osd_attr_init(const struct lu_env *env, udmu_objset_t *uos,
index eabbbc1..9f8069b 100644 (file)
@@ -482,7 +482,7 @@ int lquota_disk_for_each_slv(const struct lu_env *env, struct dt_object *parent,
        int                              rc;
        ENTRY;
 
        int                              rc;
        ENTRY;
 
-       OBD_ALLOC(name, sizeof("0x00000000-"));
+       OBD_ALLOC(name, LQUOTA_NAME_MAX);
        if (name == NULL)
                RETURN(-ENOMEM);
 
        if (name == NULL)
                RETURN(-ENOMEM);
 
@@ -493,7 +493,7 @@ int lquota_disk_for_each_slv(const struct lu_env *env, struct dt_object *parent,
        iops = &parent->do_index_ops->dio_it;
        it = iops->init(env, parent, 0, BYPASS_CAPA);
        if (IS_ERR(it)) {
        iops = &parent->do_index_ops->dio_it;
        it = iops->init(env, parent, 0, BYPASS_CAPA);
        if (IS_ERR(it)) {
-               OBD_FREE(name, sizeof("0x00000000-"));
+               OBD_FREE(name, LQUOTA_NAME_MAX);
                RETURN(PTR_ERR(it));
        }
 
                RETURN(PTR_ERR(it));
        }
 
@@ -556,7 +556,7 @@ next:
 
        iops->put(env, it);
        iops->fini(env, it);
 
        iops->put(env, it);
        iops->fini(env, it);
-       OBD_FREE(name, sizeof("0x00000000-"));
+       OBD_FREE(name, LQUOTA_NAME_MAX);
        if (rc > 0)
                rc = 0;
        RETURN(rc);
        if (rc > 0)
                rc = 0;
        RETURN(rc);
index c1d4590..5bc2c9b 100644 (file)
@@ -382,7 +382,7 @@ static void exit_lquota(void)
        lu_context_key_degister(&lquota_thread_key);
 }
 
        lu_context_key_degister(&lquota_thread_key);
 }
 
-MODULE_AUTHOR("Intel, Inc. <http://www.intel.com/>");
+MODULE_AUTHOR("Intel Corporation <http://www.intel.com/>");
 MODULE_DESCRIPTION("Lustre Quota");
 MODULE_LICENSE("GPL");
 
 MODULE_DESCRIPTION("Lustre Quota");
 MODULE_LICENSE("GPL");
 
index a4086f6..05c60b0 100644 (file)
@@ -52,7 +52,7 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld,
        struct obd_uuid         *uuid;
        struct lquota_lvb       *lvb;
        struct ldlm_resource    *res = (*lockp)->l_resource;
        struct obd_uuid         *uuid;
        struct lquota_lvb       *lvb;
        struct ldlm_resource    *res = (*lockp)->l_resource;
-       int                      rc;
+       int                      rc, lvb_len;
        ENTRY;
 
        req_capsule_extend(&req->rq_pill, &RQF_LDLM_INTENT_QUOTA);
        ENTRY;
 
        req_capsule_extend(&req->rq_pill, &RQF_LDLM_INTENT_QUOTA);
@@ -135,7 +135,9 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld,
 
        /* on success, pack lvb in reply */
        lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB);
 
        /* on success, pack lvb in reply */
        lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB);
-       ldlm_lvbo_fill(*lockp, lvb, ldlm_lvbo_size(*lockp));
+       lvb_len = ldlm_lvbo_size(*lockp);
+       lvb_len = ldlm_lvbo_fill(*lockp, lvb, lvb_len);
+       req_capsule_shrink(&req->rq_pill, &RMF_DLM_LVB, lvb_len, RCL_SERVER);
        EXIT;
 out:
        return rc;
        EXIT;
 out:
        return rc;
index dc4fdae..e3e2f7f 100644 (file)
@@ -362,7 +362,6 @@ static int qsd_qtype_init(const struct lu_env *env, struct qsd_instance *qsd,
        thread_set_flags(&qqi->qqi_reint_thread, SVC_STOPPED);
        CFS_INIT_LIST_HEAD(&qqi->qqi_deferred_glb);
        CFS_INIT_LIST_HEAD(&qqi->qqi_deferred_slv);
        thread_set_flags(&qqi->qqi_reint_thread, SVC_STOPPED);
        CFS_INIT_LIST_HEAD(&qqi->qqi_deferred_glb);
        CFS_INIT_LIST_HEAD(&qqi->qqi_deferred_slv);
-       memset(&qqi->qqi_lockh, 0, sizeof(qqi->qqi_lockh));
 
        /* open accounting object */
        LASSERT(qqi->qqi_acct_obj == NULL);
 
        /* open accounting object */
        LASSERT(qqi->qqi_acct_obj == NULL);
@@ -462,14 +461,6 @@ void qsd_fini(const struct lu_env *env, struct qsd_instance *qsd)
        qsd->qsd_stopping = true;
        write_unlock(&qsd->qsd_lock);
 
        qsd->qsd_stopping = true;
        write_unlock(&qsd->qsd_lock);
 
-       /* remove from the list of fsinfo */
-       if (!cfs_list_empty(&qsd->qsd_link)) {
-               LASSERT(qsd->qsd_fsinfo != NULL);
-               down(&qsd->qsd_fsinfo->qfs_sem);
-               cfs_list_del_init(&qsd->qsd_link);
-               up(&qsd->qsd_fsinfo->qfs_sem);
-       }
-
        /* remove qsd proc entry */
        if (qsd->qsd_proc != NULL) {
                lprocfs_remove(&qsd->qsd_proc);
        /* remove qsd proc entry */
        if (qsd->qsd_proc != NULL) {
                lprocfs_remove(&qsd->qsd_proc);
@@ -501,8 +492,14 @@ void qsd_fini(const struct lu_env *env, struct qsd_instance *qsd)
        lustre_deregister_osp_item(&qsd->qsd_exp);
 
        /* release per-filesystem information */
        lustre_deregister_osp_item(&qsd->qsd_exp);
 
        /* release per-filesystem information */
-       if (qsd->qsd_fsinfo != NULL)
+       if (qsd->qsd_fsinfo != NULL) {
+               down(&qsd->qsd_fsinfo->qfs_sem);
+               /* remove from the list of fsinfo */
+               cfs_list_del_init(&qsd->qsd_link);
+               up(&qsd->qsd_fsinfo->qfs_sem);
                qsd_put_fsinfo(qsd->qsd_fsinfo);
                qsd_put_fsinfo(qsd->qsd_fsinfo);
+               qsd->qsd_fsinfo = NULL;
+       }
 
        /* release quota root directory */
        if (qsd->qsd_root != NULL) {
 
        /* release quota root directory */
        if (qsd->qsd_root != NULL) {
index 6fd2de0..c63d033 100644 (file)
@@ -54,16 +54,19 @@ static struct qsd_qtype_info *qsd_glb_ast_data_get(struct ldlm_lock *lock,
        qqi = lock->l_ast_data;
        if (qqi != NULL) {
                qqi_getref(qqi);
        qqi = lock->l_ast_data;
        if (qqi != NULL) {
                qqi_getref(qqi);
-               lu_ref_add(&qqi->qqi_reference, "ast_data_get", lock);
                if (reset)
                        lock->l_ast_data = NULL;
        }
        unlock_res_and_lock(lock);
 
                if (reset)
                        lock->l_ast_data = NULL;
        }
        unlock_res_and_lock(lock);
 
+       if (qqi != NULL)
+               /* it is not safe to call lu_ref_add() under spinlock */
+               lu_ref_add(&qqi->qqi_reference, "ast_data_get", lock);
+
        if (reset && qqi != NULL) {
                /* release qqi reference hold for the lock */
        if (reset && qqi != NULL) {
                /* release qqi reference hold for the lock */
-               qqi_putref(qqi);
                lu_ref_del(&qqi->qqi_reference, "glb_lock", lock);
                lu_ref_del(&qqi->qqi_reference, "glb_lock", lock);
+               qqi_putref(qqi);
        }
        RETURN(qqi);
 }
        }
        RETURN(qqi);
 }
@@ -472,6 +475,7 @@ int qsd_id_lock_match(struct lustre_handle *lockh, struct lustre_handle *rlockh)
        ldlm_lock_dump_handle(D_QUOTA, lockh);
 
        if (rlockh == NULL)
        ldlm_lock_dump_handle(D_QUOTA, lockh);
 
        if (rlockh == NULL)
+               /* caller not interested in remote handle */
                RETURN(0);
 
        /* look up lock associated with local handle and extract remote handle
                RETURN(0);
 
        /* look up lock associated with local handle and extract remote handle
index f05a356..5e46bfc 100644 (file)
@@ -400,7 +400,10 @@ int qsd_fetch_index(const struct lu_env *env, struct obd_export *exp,
                                          req->rq_bulk->bd_nob_transferred);
        if (rc < 0)
                GOTO(out, rc);
                                          req->rq_bulk->bd_nob_transferred);
        if (rc < 0)
                GOTO(out, rc);
-       rc = 0;
+       else
+               /* sptlrpc_cli_unwrap_bulk_read() returns the number of bytes
+                * transferred*/
+               rc = 0;
 
        req_ii = req_capsule_server_get(&req->rq_pill, &RMF_IDX_INFO);
        *ii = *req_ii;
 
        req_ii = req_capsule_server_get(&req->rq_pill, &RMF_IDX_INFO);
        *ii = *req_ii;
index 871a14e..037fb2b 100644 (file)
@@ -209,7 +209,7 @@ void qsd_bump_version(struct qsd_qtype_info *qqi, __u64 ver, bool global)
  * \param  qid   - quota id
  * \param  rec   - global or slave record to be updated to disk
  * \param  ver   - new index file version
  * \param  qid   - quota id
  * \param  rec   - global or slave record to be updated to disk
  * \param  ver   - new index file version
- * \param  global- ture : master record; false : slave record
+ * \param  global- true: master record; false: slave record
  */
 void qsd_upd_schedule(struct qsd_qtype_info *qqi, struct lquota_entry *lqe,
                      union lquota_id *qid, union lquota_rec *rec, __u64 ver,
  */
 void qsd_upd_schedule(struct qsd_qtype_info *qqi, struct lquota_entry *lqe,
                      union lquota_id *qid, union lquota_rec *rec, __u64 ver,