};
enum ldlm_namespace_flags {
- /**
+ /*
* Flag to indicate the LRU cancel is in progress.
* Used to limit the process by 1 thread only.
*/
- LDLM_LRU_CANCEL = 0
+ LDLM_NS_LRU_CANCEL,
+ LDLM_NS_STOPPING,
+ /* Controls the stack trace log in ldlm_lock_debug */
+ LDLM_NS_DUMP_STACK,
+ /*
+ * Flag to indicate the LRU recalc on RPC reply is in progress.
+ * Used to limit the process by 1 thread only.
+ */
+ LDLM_NS_RPC_RECALC,
+ /* lru_size is set even before connection */
+ LDLM_NS_LRU_SIZE_SET_BEFORE_CONN,
+ LDLM_NS_NUM_FLAGS
};
-/**
+/*
* LDLM Namespace.
*
* Namespace serves to contain locks related to a particular service.
struct lprocfs_stats *ns_stats;
/**
- * Flag to indicate namespace is being freed. Used to determine if
- * recalculation of LDLM pool statistics should be skipped.
- */
- unsigned int ns_stopping:1,
-
-
- /**
- * This namespace will control the stack trace log in ldlm_lock_debug
- */
- ns_dump_stack_on_error:1,
-
- /**
- * Flag to indicate the LRU recalc on RPC reply is in progress.
- * Used to limit the process by 1 thread only.
- */
- ns_rpc_recalc:1,
-
- /* lru_size is set even before connection */
- ns_lru_size_set_before_connection:1;
-
- /**
* Which bucket should we start with the lock reclaim.
*/
int ns_reclaim_start;
struct kobject ns_kobj; /* sysfs object */
struct completion ns_kobj_unregister;
- /**
- * To avoid another ns_lock usage, a separate bitops field.
- */
- unsigned long ns_flags;
+ /* See enum ldlm_namespace_flags */
+ DECLARE_BITMAP(ns_flags, LDLM_NS_NUM_FLAGS);
};
/**
((libcfs_debug & (mask)) != 0 && \
(libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) { \
_ldlm_lock_debug(lock, msgdata, fmt, ##a); \
- if (unlikely(ldlm_lock_to_ns(lock)-> \
- ns_dump_stack_on_error) && \
- !!((mask) & D_ERROR)) \
+ if (unlikely(test_bit(LDLM_NS_DUMP_STACK, \
+ ldlm_lock_to_ns(lock)->ns_flags)) && \
+ !!((mask) & D_ERROR)) \
dump_stack(); \
} \
} while (0)
} else {
ldlm_pool_recalc(&blwi->blwi_ns->ns_pool, true);
spin_lock(&blwi->blwi_ns->ns_lock);
- blwi->blwi_ns->ns_rpc_recalc = 0;
+ clear_bit(LDLM_NS_RPC_RECALC, blwi->blwi_ns->ns_flags);
spin_unlock(&blwi->blwi_ns->ns_lock);
ldlm_namespace_put(blwi->blwi_ns);
}
* skip ns which is being freed, and we don't want to increase
* its refcount again, not even temporarily. bz21519 & LU-499.
*/
- if (ns->ns_stopping) {
+ if (test_bit(LDLM_NS_STOPPING, ns->ns_flags)) {
skip = 1;
} else {
skip = 0;
ratio = 100 * new_slv / ldlm_pool_get_slv(&ns->ns_pool);
if (100 - ratio >= ns->ns_recalc_pct &&
- !ns->ns_stopping && !ns->ns_rpc_recalc) {
+ !test_bit(LDLM_NS_STOPPING, ns->ns_flags) &&
+ !test_bit(LDLM_NS_RPC_RECALC, ns->ns_flags)) {
bool recalc = false;
spin_lock(&ns->ns_lock);
- if (!ns->ns_stopping && !ns->ns_rpc_recalc) {
+ if (!test_bit(LDLM_NS_STOPPING, ns->ns_flags) &&
+ !test_bit(LDLM_NS_RPC_RECALC, ns->ns_flags)) {
ldlm_namespace_get(ns);
recalc = true;
- ns->ns_rpc_recalc = 1;
+ set_bit(LDLM_NS_RPC_RECALC, ns->ns_flags);
}
spin_unlock(&ns->ns_lock);
if (recalc)
* @max limit given (ELC), as LRU may be left not cleaned up in full.
*/
if (max == 0) {
- if (test_and_set_bit(LDLM_LRU_CANCEL, &ns->ns_flags))
+ if (test_and_set_bit(LDLM_NS_LRU_CANCEL, ns->ns_flags))
RETURN(0);
- } else if (test_bit(LDLM_LRU_CANCEL, &ns->ns_flags))
+ } else if (test_bit(LDLM_NS_LRU_CANCEL, ns->ns_flags))
RETURN(0);
LASSERT(ergo(max, min <= max));
}
if (max == 0)
- clear_bit(LDLM_LRU_CANCEL, &ns->ns_flags);
+ clear_bit(LDLM_NS_LRU_CANCEL, ns->ns_flags);
RETURN(added);
}
*/
spin_lock(&ns->ns_lock);
if (ns->ns_connect_flags == 0)
- ns->ns_lru_size_set_before_connection = 1;
+ set_bit(LDLM_NS_LRU_SIZE_SET_BEFORE_CONN, ns->ns_flags);
spin_unlock(&ns->ns_lock);
/* Make sure that LRU resize was originally supported before
ns_kobj);
return snprintf(buf, sizeof(buf) - 1, "%u\n",
- ns->ns_dump_stack_on_error);
+ test_bit(LDLM_NS_DUMP_STACK, ns->ns_flags));
}
static ssize_t dump_stack_on_error_store(struct kobject *kobj,
int err;
err = kstrtobool(buffer, &tmp);
- if (err != 0)
+ if (err)
return -EINVAL;
- ns->ns_dump_stack_on_error = tmp;
+ if (tmp)
+ set_bit(LDLM_NS_DUMP_STACK, ns->ns_flags);
+ else
+ clear_bit(LDLM_NS_DUMP_STACK, ns->ns_flags);
return count;
}
atomic_set(&ns->ns_bref, 0);
init_waitqueue_head(&ns->ns_waitq);
- ns->ns_connect_flags = 0;
- ns->ns_orig_connect_flags = 0;
- ns->ns_nr_unused = 0;
- ns->ns_last_pos = &ns->ns_unused_list;
- ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
- ns->ns_cancel_batch = LDLM_DEFAULT_LRU_SHRINK_BATCH;
- ns->ns_recalc_pct = LDLM_DEFAULT_SLV_RECALC_PCT;
- ns->ns_max_age = ktime_set(LDLM_DEFAULT_LRU_MAX_AGE, 0);
- ns->ns_timeouts = 0;
- ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT;
- ns->ns_dirty_age_limit = ktime_set(LDLM_DIRTY_AGE_LIMIT, 0);
- ns->ns_contended_locks = NS_DEFAULT_CONTENDED_LOCKS;
- ns->ns_contention_time = NS_DEFAULT_CONTENTION_SECONDS;
- ns->ns_max_nolock_size = NS_DEFAULT_MAX_NOLOCK_BYTES;
- ns->ns_max_parallel_ast = LDLM_DEFAULT_PARALLEL_AST_LIMIT;
- ns->ns_stopping = 0;
- ns->ns_rpc_recalc = 0;
- ns->ns_dump_stack_on_error = 0;
- ns->ns_reclaim_start = 0;
- ns->ns_flags = 0;
+ ns->ns_connect_flags = 0;
+ ns->ns_orig_connect_flags = 0;
+ ns->ns_nr_unused = 0;
+ ns->ns_last_pos = &ns->ns_unused_list;
+ ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
+ ns->ns_cancel_batch = LDLM_DEFAULT_LRU_SHRINK_BATCH;
+ ns->ns_recalc_pct = LDLM_DEFAULT_SLV_RECALC_PCT;
+ ns->ns_max_age = ktime_set(LDLM_DEFAULT_LRU_MAX_AGE, 0);
+ ns->ns_timeouts = 0;
+ ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT;
+ ns->ns_dirty_age_limit = ktime_set(LDLM_DIRTY_AGE_LIMIT, 0);
+ ns->ns_contended_locks = NS_DEFAULT_CONTENDED_LOCKS;
+ ns->ns_contention_time = NS_DEFAULT_CONTENTION_SECONDS;
+ ns->ns_max_nolock_size = NS_DEFAULT_MAX_NOLOCK_BYTES;
+ ns->ns_max_parallel_ast = LDLM_DEFAULT_PARALLEL_AST_LIMIT;
+ ns->ns_reclaim_start = 0;
rc = ldlm_namespace_sysfs_register(ns);
if (rc) {
}
spin_lock(&ns->ns_lock);
- ns->ns_stopping = 1;
+ set_bit(LDLM_NS_STOPPING, ns->ns_flags);
spin_unlock(&ns->ns_lock);
/* Can fail with -EINTR when force == 0 in which case try harder. */
* see lru_size_store().
*/
if (ns_connect_lru_resize(ns) &&
- ns->ns_lru_size_set_before_connection &&
+ test_bit(LDLM_NS_LRU_SIZE_SET_BEFORE_CONN, ns->ns_flags) &&
ns->ns_max_unused != 0)
ns->ns_connect_flags &= ~OBD_CONNECT_LRU_RESIZE;
- ns->ns_lru_size_set_before_connection = 0;
+ clear_bit(LDLM_NS_LRU_SIZE_SET_BEFORE_CONN, ns->ns_flags);
spin_unlock(&ns->ns_lock);
}