From: Johann Lombardi Date: Tue, 18 Dec 2012 21:54:54 +0000 (+0100) Subject: LU-2509 quota: various code cleanups X-Git-Tag: 2.3.59~4 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=df66537682aef976102a5b986ec2830f8d00b0c6 LU-2509 quota: various code cleanups Address some cleanups that were mentioned during code inspection. Signed-off-by: Johann Lombardi Change-Id: I3cab9c0e6bfefef0d717e542f6620cc167075937 Reviewed-on: http://review.whamcloud.com/4855 Tested-by: Hudson Reviewed-by: Niu Yawei Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index a4d7e84..cb742d5 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -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) + else if (result < 0) CWARN("build page failed: %d!\n", result); return result; } diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 86e9d87..96eca39 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -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; + /* can't get EDQUOT when reducing usage */ rc = qsd_op_begin(env, qsd, trans, qi, NULL); - if (rc == -EDQUOT || rc == -EINPROGRESS) + if (rc == -EINPROGRESS) 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); - if (rc == -EDQUOT || rc == -EINPROGRESS) + /* can't get EDQUOT when reducing usage */ + if (rc == -EINPROGRESS) 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; + int rc; 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); - 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, diff --git a/lustre/quota/lquota_disk.c b/lustre/quota/lquota_disk.c index eabbbc1..9f8069b 100644 --- a/lustre/quota/lquota_disk.c +++ b/lustre/quota/lquota_disk.c @@ -482,7 +482,7 @@ int lquota_disk_for_each_slv(const struct lu_env *env, struct dt_object *parent, int rc; ENTRY; - OBD_ALLOC(name, sizeof("0x00000000-")); + OBD_ALLOC(name, LQUOTA_NAME_MAX); 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)) { - OBD_FREE(name, sizeof("0x00000000-")); + OBD_FREE(name, LQUOTA_NAME_MAX); RETURN(PTR_ERR(it)); } @@ -556,7 +556,7 @@ next: 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); diff --git a/lustre/quota/lquota_lib.c b/lustre/quota/lquota_lib.c index c1d4590..5bc2c9b 100644 --- a/lustre/quota/lquota_lib.c +++ b/lustre/quota/lquota_lib.c @@ -382,7 +382,7 @@ static void exit_lquota(void) lu_context_key_degister(&lquota_thread_key); } -MODULE_AUTHOR("Intel, Inc. "); +MODULE_AUTHOR("Intel Corporation "); MODULE_DESCRIPTION("Lustre Quota"); MODULE_LICENSE("GPL"); diff --git a/lustre/quota/qmt_lock.c b/lustre/quota/qmt_lock.c index a4086f6..05c60b0 100644 --- a/lustre/quota/qmt_lock.c +++ b/lustre/quota/qmt_lock.c @@ -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; - int rc; + int rc, lvb_len; 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); - 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; diff --git a/lustre/quota/qsd_lib.c b/lustre/quota/qsd_lib.c index dc4fdae..e3e2f7f 100644 --- a/lustre/quota/qsd_lib.c +++ b/lustre/quota/qsd_lib.c @@ -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); - memset(&qqi->qqi_lockh, 0, sizeof(qqi->qqi_lockh)); /* 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); - /* 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); @@ -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 */ - 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->qsd_fsinfo = NULL; + } /* release quota root directory */ if (qsd->qsd_root != NULL) { diff --git a/lustre/quota/qsd_lock.c b/lustre/quota/qsd_lock.c index 6fd2de0..c63d033 100644 --- a/lustre/quota/qsd_lock.c +++ b/lustre/quota/qsd_lock.c @@ -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); - lu_ref_add(&qqi->qqi_reference, "ast_data_get", 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 */ - qqi_putref(qqi); lu_ref_del(&qqi->qqi_reference, "glb_lock", lock); + qqi_putref(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) + /* caller not interested in remote handle */ RETURN(0); /* look up lock associated with local handle and extract remote handle diff --git a/lustre/quota/qsd_request.c b/lustre/quota/qsd_request.c index f05a356..5e46bfc 100644 --- a/lustre/quota/qsd_request.c +++ b/lustre/quota/qsd_request.c @@ -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); - 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; diff --git a/lustre/quota/qsd_writeback.c b/lustre/quota/qsd_writeback.c index 871a14e..037fb2b 100644 --- a/lustre/quota/qsd_writeback.c +++ b/lustre/quota/qsd_writeback.c @@ -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 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,