diff options
Diffstat (limited to 'fs/gfs2')
41 files changed, 819 insertions, 2170 deletions
diff --git a/fs/gfs2/Kconfig b/fs/gfs2/Kconfig index e563a6449811..3a981b7f64ca 100644 --- a/fs/gfs2/Kconfig +++ b/fs/gfs2/Kconfig | |||
@@ -1,6 +1,10 @@ | |||
1 | config GFS2_FS | 1 | config GFS2_FS |
2 | tristate "GFS2 file system support" | 2 | tristate "GFS2 file system support" |
3 | depends on EXPERIMENTAL && (64BIT || LBD) | 3 | depends on EXPERIMENTAL && (64BIT || LBD) |
4 | select DLM if GFS2_FS_LOCKING_DLM | ||
5 | select CONFIGFS_FS if GFS2_FS_LOCKING_DLM | ||
6 | select SYSFS if GFS2_FS_LOCKING_DLM | ||
7 | select IP_SCTP if DLM_SCTP | ||
4 | select FS_POSIX_ACL | 8 | select FS_POSIX_ACL |
5 | select CRC32 | 9 | select CRC32 |
6 | help | 10 | help |
@@ -18,17 +22,16 @@ config GFS2_FS | |||
18 | the locking module below. Documentation and utilities for GFS2 can | 22 | the locking module below. Documentation and utilities for GFS2 can |
19 | be found here: http://sources.redhat.com/cluster | 23 | be found here: http://sources.redhat.com/cluster |
20 | 24 | ||
21 | The "nolock" lock module is now built in to GFS2 by default. | 25 | The "nolock" lock module is now built in to GFS2 by default. If |
26 | you want to use the DLM, be sure to enable HOTPLUG and IPv4/6 | ||
27 | networking. | ||
22 | 28 | ||
23 | config GFS2_FS_LOCKING_DLM | 29 | config GFS2_FS_LOCKING_DLM |
24 | tristate "GFS2 DLM locking module" | 30 | bool "GFS2 DLM locking" |
25 | depends on GFS2_FS && SYSFS && NET && INET && (IPV6 || IPV6=n) | 31 | depends on (GFS2_FS!=n) && NET && INET && (IPV6 || IPV6=n) && HOTPLUG |
26 | select IP_SCTP if DLM_SCTP | ||
27 | select CONFIGFS_FS | ||
28 | select DLM | ||
29 | help | 32 | help |
30 | Multiple node locking module for GFS2 | 33 | Multiple node locking module for GFS2 |
31 | 34 | ||
32 | Most users of GFS2 will require this module. It provides the locking | 35 | Most users of GFS2 will require this. It provides the locking |
33 | interface between GFS2 and the DLM, which is required to use GFS2 | 36 | interface between GFS2 and the DLM, which is required to use GFS2 |
34 | in a cluster environment. | 37 | in a cluster environment. |
diff --git a/fs/gfs2/Makefile b/fs/gfs2/Makefile index c1b4ec6a9650..a851ea4bdf70 100644 --- a/fs/gfs2/Makefile +++ b/fs/gfs2/Makefile | |||
@@ -1,9 +1,9 @@ | |||
1 | obj-$(CONFIG_GFS2_FS) += gfs2.o | 1 | obj-$(CONFIG_GFS2_FS) += gfs2.o |
2 | gfs2-y := acl.o bmap.o dir.o eaops.o eattr.o glock.o \ | 2 | gfs2-y := acl.o bmap.o dir.o eaops.o eattr.o glock.o \ |
3 | glops.o inode.o log.o lops.o locking.o main.o meta_io.o \ | 3 | glops.o inode.o log.o lops.o main.o meta_io.o \ |
4 | mount.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ | 4 | mount.o ops_address.o ops_dentry.o ops_export.o ops_file.o \ |
5 | ops_fstype.o ops_inode.o ops_super.o quota.o \ | 5 | ops_fstype.o ops_inode.o ops_super.o quota.o \ |
6 | recovery.o rgrp.o super.o sys.o trans.o util.o | 6 | recovery.o rgrp.o super.o sys.o trans.o util.o |
7 | 7 | ||
8 | obj-$(CONFIG_GFS2_FS_LOCKING_DLM) += locking/dlm/ | 8 | gfs2-$(CONFIG_GFS2_FS_LOCKING_DLM) += lock_dlm.o |
9 | 9 | ||
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index e335dceb6a4f..43764f4fa763 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/posix_acl.h> | 15 | #include <linux/posix_acl.h> |
16 | #include <linux/posix_acl_xattr.h> | 16 | #include <linux/posix_acl_xattr.h> |
17 | #include <linux/gfs2_ondisk.h> | 17 | #include <linux/gfs2_ondisk.h> |
18 | #include <linux/lm_interface.h> | ||
19 | 18 | ||
20 | #include "gfs2.h" | 19 | #include "gfs2.h" |
21 | #include "incore.h" | 20 | #include "incore.h" |
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 11ffc56f1f81..3a5d3f883e10 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
14 | #include <linux/gfs2_ondisk.h> | 14 | #include <linux/gfs2_ondisk.h> |
15 | #include <linux/crc32.h> | 15 | #include <linux/crc32.h> |
16 | #include <linux/lm_interface.h> | ||
17 | 16 | ||
18 | #include "gfs2.h" | 17 | #include "gfs2.h" |
19 | #include "incore.h" | 18 | #include "incore.h" |
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index b7c8e5c70791..aef4d0c06748 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c | |||
@@ -60,7 +60,6 @@ | |||
60 | #include <linux/gfs2_ondisk.h> | 60 | #include <linux/gfs2_ondisk.h> |
61 | #include <linux/crc32.h> | 61 | #include <linux/crc32.h> |
62 | #include <linux/vmalloc.h> | 62 | #include <linux/vmalloc.h> |
63 | #include <linux/lm_interface.h> | ||
64 | 63 | ||
65 | #include "gfs2.h" | 64 | #include "gfs2.h" |
66 | #include "incore.h" | 65 | #include "incore.h" |
diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c index f114ba2b3557..dee9b03e5b37 100644 --- a/fs/gfs2/eaops.c +++ b/fs/gfs2/eaops.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/capability.h> | 14 | #include <linux/capability.h> |
15 | #include <linux/xattr.h> | 15 | #include <linux/xattr.h> |
16 | #include <linux/gfs2_ondisk.h> | 16 | #include <linux/gfs2_ondisk.h> |
17 | #include <linux/lm_interface.h> | ||
18 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
19 | 18 | ||
20 | #include "gfs2.h" | 19 | #include "gfs2.h" |
diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c index 0d1c76d906ae..899763aed217 100644 --- a/fs/gfs2/eattr.c +++ b/fs/gfs2/eattr.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
14 | #include <linux/xattr.h> | 14 | #include <linux/xattr.h> |
15 | #include <linux/gfs2_ondisk.h> | 15 | #include <linux/gfs2_ondisk.h> |
16 | #include <linux/lm_interface.h> | ||
17 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
18 | 17 | ||
19 | #include "gfs2.h" | 18 | #include "gfs2.h" |
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 6b983aef785d..cd200a564c79 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <linux/sched.h> | 10 | #include <linux/sched.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/spinlock.h> | 12 | #include <linux/spinlock.h> |
13 | #include <linux/completion.h> | ||
14 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
15 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
16 | #include <linux/sort.h> | 15 | #include <linux/sort.h> |
@@ -18,7 +17,6 @@ | |||
18 | #include <linux/kallsyms.h> | 17 | #include <linux/kallsyms.h> |
19 | #include <linux/gfs2_ondisk.h> | 18 | #include <linux/gfs2_ondisk.h> |
20 | #include <linux/list.h> | 19 | #include <linux/list.h> |
21 | #include <linux/lm_interface.h> | ||
22 | #include <linux/wait.h> | 20 | #include <linux/wait.h> |
23 | #include <linux/module.h> | 21 | #include <linux/module.h> |
24 | #include <linux/rwsem.h> | 22 | #include <linux/rwsem.h> |
@@ -155,13 +153,10 @@ static void glock_free(struct gfs2_glock *gl) | |||
155 | struct gfs2_sbd *sdp = gl->gl_sbd; | 153 | struct gfs2_sbd *sdp = gl->gl_sbd; |
156 | struct inode *aspace = gl->gl_aspace; | 154 | struct inode *aspace = gl->gl_aspace; |
157 | 155 | ||
158 | if (sdp->sd_lockstruct.ls_ops->lm_put_lock) | ||
159 | sdp->sd_lockstruct.ls_ops->lm_put_lock(gl->gl_lock); | ||
160 | |||
161 | if (aspace) | 156 | if (aspace) |
162 | gfs2_aspace_put(aspace); | 157 | gfs2_aspace_put(aspace); |
163 | 158 | ||
164 | kmem_cache_free(gfs2_glock_cachep, gl); | 159 | sdp->sd_lockstruct.ls_ops->lm_put_lock(gfs2_glock_cachep, gl); |
165 | } | 160 | } |
166 | 161 | ||
167 | /** | 162 | /** |
@@ -211,7 +206,6 @@ int gfs2_glock_put(struct gfs2_glock *gl) | |||
211 | atomic_dec(&lru_count); | 206 | atomic_dec(&lru_count); |
212 | } | 207 | } |
213 | spin_unlock(&lru_lock); | 208 | spin_unlock(&lru_lock); |
214 | GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_UNLOCKED); | ||
215 | GLOCK_BUG_ON(gl, !list_empty(&gl->gl_lru)); | 209 | GLOCK_BUG_ON(gl, !list_empty(&gl->gl_lru)); |
216 | GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders)); | 210 | GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders)); |
217 | glock_free(gl); | 211 | glock_free(gl); |
@@ -256,27 +250,6 @@ static struct gfs2_glock *search_bucket(unsigned int hash, | |||
256 | } | 250 | } |
257 | 251 | ||
258 | /** | 252 | /** |
259 | * gfs2_glock_find() - Find glock by lock number | ||
260 | * @sdp: The GFS2 superblock | ||
261 | * @name: The lock name | ||
262 | * | ||
263 | * Returns: NULL, or the struct gfs2_glock with the requested number | ||
264 | */ | ||
265 | |||
266 | static struct gfs2_glock *gfs2_glock_find(const struct gfs2_sbd *sdp, | ||
267 | const struct lm_lockname *name) | ||
268 | { | ||
269 | unsigned int hash = gl_hash(sdp, name); | ||
270 | struct gfs2_glock *gl; | ||
271 | |||
272 | read_lock(gl_lock_addr(hash)); | ||
273 | gl = search_bucket(hash, sdp, name); | ||
274 | read_unlock(gl_lock_addr(hash)); | ||
275 | |||
276 | return gl; | ||
277 | } | ||
278 | |||
279 | /** | ||
280 | * may_grant - check if its ok to grant a new lock | 253 | * may_grant - check if its ok to grant a new lock |
281 | * @gl: The glock | 254 | * @gl: The glock |
282 | * @gh: The lock request which we wish to grant | 255 | * @gh: The lock request which we wish to grant |
@@ -523,7 +496,7 @@ out_locked: | |||
523 | } | 496 | } |
524 | 497 | ||
525 | static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, | 498 | static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, |
526 | unsigned int cur_state, unsigned int req_state, | 499 | unsigned int req_state, |
527 | unsigned int flags) | 500 | unsigned int flags) |
528 | { | 501 | { |
529 | int ret = LM_OUT_ERROR; | 502 | int ret = LM_OUT_ERROR; |
@@ -532,7 +505,7 @@ static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, | |||
532 | return req_state == LM_ST_UNLOCKED ? 0 : req_state; | 505 | return req_state == LM_ST_UNLOCKED ? 0 : req_state; |
533 | 506 | ||
534 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 507 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
535 | ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state, | 508 | ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, |
536 | req_state, flags); | 509 | req_state, flags); |
537 | return ret; | 510 | return ret; |
538 | } | 511 | } |
@@ -575,7 +548,7 @@ __acquires(&gl->gl_spin) | |||
575 | gl->gl_state == LM_ST_DEFERRED) && | 548 | gl->gl_state == LM_ST_DEFERRED) && |
576 | !(lck_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) | 549 | !(lck_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) |
577 | lck_flags |= LM_FLAG_TRY_1CB; | 550 | lck_flags |= LM_FLAG_TRY_1CB; |
578 | ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, target, lck_flags); | 551 | ret = gfs2_lm_lock(sdp, gl, target, lck_flags); |
579 | 552 | ||
580 | if (!(ret & LM_OUT_ASYNC)) { | 553 | if (!(ret & LM_OUT_ASYNC)) { |
581 | finish_xmote(gl, ret); | 554 | finish_xmote(gl, ret); |
@@ -681,18 +654,6 @@ static void glock_work_func(struct work_struct *work) | |||
681 | gfs2_glock_put(gl); | 654 | gfs2_glock_put(gl); |
682 | } | 655 | } |
683 | 656 | ||
684 | static int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
685 | void **lockp) | ||
686 | { | ||
687 | int error = -EIO; | ||
688 | if (!sdp->sd_lockstruct.ls_ops->lm_get_lock) | ||
689 | return 0; | ||
690 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
691 | error = sdp->sd_lockstruct.ls_ops->lm_get_lock( | ||
692 | sdp->sd_lockstruct.ls_lockspace, name, lockp); | ||
693 | return error; | ||
694 | } | ||
695 | |||
696 | /** | 657 | /** |
697 | * gfs2_glock_get() - Get a glock, or create one if one doesn't exist | 658 | * gfs2_glock_get() - Get a glock, or create one if one doesn't exist |
698 | * @sdp: The GFS2 superblock | 659 | * @sdp: The GFS2 superblock |
@@ -736,6 +697,9 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, | |||
736 | gl->gl_demote_state = LM_ST_EXCLUSIVE; | 697 | gl->gl_demote_state = LM_ST_EXCLUSIVE; |
737 | gl->gl_hash = hash; | 698 | gl->gl_hash = hash; |
738 | gl->gl_ops = glops; | 699 | gl->gl_ops = glops; |
700 | snprintf(gl->gl_strname, GDLM_STRNAME_BYTES, "%8x%16llx", name.ln_type, (unsigned long long)number); | ||
701 | memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb)); | ||
702 | gl->gl_lksb.sb_lvbptr = gl->gl_lvb; | ||
739 | gl->gl_stamp = jiffies; | 703 | gl->gl_stamp = jiffies; |
740 | gl->gl_tchange = jiffies; | 704 | gl->gl_tchange = jiffies; |
741 | gl->gl_object = NULL; | 705 | gl->gl_object = NULL; |
@@ -753,10 +717,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, | |||
753 | } | 717 | } |
754 | } | 718 | } |
755 | 719 | ||
756 | error = gfs2_lm_get_lock(sdp, &name, &gl->gl_lock); | ||
757 | if (error) | ||
758 | goto fail_aspace; | ||
759 | |||
760 | write_lock(gl_lock_addr(hash)); | 720 | write_lock(gl_lock_addr(hash)); |
761 | tmp = search_bucket(hash, sdp, &name); | 721 | tmp = search_bucket(hash, sdp, &name); |
762 | if (tmp) { | 722 | if (tmp) { |
@@ -772,9 +732,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, | |||
772 | 732 | ||
773 | return 0; | 733 | return 0; |
774 | 734 | ||
775 | fail_aspace: | ||
776 | if (gl->gl_aspace) | ||
777 | gfs2_aspace_put(gl->gl_aspace); | ||
778 | fail: | 735 | fail: |
779 | kmem_cache_free(gfs2_glock_cachep, gl); | 736 | kmem_cache_free(gfs2_glock_cachep, gl); |
780 | return error; | 737 | return error; |
@@ -966,7 +923,7 @@ do_cancel: | |||
966 | if (!(gh->gh_flags & LM_FLAG_PRIORITY)) { | 923 | if (!(gh->gh_flags & LM_FLAG_PRIORITY)) { |
967 | spin_unlock(&gl->gl_spin); | 924 | spin_unlock(&gl->gl_spin); |
968 | if (sdp->sd_lockstruct.ls_ops->lm_cancel) | 925 | if (sdp->sd_lockstruct.ls_ops->lm_cancel) |
969 | sdp->sd_lockstruct.ls_ops->lm_cancel(gl->gl_lock); | 926 | sdp->sd_lockstruct.ls_ops->lm_cancel(gl); |
970 | spin_lock(&gl->gl_spin); | 927 | spin_lock(&gl->gl_spin); |
971 | } | 928 | } |
972 | return; | 929 | return; |
@@ -1240,70 +1197,13 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs) | |||
1240 | gfs2_glock_dq_uninit(&ghs[x]); | 1197 | gfs2_glock_dq_uninit(&ghs[x]); |
1241 | } | 1198 | } |
1242 | 1199 | ||
1243 | static int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp) | 1200 | void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state) |
1244 | { | 1201 | { |
1245 | int error = -EIO; | ||
1246 | if (!sdp->sd_lockstruct.ls_ops->lm_hold_lvb) | ||
1247 | return 0; | ||
1248 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
1249 | error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp); | ||
1250 | return error; | ||
1251 | } | ||
1252 | |||
1253 | /** | ||
1254 | * gfs2_lvb_hold - attach a LVB from a glock | ||
1255 | * @gl: The glock in question | ||
1256 | * | ||
1257 | */ | ||
1258 | |||
1259 | int gfs2_lvb_hold(struct gfs2_glock *gl) | ||
1260 | { | ||
1261 | int error; | ||
1262 | |||
1263 | if (!atomic_read(&gl->gl_lvb_count)) { | ||
1264 | error = gfs2_lm_hold_lvb(gl->gl_sbd, gl->gl_lock, &gl->gl_lvb); | ||
1265 | if (error) | ||
1266 | return error; | ||
1267 | gfs2_glock_hold(gl); | ||
1268 | } | ||
1269 | atomic_inc(&gl->gl_lvb_count); | ||
1270 | |||
1271 | return 0; | ||
1272 | } | ||
1273 | |||
1274 | /** | ||
1275 | * gfs2_lvb_unhold - detach a LVB from a glock | ||
1276 | * @gl: The glock in question | ||
1277 | * | ||
1278 | */ | ||
1279 | |||
1280 | void gfs2_lvb_unhold(struct gfs2_glock *gl) | ||
1281 | { | ||
1282 | struct gfs2_sbd *sdp = gl->gl_sbd; | ||
1283 | |||
1284 | gfs2_glock_hold(gl); | ||
1285 | gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0); | ||
1286 | if (atomic_dec_and_test(&gl->gl_lvb_count)) { | ||
1287 | if (sdp->sd_lockstruct.ls_ops->lm_unhold_lvb) | ||
1288 | sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(gl->gl_lock, gl->gl_lvb); | ||
1289 | gl->gl_lvb = NULL; | ||
1290 | gfs2_glock_put(gl); | ||
1291 | } | ||
1292 | gfs2_glock_put(gl); | ||
1293 | } | ||
1294 | |||
1295 | static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
1296 | unsigned int state) | ||
1297 | { | ||
1298 | struct gfs2_glock *gl; | ||
1299 | unsigned long delay = 0; | 1202 | unsigned long delay = 0; |
1300 | unsigned long holdtime; | 1203 | unsigned long holdtime; |
1301 | unsigned long now = jiffies; | 1204 | unsigned long now = jiffies; |
1302 | 1205 | ||
1303 | gl = gfs2_glock_find(sdp, name); | 1206 | gfs2_glock_hold(gl); |
1304 | if (!gl) | ||
1305 | return; | ||
1306 | |||
1307 | holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time; | 1207 | holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time; |
1308 | if (time_before(now, holdtime)) | 1208 | if (time_before(now, holdtime)) |
1309 | delay = holdtime - now; | 1209 | delay = holdtime - now; |
@@ -1317,74 +1217,37 @@ static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name, | |||
1317 | gfs2_glock_put(gl); | 1217 | gfs2_glock_put(gl); |
1318 | } | 1218 | } |
1319 | 1219 | ||
1320 | static void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid) | ||
1321 | { | ||
1322 | struct gfs2_jdesc *jd; | ||
1323 | |||
1324 | spin_lock(&sdp->sd_jindex_spin); | ||
1325 | list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { | ||
1326 | if (jd->jd_jid != jid) | ||
1327 | continue; | ||
1328 | jd->jd_dirty = 1; | ||
1329 | break; | ||
1330 | } | ||
1331 | spin_unlock(&sdp->sd_jindex_spin); | ||
1332 | } | ||
1333 | |||
1334 | /** | 1220 | /** |
1335 | * gfs2_glock_cb - Callback used by locking module | 1221 | * gfs2_glock_complete - Callback used by locking |
1336 | * @sdp: Pointer to the superblock | 1222 | * @gl: Pointer to the glock |
1337 | * @type: Type of callback | 1223 | * @ret: The return value from the dlm |
1338 | * @data: Type dependent data pointer | ||
1339 | * | 1224 | * |
1340 | * Called by the locking module when it wants to tell us something. | ||
1341 | * Either we need to drop a lock, one of our ASYNC requests completed, or | ||
1342 | * a journal from another client needs to be recovered. | ||
1343 | */ | 1225 | */ |
1344 | 1226 | ||
1345 | void gfs2_glock_cb(void *cb_data, unsigned int type, void *data) | 1227 | void gfs2_glock_complete(struct gfs2_glock *gl, int ret) |
1346 | { | 1228 | { |
1347 | struct gfs2_sbd *sdp = cb_data; | 1229 | struct lm_lockstruct *ls = &gl->gl_sbd->sd_lockstruct; |
1348 | 1230 | down_read(&gfs2_umount_flush_sem); | |
1349 | switch (type) { | 1231 | gl->gl_reply = ret; |
1350 | case LM_CB_NEED_E: | 1232 | if (unlikely(test_bit(DFL_BLOCK_LOCKS, &ls->ls_flags))) { |
1351 | blocking_cb(sdp, data, LM_ST_UNLOCKED); | 1233 | struct gfs2_holder *gh; |
1352 | return; | 1234 | spin_lock(&gl->gl_spin); |
1353 | 1235 | gh = find_first_waiter(gl); | |
1354 | case LM_CB_NEED_D: | 1236 | if ((!(gh && (gh->gh_flags & LM_FLAG_NOEXP)) && |
1355 | blocking_cb(sdp, data, LM_ST_DEFERRED); | 1237 | (gl->gl_target != LM_ST_UNLOCKED)) || |
1356 | return; | 1238 | ((ret & ~LM_OUT_ST_MASK) != 0)) |
1357 | 1239 | set_bit(GLF_FROZEN, &gl->gl_flags); | |
1358 | case LM_CB_NEED_S: | 1240 | spin_unlock(&gl->gl_spin); |
1359 | blocking_cb(sdp, data, LM_ST_SHARED); | 1241 | if (test_bit(GLF_FROZEN, &gl->gl_flags)) { |
1360 | return; | 1242 | up_read(&gfs2_umount_flush_sem); |
1361 | |||
1362 | case LM_CB_ASYNC: { | ||
1363 | struct lm_async_cb *async = data; | ||
1364 | struct gfs2_glock *gl; | ||
1365 | |||
1366 | down_read(&gfs2_umount_flush_sem); | ||
1367 | gl = gfs2_glock_find(sdp, &async->lc_name); | ||
1368 | if (gfs2_assert_warn(sdp, gl)) | ||
1369 | return; | 1243 | return; |
1370 | gl->gl_reply = async->lc_ret; | 1244 | } |
1371 | set_bit(GLF_REPLY_PENDING, &gl->gl_flags); | ||
1372 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) | ||
1373 | gfs2_glock_put(gl); | ||
1374 | up_read(&gfs2_umount_flush_sem); | ||
1375 | return; | ||
1376 | } | ||
1377 | |||
1378 | case LM_CB_NEED_RECOVERY: | ||
1379 | gfs2_jdesc_make_dirty(sdp, *(unsigned int *)data); | ||
1380 | if (sdp->sd_recoverd_process) | ||
1381 | wake_up_process(sdp->sd_recoverd_process); | ||
1382 | return; | ||
1383 | |||
1384 | default: | ||
1385 | gfs2_assert_warn(sdp, 0); | ||
1386 | return; | ||
1387 | } | 1245 | } |
1246 | set_bit(GLF_REPLY_PENDING, &gl->gl_flags); | ||
1247 | gfs2_glock_hold(gl); | ||
1248 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) | ||
1249 | gfs2_glock_put(gl); | ||
1250 | up_read(&gfs2_umount_flush_sem); | ||
1388 | } | 1251 | } |
1389 | 1252 | ||
1390 | /** | 1253 | /** |
@@ -1515,6 +1378,27 @@ out: | |||
1515 | return has_entries; | 1378 | return has_entries; |
1516 | } | 1379 | } |
1517 | 1380 | ||
1381 | |||
1382 | /** | ||
1383 | * thaw_glock - thaw out a glock which has an unprocessed reply waiting | ||
1384 | * @gl: The glock to thaw | ||
1385 | * | ||
1386 | * N.B. When we freeze a glock, we leave a ref to the glock outstanding, | ||
1387 | * so this has to result in the ref count being dropped by one. | ||
1388 | */ | ||
1389 | |||
1390 | static void thaw_glock(struct gfs2_glock *gl) | ||
1391 | { | ||
1392 | if (!test_and_clear_bit(GLF_FROZEN, &gl->gl_flags)) | ||
1393 | return; | ||
1394 | down_read(&gfs2_umount_flush_sem); | ||
1395 | set_bit(GLF_REPLY_PENDING, &gl->gl_flags); | ||
1396 | gfs2_glock_hold(gl); | ||
1397 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) | ||
1398 | gfs2_glock_put(gl); | ||
1399 | up_read(&gfs2_umount_flush_sem); | ||
1400 | } | ||
1401 | |||
1518 | /** | 1402 | /** |
1519 | * clear_glock - look at a glock and see if we can free it from glock cache | 1403 | * clear_glock - look at a glock and see if we can free it from glock cache |
1520 | * @gl: the glock to look at | 1404 | * @gl: the glock to look at |
@@ -1540,6 +1424,20 @@ static void clear_glock(struct gfs2_glock *gl) | |||
1540 | } | 1424 | } |
1541 | 1425 | ||
1542 | /** | 1426 | /** |
1427 | * gfs2_glock_thaw - Thaw any frozen glocks | ||
1428 | * @sdp: The super block | ||
1429 | * | ||
1430 | */ | ||
1431 | |||
1432 | void gfs2_glock_thaw(struct gfs2_sbd *sdp) | ||
1433 | { | ||
1434 | unsigned x; | ||
1435 | |||
1436 | for (x = 0; x < GFS2_GL_HASH_SIZE; x++) | ||
1437 | examine_bucket(thaw_glock, sdp, x); | ||
1438 | } | ||
1439 | |||
1440 | /** | ||
1543 | * gfs2_gl_hash_clear - Empty out the glock hash table | 1441 | * gfs2_gl_hash_clear - Empty out the glock hash table |
1544 | * @sdp: the filesystem | 1442 | * @sdp: the filesystem |
1545 | * @wait: wait until it's all gone | 1443 | * @wait: wait until it's all gone |
@@ -1619,7 +1517,7 @@ static const char *hflags2str(char *buf, unsigned flags, unsigned long iflags) | |||
1619 | if (flags & LM_FLAG_NOEXP) | 1517 | if (flags & LM_FLAG_NOEXP) |
1620 | *p++ = 'e'; | 1518 | *p++ = 'e'; |
1621 | if (flags & LM_FLAG_ANY) | 1519 | if (flags & LM_FLAG_ANY) |
1622 | *p++ = 'a'; | 1520 | *p++ = 'A'; |
1623 | if (flags & LM_FLAG_PRIORITY) | 1521 | if (flags & LM_FLAG_PRIORITY) |
1624 | *p++ = 'p'; | 1522 | *p++ = 'p'; |
1625 | if (flags & GL_ASYNC) | 1523 | if (flags & GL_ASYNC) |
@@ -1683,6 +1581,10 @@ static const char *gflags2str(char *buf, const unsigned long *gflags) | |||
1683 | *p++ = 'i'; | 1581 | *p++ = 'i'; |
1684 | if (test_bit(GLF_REPLY_PENDING, gflags)) | 1582 | if (test_bit(GLF_REPLY_PENDING, gflags)) |
1685 | *p++ = 'r'; | 1583 | *p++ = 'r'; |
1584 | if (test_bit(GLF_INITIAL, gflags)) | ||
1585 | *p++ = 'i'; | ||
1586 | if (test_bit(GLF_FROZEN, gflags)) | ||
1587 | *p++ = 'F'; | ||
1686 | *p = 0; | 1588 | *p = 0; |
1687 | return buf; | 1589 | return buf; |
1688 | } | 1590 | } |
@@ -1717,14 +1619,13 @@ static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl) | |||
1717 | dtime *= 1000000/HZ; /* demote time in uSec */ | 1619 | dtime *= 1000000/HZ; /* demote time in uSec */ |
1718 | if (!test_bit(GLF_DEMOTE, &gl->gl_flags)) | 1620 | if (!test_bit(GLF_DEMOTE, &gl->gl_flags)) |
1719 | dtime = 0; | 1621 | dtime = 0; |
1720 | gfs2_print_dbg(seq, "G: s:%s n:%u/%llu f:%s t:%s d:%s/%llu l:%d a:%d r:%d\n", | 1622 | gfs2_print_dbg(seq, "G: s:%s n:%u/%llu f:%s t:%s d:%s/%llu a:%d r:%d\n", |
1721 | state2str(gl->gl_state), | 1623 | state2str(gl->gl_state), |
1722 | gl->gl_name.ln_type, | 1624 | gl->gl_name.ln_type, |
1723 | (unsigned long long)gl->gl_name.ln_number, | 1625 | (unsigned long long)gl->gl_name.ln_number, |
1724 | gflags2str(gflags_buf, &gl->gl_flags), | 1626 | gflags2str(gflags_buf, &gl->gl_flags), |
1725 | state2str(gl->gl_target), | 1627 | state2str(gl->gl_target), |
1726 | state2str(gl->gl_demote_state), dtime, | 1628 | state2str(gl->gl_demote_state), dtime, |
1727 | atomic_read(&gl->gl_lvb_count), | ||
1728 | atomic_read(&gl->gl_ail_count), | 1629 | atomic_read(&gl->gl_ail_count), |
1729 | atomic_read(&gl->gl_ref)); | 1630 | atomic_read(&gl->gl_ref)); |
1730 | 1631 | ||
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 543ec7ecfbda..a602a28f6f08 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h | |||
@@ -11,15 +11,130 @@ | |||
11 | #define __GLOCK_DOT_H__ | 11 | #define __GLOCK_DOT_H__ |
12 | 12 | ||
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/parser.h> | ||
14 | #include "incore.h" | 15 | #include "incore.h" |
15 | 16 | ||
16 | /* Flags for lock requests; used in gfs2_holder gh_flag field. | 17 | /* Options for hostdata parser */ |
17 | From lm_interface.h: | 18 | |
19 | enum { | ||
20 | Opt_jid, | ||
21 | Opt_id, | ||
22 | Opt_first, | ||
23 | Opt_nodir, | ||
24 | Opt_err, | ||
25 | }; | ||
26 | |||
27 | /* | ||
28 | * lm_lockname types | ||
29 | */ | ||
30 | |||
31 | #define LM_TYPE_RESERVED 0x00 | ||
32 | #define LM_TYPE_NONDISK 0x01 | ||
33 | #define LM_TYPE_INODE 0x02 | ||
34 | #define LM_TYPE_RGRP 0x03 | ||
35 | #define LM_TYPE_META 0x04 | ||
36 | #define LM_TYPE_IOPEN 0x05 | ||
37 | #define LM_TYPE_FLOCK 0x06 | ||
38 | #define LM_TYPE_PLOCK 0x07 | ||
39 | #define LM_TYPE_QUOTA 0x08 | ||
40 | #define LM_TYPE_JOURNAL 0x09 | ||
41 | |||
42 | /* | ||
43 | * lm_lock() states | ||
44 | * | ||
45 | * SHARED is compatible with SHARED, not with DEFERRED or EX. | ||
46 | * DEFERRED is compatible with DEFERRED, not with SHARED or EX. | ||
47 | */ | ||
48 | |||
49 | #define LM_ST_UNLOCKED 0 | ||
50 | #define LM_ST_EXCLUSIVE 1 | ||
51 | #define LM_ST_DEFERRED 2 | ||
52 | #define LM_ST_SHARED 3 | ||
53 | |||
54 | /* | ||
55 | * lm_lock() flags | ||
56 | * | ||
57 | * LM_FLAG_TRY | ||
58 | * Don't wait to acquire the lock if it can't be granted immediately. | ||
59 | * | ||
60 | * LM_FLAG_TRY_1CB | ||
61 | * Send one blocking callback if TRY is set and the lock is not granted. | ||
62 | * | ||
63 | * LM_FLAG_NOEXP | ||
64 | * GFS sets this flag on lock requests it makes while doing journal recovery. | ||
65 | * These special requests should not be blocked due to the recovery like | ||
66 | * ordinary locks would be. | ||
67 | * | ||
68 | * LM_FLAG_ANY | ||
69 | * A SHARED request may also be granted in DEFERRED, or a DEFERRED request may | ||
70 | * also be granted in SHARED. The preferred state is whichever is compatible | ||
71 | * with other granted locks, or the specified state if no other locks exist. | ||
72 | * | ||
73 | * LM_FLAG_PRIORITY | ||
74 | * Override fairness considerations. Suppose a lock is held in a shared state | ||
75 | * and there is a pending request for the deferred state. A shared lock | ||
76 | * request with the priority flag would be allowed to bypass the deferred | ||
77 | * request and directly join the other shared lock. A shared lock request | ||
78 | * without the priority flag might be forced to wait until the deferred | ||
79 | * requested had acquired and released the lock. | ||
80 | */ | ||
81 | |||
18 | #define LM_FLAG_TRY 0x00000001 | 82 | #define LM_FLAG_TRY 0x00000001 |
19 | #define LM_FLAG_TRY_1CB 0x00000002 | 83 | #define LM_FLAG_TRY_1CB 0x00000002 |
20 | #define LM_FLAG_NOEXP 0x00000004 | 84 | #define LM_FLAG_NOEXP 0x00000004 |
21 | #define LM_FLAG_ANY 0x00000008 | 85 | #define LM_FLAG_ANY 0x00000008 |
22 | #define LM_FLAG_PRIORITY 0x00000010 */ | 86 | #define LM_FLAG_PRIORITY 0x00000010 |
87 | #define GL_ASYNC 0x00000040 | ||
88 | #define GL_EXACT 0x00000080 | ||
89 | #define GL_SKIP 0x00000100 | ||
90 | #define GL_ATIME 0x00000200 | ||
91 | #define GL_NOCACHE 0x00000400 | ||
92 | |||
93 | /* | ||
94 | * lm_lock() and lm_async_cb return flags | ||
95 | * | ||
96 | * LM_OUT_ST_MASK | ||
97 | * Masks the lower two bits of lock state in the returned value. | ||
98 | * | ||
99 | * LM_OUT_CANCELED | ||
100 | * The lock request was canceled. | ||
101 | * | ||
102 | * LM_OUT_ASYNC | ||
103 | * The result of the request will be returned in an LM_CB_ASYNC callback. | ||
104 | * | ||
105 | */ | ||
106 | |||
107 | #define LM_OUT_ST_MASK 0x00000003 | ||
108 | #define LM_OUT_CANCELED 0x00000008 | ||
109 | #define LM_OUT_ASYNC 0x00000080 | ||
110 | #define LM_OUT_ERROR 0x00000100 | ||
111 | |||
112 | /* | ||
113 | * lm_recovery_done() messages | ||
114 | */ | ||
115 | |||
116 | #define LM_RD_GAVEUP 308 | ||
117 | #define LM_RD_SUCCESS 309 | ||
118 | |||
119 | #define GLR_TRYFAILED 13 | ||
120 | |||
121 | struct lm_lockops { | ||
122 | const char *lm_proto_name; | ||
123 | int (*lm_mount) (struct gfs2_sbd *sdp, const char *fsname); | ||
124 | void (*lm_unmount) (struct gfs2_sbd *sdp); | ||
125 | void (*lm_withdraw) (struct gfs2_sbd *sdp); | ||
126 | void (*lm_put_lock) (struct kmem_cache *cachep, void *gl); | ||
127 | unsigned int (*lm_lock) (struct gfs2_glock *gl, | ||
128 | unsigned int req_state, unsigned int flags); | ||
129 | void (*lm_cancel) (struct gfs2_glock *gl); | ||
130 | const match_table_t *lm_tokens; | ||
131 | }; | ||
132 | |||
133 | #define LM_FLAG_TRY 0x00000001 | ||
134 | #define LM_FLAG_TRY_1CB 0x00000002 | ||
135 | #define LM_FLAG_NOEXP 0x00000004 | ||
136 | #define LM_FLAG_ANY 0x00000008 | ||
137 | #define LM_FLAG_PRIORITY 0x00000010 | ||
23 | 138 | ||
24 | #define GL_ASYNC 0x00000040 | 139 | #define GL_ASYNC 0x00000040 |
25 | #define GL_EXACT 0x00000080 | 140 | #define GL_EXACT 0x00000080 |
@@ -128,10 +243,12 @@ static inline int gfs2_glock_nq_init(struct gfs2_glock *gl, | |||
128 | int gfs2_lvb_hold(struct gfs2_glock *gl); | 243 | int gfs2_lvb_hold(struct gfs2_glock *gl); |
129 | void gfs2_lvb_unhold(struct gfs2_glock *gl); | 244 | void gfs2_lvb_unhold(struct gfs2_glock *gl); |
130 | 245 | ||
131 | void gfs2_glock_cb(void *cb_data, unsigned int type, void *data); | 246 | void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state); |
247 | void gfs2_glock_complete(struct gfs2_glock *gl, int ret); | ||
132 | void gfs2_reclaim_glock(struct gfs2_sbd *sdp); | 248 | void gfs2_reclaim_glock(struct gfs2_sbd *sdp); |
133 | void gfs2_gl_hash_clear(struct gfs2_sbd *sdp); | 249 | void gfs2_gl_hash_clear(struct gfs2_sbd *sdp); |
134 | void gfs2_glock_finish_truncate(struct gfs2_inode *ip); | 250 | void gfs2_glock_finish_truncate(struct gfs2_inode *ip); |
251 | void gfs2_glock_thaw(struct gfs2_sbd *sdp); | ||
135 | 252 | ||
136 | int __init gfs2_glock_init(void); | 253 | int __init gfs2_glock_init(void); |
137 | void gfs2_glock_exit(void); | 254 | void gfs2_glock_exit(void); |
@@ -141,4 +258,6 @@ void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp); | |||
141 | int gfs2_register_debugfs(void); | 258 | int gfs2_register_debugfs(void); |
142 | void gfs2_unregister_debugfs(void); | 259 | void gfs2_unregister_debugfs(void); |
143 | 260 | ||
261 | extern const struct lm_lockops gfs2_dlm_ops; | ||
262 | |||
144 | #endif /* __GLOCK_DOT_H__ */ | 263 | #endif /* __GLOCK_DOT_H__ */ |
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 8522d3aa64fc..f07ede8cb9ba 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/completion.h> | 12 | #include <linux/completion.h> |
13 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
14 | #include <linux/gfs2_ondisk.h> | 14 | #include <linux/gfs2_ondisk.h> |
15 | #include <linux/lm_interface.h> | ||
16 | #include <linux/bio.h> | 15 | #include <linux/bio.h> |
17 | 16 | ||
18 | #include "gfs2.h" | 17 | #include "gfs2.h" |
@@ -390,18 +389,6 @@ static int trans_go_demote_ok(const struct gfs2_glock *gl) | |||
390 | return 0; | 389 | return 0; |
391 | } | 390 | } |
392 | 391 | ||
393 | /** | ||
394 | * quota_go_demote_ok - Check to see if it's ok to unlock a quota glock | ||
395 | * @gl: the glock | ||
396 | * | ||
397 | * Returns: 1 if it's ok | ||
398 | */ | ||
399 | |||
400 | static int quota_go_demote_ok(const struct gfs2_glock *gl) | ||
401 | { | ||
402 | return !atomic_read(&gl->gl_lvb_count); | ||
403 | } | ||
404 | |||
405 | const struct gfs2_glock_operations gfs2_meta_glops = { | 392 | const struct gfs2_glock_operations gfs2_meta_glops = { |
406 | .go_xmote_th = meta_go_sync, | 393 | .go_xmote_th = meta_go_sync, |
407 | .go_type = LM_TYPE_META, | 394 | .go_type = LM_TYPE_META, |
@@ -448,7 +435,6 @@ const struct gfs2_glock_operations gfs2_nondisk_glops = { | |||
448 | }; | 435 | }; |
449 | 436 | ||
450 | const struct gfs2_glock_operations gfs2_quota_glops = { | 437 | const struct gfs2_glock_operations gfs2_quota_glops = { |
451 | .go_demote_ok = quota_go_demote_ok, | ||
452 | .go_type = LM_TYPE_QUOTA, | 438 | .go_type = LM_TYPE_QUOTA, |
453 | }; | 439 | }; |
454 | 440 | ||
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index a0117d6eb145..0af7c24de6a1 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -12,6 +12,8 @@ | |||
12 | 12 | ||
13 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
14 | #include <linux/workqueue.h> | 14 | #include <linux/workqueue.h> |
15 | #include <linux/dlm.h> | ||
16 | #include <linux/buffer_head.h> | ||
15 | 17 | ||
16 | #define DIO_WAIT 0x00000010 | 18 | #define DIO_WAIT 0x00000010 |
17 | #define DIO_METADATA 0x00000020 | 19 | #define DIO_METADATA 0x00000020 |
@@ -26,6 +28,7 @@ struct gfs2_trans; | |||
26 | struct gfs2_ail; | 28 | struct gfs2_ail; |
27 | struct gfs2_jdesc; | 29 | struct gfs2_jdesc; |
28 | struct gfs2_sbd; | 30 | struct gfs2_sbd; |
31 | struct lm_lockops; | ||
29 | 32 | ||
30 | typedef void (*gfs2_glop_bh_t) (struct gfs2_glock *gl, unsigned int ret); | 33 | typedef void (*gfs2_glop_bh_t) (struct gfs2_glock *gl, unsigned int ret); |
31 | 34 | ||
@@ -121,6 +124,28 @@ struct gfs2_bufdata { | |||
121 | struct list_head bd_ail_gl_list; | 124 | struct list_head bd_ail_gl_list; |
122 | }; | 125 | }; |
123 | 126 | ||
127 | /* | ||
128 | * Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a | ||
129 | * prefix of lock_dlm_ gets awkward. | ||
130 | */ | ||
131 | |||
132 | #define GDLM_STRNAME_BYTES 25 | ||
133 | #define GDLM_LVB_SIZE 32 | ||
134 | |||
135 | enum { | ||
136 | DFL_BLOCK_LOCKS = 0, | ||
137 | }; | ||
138 | |||
139 | struct lm_lockname { | ||
140 | u64 ln_number; | ||
141 | unsigned int ln_type; | ||
142 | }; | ||
143 | |||
144 | #define lm_name_equal(name1, name2) \ | ||
145 | (((name1)->ln_number == (name2)->ln_number) && \ | ||
146 | ((name1)->ln_type == (name2)->ln_type)) | ||
147 | |||
148 | |||
124 | struct gfs2_glock_operations { | 149 | struct gfs2_glock_operations { |
125 | void (*go_xmote_th) (struct gfs2_glock *gl); | 150 | void (*go_xmote_th) (struct gfs2_glock *gl); |
126 | int (*go_xmote_bh) (struct gfs2_glock *gl, struct gfs2_holder *gh); | 151 | int (*go_xmote_bh) (struct gfs2_glock *gl, struct gfs2_holder *gh); |
@@ -162,6 +187,8 @@ enum { | |||
162 | GLF_LFLUSH = 7, | 187 | GLF_LFLUSH = 7, |
163 | GLF_INVALIDATE_IN_PROGRESS = 8, | 188 | GLF_INVALIDATE_IN_PROGRESS = 8, |
164 | GLF_REPLY_PENDING = 9, | 189 | GLF_REPLY_PENDING = 9, |
190 | GLF_INITIAL = 10, | ||
191 | GLF_FROZEN = 11, | ||
165 | }; | 192 | }; |
166 | 193 | ||
167 | struct gfs2_glock { | 194 | struct gfs2_glock { |
@@ -181,10 +208,9 @@ struct gfs2_glock { | |||
181 | struct list_head gl_holders; | 208 | struct list_head gl_holders; |
182 | 209 | ||
183 | const struct gfs2_glock_operations *gl_ops; | 210 | const struct gfs2_glock_operations *gl_ops; |
184 | void *gl_lock; | 211 | char gl_strname[GDLM_STRNAME_BYTES]; |
185 | char *gl_lvb; | 212 | struct dlm_lksb gl_lksb; |
186 | atomic_t gl_lvb_count; | 213 | char gl_lvb[32]; |
187 | |||
188 | unsigned long gl_stamp; | 214 | unsigned long gl_stamp; |
189 | unsigned long gl_tchange; | 215 | unsigned long gl_tchange; |
190 | void *gl_object; | 216 | void *gl_object; |
@@ -447,6 +473,30 @@ struct gfs2_sb_host { | |||
447 | char sb_locktable[GFS2_LOCKNAME_LEN]; | 473 | char sb_locktable[GFS2_LOCKNAME_LEN]; |
448 | }; | 474 | }; |
449 | 475 | ||
476 | /* | ||
477 | * lm_mount() return values | ||
478 | * | ||
479 | * ls_jid - the journal ID this node should use | ||
480 | * ls_first - this node is the first to mount the file system | ||
481 | * ls_lockspace - lock module's context for this file system | ||
482 | * ls_ops - lock module's functions | ||
483 | */ | ||
484 | |||
485 | struct lm_lockstruct { | ||
486 | u32 ls_id; | ||
487 | unsigned int ls_jid; | ||
488 | unsigned int ls_first; | ||
489 | unsigned int ls_first_done; | ||
490 | unsigned int ls_nodir; | ||
491 | const struct lm_lockops *ls_ops; | ||
492 | unsigned long ls_flags; | ||
493 | dlm_lockspace_t *ls_dlm; | ||
494 | |||
495 | int ls_recover_jid; | ||
496 | int ls_recover_jid_done; | ||
497 | int ls_recover_jid_status; | ||
498 | }; | ||
499 | |||
450 | struct gfs2_sbd { | 500 | struct gfs2_sbd { |
451 | struct super_block *sd_vfs; | 501 | struct super_block *sd_vfs; |
452 | struct kobject sd_kobj; | 502 | struct kobject sd_kobj; |
@@ -520,7 +570,6 @@ struct gfs2_sbd { | |||
520 | spinlock_t sd_jindex_spin; | 570 | spinlock_t sd_jindex_spin; |
521 | struct mutex sd_jindex_mutex; | 571 | struct mutex sd_jindex_mutex; |
522 | unsigned int sd_journals; | 572 | unsigned int sd_journals; |
523 | unsigned long sd_jindex_refresh_time; | ||
524 | 573 | ||
525 | struct gfs2_jdesc *sd_jdesc; | 574 | struct gfs2_jdesc *sd_jdesc; |
526 | struct gfs2_holder sd_journal_gh; | 575 | struct gfs2_holder sd_journal_gh; |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 3b87c188da41..7b277d449155 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/sort.h> | 16 | #include <linux/sort.h> |
17 | #include <linux/gfs2_ondisk.h> | 17 | #include <linux/gfs2_ondisk.h> |
18 | #include <linux/crc32.h> | 18 | #include <linux/crc32.h> |
19 | #include <linux/lm_interface.h> | ||
20 | #include <linux/security.h> | 19 | #include <linux/security.h> |
21 | #include <linux/time.h> | 20 | #include <linux/time.h> |
22 | 21 | ||
@@ -137,16 +136,16 @@ void gfs2_set_iop(struct inode *inode) | |||
137 | 136 | ||
138 | if (S_ISREG(mode)) { | 137 | if (S_ISREG(mode)) { |
139 | inode->i_op = &gfs2_file_iops; | 138 | inode->i_op = &gfs2_file_iops; |
140 | if (sdp->sd_args.ar_localflocks) | 139 | if (gfs2_localflocks(sdp)) |
141 | inode->i_fop = &gfs2_file_fops_nolock; | 140 | inode->i_fop = gfs2_file_fops_nolock; |
142 | else | 141 | else |
143 | inode->i_fop = &gfs2_file_fops; | 142 | inode->i_fop = gfs2_file_fops; |
144 | } else if (S_ISDIR(mode)) { | 143 | } else if (S_ISDIR(mode)) { |
145 | inode->i_op = &gfs2_dir_iops; | 144 | inode->i_op = &gfs2_dir_iops; |
146 | if (sdp->sd_args.ar_localflocks) | 145 | if (gfs2_localflocks(sdp)) |
147 | inode->i_fop = &gfs2_dir_fops_nolock; | 146 | inode->i_fop = gfs2_dir_fops_nolock; |
148 | else | 147 | else |
149 | inode->i_fop = &gfs2_dir_fops; | 148 | inode->i_fop = gfs2_dir_fops; |
150 | } else if (S_ISLNK(mode)) { | 149 | } else if (S_ISLNK(mode)) { |
151 | inode->i_op = &gfs2_symlink_iops; | 150 | inode->i_op = &gfs2_symlink_iops; |
152 | } else { | 151 | } else { |
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h index d5329364cdff..dca4fee3078b 100644 --- a/fs/gfs2/inode.h +++ b/fs/gfs2/inode.h | |||
@@ -101,12 +101,26 @@ void gfs2_dinode_print(const struct gfs2_inode *ip); | |||
101 | extern const struct inode_operations gfs2_file_iops; | 101 | extern const struct inode_operations gfs2_file_iops; |
102 | extern const struct inode_operations gfs2_dir_iops; | 102 | extern const struct inode_operations gfs2_dir_iops; |
103 | extern const struct inode_operations gfs2_symlink_iops; | 103 | extern const struct inode_operations gfs2_symlink_iops; |
104 | extern const struct file_operations gfs2_file_fops; | 104 | extern const struct file_operations *gfs2_file_fops_nolock; |
105 | extern const struct file_operations gfs2_dir_fops; | 105 | extern const struct file_operations *gfs2_dir_fops_nolock; |
106 | extern const struct file_operations gfs2_file_fops_nolock; | ||
107 | extern const struct file_operations gfs2_dir_fops_nolock; | ||
108 | 106 | ||
109 | extern void gfs2_set_inode_flags(struct inode *inode); | 107 | extern void gfs2_set_inode_flags(struct inode *inode); |
108 | |||
109 | #ifdef CONFIG_GFS2_FS_LOCKING_DLM | ||
110 | extern const struct file_operations *gfs2_file_fops; | ||
111 | extern const struct file_operations *gfs2_dir_fops; | ||
112 | static inline int gfs2_localflocks(const struct gfs2_sbd *sdp) | ||
113 | { | ||
114 | return sdp->sd_args.ar_localflocks; | ||
115 | } | ||
116 | #else /* Single node only */ | ||
117 | #define gfs2_file_fops NULL | ||
118 | #define gfs2_dir_fops NULL | ||
119 | static inline int gfs2_localflocks(const struct gfs2_sbd *sdp) | ||
120 | { | ||
121 | return 1; | ||
122 | } | ||
123 | #endif /* CONFIG_GFS2_FS_LOCKING_DLM */ | ||
110 | 124 | ||
111 | #endif /* __INODE_DOT_H__ */ | 125 | #endif /* __INODE_DOT_H__ */ |
112 | 126 | ||
diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c new file mode 100644 index 000000000000..a0bb7d2251a0 --- /dev/null +++ b/fs/gfs2/lock_dlm.c | |||
@@ -0,0 +1,240 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
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. | ||
8 | */ | ||
9 | |||
10 | #include <linux/fs.h> | ||
11 | #include <linux/dlm.h> | ||
12 | #include <linux/types.h> | ||
13 | #include <linux/gfs2_ondisk.h> | ||
14 | |||
15 | #include "incore.h" | ||
16 | #include "glock.h" | ||
17 | #include "util.h" | ||
18 | |||
19 | |||
20 | static void gdlm_ast(void *arg) | ||
21 | { | ||
22 | struct gfs2_glock *gl = arg; | ||
23 | unsigned ret = gl->gl_state; | ||
24 | |||
25 | BUG_ON(gl->gl_lksb.sb_flags & DLM_SBF_DEMOTED); | ||
26 | |||
27 | if (gl->gl_lksb.sb_flags & DLM_SBF_VALNOTVALID) | ||
28 | memset(gl->gl_lvb, 0, GDLM_LVB_SIZE); | ||
29 | |||
30 | switch (gl->gl_lksb.sb_status) { | ||
31 | case -DLM_EUNLOCK: /* Unlocked, so glock can be freed */ | ||
32 | kmem_cache_free(gfs2_glock_cachep, gl); | ||
33 | return; | ||
34 | case -DLM_ECANCEL: /* Cancel while getting lock */ | ||
35 | ret |= LM_OUT_CANCELED; | ||
36 | goto out; | ||
37 | case -EAGAIN: /* Try lock fails */ | ||
38 | goto out; | ||
39 | case -EINVAL: /* Invalid */ | ||
40 | case -ENOMEM: /* Out of memory */ | ||
41 | ret |= LM_OUT_ERROR; | ||
42 | goto out; | ||
43 | case 0: /* Success */ | ||
44 | break; | ||
45 | default: /* Something unexpected */ | ||
46 | BUG(); | ||
47 | } | ||
48 | |||
49 | ret = gl->gl_target; | ||
50 | if (gl->gl_lksb.sb_flags & DLM_SBF_ALTMODE) { | ||
51 | if (gl->gl_target == LM_ST_SHARED) | ||
52 | ret = LM_ST_DEFERRED; | ||
53 | else if (gl->gl_target == LM_ST_DEFERRED) | ||
54 | ret = LM_ST_SHARED; | ||
55 | else | ||
56 | BUG(); | ||
57 | } | ||
58 | |||
59 | set_bit(GLF_INITIAL, &gl->gl_flags); | ||
60 | gfs2_glock_complete(gl, ret); | ||
61 | return; | ||
62 | out: | ||
63 | if (!test_bit(GLF_INITIAL, &gl->gl_flags)) | ||
64 | gl->gl_lksb.sb_lkid = 0; | ||
65 | gfs2_glock_complete(gl, ret); | ||
66 | } | ||
67 | |||
68 | static void gdlm_bast(void *arg, int mode) | ||
69 | { | ||
70 | struct gfs2_glock *gl = arg; | ||
71 | |||
72 | switch (mode) { | ||
73 | case DLM_LOCK_EX: | ||
74 | gfs2_glock_cb(gl, LM_ST_UNLOCKED); | ||
75 | break; | ||
76 | case DLM_LOCK_CW: | ||
77 | gfs2_glock_cb(gl, LM_ST_DEFERRED); | ||
78 | break; | ||
79 | case DLM_LOCK_PR: | ||
80 | gfs2_glock_cb(gl, LM_ST_SHARED); | ||
81 | break; | ||
82 | default: | ||
83 | printk(KERN_ERR "unknown bast mode %d", mode); | ||
84 | BUG(); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | /* convert gfs lock-state to dlm lock-mode */ | ||
89 | |||
90 | static int make_mode(const unsigned int lmstate) | ||
91 | { | ||
92 | switch (lmstate) { | ||
93 | case LM_ST_UNLOCKED: | ||
94 | return DLM_LOCK_NL; | ||
95 | case LM_ST_EXCLUSIVE: | ||
96 | return DLM_LOCK_EX; | ||
97 | case LM_ST_DEFERRED: | ||
98 | return DLM_LOCK_CW; | ||
99 | case LM_ST_SHARED: | ||
100 | return DLM_LOCK_PR; | ||
101 | } | ||
102 | printk(KERN_ERR "unknown LM state %d", lmstate); | ||
103 | BUG(); | ||
104 | return -1; | ||
105 | } | ||
106 | |||
107 | static u32 make_flags(const u32 lkid, const unsigned int gfs_flags, | ||
108 | const int req) | ||
109 | { | ||
110 | u32 lkf = 0; | ||
111 | |||
112 | if (gfs_flags & LM_FLAG_TRY) | ||
113 | lkf |= DLM_LKF_NOQUEUE; | ||
114 | |||
115 | if (gfs_flags & LM_FLAG_TRY_1CB) { | ||
116 | lkf |= DLM_LKF_NOQUEUE; | ||
117 | lkf |= DLM_LKF_NOQUEUEBAST; | ||
118 | } | ||
119 | |||
120 | if (gfs_flags & LM_FLAG_PRIORITY) { | ||
121 | lkf |= DLM_LKF_NOORDER; | ||
122 | lkf |= DLM_LKF_HEADQUE; | ||
123 | } | ||
124 | |||
125 | if (gfs_flags & LM_FLAG_ANY) { | ||
126 | if (req == DLM_LOCK_PR) | ||
127 | lkf |= DLM_LKF_ALTCW; | ||
128 | else if (req == DLM_LOCK_CW) | ||
129 | lkf |= DLM_LKF_ALTPR; | ||
130 | else | ||
131 | BUG(); | ||
132 | } | ||
133 | |||
134 | if (lkid != 0) | ||
135 | lkf |= DLM_LKF_CONVERT; | ||
136 | |||
137 | lkf |= DLM_LKF_VALBLK; | ||
138 | |||
139 | return lkf; | ||
140 | } | ||
141 | |||
142 | static unsigned int gdlm_lock(struct gfs2_glock *gl, | ||
143 | unsigned int req_state, unsigned int flags) | ||
144 | { | ||
145 | struct lm_lockstruct *ls = &gl->gl_sbd->sd_lockstruct; | ||
146 | int error; | ||
147 | int req; | ||
148 | u32 lkf; | ||
149 | |||
150 | req = make_mode(req_state); | ||
151 | lkf = make_flags(gl->gl_lksb.sb_lkid, flags, req); | ||
152 | |||
153 | /* | ||
154 | * Submit the actual lock request. | ||
155 | */ | ||
156 | |||
157 | error = dlm_lock(ls->ls_dlm, req, &gl->gl_lksb, lkf, gl->gl_strname, | ||
158 | GDLM_STRNAME_BYTES - 1, 0, gdlm_ast, gl, gdlm_bast); | ||
159 | if (error == -EAGAIN) | ||
160 | return 0; | ||
161 | if (error) | ||
162 | return LM_OUT_ERROR; | ||
163 | return LM_OUT_ASYNC; | ||
164 | } | ||
165 | |||
166 | static void gdlm_put_lock(struct kmem_cache *cachep, void *ptr) | ||
167 | { | ||
168 | struct gfs2_glock *gl = ptr; | ||
169 | struct lm_lockstruct *ls = &gl->gl_sbd->sd_lockstruct; | ||
170 | int error; | ||
171 | |||
172 | if (gl->gl_lksb.sb_lkid == 0) { | ||
173 | kmem_cache_free(cachep, gl); | ||
174 | return; | ||
175 | } | ||
176 | |||
177 | error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK, | ||
178 | NULL, gl); | ||
179 | if (error) { | ||
180 | printk(KERN_ERR "gdlm_unlock %x,%llx err=%d\n", | ||
181 | gl->gl_name.ln_type, | ||
182 | (unsigned long long)gl->gl_name.ln_number, error); | ||
183 | return; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | static void gdlm_cancel(struct gfs2_glock *gl) | ||
188 | { | ||
189 | struct lm_lockstruct *ls = &gl->gl_sbd->sd_lockstruct; | ||
190 | dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_CANCEL, NULL, gl); | ||
191 | } | ||
192 | |||
193 | static int gdlm_mount(struct gfs2_sbd *sdp, const char *fsname) | ||
194 | { | ||
195 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
196 | int error; | ||
197 | |||
198 | if (fsname == NULL) { | ||
199 | fs_info(sdp, "no fsname found\n"); | ||
200 | return -EINVAL; | ||
201 | } | ||
202 | |||
203 | error = dlm_new_lockspace(fsname, strlen(fsname), &ls->ls_dlm, | ||
204 | DLM_LSFL_FS | DLM_LSFL_NEWEXCL | | ||
205 | (ls->ls_nodir ? DLM_LSFL_NODIR : 0), | ||
206 | GDLM_LVB_SIZE); | ||
207 | if (error) | ||
208 | printk(KERN_ERR "dlm_new_lockspace error %d", error); | ||
209 | |||
210 | return error; | ||
211 | } | ||
212 | |||
213 | static void gdlm_unmount(struct gfs2_sbd *sdp) | ||
214 | { | ||
215 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
216 | |||
217 | if (ls->ls_dlm) { | ||
218 | dlm_release_lockspace(ls->ls_dlm, 2); | ||
219 | ls->ls_dlm = NULL; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | static const match_table_t dlm_tokens = { | ||
224 | { Opt_jid, "jid=%d"}, | ||
225 | { Opt_id, "id=%d"}, | ||
226 | { Opt_first, "first=%d"}, | ||
227 | { Opt_nodir, "nodir=%d"}, | ||
228 | { Opt_err, NULL }, | ||
229 | }; | ||
230 | |||
231 | const struct lm_lockops gfs2_dlm_ops = { | ||
232 | .lm_proto_name = "lock_dlm", | ||
233 | .lm_mount = gdlm_mount, | ||
234 | .lm_unmount = gdlm_unmount, | ||
235 | .lm_put_lock = gdlm_put_lock, | ||
236 | .lm_lock = gdlm_lock, | ||
237 | .lm_cancel = gdlm_cancel, | ||
238 | .lm_tokens = &dlm_tokens, | ||
239 | }; | ||
240 | |||
diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c deleted file mode 100644 index d3657bc7938a..000000000000 --- a/fs/gfs2/locking.c +++ /dev/null | |||
@@ -1,314 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
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. | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/string.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/wait.h> | ||
15 | #include <linux/sched.h> | ||
16 | #include <linux/kmod.h> | ||
17 | #include <linux/fs.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <linux/lm_interface.h> | ||
20 | |||
21 | struct lmh_wrapper { | ||
22 | struct list_head lw_list; | ||
23 | const struct lm_lockops *lw_ops; | ||
24 | }; | ||
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 | |||
88 | static int nolock_mount(char *table_name, char *host_data, | ||
89 | lm_callback_t cb, void *cb_data, | ||
90 | unsigned int min_lvb_size, int flags, | ||
91 | struct lm_lockstruct *lockstruct, | ||
92 | struct kobject *fskobj); | ||
93 | static void nolock_unmount(void *lockspace); | ||
94 | |||
95 | /* List of registered low-level locking protocols. A file system selects one | ||
96 | of them by name at mount time, e.g. lock_nolock, lock_dlm. */ | ||
97 | |||
98 | static const struct lm_lockops nolock_ops = { | ||
99 | .lm_proto_name = "lock_nolock", | ||
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, | ||
106 | }; | ||
107 | |||
108 | static struct lmh_wrapper nolock_proto = { | ||
109 | .lw_list = LIST_HEAD_INIT(nolock_proto.lw_list), | ||
110 | .lw_ops = &nolock_ops, | ||
111 | }; | ||
112 | |||
113 | static LIST_HEAD(lmh_list); | ||
114 | static DEFINE_MUTEX(lmh_lock); | ||
115 | |||
116 | static int nolock_mount(char *table_name, char *host_data, | ||
117 | lm_callback_t cb, void *cb_data, | ||
118 | unsigned int min_lvb_size, int flags, | ||
119 | struct lm_lockstruct *lockstruct, | ||
120 | struct kobject *fskobj) | ||
121 | { | ||
122 | char *c; | ||
123 | unsigned int jid; | ||
124 | struct nolock_lockspace *nl; | ||
125 | |||
126 | c = strstr(host_data, "jid="); | ||
127 | if (!c) | ||
128 | jid = 0; | ||
129 | else { | ||
130 | c += 4; | ||
131 | sscanf(c, "%u", &jid); | ||
132 | } | ||
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 | |||
140 | lockstruct->ls_jid = jid; | ||
141 | lockstruct->ls_first = 1; | ||
142 | lockstruct->ls_lvb_size = min_lvb_size; | ||
143 | lockstruct->ls_lockspace = nl; | ||
144 | lockstruct->ls_ops = &nolock_ops; | ||
145 | lockstruct->ls_flags = LM_LSFLAG_LOCAL; | ||
146 | |||
147 | return 0; | ||
148 | } | ||
149 | |||
150 | static void nolock_unmount(void *lockspace) | ||
151 | { | ||
152 | struct nolock_lockspace *nl = lockspace; | ||
153 | kfree(nl); | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * gfs2_register_lockproto - Register a low-level locking protocol | ||
158 | * @proto: the protocol definition | ||
159 | * | ||
160 | * Returns: 0 on success, -EXXX on failure | ||
161 | */ | ||
162 | |||
163 | int gfs2_register_lockproto(const struct lm_lockops *proto) | ||
164 | { | ||
165 | struct lmh_wrapper *lw; | ||
166 | |||
167 | mutex_lock(&lmh_lock); | ||
168 | |||
169 | list_for_each_entry(lw, &lmh_list, lw_list) { | ||
170 | if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) { | ||
171 | mutex_unlock(&lmh_lock); | ||
172 | printk(KERN_INFO "GFS2: protocol %s already exists\n", | ||
173 | proto->lm_proto_name); | ||
174 | return -EEXIST; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | lw = kzalloc(sizeof(struct lmh_wrapper), GFP_KERNEL); | ||
179 | if (!lw) { | ||
180 | mutex_unlock(&lmh_lock); | ||
181 | return -ENOMEM; | ||
182 | } | ||
183 | |||
184 | lw->lw_ops = proto; | ||
185 | list_add(&lw->lw_list, &lmh_list); | ||
186 | |||
187 | mutex_unlock(&lmh_lock); | ||
188 | |||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * gfs2_unregister_lockproto - Unregister a low-level locking protocol | ||
194 | * @proto: the protocol definition | ||
195 | * | ||
196 | */ | ||
197 | |||
198 | void gfs2_unregister_lockproto(const struct lm_lockops *proto) | ||
199 | { | ||
200 | struct lmh_wrapper *lw; | ||
201 | |||
202 | mutex_lock(&lmh_lock); | ||
203 | |||
204 | list_for_each_entry(lw, &lmh_list, lw_list) { | ||
205 | if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) { | ||
206 | list_del(&lw->lw_list); | ||
207 | mutex_unlock(&lmh_lock); | ||
208 | kfree(lw); | ||
209 | return; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | mutex_unlock(&lmh_lock); | ||
214 | |||
215 | printk(KERN_WARNING "GFS2: can't unregister lock protocol %s\n", | ||
216 | proto->lm_proto_name); | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * gfs2_mount_lockproto - Mount a lock protocol | ||
221 | * @proto_name - the name of the protocol | ||
222 | * @table_name - the name of the lock space | ||
223 | * @host_data - data specific to this host | ||
224 | * @cb - the callback to the code using the lock module | ||
225 | * @sdp - The GFS2 superblock | ||
226 | * @min_lvb_size - the mininum LVB size that the caller can deal with | ||
227 | * @flags - LM_MFLAG_* | ||
228 | * @lockstruct - a structure returned describing the mount | ||
229 | * | ||
230 | * Returns: 0 on success, -EXXX on failure | ||
231 | */ | ||
232 | |||
233 | int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data, | ||
234 | lm_callback_t cb, void *cb_data, | ||
235 | unsigned int min_lvb_size, int flags, | ||
236 | struct lm_lockstruct *lockstruct, | ||
237 | struct kobject *fskobj) | ||
238 | { | ||
239 | struct lmh_wrapper *lw = NULL; | ||
240 | int try = 0; | ||
241 | int error, found; | ||
242 | |||
243 | |||
244 | retry: | ||
245 | mutex_lock(&lmh_lock); | ||
246 | |||
247 | if (list_empty(&nolock_proto.lw_list)) | ||
248 | list_add(&nolock_proto.lw_list, &lmh_list); | ||
249 | |||
250 | found = 0; | ||
251 | list_for_each_entry(lw, &lmh_list, lw_list) { | ||
252 | if (!strcmp(lw->lw_ops->lm_proto_name, proto_name)) { | ||
253 | found = 1; | ||
254 | break; | ||
255 | } | ||
256 | } | ||
257 | |||
258 | if (!found) { | ||
259 | if (!try && capable(CAP_SYS_MODULE)) { | ||
260 | try = 1; | ||
261 | mutex_unlock(&lmh_lock); | ||
262 | request_module(proto_name); | ||
263 | goto retry; | ||
264 | } | ||
265 | printk(KERN_INFO "GFS2: can't find protocol %s\n", proto_name); | ||
266 | error = -ENOENT; | ||
267 | goto out; | ||
268 | } | ||
269 | |||
270 | if (lw->lw_ops->lm_owner && | ||
271 | !try_module_get(lw->lw_ops->lm_owner)) { | ||
272 | try = 0; | ||
273 | mutex_unlock(&lmh_lock); | ||
274 | msleep(1000); | ||
275 | goto retry; | ||
276 | } | ||
277 | |||
278 | error = lw->lw_ops->lm_mount(table_name, host_data, cb, cb_data, | ||
279 | min_lvb_size, flags, lockstruct, fskobj); | ||
280 | if (error) | ||
281 | module_put(lw->lw_ops->lm_owner); | ||
282 | out: | ||
283 | mutex_unlock(&lmh_lock); | ||
284 | return error; | ||
285 | } | ||
286 | |||
287 | void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct) | ||
288 | { | ||
289 | mutex_lock(&lmh_lock); | ||
290 | if (lockstruct->ls_ops->lm_unmount) | ||
291 | lockstruct->ls_ops->lm_unmount(lockstruct->ls_lockspace); | ||
292 | if (lockstruct->ls_ops->lm_owner) | ||
293 | module_put(lockstruct->ls_ops->lm_owner); | ||
294 | mutex_unlock(&lmh_lock); | ||
295 | } | ||
296 | |||
297 | /** | ||
298 | * gfs2_withdraw_lockproto - abnormally unmount a lock module | ||
299 | * @lockstruct: the lockstruct passed into mount | ||
300 | * | ||
301 | */ | ||
302 | |||
303 | void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct) | ||
304 | { | ||
305 | mutex_lock(&lmh_lock); | ||
306 | lockstruct->ls_ops->lm_withdraw(lockstruct->ls_lockspace); | ||
307 | if (lockstruct->ls_ops->lm_owner) | ||
308 | module_put(lockstruct->ls_ops->lm_owner); | ||
309 | mutex_unlock(&lmh_lock); | ||
310 | } | ||
311 | |||
312 | EXPORT_SYMBOL_GPL(gfs2_register_lockproto); | ||
313 | EXPORT_SYMBOL_GPL(gfs2_unregister_lockproto); | ||
314 | |||
diff --git a/fs/gfs2/locking/dlm/Makefile b/fs/gfs2/locking/dlm/Makefile deleted file mode 100644 index 2609bb6cd013..000000000000 --- a/fs/gfs2/locking/dlm/Makefile +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | obj-$(CONFIG_GFS2_FS_LOCKING_DLM) += lock_dlm.o | ||
2 | lock_dlm-y := lock.o main.o mount.o sysfs.o thread.o | ||
3 | |||
diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c deleted file mode 100644 index 2482c9047505..000000000000 --- a/fs/gfs2/locking/dlm/lock.c +++ /dev/null | |||
@@ -1,708 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
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. | ||
8 | */ | ||
9 | |||
10 | #include "lock_dlm.h" | ||
11 | |||
12 | static char junk_lvb[GDLM_LVB_SIZE]; | ||
13 | |||
14 | |||
15 | /* convert dlm lock-mode to gfs lock-state */ | ||
16 | |||
17 | static s16 gdlm_make_lmstate(s16 dlmmode) | ||
18 | { | ||
19 | switch (dlmmode) { | ||
20 | case DLM_LOCK_IV: | ||
21 | case DLM_LOCK_NL: | ||
22 | return LM_ST_UNLOCKED; | ||
23 | case DLM_LOCK_EX: | ||
24 | return LM_ST_EXCLUSIVE; | ||
25 | case DLM_LOCK_CW: | ||
26 | return LM_ST_DEFERRED; | ||
27 | case DLM_LOCK_PR: | ||
28 | return LM_ST_SHARED; | ||
29 | } | ||
30 | gdlm_assert(0, "unknown DLM mode %d", dlmmode); | ||
31 | return -1; | ||
32 | } | ||
33 | |||
34 | /* A lock placed on this queue is re-submitted to DLM as soon as the lock_dlm | ||
35 | thread gets to it. */ | ||
36 | |||
37 | static void queue_submit(struct gdlm_lock *lp) | ||
38 | { | ||
39 | struct gdlm_ls *ls = lp->ls; | ||
40 | |||
41 | spin_lock(&ls->async_lock); | ||
42 | list_add_tail(&lp->delay_list, &ls->submit); | ||
43 | spin_unlock(&ls->async_lock); | ||
44 | wake_up(&ls->thread_wait); | ||
45 | } | ||
46 | |||
47 | static void wake_up_ast(struct gdlm_lock *lp) | ||
48 | { | ||
49 | clear_bit(LFL_AST_WAIT, &lp->flags); | ||
50 | smp_mb__after_clear_bit(); | ||
51 | wake_up_bit(&lp->flags, LFL_AST_WAIT); | ||
52 | } | ||
53 | |||
54 | static void gdlm_delete_lp(struct gdlm_lock *lp) | ||
55 | { | ||
56 | struct gdlm_ls *ls = lp->ls; | ||
57 | |||
58 | spin_lock(&ls->async_lock); | ||
59 | if (!list_empty(&lp->delay_list)) | ||
60 | list_del_init(&lp->delay_list); | ||
61 | ls->all_locks_count--; | ||
62 | spin_unlock(&ls->async_lock); | ||
63 | |||
64 | kfree(lp); | ||
65 | } | ||
66 | |||
67 | static void gdlm_queue_delayed(struct gdlm_lock *lp) | ||
68 | { | ||
69 | struct gdlm_ls *ls = lp->ls; | ||
70 | |||
71 | spin_lock(&ls->async_lock); | ||
72 | list_add_tail(&lp->delay_list, &ls->delayed); | ||
73 | spin_unlock(&ls->async_lock); | ||
74 | } | ||
75 | |||
76 | static void process_complete(struct gdlm_lock *lp) | ||
77 | { | ||
78 | struct gdlm_ls *ls = lp->ls; | ||
79 | struct lm_async_cb acb; | ||
80 | |||
81 | memset(&acb, 0, sizeof(acb)); | ||
82 | |||
83 | if (lp->lksb.sb_status == -DLM_ECANCEL) { | ||
84 | log_info("complete dlm cancel %x,%llx flags %lx", | ||
85 | lp->lockname.ln_type, | ||
86 | (unsigned long long)lp->lockname.ln_number, | ||
87 | lp->flags); | ||
88 | |||
89 | lp->req = lp->cur; | ||
90 | acb.lc_ret |= LM_OUT_CANCELED; | ||
91 | if (lp->cur == DLM_LOCK_IV) | ||
92 | lp->lksb.sb_lkid = 0; | ||
93 | goto out; | ||
94 | } | ||
95 | |||
96 | if (test_and_clear_bit(LFL_DLM_UNLOCK, &lp->flags)) { | ||
97 | if (lp->lksb.sb_status != -DLM_EUNLOCK) { | ||
98 | log_info("unlock sb_status %d %x,%llx flags %lx", | ||
99 | lp->lksb.sb_status, lp->lockname.ln_type, | ||
100 | (unsigned long long)lp->lockname.ln_number, | ||
101 | lp->flags); | ||
102 | return; | ||
103 | } | ||
104 | |||
105 | lp->cur = DLM_LOCK_IV; | ||
106 | lp->req = DLM_LOCK_IV; | ||
107 | lp->lksb.sb_lkid = 0; | ||
108 | |||
109 | if (test_and_clear_bit(LFL_UNLOCK_DELETE, &lp->flags)) { | ||
110 | gdlm_delete_lp(lp); | ||
111 | return; | ||
112 | } | ||
113 | goto out; | ||
114 | } | ||
115 | |||
116 | if (lp->lksb.sb_flags & DLM_SBF_VALNOTVALID) | ||
117 | memset(lp->lksb.sb_lvbptr, 0, GDLM_LVB_SIZE); | ||
118 | |||
119 | if (lp->lksb.sb_flags & DLM_SBF_ALTMODE) { | ||
120 | if (lp->req == DLM_LOCK_PR) | ||
121 | lp->req = DLM_LOCK_CW; | ||
122 | else if (lp->req == DLM_LOCK_CW) | ||
123 | lp->req = DLM_LOCK_PR; | ||
124 | } | ||
125 | |||
126 | /* | ||
127 | * A canceled lock request. The lock was just taken off the delayed | ||
128 | * list and was never even submitted to dlm. | ||
129 | */ | ||
130 | |||
131 | if (test_and_clear_bit(LFL_CANCEL, &lp->flags)) { | ||
132 | log_info("complete internal cancel %x,%llx", | ||
133 | lp->lockname.ln_type, | ||
134 | (unsigned long long)lp->lockname.ln_number); | ||
135 | lp->req = lp->cur; | ||
136 | acb.lc_ret |= LM_OUT_CANCELED; | ||
137 | goto out; | ||
138 | } | ||
139 | |||
140 | /* | ||
141 | * An error occured. | ||
142 | */ | ||
143 | |||
144 | if (lp->lksb.sb_status) { | ||
145 | /* a "normal" error */ | ||
146 | if ((lp->lksb.sb_status == -EAGAIN) && | ||
147 | (lp->lkf & DLM_LKF_NOQUEUE)) { | ||
148 | lp->req = lp->cur; | ||
149 | if (lp->cur == DLM_LOCK_IV) | ||
150 | lp->lksb.sb_lkid = 0; | ||
151 | goto out; | ||
152 | } | ||
153 | |||
154 | /* this could only happen with cancels I think */ | ||
155 | log_info("ast sb_status %d %x,%llx flags %lx", | ||
156 | lp->lksb.sb_status, lp->lockname.ln_type, | ||
157 | (unsigned long long)lp->lockname.ln_number, | ||
158 | lp->flags); | ||
159 | return; | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | * This is an AST for an EX->EX conversion for sync_lvb from GFS. | ||
164 | */ | ||
165 | |||
166 | if (test_and_clear_bit(LFL_SYNC_LVB, &lp->flags)) { | ||
167 | wake_up_ast(lp); | ||
168 | return; | ||
169 | } | ||
170 | |||
171 | /* | ||
172 | * A lock has been demoted to NL because it initially completed during | ||
173 | * BLOCK_LOCKS. Now it must be requested in the originally requested | ||
174 | * mode. | ||
175 | */ | ||
176 | |||
177 | if (test_and_clear_bit(LFL_REREQUEST, &lp->flags)) { | ||
178 | gdlm_assert(lp->req == DLM_LOCK_NL, "%x,%llx", | ||
179 | lp->lockname.ln_type, | ||
180 | (unsigned long long)lp->lockname.ln_number); | ||
181 | gdlm_assert(lp->prev_req > DLM_LOCK_NL, "%x,%llx", | ||
182 | lp->lockname.ln_type, | ||
183 | (unsigned long long)lp->lockname.ln_number); | ||
184 | |||
185 | lp->cur = DLM_LOCK_NL; | ||
186 | lp->req = lp->prev_req; | ||
187 | lp->prev_req = DLM_LOCK_IV; | ||
188 | lp->lkf &= ~DLM_LKF_CONVDEADLK; | ||
189 | |||
190 | set_bit(LFL_NOCACHE, &lp->flags); | ||
191 | |||
192 | if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) && | ||
193 | !test_bit(LFL_NOBLOCK, &lp->flags)) | ||
194 | gdlm_queue_delayed(lp); | ||
195 | else | ||
196 | queue_submit(lp); | ||
197 | return; | ||
198 | } | ||
199 | |||
200 | /* | ||
201 | * A request is granted during dlm recovery. It may be granted | ||
202 | * because the locks of a failed node were cleared. In that case, | ||
203 | * there may be inconsistent data beneath this lock and we must wait | ||
204 | * for recovery to complete to use it. When gfs recovery is done this | ||
205 | * granted lock will be converted to NL and then reacquired in this | ||
206 | * granted state. | ||
207 | */ | ||
208 | |||
209 | if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) && | ||
210 | !test_bit(LFL_NOBLOCK, &lp->flags) && | ||
211 | lp->req != DLM_LOCK_NL) { | ||
212 | |||
213 | lp->cur = lp->req; | ||
214 | lp->prev_req = lp->req; | ||
215 | lp->req = DLM_LOCK_NL; | ||
216 | lp->lkf |= DLM_LKF_CONVERT; | ||
217 | lp->lkf &= ~DLM_LKF_CONVDEADLK; | ||
218 | |||
219 | log_debug("rereq %x,%llx id %x %d,%d", | ||
220 | lp->lockname.ln_type, | ||
221 | (unsigned long long)lp->lockname.ln_number, | ||
222 | lp->lksb.sb_lkid, lp->cur, lp->req); | ||
223 | |||
224 | set_bit(LFL_REREQUEST, &lp->flags); | ||
225 | queue_submit(lp); | ||
226 | return; | ||
227 | } | ||
228 | |||
229 | /* | ||
230 | * DLM demoted the lock to NL before it was granted so GFS must be | ||
231 | * told it cannot cache data for this lock. | ||
232 | */ | ||
233 | |||
234 | if (lp->lksb.sb_flags & DLM_SBF_DEMOTED) | ||
235 | set_bit(LFL_NOCACHE, &lp->flags); | ||
236 | |||
237 | out: | ||
238 | /* | ||
239 | * This is an internal lock_dlm lock | ||
240 | */ | ||
241 | |||
242 | if (test_bit(LFL_INLOCK, &lp->flags)) { | ||
243 | clear_bit(LFL_NOBLOCK, &lp->flags); | ||
244 | lp->cur = lp->req; | ||
245 | wake_up_ast(lp); | ||
246 | return; | ||
247 | } | ||
248 | |||
249 | /* | ||
250 | * Normal completion of a lock request. Tell GFS it now has the lock. | ||
251 | */ | ||
252 | |||
253 | clear_bit(LFL_NOBLOCK, &lp->flags); | ||
254 | lp->cur = lp->req; | ||
255 | |||
256 | acb.lc_name = lp->lockname; | ||
257 | acb.lc_ret |= gdlm_make_lmstate(lp->cur); | ||
258 | |||
259 | ls->fscb(ls->sdp, LM_CB_ASYNC, &acb); | ||
260 | } | ||
261 | |||
262 | static void gdlm_ast(void *astarg) | ||
263 | { | ||
264 | struct gdlm_lock *lp = astarg; | ||
265 | clear_bit(LFL_ACTIVE, &lp->flags); | ||
266 | process_complete(lp); | ||
267 | } | ||
268 | |||
269 | static void process_blocking(struct gdlm_lock *lp, int bast_mode) | ||
270 | { | ||
271 | struct gdlm_ls *ls = lp->ls; | ||
272 | unsigned int cb = 0; | ||
273 | |||
274 | switch (gdlm_make_lmstate(bast_mode)) { | ||
275 | case LM_ST_EXCLUSIVE: | ||
276 | cb = LM_CB_NEED_E; | ||
277 | break; | ||
278 | case LM_ST_DEFERRED: | ||
279 | cb = LM_CB_NEED_D; | ||
280 | break; | ||
281 | case LM_ST_SHARED: | ||
282 | cb = LM_CB_NEED_S; | ||
283 | break; | ||
284 | default: | ||
285 | gdlm_assert(0, "unknown bast mode %u", bast_mode); | ||
286 | } | ||
287 | |||
288 | ls->fscb(ls->sdp, cb, &lp->lockname); | ||
289 | } | ||
290 | |||
291 | |||
292 | static void gdlm_bast(void *astarg, int mode) | ||
293 | { | ||
294 | struct gdlm_lock *lp = astarg; | ||
295 | |||
296 | if (!mode) { | ||
297 | printk(KERN_INFO "lock_dlm: bast mode zero %x,%llx\n", | ||
298 | lp->lockname.ln_type, | ||
299 | (unsigned long long)lp->lockname.ln_number); | ||
300 | return; | ||
301 | } | ||
302 | |||
303 | process_blocking(lp, mode); | ||
304 | } | ||
305 | |||
306 | /* convert gfs lock-state to dlm lock-mode */ | ||
307 | |||
308 | static s16 make_mode(s16 lmstate) | ||
309 | { | ||
310 | switch (lmstate) { | ||
311 | case LM_ST_UNLOCKED: | ||
312 | return DLM_LOCK_NL; | ||
313 | case LM_ST_EXCLUSIVE: | ||
314 | return DLM_LOCK_EX; | ||
315 | case LM_ST_DEFERRED: | ||
316 | return DLM_LOCK_CW; | ||
317 | case LM_ST_SHARED: | ||
318 | return DLM_LOCK_PR; | ||
319 | } | ||
320 | gdlm_assert(0, "unknown LM state %d", lmstate); | ||
321 | return -1; | ||
322 | } | ||
323 | |||
324 | |||
325 | /* verify agreement with GFS on the current lock state, NB: DLM_LOCK_NL and | ||
326 | DLM_LOCK_IV are both considered LM_ST_UNLOCKED by GFS. */ | ||
327 | |||
328 | static void check_cur_state(struct gdlm_lock *lp, unsigned int cur_state) | ||
329 | { | ||
330 | s16 cur = make_mode(cur_state); | ||
331 | if (lp->cur != DLM_LOCK_IV) | ||
332 | gdlm_assert(lp->cur == cur, "%d, %d", lp->cur, cur); | ||
333 | } | ||
334 | |||
335 | static inline unsigned int make_flags(struct gdlm_lock *lp, | ||
336 | unsigned int gfs_flags, | ||
337 | s16 cur, s16 req) | ||
338 | { | ||
339 | unsigned int lkf = 0; | ||
340 | |||
341 | if (gfs_flags & LM_FLAG_TRY) | ||
342 | lkf |= DLM_LKF_NOQUEUE; | ||
343 | |||
344 | if (gfs_flags & LM_FLAG_TRY_1CB) { | ||
345 | lkf |= DLM_LKF_NOQUEUE; | ||
346 | lkf |= DLM_LKF_NOQUEUEBAST; | ||
347 | } | ||
348 | |||
349 | if (gfs_flags & LM_FLAG_PRIORITY) { | ||
350 | lkf |= DLM_LKF_NOORDER; | ||
351 | lkf |= DLM_LKF_HEADQUE; | ||
352 | } | ||
353 | |||
354 | if (gfs_flags & LM_FLAG_ANY) { | ||
355 | if (req == DLM_LOCK_PR) | ||
356 | lkf |= DLM_LKF_ALTCW; | ||
357 | else if (req == DLM_LOCK_CW) | ||
358 | lkf |= DLM_LKF_ALTPR; | ||
359 | } | ||
360 | |||
361 | if (lp->lksb.sb_lkid != 0) { | ||
362 | lkf |= DLM_LKF_CONVERT; | ||
363 | } | ||
364 | |||
365 | if (lp->lvb) | ||
366 | lkf |= DLM_LKF_VALBLK; | ||
367 | |||
368 | return lkf; | ||
369 | } | ||
370 | |||
371 | /* make_strname - convert GFS lock numbers to a string */ | ||
372 | |||
373 | static inline void make_strname(const struct lm_lockname *lockname, | ||
374 | struct gdlm_strname *str) | ||
375 | { | ||
376 | sprintf(str->name, "%8x%16llx", lockname->ln_type, | ||
377 | (unsigned long long)lockname->ln_number); | ||
378 | str->namelen = GDLM_STRNAME_BYTES; | ||
379 | } | ||
380 | |||
381 | static int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name, | ||
382 | struct gdlm_lock **lpp) | ||
383 | { | ||
384 | struct gdlm_lock *lp; | ||
385 | |||
386 | lp = kzalloc(sizeof(struct gdlm_lock), GFP_NOFS); | ||
387 | if (!lp) | ||
388 | return -ENOMEM; | ||
389 | |||
390 | lp->lockname = *name; | ||
391 | make_strname(name, &lp->strname); | ||
392 | lp->ls = ls; | ||
393 | lp->cur = DLM_LOCK_IV; | ||
394 | INIT_LIST_HEAD(&lp->delay_list); | ||
395 | |||
396 | spin_lock(&ls->async_lock); | ||
397 | ls->all_locks_count++; | ||
398 | spin_unlock(&ls->async_lock); | ||
399 | |||
400 | *lpp = lp; | ||
401 | return 0; | ||
402 | } | ||
403 | |||
404 | int gdlm_get_lock(void *lockspace, struct lm_lockname *name, | ||
405 | void **lockp) | ||
406 | { | ||
407 | struct gdlm_lock *lp; | ||
408 | int error; | ||
409 | |||
410 | error = gdlm_create_lp(lockspace, name, &lp); | ||
411 | |||
412 | *lockp = lp; | ||
413 | return error; | ||
414 | } | ||
415 | |||
416 | void gdlm_put_lock(void *lock) | ||
417 | { | ||
418 | gdlm_delete_lp(lock); | ||
419 | } | ||
420 | |||
421 | unsigned int gdlm_do_lock(struct gdlm_lock *lp) | ||
422 | { | ||
423 | struct gdlm_ls *ls = lp->ls; | ||
424 | int error, bast = 1; | ||
425 | |||
426 | /* | ||
427 | * When recovery is in progress, delay lock requests for submission | ||
428 | * once recovery is done. Requests for recovery (NOEXP) and unlocks | ||
429 | * can pass. | ||
430 | */ | ||
431 | |||
432 | if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) && | ||
433 | !test_bit(LFL_NOBLOCK, &lp->flags) && lp->req != DLM_LOCK_NL) { | ||
434 | gdlm_queue_delayed(lp); | ||
435 | return LM_OUT_ASYNC; | ||
436 | } | ||
437 | |||
438 | /* | ||
439 | * Submit the actual lock request. | ||
440 | */ | ||
441 | |||
442 | if (test_bit(LFL_NOBAST, &lp->flags)) | ||
443 | bast = 0; | ||
444 | |||
445 | set_bit(LFL_ACTIVE, &lp->flags); | ||
446 | |||
447 | log_debug("lk %x,%llx id %x %d,%d %x", lp->lockname.ln_type, | ||
448 | (unsigned long long)lp->lockname.ln_number, lp->lksb.sb_lkid, | ||
449 | lp->cur, lp->req, lp->lkf); | ||
450 | |||
451 | error = dlm_lock(ls->dlm_lockspace, lp->req, &lp->lksb, lp->lkf, | ||
452 | lp->strname.name, lp->strname.namelen, 0, gdlm_ast, | ||
453 | lp, bast ? gdlm_bast : NULL); | ||
454 | |||
455 | if ((error == -EAGAIN) && (lp->lkf & DLM_LKF_NOQUEUE)) { | ||
456 | lp->lksb.sb_status = -EAGAIN; | ||
457 | gdlm_ast(lp); | ||
458 | error = 0; | ||
459 | } | ||
460 | |||
461 | if (error) { | ||
462 | log_error("%s: gdlm_lock %x,%llx err=%d cur=%d req=%d lkf=%x " | ||
463 | "flags=%lx", ls->fsname, lp->lockname.ln_type, | ||
464 | (unsigned long long)lp->lockname.ln_number, error, | ||
465 | lp->cur, lp->req, lp->lkf, lp->flags); | ||
466 | return LM_OUT_ERROR; | ||
467 | } | ||
468 | return LM_OUT_ASYNC; | ||
469 | } | ||
470 | |||
471 | static unsigned int gdlm_do_unlock(struct gdlm_lock *lp) | ||
472 | { | ||
473 | struct gdlm_ls *ls = lp->ls; | ||
474 | unsigned int lkf = 0; | ||
475 | int error; | ||
476 | |||
477 | set_bit(LFL_DLM_UNLOCK, &lp->flags); | ||
478 | set_bit(LFL_ACTIVE, &lp->flags); | ||
479 | |||
480 | if (lp->lvb) | ||
481 | lkf = DLM_LKF_VALBLK; | ||
482 | |||
483 | log_debug("un %x,%llx %x %d %x", lp->lockname.ln_type, | ||
484 | (unsigned long long)lp->lockname.ln_number, | ||
485 | lp->lksb.sb_lkid, lp->cur, lkf); | ||
486 | |||
487 | error = dlm_unlock(ls->dlm_lockspace, lp->lksb.sb_lkid, lkf, NULL, lp); | ||
488 | |||
489 | if (error) { | ||
490 | log_error("%s: gdlm_unlock %x,%llx err=%d cur=%d req=%d lkf=%x " | ||
491 | "flags=%lx", ls->fsname, lp->lockname.ln_type, | ||
492 | (unsigned long long)lp->lockname.ln_number, error, | ||
493 | lp->cur, lp->req, lp->lkf, lp->flags); | ||
494 | return LM_OUT_ERROR; | ||
495 | } | ||
496 | return LM_OUT_ASYNC; | ||
497 | } | ||
498 | |||
499 | unsigned int gdlm_lock(void *lock, unsigned int cur_state, | ||
500 | unsigned int req_state, unsigned int flags) | ||
501 | { | ||
502 | struct gdlm_lock *lp = lock; | ||
503 | |||
504 | if (req_state == LM_ST_UNLOCKED) | ||
505 | return gdlm_unlock(lock, cur_state); | ||
506 | |||
507 | if (req_state == LM_ST_UNLOCKED) | ||
508 | return gdlm_unlock(lock, cur_state); | ||
509 | |||
510 | clear_bit(LFL_DLM_CANCEL, &lp->flags); | ||
511 | if (flags & LM_FLAG_NOEXP) | ||
512 | set_bit(LFL_NOBLOCK, &lp->flags); | ||
513 | |||
514 | check_cur_state(lp, cur_state); | ||
515 | lp->req = make_mode(req_state); | ||
516 | lp->lkf = make_flags(lp, flags, lp->cur, lp->req); | ||
517 | |||
518 | return gdlm_do_lock(lp); | ||
519 | } | ||
520 | |||
521 | unsigned int gdlm_unlock(void *lock, unsigned int cur_state) | ||
522 | { | ||
523 | struct gdlm_lock *lp = lock; | ||
524 | |||
525 | clear_bit(LFL_DLM_CANCEL, &lp->flags); | ||
526 | if (lp->cur == DLM_LOCK_IV) | ||
527 | return 0; | ||
528 | return gdlm_do_unlock(lp); | ||
529 | } | ||
530 | |||
531 | void gdlm_cancel(void *lock) | ||
532 | { | ||
533 | struct gdlm_lock *lp = lock; | ||
534 | struct gdlm_ls *ls = lp->ls; | ||
535 | int error, delay_list = 0; | ||
536 | |||
537 | if (test_bit(LFL_DLM_CANCEL, &lp->flags)) | ||
538 | return; | ||
539 | |||
540 | log_info("gdlm_cancel %x,%llx flags %lx", lp->lockname.ln_type, | ||
541 | (unsigned long long)lp->lockname.ln_number, lp->flags); | ||
542 | |||
543 | spin_lock(&ls->async_lock); | ||
544 | if (!list_empty(&lp->delay_list)) { | ||
545 | list_del_init(&lp->delay_list); | ||
546 | delay_list = 1; | ||
547 | } | ||
548 | spin_unlock(&ls->async_lock); | ||
549 | |||
550 | if (delay_list) { | ||
551 | set_bit(LFL_CANCEL, &lp->flags); | ||
552 | set_bit(LFL_ACTIVE, &lp->flags); | ||
553 | gdlm_ast(lp); | ||
554 | return; | ||
555 | } | ||
556 | |||
557 | if (!test_bit(LFL_ACTIVE, &lp->flags) || | ||
558 | test_bit(LFL_DLM_UNLOCK, &lp->flags)) { | ||
559 | log_info("gdlm_cancel skip %x,%llx flags %lx", | ||
560 | lp->lockname.ln_type, | ||
561 | (unsigned long long)lp->lockname.ln_number, lp->flags); | ||
562 | return; | ||
563 | } | ||
564 | |||
565 | /* the lock is blocked in the dlm */ | ||
566 | |||
567 | set_bit(LFL_DLM_CANCEL, &lp->flags); | ||
568 | set_bit(LFL_ACTIVE, &lp->flags); | ||
569 | |||
570 | error = dlm_unlock(ls->dlm_lockspace, lp->lksb.sb_lkid, DLM_LKF_CANCEL, | ||
571 | NULL, lp); | ||
572 | |||
573 | log_info("gdlm_cancel rv %d %x,%llx flags %lx", error, | ||
574 | lp->lockname.ln_type, | ||
575 | (unsigned long long)lp->lockname.ln_number, lp->flags); | ||
576 | |||
577 | if (error == -EBUSY) | ||
578 | clear_bit(LFL_DLM_CANCEL, &lp->flags); | ||
579 | } | ||
580 | |||
581 | static int gdlm_add_lvb(struct gdlm_lock *lp) | ||
582 | { | ||
583 | char *lvb; | ||
584 | |||
585 | lvb = kzalloc(GDLM_LVB_SIZE, GFP_NOFS); | ||
586 | if (!lvb) | ||
587 | return -ENOMEM; | ||
588 | |||
589 | lp->lksb.sb_lvbptr = lvb; | ||
590 | lp->lvb = lvb; | ||
591 | return 0; | ||
592 | } | ||
593 | |||
594 | static void gdlm_del_lvb(struct gdlm_lock *lp) | ||
595 | { | ||
596 | kfree(lp->lvb); | ||
597 | lp->lvb = NULL; | ||
598 | lp->lksb.sb_lvbptr = NULL; | ||
599 | } | ||
600 | |||
601 | static int gdlm_ast_wait(void *word) | ||
602 | { | ||
603 | schedule(); | ||
604 | return 0; | ||
605 | } | ||
606 | |||
607 | /* This can do a synchronous dlm request (requiring a lock_dlm thread to get | ||
608 | the completion) because gfs won't call hold_lvb() during a callback (from | ||
609 | the context of a lock_dlm thread). */ | ||
610 | |||
611 | static int hold_null_lock(struct gdlm_lock *lp) | ||
612 | { | ||
613 | struct gdlm_lock *lpn = NULL; | ||
614 | int error; | ||
615 | |||
616 | if (lp->hold_null) { | ||
617 | printk(KERN_INFO "lock_dlm: lvb already held\n"); | ||
618 | return 0; | ||
619 | } | ||
620 | |||
621 | error = gdlm_create_lp(lp->ls, &lp->lockname, &lpn); | ||
622 | if (error) | ||
623 | goto out; | ||
624 | |||
625 | lpn->lksb.sb_lvbptr = junk_lvb; | ||
626 | lpn->lvb = junk_lvb; | ||
627 | |||
628 | lpn->req = DLM_LOCK_NL; | ||
629 | lpn->lkf = DLM_LKF_VALBLK | DLM_LKF_EXPEDITE; | ||
630 | set_bit(LFL_NOBAST, &lpn->flags); | ||
631 | set_bit(LFL_INLOCK, &lpn->flags); | ||
632 | set_bit(LFL_AST_WAIT, &lpn->flags); | ||
633 | |||
634 | gdlm_do_lock(lpn); | ||
635 | wait_on_bit(&lpn->flags, LFL_AST_WAIT, gdlm_ast_wait, TASK_UNINTERRUPTIBLE); | ||
636 | error = lpn->lksb.sb_status; | ||
637 | if (error) { | ||
638 | printk(KERN_INFO "lock_dlm: hold_null_lock dlm error %d\n", | ||
639 | error); | ||
640 | gdlm_delete_lp(lpn); | ||
641 | lpn = NULL; | ||
642 | } | ||
643 | out: | ||
644 | lp->hold_null = lpn; | ||
645 | return error; | ||
646 | } | ||
647 | |||
648 | /* This cannot do a synchronous dlm request (requiring a lock_dlm thread to get | ||
649 | the completion) because gfs may call unhold_lvb() during a callback (from | ||
650 | the context of a lock_dlm thread) which could cause a deadlock since the | ||
651 | other lock_dlm thread could be engaged in recovery. */ | ||
652 | |||
653 | static void unhold_null_lock(struct gdlm_lock *lp) | ||
654 | { | ||
655 | struct gdlm_lock *lpn = lp->hold_null; | ||
656 | |||
657 | gdlm_assert(lpn, "%x,%llx", lp->lockname.ln_type, | ||
658 | (unsigned long long)lp->lockname.ln_number); | ||
659 | lpn->lksb.sb_lvbptr = NULL; | ||
660 | lpn->lvb = NULL; | ||
661 | set_bit(LFL_UNLOCK_DELETE, &lpn->flags); | ||
662 | gdlm_do_unlock(lpn); | ||
663 | lp->hold_null = NULL; | ||
664 | } | ||
665 | |||
666 | /* Acquire a NL lock because gfs requires the value block to remain | ||
667 | intact on the resource while the lvb is "held" even if it's holding no locks | ||
668 | on the resource. */ | ||
669 | |||
670 | int gdlm_hold_lvb(void *lock, char **lvbp) | ||
671 | { | ||
672 | struct gdlm_lock *lp = lock; | ||
673 | int error; | ||
674 | |||
675 | error = gdlm_add_lvb(lp); | ||
676 | if (error) | ||
677 | return error; | ||
678 | |||
679 | *lvbp = lp->lvb; | ||
680 | |||
681 | error = hold_null_lock(lp); | ||
682 | if (error) | ||
683 | gdlm_del_lvb(lp); | ||
684 | |||
685 | return error; | ||
686 | } | ||
687 | |||
688 | void gdlm_unhold_lvb(void *lock, char *lvb) | ||
689 | { | ||
690 | struct gdlm_lock *lp = lock; | ||
691 | |||
692 | unhold_null_lock(lp); | ||
693 | gdlm_del_lvb(lp); | ||
694 | } | ||
695 | |||
696 | void gdlm_submit_delayed(struct gdlm_ls *ls) | ||
697 | { | ||
698 | struct gdlm_lock *lp, *safe; | ||
699 | |||
700 | spin_lock(&ls->async_lock); | ||
701 | list_for_each_entry_safe(lp, safe, &ls->delayed, delay_list) { | ||
702 | list_del_init(&lp->delay_list); | ||
703 | list_add_tail(&lp->delay_list, &ls->submit); | ||
704 | } | ||
705 | spin_unlock(&ls->async_lock); | ||
706 | wake_up(&ls->thread_wait); | ||
707 | } | ||
708 | |||
diff --git a/fs/gfs2/locking/dlm/lock_dlm.h b/fs/gfs2/locking/dlm/lock_dlm.h deleted file mode 100644 index 3c98e7c6f93b..000000000000 --- a/fs/gfs2/locking/dlm/lock_dlm.h +++ /dev/null | |||
@@ -1,166 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
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. | ||
8 | */ | ||
9 | |||
10 | #ifndef LOCK_DLM_DOT_H | ||
11 | #define LOCK_DLM_DOT_H | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/spinlock.h> | ||
16 | #include <linux/types.h> | ||
17 | #include <linux/string.h> | ||
18 | #include <linux/list.h> | ||
19 | #include <linux/socket.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/kthread.h> | ||
22 | #include <linux/kobject.h> | ||
23 | #include <linux/fcntl.h> | ||
24 | #include <linux/wait.h> | ||
25 | #include <net/sock.h> | ||
26 | |||
27 | #include <linux/dlm.h> | ||
28 | #include <linux/dlm_plock.h> | ||
29 | #include <linux/lm_interface.h> | ||
30 | |||
31 | /* | ||
32 | * Internally, we prefix things with gdlm_ and GDLM_ (for gfs-dlm) since a | ||
33 | * prefix of lock_dlm_ gets awkward. Externally, GFS refers to this module | ||
34 | * as "lock_dlm". | ||
35 | */ | ||
36 | |||
37 | #define GDLM_STRNAME_BYTES 24 | ||
38 | #define GDLM_LVB_SIZE 32 | ||
39 | #define GDLM_DROP_COUNT 0 | ||
40 | #define GDLM_DROP_PERIOD 60 | ||
41 | #define GDLM_NAME_LEN 128 | ||
42 | |||
43 | /* GFS uses 12 bytes to identify a resource (32 bit type + 64 bit number). | ||
44 | We sprintf these numbers into a 24 byte string of hex values to make them | ||
45 | human-readable (to make debugging simpler.) */ | ||
46 | |||
47 | struct gdlm_strname { | ||
48 | unsigned char name[GDLM_STRNAME_BYTES]; | ||
49 | unsigned short namelen; | ||
50 | }; | ||
51 | |||
52 | enum { | ||
53 | DFL_BLOCK_LOCKS = 0, | ||
54 | DFL_SPECTATOR = 1, | ||
55 | DFL_WITHDRAW = 2, | ||
56 | }; | ||
57 | |||
58 | struct gdlm_ls { | ||
59 | u32 id; | ||
60 | int jid; | ||
61 | int first; | ||
62 | int first_done; | ||
63 | unsigned long flags; | ||
64 | struct kobject kobj; | ||
65 | char clustername[GDLM_NAME_LEN]; | ||
66 | char fsname[GDLM_NAME_LEN]; | ||
67 | int fsflags; | ||
68 | dlm_lockspace_t *dlm_lockspace; | ||
69 | lm_callback_t fscb; | ||
70 | struct gfs2_sbd *sdp; | ||
71 | int recover_jid; | ||
72 | int recover_jid_done; | ||
73 | int recover_jid_status; | ||
74 | spinlock_t async_lock; | ||
75 | struct list_head delayed; | ||
76 | struct list_head submit; | ||
77 | u32 all_locks_count; | ||
78 | wait_queue_head_t wait_control; | ||
79 | struct task_struct *thread; | ||
80 | wait_queue_head_t thread_wait; | ||
81 | }; | ||
82 | |||
83 | enum { | ||
84 | LFL_NOBLOCK = 0, | ||
85 | LFL_NOCACHE = 1, | ||
86 | LFL_DLM_UNLOCK = 2, | ||
87 | LFL_DLM_CANCEL = 3, | ||
88 | LFL_SYNC_LVB = 4, | ||
89 | LFL_FORCE_PROMOTE = 5, | ||
90 | LFL_REREQUEST = 6, | ||
91 | LFL_ACTIVE = 7, | ||
92 | LFL_INLOCK = 8, | ||
93 | LFL_CANCEL = 9, | ||
94 | LFL_NOBAST = 10, | ||
95 | LFL_HEADQUE = 11, | ||
96 | LFL_UNLOCK_DELETE = 12, | ||
97 | LFL_AST_WAIT = 13, | ||
98 | }; | ||
99 | |||
100 | struct gdlm_lock { | ||
101 | struct gdlm_ls *ls; | ||
102 | struct lm_lockname lockname; | ||
103 | struct gdlm_strname strname; | ||
104 | char *lvb; | ||
105 | struct dlm_lksb lksb; | ||
106 | |||
107 | s16 cur; | ||
108 | s16 req; | ||
109 | s16 prev_req; | ||
110 | u32 lkf; /* dlm flags DLM_LKF_ */ | ||
111 | unsigned long flags; /* lock_dlm flags LFL_ */ | ||
112 | |||
113 | struct list_head delay_list; /* delayed */ | ||
114 | struct gdlm_lock *hold_null; /* NL lock for hold_lvb */ | ||
115 | }; | ||
116 | |||
117 | #define gdlm_assert(assertion, fmt, args...) \ | ||
118 | do { \ | ||
119 | if (unlikely(!(assertion))) { \ | ||
120 | printk(KERN_EMERG "lock_dlm: fatal assertion failed \"%s\"\n" \ | ||
121 | "lock_dlm: " fmt "\n", \ | ||
122 | #assertion, ##args); \ | ||
123 | BUG(); \ | ||
124 | } \ | ||
125 | } while (0) | ||
126 | |||
127 | #define log_print(lev, fmt, arg...) printk(lev "lock_dlm: " fmt "\n" , ## arg) | ||
128 | #define log_info(fmt, arg...) log_print(KERN_INFO , fmt , ## arg) | ||
129 | #define log_error(fmt, arg...) log_print(KERN_ERR , fmt , ## arg) | ||
130 | #ifdef LOCK_DLM_LOG_DEBUG | ||
131 | #define log_debug(fmt, arg...) log_print(KERN_DEBUG , fmt , ## arg) | ||
132 | #else | ||
133 | #define log_debug(fmt, arg...) | ||
134 | #endif | ||
135 | |||
136 | /* sysfs.c */ | ||
137 | |||
138 | int gdlm_sysfs_init(void); | ||
139 | void gdlm_sysfs_exit(void); | ||
140 | int gdlm_kobject_setup(struct gdlm_ls *, struct kobject *); | ||
141 | void gdlm_kobject_release(struct gdlm_ls *); | ||
142 | |||
143 | /* thread.c */ | ||
144 | |||
145 | int gdlm_init_threads(struct gdlm_ls *); | ||
146 | void gdlm_release_threads(struct gdlm_ls *); | ||
147 | |||
148 | /* lock.c */ | ||
149 | |||
150 | void gdlm_submit_delayed(struct gdlm_ls *); | ||
151 | unsigned int gdlm_do_lock(struct gdlm_lock *); | ||
152 | |||
153 | int gdlm_get_lock(void *, struct lm_lockname *, void **); | ||
154 | void gdlm_put_lock(void *); | ||
155 | unsigned int gdlm_lock(void *, unsigned int, unsigned int, unsigned int); | ||
156 | unsigned int gdlm_unlock(void *, unsigned int); | ||
157 | void gdlm_cancel(void *); | ||
158 | int gdlm_hold_lvb(void *, char **); | ||
159 | void gdlm_unhold_lvb(void *, char *); | ||
160 | |||
161 | /* mount.c */ | ||
162 | |||
163 | extern const struct lm_lockops gdlm_ops; | ||
164 | |||
165 | #endif | ||
166 | |||
diff --git a/fs/gfs2/locking/dlm/main.c b/fs/gfs2/locking/dlm/main.c deleted file mode 100644 index b9a03a7ff801..000000000000 --- a/fs/gfs2/locking/dlm/main.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
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. | ||
8 | */ | ||
9 | |||
10 | #include <linux/init.h> | ||
11 | |||
12 | #include "lock_dlm.h" | ||
13 | |||
14 | static int __init init_lock_dlm(void) | ||
15 | { | ||
16 | int error; | ||
17 | |||
18 | error = gfs2_register_lockproto(&gdlm_ops); | ||
19 | if (error) { | ||
20 | printk(KERN_WARNING "lock_dlm: can't register protocol: %d\n", | ||
21 | error); | ||
22 | return error; | ||
23 | } | ||
24 | |||
25 | error = gdlm_sysfs_init(); | ||
26 | if (error) { | ||
27 | gfs2_unregister_lockproto(&gdlm_ops); | ||
28 | return error; | ||
29 | } | ||
30 | |||
31 | printk(KERN_INFO | ||
32 | "Lock_DLM (built %s %s) installed\n", __DATE__, __TIME__); | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | static void __exit exit_lock_dlm(void) | ||
37 | { | ||
38 | gdlm_sysfs_exit(); | ||
39 | gfs2_unregister_lockproto(&gdlm_ops); | ||
40 | } | ||
41 | |||
42 | module_init(init_lock_dlm); | ||
43 | module_exit(exit_lock_dlm); | ||
44 | |||
45 | MODULE_DESCRIPTION("GFS DLM Locking Module"); | ||
46 | MODULE_AUTHOR("Red Hat, Inc."); | ||
47 | MODULE_LICENSE("GPL"); | ||
48 | |||
diff --git a/fs/gfs2/locking/dlm/mount.c b/fs/gfs2/locking/dlm/mount.c deleted file mode 100644 index 1aa7eb6a0226..000000000000 --- a/fs/gfs2/locking/dlm/mount.c +++ /dev/null | |||
@@ -1,276 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
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. | ||
8 | */ | ||
9 | |||
10 | #include "lock_dlm.h" | ||
11 | |||
12 | const struct lm_lockops gdlm_ops; | ||
13 | |||
14 | |||
15 | static struct gdlm_ls *init_gdlm(lm_callback_t cb, struct gfs2_sbd *sdp, | ||
16 | int flags, char *table_name) | ||
17 | { | ||
18 | struct gdlm_ls *ls; | ||
19 | char buf[256], *p; | ||
20 | |||
21 | ls = kzalloc(sizeof(struct gdlm_ls), GFP_KERNEL); | ||
22 | if (!ls) | ||
23 | return NULL; | ||
24 | |||
25 | ls->fscb = cb; | ||
26 | ls->sdp = sdp; | ||
27 | ls->fsflags = flags; | ||
28 | spin_lock_init(&ls->async_lock); | ||
29 | INIT_LIST_HEAD(&ls->delayed); | ||
30 | INIT_LIST_HEAD(&ls->submit); | ||
31 | init_waitqueue_head(&ls->thread_wait); | ||
32 | init_waitqueue_head(&ls->wait_control); | ||
33 | ls->jid = -1; | ||
34 | |||
35 | strncpy(buf, table_name, 256); | ||
36 | buf[255] = '\0'; | ||
37 | |||
38 | p = strchr(buf, ':'); | ||
39 | if (!p) { | ||
40 | log_info("invalid table_name \"%s\"", table_name); | ||
41 | kfree(ls); | ||
42 | return NULL; | ||
43 | } | ||
44 | *p = '\0'; | ||
45 | p++; | ||
46 | |||
47 | strncpy(ls->clustername, buf, GDLM_NAME_LEN); | ||
48 | strncpy(ls->fsname, p, GDLM_NAME_LEN); | ||
49 | |||
50 | return ls; | ||
51 | } | ||
52 | |||
53 | static int make_args(struct gdlm_ls *ls, char *data_arg, int *nodir) | ||
54 | { | ||
55 | char data[256]; | ||
56 | char *options, *x, *y; | ||
57 | int error = 0; | ||
58 | |||
59 | memset(data, 0, 256); | ||
60 | strncpy(data, data_arg, 255); | ||
61 | |||
62 | if (!strlen(data)) { | ||
63 | log_error("no mount options, (u)mount helpers not installed"); | ||
64 | return -EINVAL; | ||
65 | } | ||
66 | |||
67 | for (options = data; (x = strsep(&options, ":")); ) { | ||
68 | if (!*x) | ||
69 | continue; | ||
70 | |||
71 | y = strchr(x, '='); | ||
72 | if (y) | ||
73 | *y++ = 0; | ||
74 | |||
75 | if (!strcmp(x, "jid")) { | ||
76 | if (!y) { | ||
77 | log_error("need argument to jid"); | ||
78 | error = -EINVAL; | ||
79 | break; | ||
80 | } | ||
81 | sscanf(y, "%u", &ls->jid); | ||
82 | |||
83 | } else if (!strcmp(x, "first")) { | ||
84 | if (!y) { | ||
85 | log_error("need argument to first"); | ||
86 | error = -EINVAL; | ||
87 | break; | ||
88 | } | ||
89 | sscanf(y, "%u", &ls->first); | ||
90 | |||
91 | } else if (!strcmp(x, "id")) { | ||
92 | if (!y) { | ||
93 | log_error("need argument to id"); | ||
94 | error = -EINVAL; | ||
95 | break; | ||
96 | } | ||
97 | sscanf(y, "%u", &ls->id); | ||
98 | |||
99 | } else if (!strcmp(x, "nodir")) { | ||
100 | if (!y) { | ||
101 | log_error("need argument to nodir"); | ||
102 | error = -EINVAL; | ||
103 | break; | ||
104 | } | ||
105 | sscanf(y, "%u", nodir); | ||
106 | |||
107 | } else { | ||
108 | log_error("unkonwn option: %s", x); | ||
109 | error = -EINVAL; | ||
110 | break; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | return error; | ||
115 | } | ||
116 | |||
117 | static int gdlm_mount(char *table_name, char *host_data, | ||
118 | lm_callback_t cb, void *cb_data, | ||
119 | unsigned int min_lvb_size, int flags, | ||
120 | struct lm_lockstruct *lockstruct, | ||
121 | struct kobject *fskobj) | ||
122 | { | ||
123 | struct gdlm_ls *ls; | ||
124 | int error = -ENOMEM, nodir = 0; | ||
125 | |||
126 | if (min_lvb_size > GDLM_LVB_SIZE) | ||
127 | goto out; | ||
128 | |||
129 | ls = init_gdlm(cb, cb_data, flags, table_name); | ||
130 | if (!ls) | ||
131 | goto out; | ||
132 | |||
133 | error = make_args(ls, host_data, &nodir); | ||
134 | if (error) | ||
135 | goto out; | ||
136 | |||
137 | error = gdlm_init_threads(ls); | ||
138 | if (error) | ||
139 | goto out_free; | ||
140 | |||
141 | error = gdlm_kobject_setup(ls, fskobj); | ||
142 | if (error) | ||
143 | goto out_thread; | ||
144 | |||
145 | error = dlm_new_lockspace(ls->fsname, strlen(ls->fsname), | ||
146 | &ls->dlm_lockspace, | ||
147 | DLM_LSFL_FS | DLM_LSFL_NEWEXCL | | ||
148 | (nodir ? DLM_LSFL_NODIR : 0), | ||
149 | GDLM_LVB_SIZE); | ||
150 | if (error) { | ||
151 | log_error("dlm_new_lockspace error %d", error); | ||
152 | goto out_kobj; | ||
153 | } | ||
154 | |||
155 | lockstruct->ls_jid = ls->jid; | ||
156 | lockstruct->ls_first = ls->first; | ||
157 | lockstruct->ls_lockspace = ls; | ||
158 | lockstruct->ls_ops = &gdlm_ops; | ||
159 | lockstruct->ls_flags = 0; | ||
160 | lockstruct->ls_lvb_size = GDLM_LVB_SIZE; | ||
161 | return 0; | ||
162 | |||
163 | out_kobj: | ||
164 | gdlm_kobject_release(ls); | ||
165 | out_thread: | ||
166 | gdlm_release_threads(ls); | ||
167 | out_free: | ||
168 | kfree(ls); | ||
169 | out: | ||
170 | return error; | ||
171 | } | ||
172 | |||
173 | static void gdlm_unmount(void *lockspace) | ||
174 | { | ||
175 | struct gdlm_ls *ls = lockspace; | ||
176 | |||
177 | log_debug("unmount flags %lx", ls->flags); | ||
178 | |||
179 | /* FIXME: serialize unmount and withdraw in case they | ||
180 | happen at once. Also, if unmount follows withdraw, | ||
181 | wait for withdraw to finish. */ | ||
182 | |||
183 | if (test_bit(DFL_WITHDRAW, &ls->flags)) | ||
184 | goto out; | ||
185 | |||
186 | gdlm_kobject_release(ls); | ||
187 | dlm_release_lockspace(ls->dlm_lockspace, 2); | ||
188 | gdlm_release_threads(ls); | ||
189 | BUG_ON(ls->all_locks_count); | ||
190 | out: | ||
191 | kfree(ls); | ||
192 | } | ||
193 | |||
194 | static void gdlm_recovery_done(void *lockspace, unsigned int jid, | ||
195 | unsigned int message) | ||
196 | { | ||
197 | char env_jid[20]; | ||
198 | char env_status[20]; | ||
199 | char *envp[] = { env_jid, env_status, NULL }; | ||
200 | struct gdlm_ls *ls = lockspace; | ||
201 | ls->recover_jid_done = jid; | ||
202 | ls->recover_jid_status = message; | ||
203 | sprintf(env_jid, "JID=%d", jid); | ||
204 | sprintf(env_status, "RECOVERY=%s", | ||
205 | message == LM_RD_SUCCESS ? "Done" : "Failed"); | ||
206 | kobject_uevent_env(&ls->kobj, KOBJ_CHANGE, envp); | ||
207 | } | ||
208 | |||
209 | static void gdlm_others_may_mount(void *lockspace) | ||
210 | { | ||
211 | char *message = "FIRSTMOUNT=Done"; | ||
212 | char *envp[] = { message, NULL }; | ||
213 | struct gdlm_ls *ls = lockspace; | ||
214 | ls->first_done = 1; | ||
215 | kobject_uevent_env(&ls->kobj, KOBJ_CHANGE, envp); | ||
216 | } | ||
217 | |||
218 | /* Userspace gets the offline uevent, blocks new gfs locks on | ||
219 | other mounters, and lets us know (sets WITHDRAW flag). Then, | ||
220 | userspace leaves the mount group while we leave the lockspace. */ | ||
221 | |||
222 | static void gdlm_withdraw(void *lockspace) | ||
223 | { | ||
224 | struct gdlm_ls *ls = lockspace; | ||
225 | |||
226 | kobject_uevent(&ls->kobj, KOBJ_OFFLINE); | ||
227 | |||
228 | wait_event_interruptible(ls->wait_control, | ||
229 | test_bit(DFL_WITHDRAW, &ls->flags)); | ||
230 | |||
231 | dlm_release_lockspace(ls->dlm_lockspace, 2); | ||
232 | gdlm_release_threads(ls); | ||
233 | gdlm_kobject_release(ls); | ||
234 | } | ||
235 | |||
236 | static int gdlm_plock(void *lockspace, struct lm_lockname *name, | ||
237 | struct file *file, int cmd, struct file_lock *fl) | ||
238 | { | ||
239 | struct gdlm_ls *ls = lockspace; | ||
240 | return dlm_posix_lock(ls->dlm_lockspace, name->ln_number, file, cmd, fl); | ||
241 | } | ||
242 | |||
243 | static int gdlm_punlock(void *lockspace, struct lm_lockname *name, | ||
244 | struct file *file, struct file_lock *fl) | ||
245 | { | ||
246 | struct gdlm_ls *ls = lockspace; | ||
247 | return dlm_posix_unlock(ls->dlm_lockspace, name->ln_number, file, fl); | ||
248 | } | ||
249 | |||
250 | static int gdlm_plock_get(void *lockspace, struct lm_lockname *name, | ||
251 | struct file *file, struct file_lock *fl) | ||
252 | { | ||
253 | struct gdlm_ls *ls = lockspace; | ||
254 | return dlm_posix_get(ls->dlm_lockspace, name->ln_number, file, fl); | ||
255 | } | ||
256 | |||
257 | const struct lm_lockops gdlm_ops = { | ||
258 | .lm_proto_name = "lock_dlm", | ||
259 | .lm_mount = gdlm_mount, | ||
260 | .lm_others_may_mount = gdlm_others_may_mount, | ||
261 | .lm_unmount = gdlm_unmount, | ||
262 | .lm_withdraw = gdlm_withdraw, | ||
263 | .lm_get_lock = gdlm_get_lock, | ||
264 | .lm_put_lock = gdlm_put_lock, | ||
265 | .lm_lock = gdlm_lock, | ||
266 | .lm_unlock = gdlm_unlock, | ||
267 | .lm_plock = gdlm_plock, | ||
268 | .lm_punlock = gdlm_punlock, | ||
269 | .lm_plock_get = gdlm_plock_get, | ||
270 | .lm_cancel = gdlm_cancel, | ||
271 | .lm_hold_lvb = gdlm_hold_lvb, | ||
272 | .lm_unhold_lvb = gdlm_unhold_lvb, | ||
273 | .lm_recovery_done = gdlm_recovery_done, | ||
274 | .lm_owner = THIS_MODULE, | ||
275 | }; | ||
276 | |||
diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c deleted file mode 100644 index 9b7edcf7bd49..000000000000 --- a/fs/gfs2/locking/dlm/sysfs.c +++ /dev/null | |||
@@ -1,226 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
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. | ||
8 | */ | ||
9 | |||
10 | #include <linux/ctype.h> | ||
11 | #include <linux/stat.h> | ||
12 | |||
13 | #include "lock_dlm.h" | ||
14 | |||
15 | static ssize_t proto_name_show(struct gdlm_ls *ls, char *buf) | ||
16 | { | ||
17 | return sprintf(buf, "%s\n", gdlm_ops.lm_proto_name); | ||
18 | } | ||
19 | |||
20 | static ssize_t block_show(struct gdlm_ls *ls, char *buf) | ||
21 | { | ||
22 | ssize_t ret; | ||
23 | int val = 0; | ||
24 | |||
25 | if (test_bit(DFL_BLOCK_LOCKS, &ls->flags)) | ||
26 | val = 1; | ||
27 | ret = sprintf(buf, "%d\n", val); | ||
28 | return ret; | ||
29 | } | ||
30 | |||
31 | static ssize_t block_store(struct gdlm_ls *ls, const char *buf, size_t len) | ||
32 | { | ||
33 | ssize_t ret = len; | ||
34 | int val; | ||
35 | |||
36 | val = simple_strtol(buf, NULL, 0); | ||
37 | |||
38 | if (val == 1) | ||
39 | set_bit(DFL_BLOCK_LOCKS, &ls->flags); | ||
40 | else if (val == 0) { | ||
41 | clear_bit(DFL_BLOCK_LOCKS, &ls->flags); | ||
42 | gdlm_submit_delayed(ls); | ||
43 | } else { | ||
44 | ret = -EINVAL; | ||
45 | } | ||
46 | return ret; | ||
47 | } | ||
48 | |||
49 | static ssize_t withdraw_show(struct gdlm_ls *ls, char *buf) | ||
50 | { | ||
51 | ssize_t ret; | ||
52 | int val = 0; | ||
53 | |||
54 | if (test_bit(DFL_WITHDRAW, &ls->flags)) | ||
55 | val = 1; | ||
56 | ret = sprintf(buf, "%d\n", val); | ||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | static ssize_t withdraw_store(struct gdlm_ls *ls, const char *buf, size_t len) | ||
61 | { | ||
62 | ssize_t ret = len; | ||
63 | int val; | ||
64 | |||
65 | val = simple_strtol(buf, NULL, 0); | ||
66 | |||
67 | if (val == 1) | ||
68 | set_bit(DFL_WITHDRAW, &ls->flags); | ||
69 | else | ||
70 | ret = -EINVAL; | ||
71 | wake_up(&ls->wait_control); | ||
72 | return ret; | ||
73 | } | ||
74 | |||
75 | static ssize_t id_show(struct gdlm_ls *ls, char *buf) | ||
76 | { | ||
77 | return sprintf(buf, "%u\n", ls->id); | ||
78 | } | ||
79 | |||
80 | static ssize_t jid_show(struct gdlm_ls *ls, char *buf) | ||
81 | { | ||
82 | return sprintf(buf, "%d\n", ls->jid); | ||
83 | } | ||
84 | |||
85 | static ssize_t first_show(struct gdlm_ls *ls, char *buf) | ||
86 | { | ||
87 | return sprintf(buf, "%d\n", ls->first); | ||
88 | } | ||
89 | |||
90 | static ssize_t first_done_show(struct gdlm_ls *ls, char *buf) | ||
91 | { | ||
92 | return sprintf(buf, "%d\n", ls->first_done); | ||
93 | } | ||
94 | |||
95 | static ssize_t recover_show(struct gdlm_ls *ls, char *buf) | ||
96 | { | ||
97 | return sprintf(buf, "%d\n", ls->recover_jid); | ||
98 | } | ||
99 | |||
100 | static ssize_t recover_store(struct gdlm_ls *ls, const char *buf, size_t len) | ||
101 | { | ||
102 | ls->recover_jid = simple_strtol(buf, NULL, 0); | ||
103 | ls->fscb(ls->sdp, LM_CB_NEED_RECOVERY, &ls->recover_jid); | ||
104 | return len; | ||
105 | } | ||
106 | |||
107 | static ssize_t recover_done_show(struct gdlm_ls *ls, char *buf) | ||
108 | { | ||
109 | return sprintf(buf, "%d\n", ls->recover_jid_done); | ||
110 | } | ||
111 | |||
112 | static ssize_t recover_status_show(struct gdlm_ls *ls, char *buf) | ||
113 | { | ||
114 | return sprintf(buf, "%d\n", ls->recover_jid_status); | ||
115 | } | ||
116 | |||
117 | struct gdlm_attr { | ||
118 | struct attribute attr; | ||
119 | ssize_t (*show)(struct gdlm_ls *, char *); | ||
120 | ssize_t (*store)(struct gdlm_ls *, const char *, size_t); | ||
121 | }; | ||
122 | |||
123 | #define GDLM_ATTR(_name,_mode,_show,_store) \ | ||
124 | static struct gdlm_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
125 | |||
126 | GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); | ||
127 | GDLM_ATTR(block, 0644, block_show, block_store); | ||
128 | GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store); | ||
129 | GDLM_ATTR(id, 0444, id_show, NULL); | ||
130 | GDLM_ATTR(jid, 0444, jid_show, NULL); | ||
131 | GDLM_ATTR(first, 0444, first_show, NULL); | ||
132 | GDLM_ATTR(first_done, 0444, first_done_show, NULL); | ||
133 | GDLM_ATTR(recover, 0644, recover_show, recover_store); | ||
134 | GDLM_ATTR(recover_done, 0444, recover_done_show, NULL); | ||
135 | GDLM_ATTR(recover_status, 0444, recover_status_show, NULL); | ||
136 | |||
137 | static struct attribute *gdlm_attrs[] = { | ||
138 | &gdlm_attr_proto_name.attr, | ||
139 | &gdlm_attr_block.attr, | ||
140 | &gdlm_attr_withdraw.attr, | ||
141 | &gdlm_attr_id.attr, | ||
142 | &gdlm_attr_jid.attr, | ||
143 | &gdlm_attr_first.attr, | ||
144 | &gdlm_attr_first_done.attr, | ||
145 | &gdlm_attr_recover.attr, | ||
146 | &gdlm_attr_recover_done.attr, | ||
147 | &gdlm_attr_recover_status.attr, | ||
148 | NULL, | ||
149 | }; | ||
150 | |||
151 | static ssize_t gdlm_attr_show(struct kobject *kobj, struct attribute *attr, | ||
152 | char *buf) | ||
153 | { | ||
154 | struct gdlm_ls *ls = container_of(kobj, struct gdlm_ls, kobj); | ||
155 | struct gdlm_attr *a = container_of(attr, struct gdlm_attr, attr); | ||
156 | return a->show ? a->show(ls, buf) : 0; | ||
157 | } | ||
158 | |||
159 | static ssize_t gdlm_attr_store(struct kobject *kobj, struct attribute *attr, | ||
160 | const char *buf, size_t len) | ||
161 | { | ||
162 | struct gdlm_ls *ls = container_of(kobj, struct gdlm_ls, kobj); | ||
163 | struct gdlm_attr *a = container_of(attr, struct gdlm_attr, attr); | ||
164 | return a->store ? a->store(ls, buf, len) : len; | ||
165 | } | ||
166 | |||
167 | static struct sysfs_ops gdlm_attr_ops = { | ||
168 | .show = gdlm_attr_show, | ||
169 | .store = gdlm_attr_store, | ||
170 | }; | ||
171 | |||
172 | static struct kobj_type gdlm_ktype = { | ||
173 | .default_attrs = gdlm_attrs, | ||
174 | .sysfs_ops = &gdlm_attr_ops, | ||
175 | }; | ||
176 | |||
177 | static struct kset *gdlm_kset; | ||
178 | |||
179 | int gdlm_kobject_setup(struct gdlm_ls *ls, struct kobject *fskobj) | ||
180 | { | ||
181 | int error; | ||
182 | |||
183 | ls->kobj.kset = gdlm_kset; | ||
184 | error = kobject_init_and_add(&ls->kobj, &gdlm_ktype, fskobj, | ||
185 | "lock_module"); | ||
186 | if (error) | ||
187 | log_error("can't register kobj %d", error); | ||
188 | kobject_uevent(&ls->kobj, KOBJ_ADD); | ||
189 | |||
190 | return error; | ||
191 | } | ||
192 | |||
193 | void gdlm_kobject_release(struct gdlm_ls *ls) | ||
194 | { | ||
195 | kobject_put(&ls->kobj); | ||
196 | } | ||
197 | |||
198 | static int gdlm_uevent(struct kset *kset, struct kobject *kobj, | ||
199 | struct kobj_uevent_env *env) | ||
200 | { | ||
201 | struct gdlm_ls *ls = container_of(kobj, struct gdlm_ls, kobj); | ||
202 | add_uevent_var(env, "LOCKTABLE=%s:%s", ls->clustername, ls->fsname); | ||
203 | add_uevent_var(env, "LOCKPROTO=lock_dlm"); | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | static struct kset_uevent_ops gdlm_uevent_ops = { | ||
208 | .uevent = gdlm_uevent, | ||
209 | }; | ||
210 | |||
211 | |||
212 | int gdlm_sysfs_init(void) | ||
213 | { | ||
214 | gdlm_kset = kset_create_and_add("lock_dlm", &gdlm_uevent_ops, kernel_kobj); | ||
215 | if (!gdlm_kset) { | ||
216 | printk(KERN_WARNING "%s: can not create kset\n", __func__); | ||
217 | return -ENOMEM; | ||
218 | } | ||
219 | return 0; | ||
220 | } | ||
221 | |||
222 | void gdlm_sysfs_exit(void) | ||
223 | { | ||
224 | kset_unregister(gdlm_kset); | ||
225 | } | ||
226 | |||
diff --git a/fs/gfs2/locking/dlm/thread.c b/fs/gfs2/locking/dlm/thread.c deleted file mode 100644 index 38823efd698c..000000000000 --- a/fs/gfs2/locking/dlm/thread.c +++ /dev/null | |||
@@ -1,68 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | ||
3 | * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. | ||
4 | * | ||
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. | ||
8 | */ | ||
9 | |||
10 | #include "lock_dlm.h" | ||
11 | |||
12 | static inline int no_work(struct gdlm_ls *ls) | ||
13 | { | ||
14 | int ret; | ||
15 | |||
16 | spin_lock(&ls->async_lock); | ||
17 | ret = list_empty(&ls->submit); | ||
18 | spin_unlock(&ls->async_lock); | ||
19 | |||
20 | return ret; | ||
21 | } | ||
22 | |||
23 | static int gdlm_thread(void *data) | ||
24 | { | ||
25 | struct gdlm_ls *ls = (struct gdlm_ls *) data; | ||
26 | struct gdlm_lock *lp = NULL; | ||
27 | |||
28 | while (!kthread_should_stop()) { | ||
29 | wait_event_interruptible(ls->thread_wait, | ||
30 | !no_work(ls) || kthread_should_stop()); | ||
31 | |||
32 | spin_lock(&ls->async_lock); | ||
33 | |||
34 | if (!list_empty(&ls->submit)) { | ||
35 | lp = list_entry(ls->submit.next, struct gdlm_lock, | ||
36 | delay_list); | ||
37 | list_del_init(&lp->delay_list); | ||
38 | spin_unlock(&ls->async_lock); | ||
39 | gdlm_do_lock(lp); | ||
40 | spin_lock(&ls->async_lock); | ||
41 | } | ||
42 | spin_unlock(&ls->async_lock); | ||
43 | } | ||
44 | |||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | int gdlm_init_threads(struct gdlm_ls *ls) | ||
49 | { | ||
50 | struct task_struct *p; | ||
51 | int error; | ||
52 | |||
53 | p = kthread_run(gdlm_thread, ls, "lock_dlm"); | ||
54 | error = IS_ERR(p); | ||
55 | if (error) { | ||
56 | log_error("can't start lock_dlm thread %d", error); | ||
57 | return error; | ||
58 | } | ||
59 | ls->thread = p; | ||
60 | |||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | void gdlm_release_threads(struct gdlm_ls *ls) | ||
65 | { | ||
66 | kthread_stop(ls->thread); | ||
67 | } | ||
68 | |||
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index ad305854bdc6..98918a756410 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
15 | #include <linux/gfs2_ondisk.h> | 15 | #include <linux/gfs2_ondisk.h> |
16 | #include <linux/crc32.h> | 16 | #include <linux/crc32.h> |
17 | #include <linux/lm_interface.h> | ||
18 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
19 | #include <linux/kthread.h> | 18 | #include <linux/kthread.h> |
20 | #include <linux/freezer.h> | 19 | #include <linux/freezer.h> |
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index 4390f6f4047d..80e4f5f898bb 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/completion.h> | 13 | #include <linux/completion.h> |
14 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
15 | #include <linux/gfs2_ondisk.h> | 15 | #include <linux/gfs2_ondisk.h> |
16 | #include <linux/lm_interface.h> | ||
17 | 16 | ||
18 | #include "gfs2.h" | 17 | #include "gfs2.h" |
19 | #include "incore.h" | 18 | #include "incore.h" |
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 86fe06798711..a6892ed0840a 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/gfs2_ondisk.h> | 16 | #include <linux/gfs2_ondisk.h> |
17 | #include <linux/lm_interface.h> | ||
18 | #include <asm/atomic.h> | 17 | #include <asm/atomic.h> |
19 | 18 | ||
20 | #include "gfs2.h" | 19 | #include "gfs2.h" |
@@ -47,8 +46,6 @@ static void gfs2_init_glock_once(void *foo) | |||
47 | INIT_HLIST_NODE(&gl->gl_list); | 46 | INIT_HLIST_NODE(&gl->gl_list); |
48 | spin_lock_init(&gl->gl_spin); | 47 | spin_lock_init(&gl->gl_spin); |
49 | INIT_LIST_HEAD(&gl->gl_holders); | 48 | INIT_LIST_HEAD(&gl->gl_holders); |
50 | gl->gl_lvb = NULL; | ||
51 | atomic_set(&gl->gl_lvb_count, 0); | ||
52 | INIT_LIST_HEAD(&gl->gl_lru); | 49 | INIT_LIST_HEAD(&gl->gl_lru); |
53 | INIT_LIST_HEAD(&gl->gl_ail_list); | 50 | INIT_LIST_HEAD(&gl->gl_ail_list); |
54 | atomic_set(&gl->gl_ail_count, 0); | 51 | atomic_set(&gl->gl_ail_count, 0); |
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c index 09853620c951..870d65ae7ae2 100644 --- a/fs/gfs2/meta_io.c +++ b/fs/gfs2/meta_io.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/bio.h> | 20 | #include <linux/bio.h> |
21 | #include <linux/gfs2_ondisk.h> | 21 | #include <linux/gfs2_ondisk.h> |
22 | #include <linux/lm_interface.h> | ||
23 | 22 | ||
24 | #include "gfs2.h" | 23 | #include "gfs2.h" |
25 | #include "incore.h" | 24 | #include "incore.h" |
diff --git a/fs/gfs2/mount.c b/fs/gfs2/mount.c index 3524ae81189b..fba502aa8b2d 100644 --- a/fs/gfs2/mount.c +++ b/fs/gfs2/mount.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/completion.h> | 12 | #include <linux/completion.h> |
13 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
14 | #include <linux/gfs2_ondisk.h> | 14 | #include <linux/gfs2_ondisk.h> |
15 | #include <linux/lm_interface.h> | ||
16 | #include <linux/parser.h> | 15 | #include <linux/parser.h> |
17 | 16 | ||
18 | #include "gfs2.h" | 17 | #include "gfs2.h" |
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c index dde4ead2c3be..a6d00e8ffe10 100644 --- a/fs/gfs2/ops_address.c +++ b/fs/gfs2/ops_address.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/writeback.h> | 19 | #include <linux/writeback.h> |
20 | #include <linux/swap.h> | 20 | #include <linux/swap.h> |
21 | #include <linux/gfs2_ondisk.h> | 21 | #include <linux/gfs2_ondisk.h> |
22 | #include <linux/lm_interface.h> | ||
23 | #include <linux/backing-dev.h> | 22 | #include <linux/backing-dev.h> |
24 | 23 | ||
25 | #include "gfs2.h" | 24 | #include "gfs2.h" |
diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c index c2ad36330ca3..5eb57b044382 100644 --- a/fs/gfs2/ops_dentry.c +++ b/fs/gfs2/ops_dentry.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
14 | #include <linux/gfs2_ondisk.h> | 14 | #include <linux/gfs2_ondisk.h> |
15 | #include <linux/crc32.h> | 15 | #include <linux/crc32.h> |
16 | #include <linux/lm_interface.h> | ||
17 | 16 | ||
18 | #include "gfs2.h" | 17 | #include "gfs2.h" |
19 | #include "incore.h" | 18 | #include "incore.h" |
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c index 7fdeb14ddd1a..9200ef221716 100644 --- a/fs/gfs2/ops_export.c +++ b/fs/gfs2/ops_export.c | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/exportfs.h> | 14 | #include <linux/exportfs.h> |
15 | #include <linux/gfs2_ondisk.h> | 15 | #include <linux/gfs2_ondisk.h> |
16 | #include <linux/crc32.h> | 16 | #include <linux/crc32.h> |
17 | #include <linux/lm_interface.h> | ||
18 | 17 | ||
19 | #include "gfs2.h" | 18 | #include "gfs2.h" |
20 | #include "incore.h" | 19 | #include "incore.h" |
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 93fe41b67f97..99d726f1c7a6 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c | |||
@@ -20,9 +20,10 @@ | |||
20 | #include <linux/gfs2_ondisk.h> | 20 | #include <linux/gfs2_ondisk.h> |
21 | #include <linux/ext2_fs.h> | 21 | #include <linux/ext2_fs.h> |
22 | #include <linux/crc32.h> | 22 | #include <linux/crc32.h> |
23 | #include <linux/lm_interface.h> | ||
24 | #include <linux/writeback.h> | 23 | #include <linux/writeback.h> |
25 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
25 | #include <linux/dlm.h> | ||
26 | #include <linux/dlm_plock.h> | ||
26 | 27 | ||
27 | #include "gfs2.h" | 28 | #include "gfs2.h" |
28 | #include "incore.h" | 29 | #include "incore.h" |
@@ -560,57 +561,24 @@ static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) | |||
560 | return ret; | 561 | return ret; |
561 | } | 562 | } |
562 | 563 | ||
564 | #ifdef CONFIG_GFS2_FS_LOCKING_DLM | ||
565 | |||
563 | /** | 566 | /** |
564 | * gfs2_setlease - acquire/release a file lease | 567 | * gfs2_setlease - acquire/release a file lease |
565 | * @file: the file pointer | 568 | * @file: the file pointer |
566 | * @arg: lease type | 569 | * @arg: lease type |
567 | * @fl: file lock | 570 | * @fl: file lock |
568 | * | 571 | * |
572 | * We don't currently have a way to enforce a lease across the whole | ||
573 | * cluster; until we do, disable leases (by just returning -EINVAL), | ||
574 | * unless the administrator has requested purely local locking. | ||
575 | * | ||
569 | * Returns: errno | 576 | * Returns: errno |
570 | */ | 577 | */ |
571 | 578 | ||
572 | static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl) | 579 | static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl) |
573 | { | 580 | { |
574 | struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); | 581 | return -EINVAL; |
575 | |||
576 | /* | ||
577 | * We don't currently have a way to enforce a lease across the whole | ||
578 | * cluster; until we do, disable leases (by just returning -EINVAL), | ||
579 | * unless the administrator has requested purely local locking. | ||
580 | */ | ||
581 | if (!sdp->sd_args.ar_localflocks) | ||
582 | return -EINVAL; | ||
583 | return generic_setlease(file, arg, fl); | ||
584 | } | ||
585 | |||
586 | static int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
587 | struct file *file, struct file_lock *fl) | ||
588 | { | ||
589 | int error = -EIO; | ||
590 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
591 | error = sdp->sd_lockstruct.ls_ops->lm_plock_get( | ||
592 | sdp->sd_lockstruct.ls_lockspace, name, file, fl); | ||
593 | return error; | ||
594 | } | ||
595 | |||
596 | static int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
597 | struct file *file, int cmd, struct file_lock *fl) | ||
598 | { | ||
599 | int error = -EIO; | ||
600 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
601 | error = sdp->sd_lockstruct.ls_ops->lm_plock( | ||
602 | sdp->sd_lockstruct.ls_lockspace, name, file, cmd, fl); | ||
603 | return error; | ||
604 | } | ||
605 | |||
606 | static int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
607 | struct file *file, struct file_lock *fl) | ||
608 | { | ||
609 | int error = -EIO; | ||
610 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
611 | error = sdp->sd_lockstruct.ls_ops->lm_punlock( | ||
612 | sdp->sd_lockstruct.ls_lockspace, name, file, fl); | ||
613 | return error; | ||
614 | } | 582 | } |
615 | 583 | ||
616 | /** | 584 | /** |
@@ -626,9 +594,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) | |||
626 | { | 594 | { |
627 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); | 595 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
628 | struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); | 596 | struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); |
629 | struct lm_lockname name = | 597 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; |
630 | { .ln_number = ip->i_no_addr, | ||
631 | .ln_type = LM_TYPE_PLOCK }; | ||
632 | 598 | ||
633 | if (!(fl->fl_flags & FL_POSIX)) | 599 | if (!(fl->fl_flags & FL_POSIX)) |
634 | return -ENOLCK; | 600 | return -ENOLCK; |
@@ -640,12 +606,14 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) | |||
640 | cmd = F_SETLK; | 606 | cmd = F_SETLK; |
641 | fl->fl_type = F_UNLCK; | 607 | fl->fl_type = F_UNLCK; |
642 | } | 608 | } |
609 | if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
610 | return -EIO; | ||
643 | if (IS_GETLK(cmd)) | 611 | if (IS_GETLK(cmd)) |
644 | return gfs2_lm_plock_get(sdp, &name, file, fl); | 612 | return dlm_posix_get(ls->ls_dlm, ip->i_no_addr, file, fl); |
645 | else if (fl->fl_type == F_UNLCK) | 613 | else if (fl->fl_type == F_UNLCK) |
646 | return gfs2_lm_punlock(sdp, &name, file, fl); | 614 | return dlm_posix_unlock(ls->ls_dlm, ip->i_no_addr, file, fl); |
647 | else | 615 | else |
648 | return gfs2_lm_plock(sdp, &name, file, cmd, fl); | 616 | return dlm_posix_lock(ls->ls_dlm, ip->i_no_addr, file, cmd, fl); |
649 | } | 617 | } |
650 | 618 | ||
651 | static int do_flock(struct file *file, int cmd, struct file_lock *fl) | 619 | static int do_flock(struct file *file, int cmd, struct file_lock *fl) |
@@ -732,7 +700,7 @@ static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl) | |||
732 | } | 700 | } |
733 | } | 701 | } |
734 | 702 | ||
735 | const struct file_operations gfs2_file_fops = { | 703 | const struct file_operations *gfs2_file_fops = &(const struct file_operations){ |
736 | .llseek = gfs2_llseek, | 704 | .llseek = gfs2_llseek, |
737 | .read = do_sync_read, | 705 | .read = do_sync_read, |
738 | .aio_read = generic_file_aio_read, | 706 | .aio_read = generic_file_aio_read, |
@@ -750,7 +718,7 @@ const struct file_operations gfs2_file_fops = { | |||
750 | .setlease = gfs2_setlease, | 718 | .setlease = gfs2_setlease, |
751 | }; | 719 | }; |
752 | 720 | ||
753 | const struct file_operations gfs2_dir_fops = { | 721 | const struct file_operations *gfs2_dir_fops = &(const struct file_operations){ |
754 | .readdir = gfs2_readdir, | 722 | .readdir = gfs2_readdir, |
755 | .unlocked_ioctl = gfs2_ioctl, | 723 | .unlocked_ioctl = gfs2_ioctl, |
756 | .open = gfs2_open, | 724 | .open = gfs2_open, |
@@ -760,7 +728,9 @@ const struct file_operations gfs2_dir_fops = { | |||
760 | .flock = gfs2_flock, | 728 | .flock = gfs2_flock, |
761 | }; | 729 | }; |
762 | 730 | ||
763 | const struct file_operations gfs2_file_fops_nolock = { | 731 | #endif /* CONFIG_GFS2_FS_LOCKING_DLM */ |
732 | |||
733 | const struct file_operations *gfs2_file_fops_nolock = &(const struct file_operations){ | ||
764 | .llseek = gfs2_llseek, | 734 | .llseek = gfs2_llseek, |
765 | .read = do_sync_read, | 735 | .read = do_sync_read, |
766 | .aio_read = generic_file_aio_read, | 736 | .aio_read = generic_file_aio_read, |
@@ -773,10 +743,10 @@ const struct file_operations gfs2_file_fops_nolock = { | |||
773 | .fsync = gfs2_fsync, | 743 | .fsync = gfs2_fsync, |
774 | .splice_read = generic_file_splice_read, | 744 | .splice_read = generic_file_splice_read, |
775 | .splice_write = generic_file_splice_write, | 745 | .splice_write = generic_file_splice_write, |
776 | .setlease = gfs2_setlease, | 746 | .setlease = generic_setlease, |
777 | }; | 747 | }; |
778 | 748 | ||
779 | const struct file_operations gfs2_dir_fops_nolock = { | 749 | const struct file_operations *gfs2_dir_fops_nolock = &(const struct file_operations){ |
780 | .readdir = gfs2_readdir, | 750 | .readdir = gfs2_readdir, |
781 | .unlocked_ioctl = gfs2_ioctl, | 751 | .unlocked_ioctl = gfs2_ioctl, |
782 | .open = gfs2_open, | 752 | .open = gfs2_open, |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 402b6a2cd2c9..95bb33e41a76 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/namei.h> | 17 | #include <linux/namei.h> |
18 | #include <linux/mount.h> | 18 | #include <linux/mount.h> |
19 | #include <linux/gfs2_ondisk.h> | 19 | #include <linux/gfs2_ondisk.h> |
20 | #include <linux/lm_interface.h> | ||
21 | 20 | ||
22 | #include "gfs2.h" | 21 | #include "gfs2.h" |
23 | #include "incore.h" | 22 | #include "incore.h" |
@@ -627,13 +626,13 @@ static int map_journal_extents(struct gfs2_sbd *sdp) | |||
627 | return rc; | 626 | return rc; |
628 | } | 627 | } |
629 | 628 | ||
630 | static void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp) | 629 | static void gfs2_others_may_mount(struct gfs2_sbd *sdp) |
631 | { | 630 | { |
632 | if (!sdp->sd_lockstruct.ls_ops->lm_others_may_mount) | 631 | char *message = "FIRSTMOUNT=Done"; |
633 | return; | 632 | char *envp[] = { message, NULL }; |
634 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 633 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; |
635 | sdp->sd_lockstruct.ls_ops->lm_others_may_mount( | 634 | ls->ls_first_done = 1; |
636 | sdp->sd_lockstruct.ls_lockspace); | 635 | kobject_uevent_env(&sdp->sd_kobj, KOBJ_CHANGE, envp); |
637 | } | 636 | } |
638 | 637 | ||
639 | /** | 638 | /** |
@@ -793,7 +792,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) | |||
793 | } | 792 | } |
794 | } | 793 | } |
795 | 794 | ||
796 | gfs2_lm_others_may_mount(sdp); | 795 | gfs2_others_may_mount(sdp); |
797 | } else if (!sdp->sd_args.ar_spectator) { | 796 | } else if (!sdp->sd_args.ar_spectator) { |
798 | error = gfs2_recover_journal(sdp->sd_jdesc); | 797 | error = gfs2_recover_journal(sdp->sd_jdesc); |
799 | if (error) { | 798 | if (error) { |
@@ -1002,7 +1001,6 @@ static int init_threads(struct gfs2_sbd *sdp, int undo) | |||
1002 | goto fail_quotad; | 1001 | goto fail_quotad; |
1003 | 1002 | ||
1004 | sdp->sd_log_flush_time = jiffies; | 1003 | sdp->sd_log_flush_time = jiffies; |
1005 | sdp->sd_jindex_refresh_time = jiffies; | ||
1006 | 1004 | ||
1007 | p = kthread_run(gfs2_logd, sdp, "gfs2_logd"); | 1005 | p = kthread_run(gfs2_logd, sdp, "gfs2_logd"); |
1008 | error = IS_ERR(p); | 1006 | error = IS_ERR(p); |
@@ -1030,6 +1028,17 @@ fail: | |||
1030 | return error; | 1028 | return error; |
1031 | } | 1029 | } |
1032 | 1030 | ||
1031 | static const match_table_t nolock_tokens = { | ||
1032 | { Opt_jid, "jid=%d\n", }, | ||
1033 | { Opt_err, NULL }, | ||
1034 | }; | ||
1035 | |||
1036 | static const struct lm_lockops nolock_ops = { | ||
1037 | .lm_proto_name = "lock_nolock", | ||
1038 | .lm_put_lock = kmem_cache_free, | ||
1039 | .lm_tokens = &nolock_tokens, | ||
1040 | }; | ||
1041 | |||
1033 | /** | 1042 | /** |
1034 | * gfs2_lm_mount - mount a locking protocol | 1043 | * gfs2_lm_mount - mount a locking protocol |
1035 | * @sdp: the filesystem | 1044 | * @sdp: the filesystem |
@@ -1041,31 +1050,73 @@ fail: | |||
1041 | 1050 | ||
1042 | static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) | 1051 | static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) |
1043 | { | 1052 | { |
1044 | char *proto = sdp->sd_proto_name; | 1053 | const struct lm_lockops *lm; |
1045 | char *table = sdp->sd_table_name; | 1054 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; |
1046 | int flags = LM_MFLAG_CONV_NODROP; | 1055 | struct gfs2_args *args = &sdp->sd_args; |
1047 | int error; | 1056 | const char *proto = sdp->sd_proto_name; |
1057 | const char *table = sdp->sd_table_name; | ||
1058 | const char *fsname; | ||
1059 | char *o, *options; | ||
1060 | int ret; | ||
1048 | 1061 | ||
1049 | if (sdp->sd_args.ar_spectator) | 1062 | if (!strcmp("lock_nolock", proto)) { |
1050 | flags |= LM_MFLAG_SPECTATOR; | 1063 | lm = &nolock_ops; |
1064 | sdp->sd_args.ar_localflocks = 1; | ||
1065 | sdp->sd_args.ar_localcaching = 1; | ||
1066 | #ifdef CONFIG_GFS2_FS_LOCKING_DLM | ||
1067 | } else if (!strcmp("lock_dlm", proto)) { | ||
1068 | lm = &gfs2_dlm_ops; | ||
1069 | #endif | ||
1070 | } else { | ||
1071 | printk(KERN_INFO "GFS2: can't find protocol %s\n", proto); | ||
1072 | return -ENOENT; | ||
1073 | } | ||
1051 | 1074 | ||
1052 | fs_info(sdp, "Trying to join cluster \"%s\", \"%s\"\n", proto, table); | 1075 | fs_info(sdp, "Trying to join cluster \"%s\", \"%s\"\n", proto, table); |
1053 | 1076 | ||
1054 | error = gfs2_mount_lockproto(proto, table, sdp->sd_args.ar_hostdata, | 1077 | ls->ls_ops = lm; |
1055 | gfs2_glock_cb, sdp, | 1078 | ls->ls_first = 1; |
1056 | GFS2_MIN_LVB_SIZE, flags, | 1079 | ls->ls_id = 0; |
1057 | &sdp->sd_lockstruct, &sdp->sd_kobj); | ||
1058 | if (error) { | ||
1059 | fs_info(sdp, "can't mount proto=%s, table=%s, hostdata=%s\n", | ||
1060 | proto, table, sdp->sd_args.ar_hostdata); | ||
1061 | goto out; | ||
1062 | } | ||
1063 | 1080 | ||
1064 | if (gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_ops) || | 1081 | for (options = args->ar_hostdata; (o = strsep(&options, ":")); ) { |
1065 | gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lvb_size >= | 1082 | substring_t tmp[MAX_OPT_ARGS]; |
1066 | GFS2_MIN_LVB_SIZE)) { | 1083 | int token, option; |
1067 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); | 1084 | |
1068 | goto out; | 1085 | if (!o || !*o) |
1086 | continue; | ||
1087 | |||
1088 | token = match_token(o, *lm->lm_tokens, tmp); | ||
1089 | switch (token) { | ||
1090 | case Opt_jid: | ||
1091 | ret = match_int(&tmp[0], &option); | ||
1092 | if (ret || option < 0) | ||
1093 | goto hostdata_error; | ||
1094 | ls->ls_jid = option; | ||
1095 | break; | ||
1096 | case Opt_id: | ||
1097 | ret = match_int(&tmp[0], &option); | ||
1098 | if (ret) | ||
1099 | goto hostdata_error; | ||
1100 | ls->ls_id = option; | ||
1101 | break; | ||
1102 | case Opt_first: | ||
1103 | ret = match_int(&tmp[0], &option); | ||
1104 | if (ret || (option != 0 && option != 1)) | ||
1105 | goto hostdata_error; | ||
1106 | ls->ls_first = option; | ||
1107 | break; | ||
1108 | case Opt_nodir: | ||
1109 | ret = match_int(&tmp[0], &option); | ||
1110 | if (ret || (option != 0 && option != 1)) | ||
1111 | goto hostdata_error; | ||
1112 | ls->ls_nodir = option; | ||
1113 | break; | ||
1114 | case Opt_err: | ||
1115 | default: | ||
1116 | hostdata_error: | ||
1117 | fs_info(sdp, "unknown hostdata (%s)\n", o); | ||
1118 | return -EINVAL; | ||
1119 | } | ||
1069 | } | 1120 | } |
1070 | 1121 | ||
1071 | if (sdp->sd_args.ar_spectator) | 1122 | if (sdp->sd_args.ar_spectator) |
@@ -1074,22 +1125,25 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) | |||
1074 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.%u", table, | 1125 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.%u", table, |
1075 | sdp->sd_lockstruct.ls_jid); | 1126 | sdp->sd_lockstruct.ls_jid); |
1076 | 1127 | ||
1077 | fs_info(sdp, "Joined cluster. Now mounting FS...\n"); | 1128 | fsname = strchr(table, ':'); |
1078 | 1129 | if (fsname) | |
1079 | if ((sdp->sd_lockstruct.ls_flags & LM_LSFLAG_LOCAL) && | 1130 | fsname++; |
1080 | !sdp->sd_args.ar_ignore_local_fs) { | 1131 | if (lm->lm_mount == NULL) { |
1081 | sdp->sd_args.ar_localflocks = 1; | 1132 | fs_info(sdp, "Now mounting FS...\n"); |
1082 | sdp->sd_args.ar_localcaching = 1; | 1133 | return 0; |
1083 | } | 1134 | } |
1084 | 1135 | ret = lm->lm_mount(sdp, fsname); | |
1085 | out: | 1136 | if (ret == 0) |
1086 | return error; | 1137 | fs_info(sdp, "Joined cluster. Now mounting FS...\n"); |
1138 | return ret; | ||
1087 | } | 1139 | } |
1088 | 1140 | ||
1089 | void gfs2_lm_unmount(struct gfs2_sbd *sdp) | 1141 | void gfs2_lm_unmount(struct gfs2_sbd *sdp) |
1090 | { | 1142 | { |
1091 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 1143 | const struct lm_lockops *lm = sdp->sd_lockstruct.ls_ops; |
1092 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); | 1144 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) && |
1145 | lm->lm_unmount) | ||
1146 | lm->lm_unmount(sdp); | ||
1093 | } | 1147 | } |
1094 | 1148 | ||
1095 | /** | 1149 | /** |
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c index 49877546beb9..abd5429ae285 100644 --- a/fs/gfs2/ops_inode.c +++ b/fs/gfs2/ops_inode.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/posix_acl.h> | 18 | #include <linux/posix_acl.h> |
19 | #include <linux/gfs2_ondisk.h> | 19 | #include <linux/gfs2_ondisk.h> |
20 | #include <linux/crc32.h> | 20 | #include <linux/crc32.h> |
21 | #include <linux/lm_interface.h> | ||
22 | #include <linux/fiemap.h> | 21 | #include <linux/fiemap.h> |
23 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
24 | 23 | ||
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index f0699ac453f7..4ecdad026eaf 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/gfs2_ondisk.h> | 20 | #include <linux/gfs2_ondisk.h> |
21 | #include <linux/crc32.h> | 21 | #include <linux/crc32.h> |
22 | #include <linux/lm_interface.h> | ||
23 | #include <linux/time.h> | 22 | #include <linux/time.h> |
24 | 23 | ||
25 | #include "gfs2.h" | 24 | #include "gfs2.h" |
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index e8ef0f80fb11..8d53f66b5bcc 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <linux/fs.h> | 45 | #include <linux/fs.h> |
46 | #include <linux/bio.h> | 46 | #include <linux/bio.h> |
47 | #include <linux/gfs2_ondisk.h> | 47 | #include <linux/gfs2_ondisk.h> |
48 | #include <linux/lm_interface.h> | ||
49 | #include <linux/kthread.h> | 48 | #include <linux/kthread.h> |
50 | #include <linux/freezer.h> | 49 | #include <linux/freezer.h> |
51 | 50 | ||
@@ -108,7 +107,7 @@ int gfs2_shrink_qd_memory(int nr, gfp_t gfp_mask) | |||
108 | gfs2_assert_warn(sdp, !qd->qd_slot_count); | 107 | gfs2_assert_warn(sdp, !qd->qd_slot_count); |
109 | gfs2_assert_warn(sdp, !qd->qd_bh_count); | 108 | gfs2_assert_warn(sdp, !qd->qd_bh_count); |
110 | 109 | ||
111 | gfs2_lvb_unhold(qd->qd_gl); | 110 | gfs2_glock_put(qd->qd_gl); |
112 | atomic_dec(&sdp->sd_quota_count); | 111 | atomic_dec(&sdp->sd_quota_count); |
113 | 112 | ||
114 | /* Delete it from the common reclaim list */ | 113 | /* Delete it from the common reclaim list */ |
@@ -157,11 +156,6 @@ static int qd_alloc(struct gfs2_sbd *sdp, int user, u32 id, | |||
157 | if (error) | 156 | if (error) |
158 | goto fail; | 157 | goto fail; |
159 | 158 | ||
160 | error = gfs2_lvb_hold(qd->qd_gl); | ||
161 | gfs2_glock_put(qd->qd_gl); | ||
162 | if (error) | ||
163 | goto fail; | ||
164 | |||
165 | *qdp = qd; | 159 | *qdp = qd; |
166 | 160 | ||
167 | return 0; | 161 | return 0; |
@@ -211,7 +205,7 @@ static int qd_get(struct gfs2_sbd *sdp, int user, u32 id, int create, | |||
211 | 205 | ||
212 | if (qd || !create) { | 206 | if (qd || !create) { |
213 | if (new_qd) { | 207 | if (new_qd) { |
214 | gfs2_lvb_unhold(new_qd->qd_gl); | 208 | gfs2_glock_put(new_qd->qd_gl); |
215 | kmem_cache_free(gfs2_quotad_cachep, new_qd); | 209 | kmem_cache_free(gfs2_quotad_cachep, new_qd); |
216 | } | 210 | } |
217 | *qdp = qd; | 211 | *qdp = qd; |
@@ -1280,7 +1274,7 @@ void gfs2_quota_cleanup(struct gfs2_sbd *sdp) | |||
1280 | gfs2_assert_warn(sdp, qd->qd_slot_count == 1); | 1274 | gfs2_assert_warn(sdp, qd->qd_slot_count == 1); |
1281 | gfs2_assert_warn(sdp, !qd->qd_bh_count); | 1275 | gfs2_assert_warn(sdp, !qd->qd_bh_count); |
1282 | 1276 | ||
1283 | gfs2_lvb_unhold(qd->qd_gl); | 1277 | gfs2_glock_put(qd->qd_gl); |
1284 | kmem_cache_free(gfs2_quotad_cachep, qd); | 1278 | kmem_cache_free(gfs2_quotad_cachep, qd); |
1285 | 1279 | ||
1286 | spin_lock(&qd_lru_lock); | 1280 | spin_lock(&qd_lru_lock); |
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index efd09c3d2b26..247e8f7d6b3d 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
14 | #include <linux/gfs2_ondisk.h> | 14 | #include <linux/gfs2_ondisk.h> |
15 | #include <linux/crc32.h> | 15 | #include <linux/crc32.h> |
16 | #include <linux/lm_interface.h> | ||
17 | #include <linux/kthread.h> | 16 | #include <linux/kthread.h> |
18 | #include <linux/freezer.h> | 17 | #include <linux/freezer.h> |
19 | 18 | ||
@@ -427,20 +426,23 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header_host *hea | |||
427 | } | 426 | } |
428 | 427 | ||
429 | 428 | ||
430 | static void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid, | 429 | static void gfs2_recovery_done(struct gfs2_sbd *sdp, unsigned int jid, |
431 | unsigned int message) | 430 | unsigned int message) |
432 | { | 431 | { |
433 | if (!sdp->sd_lockstruct.ls_ops->lm_recovery_done) | 432 | char env_jid[20]; |
434 | return; | 433 | char env_status[20]; |
435 | 434 | char *envp[] = { env_jid, env_status, NULL }; | |
436 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 435 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; |
437 | sdp->sd_lockstruct.ls_ops->lm_recovery_done( | 436 | ls->ls_recover_jid_done = jid; |
438 | sdp->sd_lockstruct.ls_lockspace, jid, message); | 437 | ls->ls_recover_jid_status = message; |
438 | sprintf(env_jid, "JID=%d", jid); | ||
439 | sprintf(env_status, "RECOVERY=%s", | ||
440 | message == LM_RD_SUCCESS ? "Done" : "Failed"); | ||
441 | kobject_uevent_env(&sdp->sd_kobj, KOBJ_CHANGE, envp); | ||
439 | } | 442 | } |
440 | 443 | ||
441 | |||
442 | /** | 444 | /** |
443 | * gfs2_recover_journal - recovery a given journal | 445 | * gfs2_recover_journal - recover a given journal |
444 | * @jd: the struct gfs2_jdesc describing the journal | 446 | * @jd: the struct gfs2_jdesc describing the journal |
445 | * | 447 | * |
446 | * Acquire the journal's lock, check to see if the journal is clean, and | 448 | * Acquire the journal's lock, check to see if the journal is clean, and |
@@ -561,7 +563,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd) | |||
561 | if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) | 563 | if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) |
562 | gfs2_glock_dq_uninit(&ji_gh); | 564 | gfs2_glock_dq_uninit(&ji_gh); |
563 | 565 | ||
564 | gfs2_lm_recovery_done(sdp, jd->jd_jid, LM_RD_SUCCESS); | 566 | gfs2_recovery_done(sdp, jd->jd_jid, LM_RD_SUCCESS); |
565 | 567 | ||
566 | if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) | 568 | if (jd->jd_jid != sdp->sd_lockstruct.ls_jid) |
567 | gfs2_glock_dq_uninit(&j_gh); | 569 | gfs2_glock_dq_uninit(&j_gh); |
@@ -581,7 +583,7 @@ fail_gunlock_j: | |||
581 | fs_info(sdp, "jid=%u: %s\n", jd->jd_jid, (error) ? "Failed" : "Done"); | 583 | fs_info(sdp, "jid=%u: %s\n", jd->jd_jid, (error) ? "Failed" : "Done"); |
582 | 584 | ||
583 | fail: | 585 | fail: |
584 | gfs2_lm_recovery_done(sdp, jd->jd_jid, LM_RD_GAVEUP); | 586 | gfs2_recovery_done(sdp, jd->jd_jid, LM_RD_GAVEUP); |
585 | return error; | 587 | return error; |
586 | } | 588 | } |
587 | 589 | ||
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 8b01c635d925..ba5a021b1c57 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
14 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
15 | #include <linux/gfs2_ondisk.h> | 15 | #include <linux/gfs2_ondisk.h> |
16 | #include <linux/lm_interface.h> | ||
17 | #include <linux/prefetch.h> | 16 | #include <linux/prefetch.h> |
18 | 17 | ||
19 | #include "gfs2.h" | 18 | #include "gfs2.h" |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 141b781f2fcc..7cf302b135ce 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/crc32.h> | 15 | #include <linux/crc32.h> |
16 | #include <linux/gfs2_ondisk.h> | 16 | #include <linux/gfs2_ondisk.h> |
17 | #include <linux/bio.h> | 17 | #include <linux/bio.h> |
18 | #include <linux/lm_interface.h> | ||
19 | 18 | ||
20 | #include "gfs2.h" | 19 | #include "gfs2.h" |
21 | #include "incore.h" | 20 | #include "incore.h" |
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index a58a120dac92..a78997ea5037 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
@@ -14,9 +14,8 @@ | |||
14 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kobject.h> | 16 | #include <linux/kobject.h> |
17 | #include <linux/gfs2_ondisk.h> | ||
18 | #include <linux/lm_interface.h> | ||
19 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
18 | #include <linux/gfs2_ondisk.h> | ||
20 | 19 | ||
21 | #include "gfs2.h" | 20 | #include "gfs2.h" |
22 | #include "incore.h" | 21 | #include "incore.h" |
@@ -224,14 +223,145 @@ static struct lockstruct_attr lockstruct_attr_##name = __ATTR_RO(name) | |||
224 | 223 | ||
225 | LOCKSTRUCT_ATTR(jid, "%u\n"); | 224 | LOCKSTRUCT_ATTR(jid, "%u\n"); |
226 | LOCKSTRUCT_ATTR(first, "%u\n"); | 225 | LOCKSTRUCT_ATTR(first, "%u\n"); |
227 | LOCKSTRUCT_ATTR(lvb_size, "%u\n"); | ||
228 | LOCKSTRUCT_ATTR(flags, "%d\n"); | ||
229 | 226 | ||
230 | static struct attribute *lockstruct_attrs[] = { | 227 | static struct attribute *lockstruct_attrs[] = { |
231 | &lockstruct_attr_jid.attr, | 228 | &lockstruct_attr_jid.attr, |
232 | &lockstruct_attr_first.attr, | 229 | &lockstruct_attr_first.attr, |
233 | &lockstruct_attr_lvb_size.attr, | 230 | NULL, |
234 | &lockstruct_attr_flags.attr, | 231 | }; |
232 | |||
233 | /* | ||
234 | * lock_module. Originally from lock_dlm | ||
235 | */ | ||
236 | |||
237 | static ssize_t proto_name_show(struct gfs2_sbd *sdp, char *buf) | ||
238 | { | ||
239 | const struct lm_lockops *ops = sdp->sd_lockstruct.ls_ops; | ||
240 | return sprintf(buf, "%s\n", ops->lm_proto_name); | ||
241 | } | ||
242 | |||
243 | static ssize_t block_show(struct gfs2_sbd *sdp, char *buf) | ||
244 | { | ||
245 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
246 | ssize_t ret; | ||
247 | int val = 0; | ||
248 | |||
249 | if (test_bit(DFL_BLOCK_LOCKS, &ls->ls_flags)) | ||
250 | val = 1; | ||
251 | ret = sprintf(buf, "%d\n", val); | ||
252 | return ret; | ||
253 | } | ||
254 | |||
255 | static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len) | ||
256 | { | ||
257 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
258 | ssize_t ret = len; | ||
259 | int val; | ||
260 | |||
261 | val = simple_strtol(buf, NULL, 0); | ||
262 | |||
263 | if (val == 1) | ||
264 | set_bit(DFL_BLOCK_LOCKS, &ls->ls_flags); | ||
265 | else if (val == 0) { | ||
266 | clear_bit(DFL_BLOCK_LOCKS, &ls->ls_flags); | ||
267 | smp_mb__after_clear_bit(); | ||
268 | gfs2_glock_thaw(sdp); | ||
269 | } else { | ||
270 | ret = -EINVAL; | ||
271 | } | ||
272 | return ret; | ||
273 | } | ||
274 | |||
275 | static ssize_t lkid_show(struct gfs2_sbd *sdp, char *buf) | ||
276 | { | ||
277 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
278 | return sprintf(buf, "%u\n", ls->ls_id); | ||
279 | } | ||
280 | |||
281 | static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf) | ||
282 | { | ||
283 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
284 | return sprintf(buf, "%d\n", ls->ls_first); | ||
285 | } | ||
286 | |||
287 | static ssize_t first_done_show(struct gfs2_sbd *sdp, char *buf) | ||
288 | { | ||
289 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
290 | return sprintf(buf, "%d\n", ls->ls_first_done); | ||
291 | } | ||
292 | |||
293 | static ssize_t recover_show(struct gfs2_sbd *sdp, char *buf) | ||
294 | { | ||
295 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
296 | return sprintf(buf, "%d\n", ls->ls_recover_jid); | ||
297 | } | ||
298 | |||
299 | static void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid) | ||
300 | { | ||
301 | struct gfs2_jdesc *jd; | ||
302 | |||
303 | spin_lock(&sdp->sd_jindex_spin); | ||
304 | list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { | ||
305 | if (jd->jd_jid != jid) | ||
306 | continue; | ||
307 | jd->jd_dirty = 1; | ||
308 | break; | ||
309 | } | ||
310 | spin_unlock(&sdp->sd_jindex_spin); | ||
311 | } | ||
312 | |||
313 | static ssize_t recover_store(struct gfs2_sbd *sdp, const char *buf, size_t len) | ||
314 | { | ||
315 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
316 | ls->ls_recover_jid = simple_strtol(buf, NULL, 0); | ||
317 | gfs2_jdesc_make_dirty(sdp, ls->ls_recover_jid); | ||
318 | if (sdp->sd_recoverd_process) | ||
319 | wake_up_process(sdp->sd_recoverd_process); | ||
320 | return len; | ||
321 | } | ||
322 | |||
323 | static ssize_t recover_done_show(struct gfs2_sbd *sdp, char *buf) | ||
324 | { | ||
325 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
326 | return sprintf(buf, "%d\n", ls->ls_recover_jid_done); | ||
327 | } | ||
328 | |||
329 | static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf) | ||
330 | { | ||
331 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
332 | return sprintf(buf, "%d\n", ls->ls_recover_jid_status); | ||
333 | } | ||
334 | |||
335 | struct gdlm_attr { | ||
336 | struct attribute attr; | ||
337 | ssize_t (*show)(struct gfs2_sbd *sdp, char *); | ||
338 | ssize_t (*store)(struct gfs2_sbd *sdp, const char *, size_t); | ||
339 | }; | ||
340 | |||
341 | #define GDLM_ATTR(_name,_mode,_show,_store) \ | ||
342 | static struct gdlm_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
343 | |||
344 | GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); | ||
345 | GDLM_ATTR(block, 0644, block_show, block_store); | ||
346 | GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store); | ||
347 | GDLM_ATTR(id, 0444, lkid_show, NULL); | ||
348 | GDLM_ATTR(first, 0444, lkfirst_show, NULL); | ||
349 | GDLM_ATTR(first_done, 0444, first_done_show, NULL); | ||
350 | GDLM_ATTR(recover, 0644, recover_show, recover_store); | ||
351 | GDLM_ATTR(recover_done, 0444, recover_done_show, NULL); | ||
352 | GDLM_ATTR(recover_status, 0444, recover_status_show, NULL); | ||
353 | |||
354 | static struct attribute *lock_module_attrs[] = { | ||
355 | &gdlm_attr_proto_name.attr, | ||
356 | &gdlm_attr_block.attr, | ||
357 | &gdlm_attr_withdraw.attr, | ||
358 | &gdlm_attr_id.attr, | ||
359 | &lockstruct_attr_jid.attr, | ||
360 | &gdlm_attr_first.attr, | ||
361 | &gdlm_attr_first_done.attr, | ||
362 | &gdlm_attr_recover.attr, | ||
363 | &gdlm_attr_recover_done.attr, | ||
364 | &gdlm_attr_recover_status.attr, | ||
235 | NULL, | 365 | NULL, |
236 | }; | 366 | }; |
237 | 367 | ||
@@ -412,6 +542,11 @@ static struct attribute_group tune_group = { | |||
412 | .attrs = tune_attrs, | 542 | .attrs = tune_attrs, |
413 | }; | 543 | }; |
414 | 544 | ||
545 | static struct attribute_group lock_module_group = { | ||
546 | .name = "lock_module", | ||
547 | .attrs = lock_module_attrs, | ||
548 | }; | ||
549 | |||
415 | int gfs2_sys_fs_add(struct gfs2_sbd *sdp) | 550 | int gfs2_sys_fs_add(struct gfs2_sbd *sdp) |
416 | { | 551 | { |
417 | int error; | 552 | int error; |
@@ -434,9 +569,15 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) | |||
434 | if (error) | 569 | if (error) |
435 | goto fail_args; | 570 | goto fail_args; |
436 | 571 | ||
572 | error = sysfs_create_group(&sdp->sd_kobj, &lock_module_group); | ||
573 | if (error) | ||
574 | goto fail_tune; | ||
575 | |||
437 | kobject_uevent(&sdp->sd_kobj, KOBJ_ADD); | 576 | kobject_uevent(&sdp->sd_kobj, KOBJ_ADD); |
438 | return 0; | 577 | return 0; |
439 | 578 | ||
579 | fail_tune: | ||
580 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); | ||
440 | fail_args: | 581 | fail_args: |
441 | sysfs_remove_group(&sdp->sd_kobj, &args_group); | 582 | sysfs_remove_group(&sdp->sd_kobj, &args_group); |
442 | fail_lockstruct: | 583 | fail_lockstruct: |
@@ -453,6 +594,7 @@ void gfs2_sys_fs_del(struct gfs2_sbd *sdp) | |||
453 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); | 594 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); |
454 | sysfs_remove_group(&sdp->sd_kobj, &args_group); | 595 | sysfs_remove_group(&sdp->sd_kobj, &args_group); |
455 | sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group); | 596 | sysfs_remove_group(&sdp->sd_kobj, &lockstruct_group); |
597 | sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); | ||
456 | kobject_put(&sdp->sd_kobj); | 598 | kobject_put(&sdp->sd_kobj); |
457 | } | 599 | } |
458 | 600 | ||
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index f677b8a83f0c..33cd523ec97e 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c | |||
@@ -12,9 +12,8 @@ | |||
12 | #include <linux/spinlock.h> | 12 | #include <linux/spinlock.h> |
13 | #include <linux/completion.h> | 13 | #include <linux/completion.h> |
14 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
15 | #include <linux/gfs2_ondisk.h> | ||
16 | #include <linux/kallsyms.h> | 15 | #include <linux/kallsyms.h> |
17 | #include <linux/lm_interface.h> | 16 | #include <linux/gfs2_ondisk.h> |
18 | 17 | ||
19 | #include "gfs2.h" | 18 | #include "gfs2.h" |
20 | #include "incore.h" | 19 | #include "incore.h" |
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index 374f50e95496..9d12b1118ba0 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/buffer_head.h> | 13 | #include <linux/buffer_head.h> |
14 | #include <linux/crc32.h> | 14 | #include <linux/crc32.h> |
15 | #include <linux/gfs2_ondisk.h> | 15 | #include <linux/gfs2_ondisk.h> |
16 | #include <linux/lm_interface.h> | ||
17 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
18 | 17 | ||
19 | #include "gfs2.h" | 18 | #include "gfs2.h" |
@@ -35,6 +34,8 @@ void gfs2_assert_i(struct gfs2_sbd *sdp) | |||
35 | 34 | ||
36 | int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) | 35 | int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) |
37 | { | 36 | { |
37 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
38 | const struct lm_lockops *lm = ls->ls_ops; | ||
38 | va_list args; | 39 | va_list args; |
39 | 40 | ||
40 | if (test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags)) | 41 | if (test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags)) |
@@ -47,8 +48,12 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) | |||
47 | fs_err(sdp, "about to withdraw this file system\n"); | 48 | fs_err(sdp, "about to withdraw this file system\n"); |
48 | BUG_ON(sdp->sd_args.ar_debug); | 49 | BUG_ON(sdp->sd_args.ar_debug); |
49 | 50 | ||
50 | fs_err(sdp, "telling LM to withdraw\n"); | 51 | kobject_uevent(&sdp->sd_kobj, KOBJ_OFFLINE); |
51 | gfs2_withdraw_lockproto(&sdp->sd_lockstruct); | 52 | |
53 | if (lm->lm_unmount) { | ||
54 | fs_err(sdp, "telling LM to unmount\n"); | ||
55 | lm->lm_unmount(sdp); | ||
56 | } | ||
52 | fs_err(sdp, "withdrawn\n"); | 57 | fs_err(sdp, "withdrawn\n"); |
53 | dump_stack(); | 58 | dump_stack(); |
54 | 59 | ||