]>
git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - fs/gfs2/locking/nolock/main.c
5cc1dfa7944a2ee3ff9f14c4f6447768063dfc22
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/types.h>
16 #include <linux/smp_lock.h>
17 #include <linux/lm_interface.h>
19 struct nolock_lockspace
{
20 unsigned int nl_lvb_size
;
23 static const struct lm_lockops nolock_ops
;
25 static int nolock_mount(char *table_name
, char *host_data
,
26 lm_callback_t cb
, void *cb_data
,
27 unsigned int min_lvb_size
, int flags
,
28 struct lm_lockstruct
*lockstruct
,
29 struct kobject
*fskobj
)
33 struct nolock_lockspace
*nl
;
35 c
= strstr(host_data
, "jid=");
40 sscanf(c
, "%u", &jid
);
43 nl
= kzalloc(sizeof(struct nolock_lockspace
), GFP_KERNEL
);
47 nl
->nl_lvb_size
= min_lvb_size
;
49 lockstruct
->ls_jid
= jid
;
50 lockstruct
->ls_first
= 1;
51 lockstruct
->ls_lvb_size
= min_lvb_size
;
52 lockstruct
->ls_lockspace
= nl
;
53 lockstruct
->ls_ops
= &nolock_ops
;
54 lockstruct
->ls_flags
= LM_LSFLAG_LOCAL
;
59 static void nolock_others_may_mount(void *lockspace
)
63 static void nolock_unmount(void *lockspace
)
65 struct nolock_lockspace
*nl
= lockspace
;
69 static void nolock_withdraw(void *lockspace
)
74 * nolock_get_lock - get a lm_lock_t given a descripton of the lock
75 * @lockspace: the lockspace the lock lives in
76 * @name: the name of the lock
77 * @lockp: return the lm_lock_t here
79 * Returns: 0 on success, -EXXX on failure
82 static int nolock_get_lock(void *lockspace
, struct lm_lockname
*name
,
90 * nolock_put_lock - get rid of a lock structure
91 * @lock: the lock to throw away
95 static void nolock_put_lock(void *lock
)
100 * nolock_lock - acquire a lock
101 * @lock: the lock to manipulate
102 * @cur_state: the current state
103 * @req_state: the requested state
104 * @flags: modifier flags
106 * Returns: A bitmap of LM_OUT_*
109 static unsigned int nolock_lock(void *lock
, unsigned int cur_state
,
110 unsigned int req_state
, unsigned int flags
)
112 return req_state
| LM_OUT_CACHEABLE
;
116 * nolock_unlock - unlock a lock
117 * @lock: the lock to manipulate
118 * @cur_state: the current state
123 static unsigned int nolock_unlock(void *lock
, unsigned int cur_state
)
128 static void nolock_cancel(void *lock
)
133 * nolock_hold_lvb - hold on to a lock value block
134 * @lock: the lock the LVB is associated with
135 * @lvbp: return the lm_lvb_t here
137 * Returns: 0 on success, -EXXX on failure
140 static int nolock_hold_lvb(void *lock
, char **lvbp
)
142 struct nolock_lockspace
*nl
= lock
;
145 *lvbp
= kzalloc(nl
->nl_lvb_size
, GFP_KERNEL
);
153 * nolock_unhold_lvb - release a LVB
154 * @lock: the lock the LVB is associated with
155 * @lvb: the lock value block
159 static void nolock_unhold_lvb(void *lock
, char *lvb
)
164 static int nolock_plock_get(void *lockspace
, struct lm_lockname
*name
,
165 struct file
*file
, struct file_lock
*fl
)
167 posix_test_lock(file
, fl
);
172 static int nolock_plock(void *lockspace
, struct lm_lockname
*name
,
173 struct file
*file
, int cmd
, struct file_lock
*fl
)
176 error
= posix_lock_file_wait(file
, fl
);
180 static int nolock_punlock(void *lockspace
, struct lm_lockname
*name
,
181 struct file
*file
, struct file_lock
*fl
)
184 error
= posix_lock_file_wait(file
, fl
);
188 static void nolock_recovery_done(void *lockspace
, unsigned int jid
,
189 unsigned int message
)
193 static const struct lm_lockops nolock_ops
= {
194 .lm_proto_name
= "lock_nolock",
195 .lm_mount
= nolock_mount
,
196 .lm_others_may_mount
= nolock_others_may_mount
,
197 .lm_unmount
= nolock_unmount
,
198 .lm_withdraw
= nolock_withdraw
,
199 .lm_get_lock
= nolock_get_lock
,
200 .lm_put_lock
= nolock_put_lock
,
201 .lm_lock
= nolock_lock
,
202 .lm_unlock
= nolock_unlock
,
203 .lm_cancel
= nolock_cancel
,
204 .lm_hold_lvb
= nolock_hold_lvb
,
205 .lm_unhold_lvb
= nolock_unhold_lvb
,
206 .lm_plock_get
= nolock_plock_get
,
207 .lm_plock
= nolock_plock
,
208 .lm_punlock
= nolock_punlock
,
209 .lm_recovery_done
= nolock_recovery_done
,
210 .lm_owner
= THIS_MODULE
,
213 static int __init
init_nolock(void)
217 error
= gfs2_register_lockproto(&nolock_ops
);
220 "lock_nolock: can't register protocol: %d\n", error
);
225 "Lock_Nolock (built %s %s) installed\n", __DATE__
, __TIME__
);
229 static void __exit
exit_nolock(void)
231 gfs2_unregister_lockproto(&nolock_ops
);
234 module_init(init_nolock
);
235 module_exit(exit_nolock
);
237 MODULE_DESCRIPTION("GFS Nolock Locking Module");
238 MODULE_AUTHOR("Red Hat, Inc.");
239 MODULE_LICENSE("GPL");