X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fquota%2Fqmt_pool.c;h=30ad195ef37c96ad28f34bbde9be2a7d66c462f7;hb=d14c3dfec382446a2f5e4e91c56d162e56563d0f;hp=04ffa919242f368ae019eb86d54ba0f752890cbf;hpb=11db1a551172f596d1d284e8496530f9ce24ac81;p=fs%2Flustre-release.git diff --git a/lustre/quota/qmt_pool.c b/lustre/quota/qmt_pool.c index 04ffa91..30ad195 100644 --- a/lustre/quota/qmt_pool.c +++ b/lustre/quota/qmt_pool.c @@ -65,21 +65,21 @@ static void qmt_pool_free(const struct lu_env *, struct qmt_pool_info *); */ static inline void qpi_getref(struct qmt_pool_info *pool) { - cfs_atomic_inc(&pool->qpi_ref); + atomic_inc(&pool->qpi_ref); } static inline void qpi_putref(const struct lu_env *env, struct qmt_pool_info *pool) { LASSERT(atomic_read(&pool->qpi_ref) > 0); - if (cfs_atomic_dec_and_test(&pool->qpi_ref)) + if (atomic_dec_and_test(&pool->qpi_ref)) qmt_pool_free(env, pool); } static inline void qpi_putref_locked(struct qmt_pool_info *pool) { - LASSERT(cfs_atomic_read(&pool->qpi_ref) > 1); - cfs_atomic_dec(&pool->qpi_ref); + LASSERT(atomic_read(&pool->qpi_ref) > 1); + atomic_dec(&pool->qpi_ref); } /* @@ -91,40 +91,40 @@ static unsigned qpi_hash_hash(cfs_hash_t *hs, const void *key, unsigned mask) return cfs_hash_u32_hash(*((__u32 *)key), mask); } -static void *qpi_hash_key(cfs_hlist_node_t *hnode) +static void *qpi_hash_key(struct hlist_node *hnode) { struct qmt_pool_info *pool; - pool = cfs_hlist_entry(hnode, struct qmt_pool_info, qpi_hash); + pool = hlist_entry(hnode, struct qmt_pool_info, qpi_hash); return &pool->qpi_key; } -static int qpi_hash_keycmp(const void *key, cfs_hlist_node_t *hnode) +static int qpi_hash_keycmp(const void *key, struct hlist_node *hnode) { struct qmt_pool_info *pool; - pool = cfs_hlist_entry(hnode, struct qmt_pool_info, qpi_hash); + pool = hlist_entry(hnode, struct qmt_pool_info, qpi_hash); return pool->qpi_key == *((__u32 *)key); } -static void *qpi_hash_object(cfs_hlist_node_t *hnode) +static void *qpi_hash_object(struct hlist_node *hnode) { - return cfs_hlist_entry(hnode, struct qmt_pool_info, qpi_hash); + return hlist_entry(hnode, struct qmt_pool_info, qpi_hash); } -static void qpi_hash_get(cfs_hash_t *hs, cfs_hlist_node_t *hnode) +static void qpi_hash_get(cfs_hash_t *hs, struct hlist_node *hnode) { struct qmt_pool_info *pool; - pool = cfs_hlist_entry(hnode, struct qmt_pool_info, qpi_hash); + pool = hlist_entry(hnode, struct qmt_pool_info, qpi_hash); qpi_getref(pool); } -static void qpi_hash_put_locked(cfs_hash_t *hs, cfs_hlist_node_t *hnode) +static void qpi_hash_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) { struct qmt_pool_info *pool; - pool = cfs_hlist_entry(hnode, struct qmt_pool_info, qpi_hash); + pool = hlist_entry(hnode, struct qmt_pool_info, qpi_hash); qpi_putref_locked(pool); } -static void qpi_hash_exit(cfs_hash_t *hs, cfs_hlist_node_t *hnode) +static void qpi_hash_exit(cfs_hash_t *hs, struct hlist_node *hnode) { CERROR("Should not have any item left!\n"); } @@ -141,40 +141,38 @@ static cfs_hash_ops_t qpi_hash_ops = { }; /* some procfs helpers */ -static int lprocfs_qpi_rd_state(char *page, char **start, off_t off, - int count, int *eof, void *data) +static int qpi_state_seq_show(struct seq_file *m, void *data) { - struct qmt_pool_info *pool = (struct qmt_pool_info *)data; - int type, i = 0; + struct qmt_pool_info *pool = m->private; + int type; LASSERT(pool != NULL); - i = snprintf(page, count, - "pool:\n" - " id: %u\n" - " type: %s\n" - " ref: %d\n" - " least qunit: %lu\n", - pool->qpi_key & 0x0000ffff, - RES_NAME(pool->qpi_key >> 16), - cfs_atomic_read(&pool->qpi_ref), - pool->qpi_least_qunit); - + seq_printf(m, "pool:\n" + " id: %u\n" + " type: %s\n" + " ref: %d\n" + " least qunit: %lu\n", + pool->qpi_key & 0x0000ffff, + RES_NAME(pool->qpi_key >> 16), + atomic_read(&pool->qpi_ref), + pool->qpi_least_qunit); for (type = 0; type < MAXQUOTAS; type++) - i += snprintf(page + i, count - i, - " %s:\n" - " #slv: %d\n" - " #lqe: %d\n", - QTYPE_NAME(type), - pool->qpi_slv_nr[type], - cfs_atomic_read(&pool->qpi_site[type]->lqs_hash->hs_count)); - - return i; + seq_printf(m, " %s:\n" + " #slv: %d\n" + " #lqe: %d\n", + QTYPE_NAME(type), + pool->qpi_slv_nr[type], + atomic_read(&pool->qpi_site[type]->lqs_hash->hs_count)); + + return 0; } +LPROC_SEQ_FOPS_RO(qpi_state); -static struct lprocfs_vars lprocfs_quota_qpi_vars[] = { - { "info", lprocfs_qpi_rd_state, 0, 0}, +static struct lprocfs_seq_vars lprocfs_quota_qpi_vars[] = { + { .name = "info", + .fops = &qpi_state_fops }, { NULL } }; @@ -201,7 +199,7 @@ static int qmt_pool_alloc(const struct lu_env *env, struct qmt_device *qmt, OBD_ALLOC_PTR(pool); if (pool == NULL) RETURN(-ENOMEM); - CFS_INIT_LIST_HEAD(&pool->qpi_linkage); + INIT_LIST_HEAD(&pool->qpi_linkage); /* assign key used by hash functions */ pool->qpi_key = pool_id + (pool_type << 16); @@ -215,8 +213,8 @@ static int qmt_pool_alloc(const struct lu_env *env, struct qmt_device *qmt, /* create pool proc directory */ sprintf(qti->qti_buf, "%s-0x%x", RES_NAME(pool_type), pool_id); - pool->qpi_proc = lprocfs_register(qti->qti_buf, qmt->qmt_proc, - lprocfs_quota_qpi_vars, pool); + pool->qpi_proc = lprocfs_seq_register(qti->qti_buf, qmt->qmt_proc, + lprocfs_quota_qpi_vars, pool); if (IS_ERR(pool->qpi_proc)) { rc = PTR_ERR(pool->qpi_proc); CERROR("%s: failed to create proc entry for pool %s (%d)\n", @@ -240,7 +238,7 @@ static int qmt_pool_alloc(const struct lu_env *env, struct qmt_device *qmt, } /* add to qmt pool list */ - cfs_list_add_tail(&pool->qpi_linkage, &qmt->qmt_pool_list); + list_add_tail(&pool->qpi_linkage, &qmt->qmt_pool_list); EXIT; out: if (rc) @@ -296,7 +294,7 @@ static void qmt_pool_free(const struct lu_env *env, struct qmt_pool_info *pool) pool->qpi_qmt = NULL; } - LASSERT(cfs_list_empty(&pool->qpi_linkage)); + LASSERT(list_empty(&pool->qpi_linkage)); OBD_FREE_PTR(pool); } @@ -347,27 +345,27 @@ static struct qmt_pool_info *qmt_pool_lookup(const struct lu_env *env, void qmt_pool_fini(const struct lu_env *env, struct qmt_device *qmt) { struct qmt_pool_info *pool; - cfs_list_t *pos, *n; + struct list_head *pos, *n; ENTRY; if (qmt->qmt_pool_hash == NULL) RETURN_EXIT; /* parse list of pool and destroy each element */ - cfs_list_for_each_safe(pos, n, &qmt->qmt_pool_list) { - pool = cfs_list_entry(pos, struct qmt_pool_info, - qpi_linkage); + list_for_each_safe(pos, n, &qmt->qmt_pool_list) { + pool = list_entry(pos, struct qmt_pool_info, + qpi_linkage); /* remove from hash */ cfs_hash_del(qmt->qmt_pool_hash, &pool->qpi_key, &pool->qpi_hash); /* remove from list */ - cfs_list_del_init(&pool->qpi_linkage); + list_del_init(&pool->qpi_linkage); /* release extra reference taken in qmt_pool_alloc */ qpi_putref(env, pool); } - LASSERT(cfs_list_empty(&qmt->qmt_pool_list)); + LASSERT(list_empty(&qmt->qmt_pool_list)); cfs_hash_putref(qmt->qmt_pool_hash); qmt->qmt_pool_hash = NULL; @@ -406,7 +404,7 @@ int qmt_pool_init(const struct lu_env *env, struct qmt_device *qmt) } /* initialize pool list */ - CFS_INIT_LIST_HEAD(&qmt->qmt_pool_list); + INIT_LIST_HEAD(&qmt->qmt_pool_list); /* Instantiate pool master for the default data and metadata pool (both * have pool ID equals to 0). @@ -453,7 +451,7 @@ int qmt_pool_prepare(const struct lu_env *env, struct qmt_device *qmt, struct qmt_pool_info *pool; struct dt_device *dev = NULL; dt_obj_version_t version; - cfs_list_t *pos; + struct list_head *pos; int rc = 0, qtype; ENTRY; @@ -461,13 +459,13 @@ int qmt_pool_prepare(const struct lu_env *env, struct qmt_device *qmt, /* iterate over each pool in the hash and allocate a quota site for each * one. This involves creating a global index file on disk */ - cfs_list_for_each(pos, &qmt->qmt_pool_list) { + list_for_each(pos, &qmt->qmt_pool_list) { struct dt_object *obj; int pool_type, pool_id; struct lquota_entry *lqe; - pool = cfs_list_entry(pos, struct qmt_pool_info, - qpi_linkage); + pool = list_entry(pos, struct qmt_pool_info, + qpi_linkage); pool_id = pool->qpi_key & 0x0000ffff; pool_type = pool->qpi_key >> 16; @@ -680,7 +678,7 @@ struct lquota_entry *qmt_pool_lqe_lookup(const struct lu_env *env, * entry since we keep a reference on ID 0 all the time */ lqe = pool->qpi_grace_lqe[qtype]; lqe_getref(lqe); - GOTO(out, 0); + GOTO(out, lqe); } /* now that we have the pool, let's look-up the quota entry in the