} ldlm_error_t;
typedef enum {
- LDLM_NAMESPACE_SERVER = 0,
- LDLM_NAMESPACE_CLIENT = 1
+ LDLM_NAMESPACE_SERVER = 1 << 0,
+ LDLM_NAMESPACE_CLIENT = 1 << 1
} ldlm_side_t;
#define LDLM_FL_LOCK_CHANGED 0x000001 /* extent, mode, or resource changed */
struct adaptive_timeout ns_at_estimate;/* estimated lock callback time*/
};
+static inline int ns_is_client(struct ldlm_namespace *ns)
+{
+ LASSERT(ns != NULL);
+ LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT |
+ LDLM_NAMESPACE_SERVER)));
+ LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT ||
+ ns->ns_client == LDLM_NAMESPACE_SERVER);
+ return ns->ns_client == LDLM_NAMESPACE_CLIENT;
+}
+
+static inline int ns_is_server(struct ldlm_namespace *ns)
+{
+ LASSERT(ns != NULL);
+ LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT |
+ LDLM_NAMESPACE_SERVER)));
+ LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT ||
+ ns->ns_client == LDLM_NAMESPACE_SERVER);
+ return ns->ns_client == LDLM_NAMESPACE_SERVER;
+}
+
static inline int ns_connect_lru_resize(struct ldlm_namespace *ns)
{
LASSERT(ns != NULL);
- return ns->ns_connect_flags & OBD_CONNECT_LRU_RESIZE;
+ return !!(ns->ns_connect_flags & OBD_CONNECT_LRU_RESIZE);
}
/*
struct ldlm_request *dlm_req, int first);
int ldlm_del_waiting_lock(struct ldlm_lock *lock);
int ldlm_refresh_waiting_lock(struct ldlm_lock *lock);
-int ldlm_get_ref(ldlm_side_t client);
-void ldlm_put_ref(ldlm_side_t client, int force);
+int ldlm_get_ref(void);
+void ldlm_put_ref(int force);
/* ldlm_lock.c */
ldlm_processing_policy ldlm_get_processing_policy(struct ldlm_resource *res);
void unlock_res_and_lock(struct ldlm_lock *lock);
/* ldlm_pool.c */
-int ldlm_pools_init(ldlm_side_t client);
void ldlm_pools_recalc(ldlm_side_t client);
+int ldlm_pools_init(void);
void ldlm_pools_fini(void);
void ldlm_pools_wakeup(void);
static inline int exp_connect_cancelset(struct obd_export *exp)
{
- return exp ? exp->exp_connect_flags & OBD_CONNECT_CANCELSET : 0;
+ return exp ? !!(exp->exp_connect_flags & OBD_CONNECT_CANCELSET) : 0;
}
static inline int exp_connect_lru_resize(struct obd_export *exp)
{
LASSERT(exp != NULL);
- return exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE;
+ return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE);
}
static inline int imp_connect_lru_resize(struct obd_import *imp)
{
+ struct obd_connect_data *ocd;
+
LASSERT(imp != NULL);
- return imp->imp_connect_data.ocd_connect_flags &
- OBD_CONNECT_LRU_RESIZE;
+ ocd = &imp->imp_connect_data;
+ return !!(ocd->ocd_connect_flags & OBD_CONNECT_LRU_RESIZE);
}
struct exp_uuid_cb_data {
{
struct ldlm_resource *res = lock->l_resource;
- if (!res->lr_namespace->ns_client) {
+ if (ns_is_server(res->lr_namespace)) {
/* on server-side resource of lock doesn't change */
lock_res(res);
return res;
{
struct ldlm_resource *res = lock->l_resource;
- if (!res->lr_namespace->ns_client) {
+ if (ns_is_server(res->lr_namespace)) {
/* on server-side resource of lock doesn't change */
unlock_res(res);
return;
struct ldlm_lock *new = req;
struct ldlm_lock *new2 = NULL;
ldlm_mode_t mode = req->l_req_mode;
- int local = ns->ns_client;
+ int local = ns_is_client(ns);
int added = (mode == LCK_NL);
int overlaps = 0;
int splitted = 0;
} else {
cli->cl_max_rpcs_in_flight = OSC_MAX_RIF_DEFAULT;
}
- rc = ldlm_get_ref(LDLM_NAMESPACE_CLIENT);
+ rc = ldlm_get_ref();
if (rc) {
CERROR("ldlm_get_ref failed: %d\n", rc);
GOTO(err, rc);
err_import:
class_destroy_import(imp);
err_ldlm:
- ldlm_put_ref(LDLM_NAMESPACE_CLIENT, 0);
+ ldlm_put_ref(0);
err:
RETURN(rc);
int client_obd_cleanup(struct obd_device *obddev)
{
ENTRY;
- ldlm_put_ref(LDLM_NAMESPACE_CLIENT, obddev->obd_force);
+ ldlm_put_ref(obddev->obd_force);
RETURN(0);
}
int type;
ENTRY;
- LASSERT(ns->ns_client != 0);
+ LASSERT(ns_is_client(ns));
lock_res_and_lock(lock);
if (memcmp(&new_resid, &lock->l_resource->lr_name,
(lock->l_flags & LDLM_FL_CBPENDING)) {
/* If we received a blocked AST and this was the last reference,
* run the callback. */
- if (ns->ns_client == LDLM_NAMESPACE_SERVER && lock->l_export)
+ if (ns_is_server(ns) && lock->l_export)
CERROR("FL_CBPENDING set on non-local lock--just a "
"warning\n");
if ((lock->l_flags & LDLM_FL_ATOMIC_CB) ||
ldlm_bl_to_thread(ns, NULL, lock, 0) != 0)
ldlm_handle_bl_callback(ns, NULL, lock);
- } else if (ns->ns_client == LDLM_NAMESPACE_CLIENT &&
+ } else if (ns_is_client(ns) &&
!lock->l_readers && !lock->l_writers &&
!(lock->l_flags & LDLM_FL_NO_LRU)) {
/* If this is a client-side namespace and this was the last
{
struct ldlm_lock *lock = *lockp;
struct ldlm_resource *res = lock->l_resource;
- int local = res->lr_namespace->ns_client;
+ int local = ns_is_client(res->lr_namespace);
ldlm_processing_policy policy;
ldlm_error_t rc = ELDLM_OK;
ENTRY;
ENTRY;
/* Local lock trees don't get reprocessed. */
- if (res->lr_namespace->ns_client) {
+ if (ns_is_client(res->lr_namespace)) {
EXIT;
return;
}
ldlm_resource_unlink_lock(lock);
/* If this is a local resource, put it on the appropriate list. */
- if (res->lr_namespace->ns_client) {
+ if (ns_is_client(res->lr_namespace)) {
if (*flags & (LDLM_FL_BLOCK_CONV | LDLM_FL_BLOCK_GRANTED)) {
ldlm_resource_add_lock(res, &res->lr_converting, lock);
} else {
#endif
-static int ldlm_setup(ldlm_side_t client);
-static int ldlm_cleanup(ldlm_side_t client, int force);
+static int ldlm_setup(void);
+static int ldlm_cleanup(int force);
-int ldlm_get_ref(ldlm_side_t client)
+int ldlm_get_ref(void)
{
int rc = 0;
ENTRY;
mutex_down(&ldlm_ref_sem);
if (++ldlm_refcount == 1) {
- rc = ldlm_setup(client);
+ rc = ldlm_setup();
if (rc)
ldlm_refcount--;
}
RETURN(rc);
}
-void ldlm_put_ref(ldlm_side_t client, int force)
+void ldlm_put_ref(int force)
{
ENTRY;
mutex_down(&ldlm_ref_sem);
if (ldlm_refcount == 1) {
- int rc = ldlm_cleanup(client, force);
+ int rc = ldlm_cleanup(force);
if (rc)
CERROR("ldlm_cleanup failed: %d\n", rc);
else
EXIT;
}
-static int ldlm_setup(ldlm_side_t client)
+static int ldlm_setup(void)
{
struct ldlm_bl_pool *blp;
int rc = 0;
#endif
#ifdef __KERNEL__
- rc = ldlm_pools_init(client);
+ rc = ldlm_pools_init();
if (rc)
GOTO(out_thread, rc);
#endif
return rc;
}
-static int ldlm_cleanup(ldlm_side_t client, int force)
+static int ldlm_cleanup(int force)
{
#ifdef __KERNEL__
struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool;
int ldlm_pool_setup(struct ldlm_pool *pl, __u32 limit)
{
ENTRY;
- if (ldlm_pl2ns(pl)->ns_client == LDLM_NAMESPACE_SERVER)
+ if (ns_is_server(ldlm_pl2ns(pl)))
ldlm_pool_set_limit(pl, limit);
RETURN(0);
}
pl->pl_name);
nr += snprintf(page + nr, count - nr, " SLV: "LPU64"\n", slv);
- if (ldlm_pl2ns(pl)->ns_client == LDLM_NAMESPACE_CLIENT) {
+ if (ns_is_client(ldlm_pl2ns(pl))) {
nr += snprintf(page + nr, count - nr, " LVF: %d\n",
atomic_read(&pl->pl_lock_volume_factor));
}
snprintf(var_name, MAX_STRING_SIZE, "grant_step");
pool_vars[0].data = &pl->pl_grant_step;
pool_vars[0].read_fptr = lprocfs_rd_atomic;
- if (ns->ns_client == LDLM_NAMESPACE_SERVER)
+ if (ns_is_server(ns))
pool_vars[0].write_fptr = lprocfs_wr_atomic;
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
- if (ns->ns_client == LDLM_NAMESPACE_CLIENT) {
+ if (ns_is_client(ns)) {
snprintf(var_name, MAX_STRING_SIZE, "lock_volume_factor");
pool_vars[0].data = &pl->pl_lock_volume_factor;
pool_vars[0].read_fptr = lprocfs_rd_uint;
/* No need to recalc client pools here as this is already done
* on enqueue/cancel and locks to cancel already packed to the
* rpc. */
- if (ldlm_pl2ns(pl)->ns_client == LDLM_NAMESPACE_SERVER)
+ if (ns_is_server(ldlm_pl2ns(pl)))
ldlm_pool_recalc(pl);
EXIT;
}
atomic_dec(&pl->pl_grant_speed);
/* Same as in ldlm_pool_add() */
- if (ldlm_pl2ns(pl)->ns_client == LDLM_NAMESPACE_SERVER)
+ if (ns_is_server(ldlm_pl2ns(pl)))
ldlm_pool_recalc(pl);
EXIT;
}
struct l_wait_info lwi;
/* Recal all pools on this tick. */
- ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT);
ldlm_pools_recalc(LDLM_NAMESPACE_SERVER);
+ ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT);
/* Wait until the next check time, or until we're
* stopped. */
complete_and_exit(&ldlm_pools_comp, 0);
}
-static int ldlm_pools_thread_start(ldlm_side_t client)
+static int ldlm_pools_thread_start(void)
{
struct l_wait_info lwi = { 0 };
int rc;
if (ldlm_pools_thread == NULL)
RETURN(-ENOMEM);
- ldlm_pools_thread->t_id = client;
init_completion(&ldlm_pools_comp);
cfs_waitq_init(&ldlm_pools_thread->t_ctl_waitq);
EXIT;
}
-int ldlm_pools_init(ldlm_side_t client)
+int ldlm_pools_init(void)
{
int rc;
ENTRY;
- rc = ldlm_pools_thread_start(client);
+ rc = ldlm_pools_thread_start();
if (rc == 0) {
ldlm_pools_srv_shrinker = set_shrinker(DEFAULT_SEEKS,
ldlm_pools_srv_shrink);
}
EXPORT_SYMBOL(ldlm_pool_set_limit);
-int ldlm_pools_init(ldlm_side_t client)
+int ldlm_pools_init(void)
{
return 0;
}
ENTRY;
LASSERT(!(*flags & LDLM_FL_REPLAY));
- if (ns->ns_client) {
+ if (ns_is_client(ns)) {
CERROR("Trying to enqueue local lock in a shadow namespace\n");
LBUG();
}
struct ldlm_resource *res;
int rc;
ENTRY;
- if (lock->l_resource->lr_namespace->ns_client) {
+ if (ns_is_client(lock->l_resource->lr_namespace)) {
CERROR("Trying to cancel local lock\n");
LBUG();
}
}
ldlm_lock_cancel(lock);
} else {
- if (lock->l_resource->lr_namespace->ns_client) {
+ if (ns_is_client(lock->l_resource->lr_namespace)) {
LDLM_ERROR(lock, "Trying to cancel local lock");
LBUG();
}
int count = 0;
ENTRY;
- LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT);
+ LASSERT(ns_is_client(ns));
res = ldlm_resource_get(ns, NULL, *res_id, LDLM_EXTENT, 0);
if (res == NULL)
lock_vars[0].read_fptr = lprocfs_rd_atomic;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
- if (ns->ns_client) {
+ if (ns_is_client(ns)) {
snprintf(lock_name, MAX_STRING_SIZE, "%s/lock_unused_count",
ns->ns_name);
lock_vars[0].data = &ns->ns_nr_unused;
int rc, idx, namelen;
ENTRY;
- rc = ldlm_get_ref(client);
+ rc = ldlm_get_ref();
if (rc) {
CERROR("ldlm_get_ref failed: %d\n", rc);
RETURN(NULL);
out_ns:
OBD_FREE_PTR(ns);
out_ref:
- ldlm_put_ref(client, 0);
+ ldlm_put_ref(0);
RETURN(NULL);
}
int flags)
{
struct list_head *tmp;
- int rc = 0, client = res->lr_namespace->ns_client;
+ int rc = 0, client = ns_is_client(res->lr_namespace);
int local_only = (flags & LDLM_FL_LOCAL_ONLY);
ENTRY;
int ldlm_namespace_free_post(struct ldlm_namespace *ns, int force)
{
- ldlm_side_t client;
ENTRY;
if (!ns)
RETURN(ELDLM_OK);
}
}
#endif
- client = ns->ns_client;
- POISON(ns->ns_hash, 0x5a, sizeof(*ns->ns_hash) * RES_HASH_SIZE);
OBD_VFREE(ns->ns_hash, sizeof(*ns->ns_hash) * RES_HASH_SIZE);
OBD_FREE(ns->ns_name, strlen(ns->ns_name) + 1);
OBD_FREE_PTR(ns);
- ldlm_put_ref(client, force);
+ ldlm_put_ref(force);
RETURN(ELDLM_OK);
}
if (!((libcfs_debug | D_ERROR) & level))
return;
- CDEBUG(level, "--- Namespace: %s (rc: %d, client: %d)\n",
- ns->ns_name, ns->ns_refcount, ns->ns_client);
+ CDEBUG(level, "--- Namespace: %s (rc: %d, side: %s)\n",
+ ns->ns_name, ns->ns_refcount,
+ ns_is_client(ns) ? "client" : "server");
if (cfs_time_before(cfs_time_current(), ns->ns_next_dump))
return;