From 106e231e291f0f42d476673048fba265ad6c8c42 Mon Sep 17 00:00:00 2001 From: shaver Date: Thu, 22 Aug 2002 13:30:11 +0000 Subject: [PATCH] * Chain granted locks off the export. --- lustre/include/linux/lustre_dlm.h | 11 +++++++++-- lustre/include/linux/obd_class.h | 3 ++- lustre/ldlm/ldlm_lock.c | 7 ++++--- lustre/ldlm/ldlm_lockd.c | 10 +++++++++- lustre/mds/handler.c | 1 + lustre/obdclass/genops.c | 2 ++ 6 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lustre/include/linux/lustre_dlm.h b/lustre/include/linux/lustre_dlm.h index cd18fa2..d43c366 100644 --- a/lustre/include/linux/lustre_dlm.h +++ b/lustre/include/linux/lustre_dlm.h @@ -8,9 +8,12 @@ #ifdef __KERNEL__ #include -#include #include +struct obd_ops; +struct obd_export; +struct obd_device; + #define OBD_LDLM_DEVICENAME "ldlm" typedef enum { @@ -193,6 +196,11 @@ struct ldlm_ast_work { void *w_data; int w_datalen; }; + +/* Per-export ldlm state. */ +struct ldlm_export_data { + struct list_head led_held_locks; +}; static inline struct ldlm_extent *ldlm_res2extent(struct ldlm_resource *res) { @@ -201,7 +209,6 @@ static inline struct ldlm_extent *ldlm_res2extent(struct ldlm_resource *res) extern struct obd_ops ldlm_obd_ops; - extern char *ldlm_lockname[]; extern char *ldlm_typename[]; extern char *ldlm_it2str(int it); diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 66b7713..793b1a6 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -40,6 +40,7 @@ #include #include #include +#include #endif @@ -76,8 +77,8 @@ struct obd_export { struct obd_device *exp_obd; struct ptlrpc_connection *exp_connection; struct mds_export_data exp_mds_data; -#if NOTYET && 0 struct ldlm_export_data exp_ldlm_data; +#if NOTYET && 0 struct ost_export_data exp_ost_data; #endif void *exp_data; /* device specific data */ diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index c2f9f25..d1edbdb 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -28,6 +28,7 @@ #include #include #include +#include /* lock types */ char *ldlm_lockname[] = { @@ -189,7 +190,10 @@ void ldlm_lock_destroy(struct ldlm_lock *lock) return; } + list_del(&lock->l_export_chain); + lock->l_export = NULL; lock->l_flags = LDLM_FL_DESTROYED; + l_unlock(&lock->l_resource->lr_namespace->ns_lock); LDLM_LOCK_PUT(lock); EXIT; @@ -317,9 +321,6 @@ struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *handle) return retval; } - - - static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b) { return lockmode_compat(a->l_req_mode, b->l_req_mode); diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 4d687a3..374f777 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -28,6 +28,7 @@ #include #include #include +#include extern kmem_cache_t *ldlm_resource_slab; extern kmem_cache_t *ldlm_lock_slab; @@ -74,7 +75,7 @@ int ldlm_add_waiting_lock(struct ldlm_lock *lock) waiting_locks_timer.expires); mod_timer(&waiting_locks_timer, timeout_rounded); } - list_add(&lock->l_pending_chain, waiting_locks_list.prev); /* FIFO */ + list_add_tail(&lock->l_pending_chain, &waiting_locks_list); /* FIFO */ spin_unlock_bh(&waiting_locks_spinlock); RETURN(1); } @@ -254,6 +255,13 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req) } lock->l_export = req->rq_export; + if (lock->l_export) { + l_lock(&lock->l_resource->lr_namespace->ns_lock); + list_add(&lock->l_export_chain, + &lock->l_export->exp_ldlm_data.led_held_locks); + l_unlock(&lock->l_resource->lr_namespace->ns_lock); + } + ptlrpc_connection_addref(req->rq_connection); EXIT; out: diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 11b3dda..b179fa9 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -32,6 +32,7 @@ #include #include #include +#include extern int mds_get_lovtgts(struct obd_device *obd, int tgt_count, uuid_t *uuidarray); diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 3061d13..359fcfa 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -274,7 +274,9 @@ struct obd_export *class_new_export(struct obd_device *obddev) memset(export, 0, sizeof(*export)); get_random_bytes(&export->exp_cookie, sizeof(__u64)); export->exp_obd = obddev; + /* XXX should these be in MDS and LDLM init functions? */ INIT_LIST_HEAD(&export->exp_mds_data.med_open_head); + INIT_LIST_HEAD(&export->exp_ldlm_data.led_held_locks); list_add(&(export->exp_chain), &export->exp_obd->obd_exports); return export; } -- 1.8.3.1