diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/ldlm')
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/interval_tree.c | 46 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/l_lock.c | 6 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 12 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 14 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c | 6 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 9 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 12 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 17 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 10 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_plain.c | 6 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 8 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 36 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 53 |
13 files changed, 132 insertions, 103 deletions
diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index e1069021420d..19e285dd2ee1 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -34,9 +34,9 @@ * Author: Huang Wei <huangwei@clusterfs.com> * Author: Jay Xiong <jinshan.xiong@sun.com> */ -#include "../include/lustre_dlm.h" -#include "../include/obd_support.h" -#include "../include/interval_tree.h" +#include <lustre_dlm.h> +#include <obd_support.h> +#include <interval_tree.h> enum { INTERVAL_RED = 0, @@ -110,6 +110,15 @@ static struct interval_node *interval_first(struct interval_node *node) return node; } +static struct interval_node *interval_last(struct interval_node *node) +{ + if (!node) + return NULL; + while (node->in_right) + node = node->in_right; + return node; +} + static struct interval_node *interval_next(struct interval_node *node) { if (!node) @@ -121,6 +130,37 @@ static struct interval_node *interval_next(struct interval_node *node) return node->in_parent; } +static struct interval_node *interval_prev(struct interval_node *node) +{ + if (!node) + return NULL; + + if (node->in_left) + return interval_last(node->in_left); + + while (node->in_parent && node_is_left_child(node)) + node = node->in_parent; + + return node->in_parent; +} + +enum interval_iter interval_iterate_reverse(struct interval_node *root, + interval_callback_t func, + void *data) +{ + enum interval_iter rc = INTERVAL_ITER_CONT; + struct interval_node *node; + + for (node = interval_last(root); node; node = interval_prev(node)) { + rc = func(node, data); + if (rc == INTERVAL_ITER_STOP) + break; + } + + return rc; +} +EXPORT_SYMBOL(interval_iterate_reverse); + static void __rotate_change_maxhigh(struct interval_node *node, struct interval_node *rotate) { diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c index 3845f386f1db..57fd84effdfa 100644 --- a/drivers/staging/lustre/lustre/ldlm/l_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c @@ -31,10 +31,10 @@ */ #define DEBUG_SUBSYSTEM S_LDLM -#include "../../include/linux/libcfs/libcfs.h" +#include <linux/libcfs/libcfs.h> -#include "../include/lustre_dlm.h" -#include "../include/lustre_lib.h" +#include <lustre_dlm.h> +#include <lustre_lib.h> /** * Lock a lock and its resource. diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index 08f97e2117ed..2cc6dc2b281f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -46,12 +46,12 @@ */ #define DEBUG_SUBSYSTEM S_LDLM -#include "../../include/linux/libcfs/libcfs.h" -#include "../include/lustre_dlm.h" -#include "../include/obd_support.h" -#include "../include/obd.h" -#include "../include/obd_class.h" -#include "../include/lustre_lib.h" +#include <linux/libcfs/libcfs.h> +#include <lustre_dlm.h> +#include <obd_support.h> +#include <obd.h> +#include <obd_class.h> +#include <lustre_lib.h> #include "ldlm_internal.h" /* When a lock is cancelled by a client, the KMS may undergo change if this diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index b7f28b39c7b3..cb826e9e840e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -52,10 +52,10 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include "../include/lustre_dlm.h" -#include "../include/obd_support.h" -#include "../include/obd_class.h" -#include "../include/lustre_lib.h" +#include <lustre_dlm.h> +#include <obd_support.h> +#include <obd_class.h> +#include <lustre_lib.h> #include <linux/list.h> #include "ldlm_internal.h" @@ -90,8 +90,8 @@ ldlm_flocks_overlap(struct ldlm_lock *lock, struct ldlm_lock *new) static inline void ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode, __u64 flags) { - LDLM_DEBUG(lock, "ldlm_flock_destroy(mode: %d, flags: 0x%llx)", - mode, flags); + LDLM_DEBUG(lock, "%s(mode: %d, flags: 0x%llx)", + __func__, mode, flags); /* Safe to not lock here, since it should be empty anyway */ LASSERT(hlist_unhashed(&lock->l_exp_flock_hash)); @@ -596,7 +596,7 @@ granted: default: getlk->fl_type = F_UNLCK; } - getlk->fl_pid = (pid_t)lock->l_policy_data.l_flock.pid; + getlk->fl_pid = -(pid_t)lock->l_policy_data.l_flock.pid; getlk->fl_start = (loff_t)lock->l_policy_data.l_flock.start; getlk->fl_end = (loff_t)lock->l_policy_data.l_flock.end; } else { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c index ae37c3686b1b..fcb6e44bd319 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c @@ -49,9 +49,9 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include "../include/lustre_dlm.h" -#include "../include/obd_support.h" -#include "../include/lustre_lib.h" +#include <lustre_dlm.h> +#include <obd_support.h> +#include <lustre_lib.h> #include "ldlm_internal.h" void ldlm_ibits_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index ec3b23cd09ec..36808dbe8790 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -106,9 +106,6 @@ int ldlm_cancel_lru_local(struct ldlm_namespace *ns, extern unsigned int ldlm_enqueue_min; extern unsigned int ldlm_cancel_unused_locks_before_replay; -/* ldlm_resource.c */ -int ldlm_resource_putref_locked(struct ldlm_resource *res); - /* ldlm_lock.c */ struct ldlm_cb_set_arg { @@ -336,3 +333,9 @@ void ldlm_flock_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy, union ldlm_policy_data *lpolicy); void ldlm_flock_policy_local_to_wire(const union ldlm_policy_data *lpolicy, union ldlm_wire_policy_data *wpolicy); + +static inline bool ldlm_res_eq(const struct ldlm_res_id *res0, + const struct ldlm_res_id *res1) +{ + return memcmp(res0, res1, sizeof(*res0)) == 0; +} diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 4dc7baee1f28..22600c2a73ea 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -39,12 +39,12 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include "../../include/linux/libcfs/libcfs.h" -#include "../include/obd.h" -#include "../include/obd_class.h" -#include "../include/lustre_dlm.h" -#include "../include/lustre_net.h" -#include "../include/lustre_sec.h" +#include <linux/libcfs/libcfs.h> +#include <obd.h> +#include <obd_class.h> +#include <lustre_dlm.h> +#include <lustre_net.h> +#include <lustre_sec.h> #include "ldlm_internal.h" /* @priority: If non-zero, move the selected connection to the list head. diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index ddb46428093f..b5d84f3f6071 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -37,10 +37,10 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include "../../include/linux/libcfs/libcfs.h" -#include "../include/lustre_intent.h" -#include "../include/lustre_swab.h" -#include "../include/obd_class.h" +#include <linux/libcfs/libcfs.h> +#include <lustre_intent.h> +#include <lustre_swab.h> +#include <obd_class.h> #include "ldlm_internal.h" /* lock types */ @@ -1029,11 +1029,11 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) if (work_list && lock->l_completion_ast) ldlm_add_ast_work_item(lock, NULL, work_list); - if (res->lr_type == LDLM_PLAIN || res->lr_type == LDLM_IBITS) + if (res->lr_type == LDLM_PLAIN || res->lr_type == LDLM_IBITS) { ldlm_grant_lock_with_skiplist(lock); - else if (res->lr_type == LDLM_EXTENT) + } else if (res->lr_type == LDLM_EXTENT) { ldlm_extent_add_lock(res, lock); - else if (res->lr_type == LDLM_FLOCK) { + } else if (res->lr_type == LDLM_FLOCK) { /* * We should not add locks to granted list in the following cases: * - this is an UNLOCK but not a real lock; @@ -1045,8 +1045,9 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) ldlm_is_test_lock(lock) || ldlm_is_flock_deadlock(lock)) return; ldlm_resource_add_lock(res, &res->lr_granted, lock); - } else + } else { LBUG(); + } ldlm_pool_add(&ldlm_res_to_ns(res)->ns_pool, lock); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index fff930fc3cff..e2707336586c 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -37,9 +37,9 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include "../../include/linux/libcfs/libcfs.h" -#include "../include/lustre_dlm.h" -#include "../include/obd_class.h" +#include <linux/libcfs/libcfs.h> +#include <lustre_dlm.h> +#include <obd_class.h> #include <linux/list.h> #include "ldlm_internal.h" @@ -926,7 +926,7 @@ static struct attribute *ldlm_attrs[] = { NULL, }; -static struct attribute_group ldlm_attr_group = { +static const struct attribute_group ldlm_attr_group = { .attrs = ldlm_attrs, }; @@ -1138,7 +1138,7 @@ int ldlm_init(void) void ldlm_exit(void) { if (ldlm_refcount) - CERROR("ldlm_refcount is %d in ldlm_exit!\n", ldlm_refcount); + CERROR("ldlm_refcount is %d in %s!\n", ldlm_refcount, __func__); kmem_cache_destroy(ldlm_resource_slab); /* ldlm_lock_put() use RCU to call ldlm_lock_free, so need call * synchronize_rcu() to wait a grace period elapsed, so that diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c index 862ea0a1dc97..1ca605fe25ff 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c @@ -48,9 +48,9 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include "../include/lustre_dlm.h" -#include "../include/obd_support.h" -#include "../include/lustre_lib.h" +#include <lustre_dlm.h> +#include <obd_support.h> +#include <lustre_lib.h> #include "ldlm_internal.h" diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index cf3fc5793377..d77bf0baa84f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -94,10 +94,10 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include "../include/lustre_dlm.h" -#include "../include/cl_object.h" -#include "../include/obd_class.h" -#include "../include/obd_support.h" +#include <lustre_dlm.h> +#include <cl_object.h> +#include <obd_class.h> +#include <obd_support.h> #include "ldlm_internal.h" /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 4028e11249a2..f3bf238d0748 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -57,9 +57,10 @@ #define DEBUG_SUBSYSTEM S_LDLM -#include "../include/lustre_dlm.h" -#include "../include/obd_class.h" -#include "../include/obd.h" +#include <lustre_errno.h> +#include <lustre_dlm.h> +#include <obd_class.h> +#include <obd.h> #include "ldlm_internal.h" @@ -83,6 +84,33 @@ struct ldlm_async_args { struct lustre_handle lock_handle; }; +/** + * ldlm_request_bufsize + * + * @count: number of ldlm handles + * @type: ldlm opcode + * + * If opcode=LDLM_ENQUEUE, 1 slot is already occupied, + * LDLM_LOCKREQ_HANDLE -1 slots are available. + * Otherwise, LDLM_LOCKREQ_HANDLE slots are available. + * + * Return: size of the request buffer + */ +static int ldlm_request_bufsize(int count, int type) +{ + int avail = LDLM_LOCKREQ_HANDLES; + + if (type == LDLM_ENQUEUE) + avail -= LDLM_ENQUEUE_CANCEL_OFF; + + if (count > avail) + avail = (count - avail) * sizeof(struct lustre_handle); + else + avail = 0; + + return sizeof(struct ldlm_request) + avail; +} + static int ldlm_expired_completion_wait(void *data) { struct lock_wait_data *lwd = data; @@ -1635,7 +1663,7 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count, if (res < 0) { CDEBUG_LIMIT(res == -ESHUTDOWN ? D_DLMTRACE : D_ERROR, - "ldlm_cli_cancel_list: %d\n", res); + "%s: %d\n", __func__, res); res = count; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index c9ef247d9be4..c2ddf7312571 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -36,9 +36,9 @@ */ #define DEBUG_SUBSYSTEM S_LDLM -#include "../include/lustre_dlm.h" -#include "../include/lustre_fid.h" -#include "../include/obd_class.h" +#include <lustre_dlm.h> +#include <lustre_fid.h> +#include <obd_class.h> #include "ldlm_internal.h" struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab; @@ -223,7 +223,7 @@ static ssize_t lru_size_show(struct kobject *kobj, struct attribute *attr, if (ns_connect_lru_resize(ns)) nr = &ns->ns_nr_unused; - return sprintf(buf, "%u", *nr); + return sprintf(buf, "%u\n", *nr); } static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr, @@ -318,7 +318,7 @@ static ssize_t lru_max_age_show(struct kobject *kobj, struct attribute *attr, struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace, ns_kobj); - return sprintf(buf, "%u", ns->ns_max_age); + return sprintf(buf, "%u\n", ns->ns_max_age); } static ssize_t lru_max_age_store(struct kobject *kobj, struct attribute *attr, @@ -536,16 +536,6 @@ static void ldlm_res_hop_get_locked(struct cfs_hash *hs, ldlm_resource_getref(res); } -static void ldlm_res_hop_put_locked(struct cfs_hash *hs, - struct hlist_node *hnode) -{ - struct ldlm_resource *res; - - res = hlist_entry(hnode, struct ldlm_resource, lr_hash); - /* cfs_hash_for_each_nolock is the only chance we call it */ - ldlm_resource_putref_locked(res); -} - static void ldlm_res_hop_put(struct cfs_hash *hs, struct hlist_node *hnode) { struct ldlm_resource *res; @@ -561,7 +551,6 @@ static struct cfs_hash_ops ldlm_ns_hash_ops = { .hs_keycpy = NULL, .hs_object = ldlm_res_hop_object, .hs_get = ldlm_res_hop_get_locked, - .hs_put_locked = ldlm_res_hop_put_locked, .hs_put = ldlm_res_hop_put }; @@ -572,7 +561,6 @@ static struct cfs_hash_ops ldlm_ns_fid_hash_ops = { .hs_keycpy = NULL, .hs_object = ldlm_res_hop_object, .hs_get = ldlm_res_hop_get_locked, - .hs_put_locked = ldlm_res_hop_put_locked, .hs_put = ldlm_res_hop_put }; @@ -1249,37 +1237,6 @@ int ldlm_resource_putref(struct ldlm_resource *res) } EXPORT_SYMBOL(ldlm_resource_putref); -/* Returns 1 if the resource was freed, 0 if it remains. */ -int ldlm_resource_putref_locked(struct ldlm_resource *res) -{ - struct ldlm_namespace *ns = ldlm_res_to_ns(res); - - LASSERT_ATOMIC_GT_LT(&res->lr_refcount, 0, LI_POISON); - CDEBUG(D_INFO, "putref res: %p count: %d\n", - res, atomic_read(&res->lr_refcount) - 1); - - if (atomic_dec_and_test(&res->lr_refcount)) { - struct cfs_hash_bd bd; - - cfs_hash_bd_get(ldlm_res_to_ns(res)->ns_rs_hash, - &res->lr_name, &bd); - __ldlm_resource_putref_final(&bd, res); - cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); - /* NB: ns_rs_hash is created with CFS_HASH_NO_ITEMREF, - * so we should never be here while calling cfs_hash_del, - * cfs_hash_for_each_nolock is the only case we can get - * here, which is safe to release cfs_hash_bd_lock. - */ - if (ns->ns_lvbo && ns->ns_lvbo->lvbo_free) - ns->ns_lvbo->lvbo_free(res); - kmem_cache_free(ldlm_resource_slab, res); - - cfs_hash_bd_lock(ns->ns_rs_hash, &bd, 1); - return 1; - } - return 0; -} - /** * Add a lock into a given resource into specified lock list. */ |