Whamcloud - gitweb
We touched everything, but it's not as scary as it looks.
[fs/lustre-release.git] / lustre / ldlm / ldlm_test.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  *
9  * by Cluster File Systems, Inc.
10  */
11
12 #define EXPORT_SYMTAB
13
14 #include <linux/version.h>
15 #include <linux/module.h>
16 #include <linux/slab.h>
17 #include <asm/unistd.h>
18
19 #define DEBUG_SUBSYSTEM S_LDLM
20
21 #include <linux/obd_support.h>
22 #include <linux/obd_class.h>
23
24 #include <linux/lustre_dlm.h>
25
26 static void ldlm_test_callback(struct ldlm_lock *lock, struct ldlm_lock *new)
27 {
28         printk("ldlm_test_callback: lock=%p, new=%p\n", lock, new);
29 }
30
31 int ldlm_test(struct obd_device *obddev)
32 {
33         struct ldlm_namespace *ns;
34         struct ldlm_resource *res;
35         __u32 res_id[RES_NAME_SIZE] = {1, 2, 3, 4, 5, 6};
36         ldlm_error_t err;
37
38         ns = ldlm_namespace_new(obddev, 1);
39         if (ns == NULL)
40                 BUG();
41
42         res = ldlm_resource_get(ns, NULL, res_id, 1);
43         if (res == NULL)
44                 BUG();
45
46         res->lr_blocking = ldlm_test_callback;
47
48         /* Get a couple of read locks */
49         err = ldlm_local_lock_enqueue(obddev, 1, NULL, NULL, res_id, LCK_CR);
50         if (err != ELDLM_OK)
51                 BUG();
52
53         err = ldlm_local_lock_enqueue(obddev, 1, NULL, NULL, res_id, LCK_CR);
54         if (err != ELDLM_OK)
55                 BUG();
56
57         ldlm_resource_dump(res);
58
59         return 0;
60 }