#ifdef __KERNEL__
-#include <linux/obd_class.h>
+#include <linux/proc_fs.h>
+#include <linux/lustre_lib.h>
#include <linux/lustre_net.h>
+#include <linux/lustre_import.h>
+
+struct obd_ops;
+struct obd_device;
#define OBD_LDLM_DEVICENAME "ldlm"
ELDLM_LOCK_CHANGED = 300,
ELDLM_LOCK_ABORTED = 301,
- ELDLM_RESOURCE_FREED = 302,
ELDLM_NAMESPACE_EXISTS = 400,
ELDLM_BAD_NAMESPACE = 401
*/
struct ldlm_namespace {
- char *ns_name;
- struct ptlrpc_client ns_rpc_client; /* used for revocation callbacks */
- __u32 ns_client; /* is this a client-side lock tree? */
- struct list_head *ns_hash; /* hash table for ns */
- __u32 ns_refcount; /* count of resources in the hash */
- struct list_head ns_root_list; /* all root resources in ns */
- struct lustre_lock ns_lock; /* protects hash, refcount, list */
+ char *ns_name;
+ __u32 ns_client; /* is this a client-side lock tree? */
+ struct list_head *ns_hash; /* hash table for ns */
+ __u32 ns_refcount; /* count of resources in the hash */
+ struct list_head ns_root_list; /* all root resources in ns */
+ struct lustre_lock ns_lock; /* protects hash, refcount, list */
+ struct list_head ns_list_chain; /* position in global NS list */
+ struct proc_dir_entry *ns_proc_dir;
+
+ spinlock_t ns_counter_lock;
+ __u64 ns_locks;
+ __u64 ns_resources;
};
/*
struct ldlm_lock;
-typedef int (*ldlm_lock_callback)(struct lustre_handle *lockh,
- struct ldlm_lock_desc *new, void *data,
- __u32 data_len);
+typedef int (*ldlm_blocking_callback)(struct ldlm_lock *lock,
+ struct ldlm_lock_desc *new, void *data,
+ __u32 data_len);
typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, int flags);
struct ldlm_lock {
- __u64 l_random;
+ __u64 l_random;
int l_refc;
struct ldlm_resource *l_resource;
struct ldlm_lock *l_parent;
struct list_head l_children;
struct list_head l_childof;
struct list_head l_res_link; /*position in one of three res lists*/
+ struct list_head l_export_chain; /* per-export chain of locks */
+ struct list_head l_pending_chain; /* locks with callbacks pending*/
+ unsigned long l_callback_timeout;
ldlm_mode_t l_req_mode;
ldlm_mode_t l_granted_mode;
ldlm_completion_callback l_completion_ast;
- ldlm_lock_callback l_blocking_ast;
+ ldlm_blocking_callback l_blocking_ast;
- struct ptlrpc_connection *l_connection;
- struct ptlrpc_client *l_client;
+ struct obd_export *l_export;
struct lustre_handle *l_connh;
__u32 l_flags;
- struct lustre_handle l_remote_handle;
+ struct lustre_handle l_remote_handle;
void *l_data;
__u32 l_data_len;
void *l_cookie;
struct ldlm_resource {
struct ldlm_namespace *lr_namespace;
struct list_head lr_hash;
- struct list_head lr_rootlink; /* link all root resources in NS */
struct ldlm_resource *lr_parent; /* 0 for a root resource */
struct list_head lr_children; /* list head for child resources */
- struct list_head lr_childof; /* part of child list of parent */
+ struct list_head lr_childof; /* part of ns_root_list if root res,
+ * part of lr_children if child */
struct list_head lr_granted;
struct list_head lr_converting;
void *w_data;
int w_datalen;
};
+
+/* Per-export ldlm state. */
+struct ldlm_export_data {
+ struct list_head led_held_locks;
+ struct obd_import led_import;
+};
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);
if (lock->l_resource == NULL) \
CDEBUG(D_DLMTRACE, "### " format \
" (UNKNOWN: lock %p(rc=%d/%d,%d) mode %s/%s on " \
- "res \?\? (rc=\?\?) type \?\?\? remote %Lx)\n" , \
+ "res \?\? (rc=\?\?) type \?\?\? remote "LPX64")\n" , \
## a, lock, lock->l_refc, lock->l_readers, \
lock->l_writers, \
ldlm_lockname[lock->l_granted_mode], \
else \
CDEBUG(D_DLMTRACE, "### " format \
" (%s: lock %p(rc=%d/%d,%d) mode %s/%s on res " \
- "%Lu (rc=%d) type %s remote %Lx)\n" , ## a, \
+ LPU64" (rc=%d) type %s remote "LPX64")\n" , ## a, \
lock->l_resource->lr_namespace->ns_name, lock, \
lock->l_refc, lock->l_readers, lock->l_writers, \
ldlm_lockname[lock->l_granted_mode], \
#define LDLM_LOCK_PUT(lock) \
do { \
- LDLM_DEBUG(lock, "put"); \
+ /*LDLM_DEBUG(lock, "put");*/ \
ldlm_lock_put(lock); \
} while (0)
#define LDLM_LOCK_GET(lock) \
({ \
ldlm_lock_get(lock); \
- LDLM_DEBUG(lock, "get"); \
+ /*LDLM_DEBUG(lock, "get");*/ \
lock; \
})
+struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
void ldlm_lock_put(struct ldlm_lock *lock);
void ldlm_lock_destroy(struct ldlm_lock *lock);
void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc);
ldlm_error_t ldlm_lock_enqueue(struct ldlm_lock *lock, void *cookie,
int cookie_len, int *flags,
ldlm_completion_callback completion,
- ldlm_lock_callback blocking);
+ ldlm_blocking_callback blocking);
struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
int *flags);
void ldlm_lock_cancel(struct ldlm_lock *lock);
void ldlm_lock_dump(struct ldlm_lock *lock);
/* ldlm_test.c */
-int ldlm_test(struct obd_device *device, struct ptlrpc_connection *conn);
+int ldlm_test(struct obd_device *device, struct lustre_handle *connh);
+int ldlm_regression_start(struct obd_device *obddev,
+ struct lustre_handle *connh,
+ unsigned int threads, unsigned int max_locks_in,
+ unsigned int num_resources_in,
+ unsigned int num_extents_in);
+int ldlm_regression_stop(void);
+
/* resource.c */
struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 local);
int ldlm_namespace_free(struct ldlm_namespace *ns);
+int ldlm_proc_setup(struct obd_device *obd);
+void ldlm_proc_cleanup(struct obd_device *obd);
/* resource.c - internal */
struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
struct ldlm_lock *lock);
void ldlm_resource_unlink_lock(struct ldlm_lock *lock);
void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc);
-void ldlm_resource_dump(struct ldlm_resource *res);
-int ldlm_lock_change_resource(struct ldlm_lock *lock, __u64 new_resid[3]);
+void ldlm_dump_all_namespaces(void);
+void ldlm_namespace_dump(struct ldlm_namespace *);
+void ldlm_resource_dump(struct ldlm_resource *);
+int ldlm_lock_change_resource(struct ldlm_lock *, __u64 new_resid[3]);
/* ldlm_request.c */
int ldlm_completion_ast(struct ldlm_lock *lock, int flags);
ldlm_mode_t mode,
int *flags,
ldlm_completion_callback completion,
- ldlm_lock_callback callback,
+ ldlm_blocking_callback callback,
void *data,
__u32 data_len,
struct lustre_handle *lockh);
ldlm_mode_t mode,
int *flags,
ldlm_completion_callback completion,
- ldlm_lock_callback callback,
+ ldlm_blocking_callback callback,
void *data,
__u32 data_len,
struct lustre_handle *lockh);
void *data, __u32 data_len);
int ldlm_cli_convert(struct lustre_handle *, int new_mode, int *flags);
int ldlm_cli_cancel(struct lustre_handle *lockh);
+int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, __u64 *res_id);
+
+/* mds/handler.c */
+/* This has to be here because recurisve inclusion sucks. */
+int mds_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
+ void *data, __u32 data_len);
#endif /* __KERNEL__ */
#define IOC_LDLM_MIN_NR 40
#define IOC_LDLM_TEST _IOWR('f', 40, long)
-#define IOC_LDLM_MAX_NR 41
+#define IOC_LDLM_DUMP _IOWR('f', 41, long)
+#define IOC_LDLM_REGRESS_START _IOWR('f', 42, long)
+#define IOC_LDLM_REGRESS_STOP _IOWR('f', 43, long)
+#define IOC_LDLM_MAX_NR 43
#endif