diff options
-rw-r--r-- | fs/gfs2/locking.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c index 523243a13a21..d3657bc7938a 100644 --- a/fs/gfs2/locking.c +++ b/fs/gfs2/locking.c | |||
@@ -23,11 +23,74 @@ struct lmh_wrapper { | |||
23 | const struct lm_lockops *lw_ops; | 23 | const struct lm_lockops *lw_ops; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | struct nolock_lockspace { | ||
27 | unsigned int nl_lvb_size; | ||
28 | }; | ||
29 | |||
30 | /** | ||
31 | * nolock_get_lock - get a lm_lock_t given a descripton of the lock | ||
32 | * @lockspace: the lockspace the lock lives in | ||
33 | * @name: the name of the lock | ||
34 | * @lockp: return the lm_lock_t here | ||
35 | * | ||
36 | * Returns: 0 on success, -EXXX on failure | ||
37 | */ | ||
38 | |||
39 | static int nolock_get_lock(void *lockspace, struct lm_lockname *name, | ||
40 | void **lockp) | ||
41 | { | ||
42 | *lockp = lockspace; | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | /** | ||
47 | * nolock_put_lock - get rid of a lock structure | ||
48 | * @lock: the lock to throw away | ||
49 | * | ||
50 | */ | ||
51 | |||
52 | static void nolock_put_lock(void *lock) | ||
53 | { | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * nolock_hold_lvb - hold on to a lock value block | ||
58 | * @lock: the lock the LVB is associated with | ||
59 | * @lvbp: return the lm_lvb_t here | ||
60 | * | ||
61 | * Returns: 0 on success, -EXXX on failure | ||
62 | */ | ||
63 | |||
64 | static int nolock_hold_lvb(void *lock, char **lvbp) | ||
65 | { | ||
66 | struct nolock_lockspace *nl = lock; | ||
67 | int error = 0; | ||
68 | |||
69 | *lvbp = kzalloc(nl->nl_lvb_size, GFP_KERNEL); | ||
70 | if (!*lvbp) | ||
71 | error = -ENOMEM; | ||
72 | |||
73 | return error; | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * nolock_unhold_lvb - release a LVB | ||
78 | * @lock: the lock the LVB is associated with | ||
79 | * @lvb: the lock value block | ||
80 | * | ||
81 | */ | ||
82 | |||
83 | static void nolock_unhold_lvb(void *lock, char *lvb) | ||
84 | { | ||
85 | kfree(lvb); | ||
86 | } | ||
87 | |||
26 | static int nolock_mount(char *table_name, char *host_data, | 88 | static int nolock_mount(char *table_name, char *host_data, |
27 | lm_callback_t cb, void *cb_data, | 89 | lm_callback_t cb, void *cb_data, |
28 | unsigned int min_lvb_size, int flags, | 90 | unsigned int min_lvb_size, int flags, |
29 | struct lm_lockstruct *lockstruct, | 91 | struct lm_lockstruct *lockstruct, |
30 | struct kobject *fskobj); | 92 | struct kobject *fskobj); |
93 | static void nolock_unmount(void *lockspace); | ||
31 | 94 | ||
32 | /* List of registered low-level locking protocols. A file system selects one | 95 | /* List of registered low-level locking protocols. A file system selects one |
33 | of them by name at mount time, e.g. lock_nolock, lock_dlm. */ | 96 | of them by name at mount time, e.g. lock_nolock, lock_dlm. */ |
@@ -35,6 +98,11 @@ static int nolock_mount(char *table_name, char *host_data, | |||
35 | static const struct lm_lockops nolock_ops = { | 98 | static const struct lm_lockops nolock_ops = { |
36 | .lm_proto_name = "lock_nolock", | 99 | .lm_proto_name = "lock_nolock", |
37 | .lm_mount = nolock_mount, | 100 | .lm_mount = nolock_mount, |
101 | .lm_unmount = nolock_unmount, | ||
102 | .lm_get_lock = nolock_get_lock, | ||
103 | .lm_put_lock = nolock_put_lock, | ||
104 | .lm_hold_lvb = nolock_hold_lvb, | ||
105 | .lm_unhold_lvb = nolock_unhold_lvb, | ||
38 | }; | 106 | }; |
39 | 107 | ||
40 | static struct lmh_wrapper nolock_proto = { | 108 | static struct lmh_wrapper nolock_proto = { |
@@ -53,6 +121,7 @@ static int nolock_mount(char *table_name, char *host_data, | |||
53 | { | 121 | { |
54 | char *c; | 122 | char *c; |
55 | unsigned int jid; | 123 | unsigned int jid; |
124 | struct nolock_lockspace *nl; | ||
56 | 125 | ||
57 | c = strstr(host_data, "jid="); | 126 | c = strstr(host_data, "jid="); |
58 | if (!c) | 127 | if (!c) |
@@ -62,15 +131,28 @@ static int nolock_mount(char *table_name, char *host_data, | |||
62 | sscanf(c, "%u", &jid); | 131 | sscanf(c, "%u", &jid); |
63 | } | 132 | } |
64 | 133 | ||
134 | nl = kzalloc(sizeof(struct nolock_lockspace), GFP_KERNEL); | ||
135 | if (!nl) | ||
136 | return -ENOMEM; | ||
137 | |||
138 | nl->nl_lvb_size = min_lvb_size; | ||
139 | |||
65 | lockstruct->ls_jid = jid; | 140 | lockstruct->ls_jid = jid; |
66 | lockstruct->ls_first = 1; | 141 | lockstruct->ls_first = 1; |
67 | lockstruct->ls_lvb_size = min_lvb_size; | 142 | lockstruct->ls_lvb_size = min_lvb_size; |
143 | lockstruct->ls_lockspace = nl; | ||
68 | lockstruct->ls_ops = &nolock_ops; | 144 | lockstruct->ls_ops = &nolock_ops; |
69 | lockstruct->ls_flags = LM_LSFLAG_LOCAL; | 145 | lockstruct->ls_flags = LM_LSFLAG_LOCAL; |
70 | 146 | ||
71 | return 0; | 147 | return 0; |
72 | } | 148 | } |
73 | 149 | ||
150 | static void nolock_unmount(void *lockspace) | ||
151 | { | ||
152 | struct nolock_lockspace *nl = lockspace; | ||
153 | kfree(nl); | ||
154 | } | ||
155 | |||
74 | /** | 156 | /** |
75 | * gfs2_register_lockproto - Register a low-level locking protocol | 157 | * gfs2_register_lockproto - Register a low-level locking protocol |
76 | * @proto: the protocol definition | 158 | * @proto: the protocol definition |