* GPL HEADER END
*/
/*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
* Use is subject to license terms.
*
* Author: Johann Lombardi <johann.lombardi@intel.com>
#include "lquota_internal.h"
static int hash_lqs_cur_bits = HASH_LQE_CUR_BITS;
-CFS_MODULE_PARM(hash_lqs_cur_bits, "i", int, 0444,
- "the current bits of lqe hash");
+module_param(hash_lqs_cur_bits, int, 0444);
+MODULE_PARM_DESC(hash_lqs_cur_bits, "the current bits of lqe hash");
static unsigned
lqe64_hash_hash(struct cfs_hash *hs, const void *key, unsigned mask)
const char *fmt, ...)
{
struct lquota_site *site = lqe->lqe_site;
+ struct va_format vaf;
va_list args;
LASSERT(site->lqs_ops->lqe_debug != NULL);
va_start(args, fmt);
- site->lqs_ops->lqe_debug(lqe, site->lqs_parent, msgdata, fmt, args);
+ vaf.fmt = fmt;
+ vaf.va = &args;
+ site->lqs_ops->lqe_debug(lqe, site->lqs_parent, msgdata, &vaf);
va_end(args);
}
"freed:%lu, repeat:%u\n", hash,
d.lid_inuse, d.lid_freed, repeat);
repeat++;
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(cfs_time_seconds(1));
+ schedule_timeout_interruptible(cfs_time_seconds(1));
goto retry;
}
EXIT;
char hashname[15];
ENTRY;
- LASSERT(qtype < MAXQUOTAS);
+ if (qtype >= LL_MAXQUOTAS)
+ RETURN(ERR_PTR(-ENOTSUPP));
OBD_ALLOC_PTR(site);
if (site == NULL)
/* allocate hash table */
memset(hashname, 0, sizeof(hashname));
- sprintf(hashname, "LQUOTA_HASH%u", qtype);
+ snprintf(hashname, sizeof(hashname), "LQUOTA_HASH%hu", qtype);
site->lqs_hash= cfs_hash_create(hashname, hash_lqs_cur_bits,
HASH_LQE_MAX_BITS,
min(hash_lqs_cur_bits,
HASH_LQE_BKT_BITS),
0, CFS_HASH_MIN_THETA,
CFS_HASH_MAX_THETA, &lqe64_hash_ops,
- CFS_HASH_DEFAULT|CFS_HASH_BIGNAME);
+ CFS_HASH_RW_SEM_BKTLOCK |
+ CFS_HASH_COUNTER |
+ CFS_HASH_REHASH |
+ CFS_HASH_BIGNAME);
+
if (site->lqs_hash == NULL) {
OBD_FREE_PTR(site);
RETURN(ERR_PTR(-ENOMEM));
*
* \param env - the environment passed by the caller
* \param lqe - is the quota entry to refresh
+ * \param find - don't create entry on disk if true
*/
-static int lqe_read(const struct lu_env *env, struct lquota_entry *lqe)
+static int lqe_read(const struct lu_env *env,
+ struct lquota_entry *lqe, bool find)
{
struct lquota_site *site;
int rc;
LQUOTA_DEBUG(lqe, "read");
- rc = site->lqs_ops->lqe_read(env, lqe, site->lqs_parent);
+ rc = site->lqs_ops->lqe_read(env, lqe, site->lqs_parent, find);
if (rc == 0)
/* mark the entry as up-to-date */
lqe->lqe_uptodate = true;
* \param env - the environment passed by the caller
* \param site - lquota site which stores quota entries in a hash table
* \param qid - is the quota ID to be found/created
+ * \param find - don't create lqe on disk in case of ENOENT if true
*
* \retval 0 - success
* \retval -ve - failure
*/
-struct lquota_entry *lqe_locate(const struct lu_env *env,
- struct lquota_site *site, union lquota_id *qid)
+struct lquota_entry *lqe_locate_find(const struct lu_env *env,
+ struct lquota_site *site,
+ union lquota_id *qid,
+ bool find)
{
struct lquota_entry *lqe, *new = NULL;
int rc = 0;
OBD_SLAB_ALLOC_PTR_GFP(new, lqe_kmem, GFP_NOFS);
if (new == NULL) {
- CERROR("Fail to allocate lqe for id:"LPU64", "
+ CERROR("Fail to allocate lqe for id:%llu, "
"hash:%s\n", qid->qid_uid, site->lqs_hash->hs_name);
RETURN(ERR_PTR(-ENOMEM));
}
lqe_init(new);
/* read quota settings from disk and mark lqe as up-to-date */
- rc = lqe_read(env, new);
+ rc = lqe_read(env, new, find);
if (rc)
GOTO(out, lqe = ERR_PTR(rc));