diff options
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/Makefile | 2 | ||||
-rw-r--r-- | fs/gfs2/glock.c | 51 | ||||
-rw-r--r-- | fs/gfs2/incore.h | 2 | ||||
-rw-r--r-- | fs/gfs2/lm.c | 210 | ||||
-rw-r--r-- | fs/gfs2/lm.h | 42 | ||||
-rw-r--r-- | fs/gfs2/ops_file.c | 31 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 71 | ||||
-rw-r--r-- | fs/gfs2/ops_super.c | 1 | ||||
-rw-r--r-- | fs/gfs2/recovery.c | 11 | ||||
-rw-r--r-- | fs/gfs2/super.h | 1 | ||||
-rw-r--r-- | fs/gfs2/sys.c | 1 | ||||
-rw-r--r-- | fs/gfs2/util.c | 23 | ||||
-rw-r--r-- | fs/gfs2/util.h | 1 |
13 files changed, 184 insertions, 263 deletions
diff --git a/fs/gfs2/Makefile b/fs/gfs2/Makefile index 8fff11058cee..e2350df02a07 100644 --- a/fs/gfs2/Makefile +++ b/fs/gfs2/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | obj-$(CONFIG_GFS2_FS) += gfs2.o | 1 | obj-$(CONFIG_GFS2_FS) += gfs2.o |
2 | gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \ | 2 | gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \ |
3 | glops.o inode.o lm.o log.o lops.o locking.o main.o meta_io.o \ | 3 | glops.o inode.o log.o lops.o locking.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 |
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index a8387e0b5068..611f84d22573 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include "glock.h" | 35 | #include "glock.h" |
36 | #include "glops.h" | 36 | #include "glops.h" |
37 | #include "inode.h" | 37 | #include "inode.h" |
38 | #include "lm.h" | ||
39 | #include "lops.h" | 38 | #include "lops.h" |
40 | #include "meta_io.h" | 39 | #include "meta_io.h" |
41 | #include "quota.h" | 40 | #include "quota.h" |
@@ -183,7 +182,8 @@ static void glock_free(struct gfs2_glock *gl) | |||
183 | struct gfs2_sbd *sdp = gl->gl_sbd; | 182 | struct gfs2_sbd *sdp = gl->gl_sbd; |
184 | struct inode *aspace = gl->gl_aspace; | 183 | struct inode *aspace = gl->gl_aspace; |
185 | 184 | ||
186 | gfs2_lm_put_lock(sdp, gl->gl_lock); | 185 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
186 | sdp->sd_lockstruct.ls_ops->lm_put_lock(gl->gl_lock); | ||
187 | 187 | ||
188 | if (aspace) | 188 | if (aspace) |
189 | gfs2_aspace_put(aspace); | 189 | gfs2_aspace_put(aspace); |
@@ -293,6 +293,16 @@ static void glock_work_func(struct work_struct *work) | |||
293 | gfs2_glock_put(gl); | 293 | gfs2_glock_put(gl); |
294 | } | 294 | } |
295 | 295 | ||
296 | static int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
297 | void **lockp) | ||
298 | { | ||
299 | int error = -EIO; | ||
300 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
301 | error = sdp->sd_lockstruct.ls_ops->lm_get_lock( | ||
302 | sdp->sd_lockstruct.ls_lockspace, name, lockp); | ||
303 | return error; | ||
304 | } | ||
305 | |||
296 | /** | 306 | /** |
297 | * gfs2_glock_get() - Get a glock, or create one if one doesn't exist | 307 | * gfs2_glock_get() - Get a glock, or create one if one doesn't exist |
298 | * @sdp: The GFS2 superblock | 308 | * @sdp: The GFS2 superblock |
@@ -882,6 +892,17 @@ out: | |||
882 | gfs2_holder_wake(gh); | 892 | gfs2_holder_wake(gh); |
883 | } | 893 | } |
884 | 894 | ||
895 | static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, | ||
896 | unsigned int cur_state, unsigned int req_state, | ||
897 | unsigned int flags) | ||
898 | { | ||
899 | int ret = 0; | ||
900 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
901 | ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state, | ||
902 | req_state, flags); | ||
903 | return ret; | ||
904 | } | ||
905 | |||
885 | /** | 906 | /** |
886 | * gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock | 907 | * gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock |
887 | * @gl: The glock in question | 908 | * @gl: The glock in question |
@@ -922,6 +943,15 @@ static void gfs2_glock_xmote_th(struct gfs2_glock *gl, struct gfs2_holder *gh) | |||
922 | xmote_bh(gl, lck_ret); | 943 | xmote_bh(gl, lck_ret); |
923 | } | 944 | } |
924 | 945 | ||
946 | static unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, void *lock, | ||
947 | unsigned int cur_state) | ||
948 | { | ||
949 | int ret = 0; | ||
950 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
951 | ret = sdp->sd_lockstruct.ls_ops->lm_unlock(lock, cur_state); | ||
952 | return ret; | ||
953 | } | ||
954 | |||
925 | /** | 955 | /** |
926 | * gfs2_glock_drop_th - call into the lock module to unlock a lock | 956 | * gfs2_glock_drop_th - call into the lock module to unlock a lock |
927 | * @gl: the glock | 957 | * @gl: the glock |
@@ -964,6 +994,7 @@ static void gfs2_glock_drop_th(struct gfs2_glock *gl) | |||
964 | static void do_cancels(struct gfs2_holder *gh) | 994 | static void do_cancels(struct gfs2_holder *gh) |
965 | { | 995 | { |
966 | struct gfs2_glock *gl = gh->gh_gl; | 996 | struct gfs2_glock *gl = gh->gh_gl; |
997 | struct gfs2_sbd *sdp = gl->gl_sbd; | ||
967 | 998 | ||
968 | spin_lock(&gl->gl_spin); | 999 | spin_lock(&gl->gl_spin); |
969 | 1000 | ||
@@ -972,7 +1003,8 @@ static void do_cancels(struct gfs2_holder *gh) | |||
972 | !list_empty(&gh->gh_list)) { | 1003 | !list_empty(&gh->gh_list)) { |
973 | if (!(gl->gl_req_gh && (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) { | 1004 | if (!(gl->gl_req_gh && (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) { |
974 | spin_unlock(&gl->gl_spin); | 1005 | spin_unlock(&gl->gl_spin); |
975 | gfs2_lm_cancel(gl->gl_sbd, gl->gl_lock); | 1006 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
1007 | sdp->sd_lockstruct.ls_ops->lm_cancel(gl->gl_lock); | ||
976 | msleep(100); | 1008 | msleep(100); |
977 | spin_lock(&gl->gl_spin); | 1009 | spin_lock(&gl->gl_spin); |
978 | } else { | 1010 | } else { |
@@ -1426,6 +1458,14 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs) | |||
1426 | gfs2_glock_dq_uninit(&ghs[x]); | 1458 | gfs2_glock_dq_uninit(&ghs[x]); |
1427 | } | 1459 | } |
1428 | 1460 | ||
1461 | static int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp) | ||
1462 | { | ||
1463 | int error = -EIO; | ||
1464 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
1465 | error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp); | ||
1466 | return error; | ||
1467 | } | ||
1468 | |||
1429 | /** | 1469 | /** |
1430 | * gfs2_lvb_hold - attach a LVB from a glock | 1470 | * gfs2_lvb_hold - attach a LVB from a glock |
1431 | * @gl: The glock in question | 1471 | * @gl: The glock in question |
@@ -1461,12 +1501,15 @@ int gfs2_lvb_hold(struct gfs2_glock *gl) | |||
1461 | 1501 | ||
1462 | void gfs2_lvb_unhold(struct gfs2_glock *gl) | 1502 | void gfs2_lvb_unhold(struct gfs2_glock *gl) |
1463 | { | 1503 | { |
1504 | struct gfs2_sbd *sdp = gl->gl_sbd; | ||
1505 | |||
1464 | gfs2_glock_hold(gl); | 1506 | gfs2_glock_hold(gl); |
1465 | gfs2_glmutex_lock(gl); | 1507 | gfs2_glmutex_lock(gl); |
1466 | 1508 | ||
1467 | gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0); | 1509 | gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0); |
1468 | if (atomic_dec_and_test(&gl->gl_lvb_count)) { | 1510 | if (atomic_dec_and_test(&gl->gl_lvb_count)) { |
1469 | gfs2_lm_unhold_lvb(gl->gl_sbd, gl->gl_lock, gl->gl_lvb); | 1511 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
1512 | sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(gl->gl_lock, gl->gl_lvb); | ||
1470 | gl->gl_lvb = NULL; | 1513 | gl->gl_lvb = NULL; |
1471 | gfs2_glock_put(gl); | 1514 | gfs2_glock_put(gl); |
1472 | } | 1515 | } |
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 65aa46acb082..8dee4672c3d8 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -211,6 +211,8 @@ struct gfs2_glock { | |||
211 | struct delayed_work gl_work; | 211 | struct delayed_work gl_work; |
212 | }; | 212 | }; |
213 | 213 | ||
214 | #define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */ | ||
215 | |||
214 | struct gfs2_alloc { | 216 | struct gfs2_alloc { |
215 | /* Quota stuff */ | 217 | /* Quota stuff */ |
216 | 218 | ||
diff --git a/fs/gfs2/lm.c b/fs/gfs2/lm.c deleted file mode 100644 index cfcc39b86a53..000000000000 --- a/fs/gfs2/lm.c +++ /dev/null | |||
@@ -1,210 +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/slab.h> | ||
11 | #include <linux/spinlock.h> | ||
12 | #include <linux/completion.h> | ||
13 | #include <linux/buffer_head.h> | ||
14 | #include <linux/delay.h> | ||
15 | #include <linux/gfs2_ondisk.h> | ||
16 | #include <linux/lm_interface.h> | ||
17 | |||
18 | #include "gfs2.h" | ||
19 | #include "incore.h" | ||
20 | #include "glock.h" | ||
21 | #include "lm.h" | ||
22 | #include "super.h" | ||
23 | #include "util.h" | ||
24 | |||
25 | /** | ||
26 | * gfs2_lm_mount - mount a locking protocol | ||
27 | * @sdp: the filesystem | ||
28 | * @args: mount arguements | ||
29 | * @silent: if 1, don't complain if the FS isn't a GFS2 fs | ||
30 | * | ||
31 | * Returns: errno | ||
32 | */ | ||
33 | |||
34 | int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) | ||
35 | { | ||
36 | char *proto = sdp->sd_proto_name; | ||
37 | char *table = sdp->sd_table_name; | ||
38 | int flags = 0; | ||
39 | int error; | ||
40 | |||
41 | if (sdp->sd_args.ar_spectator) | ||
42 | flags |= LM_MFLAG_SPECTATOR; | ||
43 | |||
44 | fs_info(sdp, "Trying to join cluster \"%s\", \"%s\"\n", proto, table); | ||
45 | |||
46 | error = gfs2_mount_lockproto(proto, table, sdp->sd_args.ar_hostdata, | ||
47 | gfs2_glock_cb, sdp, | ||
48 | GFS2_MIN_LVB_SIZE, flags, | ||
49 | &sdp->sd_lockstruct, &sdp->sd_kobj); | ||
50 | if (error) { | ||
51 | fs_info(sdp, "can't mount proto=%s, table=%s, hostdata=%s\n", | ||
52 | proto, table, sdp->sd_args.ar_hostdata); | ||
53 | goto out; | ||
54 | } | ||
55 | |||
56 | if (gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lockspace) || | ||
57 | gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_ops) || | ||
58 | gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lvb_size >= | ||
59 | GFS2_MIN_LVB_SIZE)) { | ||
60 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); | ||
61 | goto out; | ||
62 | } | ||
63 | |||
64 | if (sdp->sd_args.ar_spectator) | ||
65 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.s", table); | ||
66 | else | ||
67 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.%u", table, | ||
68 | sdp->sd_lockstruct.ls_jid); | ||
69 | |||
70 | fs_info(sdp, "Joined cluster. Now mounting FS...\n"); | ||
71 | |||
72 | if ((sdp->sd_lockstruct.ls_flags & LM_LSFLAG_LOCAL) && | ||
73 | !sdp->sd_args.ar_ignore_local_fs) { | ||
74 | sdp->sd_args.ar_localflocks = 1; | ||
75 | sdp->sd_args.ar_localcaching = 1; | ||
76 | } | ||
77 | |||
78 | out: | ||
79 | return error; | ||
80 | } | ||
81 | |||
82 | void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp) | ||
83 | { | ||
84 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
85 | sdp->sd_lockstruct.ls_ops->lm_others_may_mount( | ||
86 | sdp->sd_lockstruct.ls_lockspace); | ||
87 | } | ||
88 | |||
89 | void gfs2_lm_unmount(struct gfs2_sbd *sdp) | ||
90 | { | ||
91 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
92 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); | ||
93 | } | ||
94 | |||
95 | int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) | ||
96 | { | ||
97 | va_list args; | ||
98 | |||
99 | if (test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags)) | ||
100 | return 0; | ||
101 | |||
102 | va_start(args, fmt); | ||
103 | vprintk(fmt, args); | ||
104 | va_end(args); | ||
105 | |||
106 | fs_err(sdp, "about to withdraw this file system\n"); | ||
107 | BUG_ON(sdp->sd_args.ar_debug); | ||
108 | |||
109 | fs_err(sdp, "telling LM to withdraw\n"); | ||
110 | gfs2_withdraw_lockproto(&sdp->sd_lockstruct); | ||
111 | fs_err(sdp, "withdrawn\n"); | ||
112 | dump_stack(); | ||
113 | |||
114 | return -1; | ||
115 | } | ||
116 | |||
117 | int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
118 | void **lockp) | ||
119 | { | ||
120 | int error = -EIO; | ||
121 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
122 | error = sdp->sd_lockstruct.ls_ops->lm_get_lock( | ||
123 | sdp->sd_lockstruct.ls_lockspace, name, lockp); | ||
124 | return error; | ||
125 | } | ||
126 | |||
127 | void gfs2_lm_put_lock(struct gfs2_sbd *sdp, void *lock) | ||
128 | { | ||
129 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
130 | sdp->sd_lockstruct.ls_ops->lm_put_lock(lock); | ||
131 | } | ||
132 | |||
133 | unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, | ||
134 | unsigned int cur_state, unsigned int req_state, | ||
135 | unsigned int flags) | ||
136 | { | ||
137 | int ret = 0; | ||
138 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
139 | ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state, | ||
140 | req_state, flags); | ||
141 | return ret; | ||
142 | } | ||
143 | |||
144 | unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, void *lock, | ||
145 | unsigned int cur_state) | ||
146 | { | ||
147 | int ret = 0; | ||
148 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
149 | ret = sdp->sd_lockstruct.ls_ops->lm_unlock(lock, cur_state); | ||
150 | return ret; | ||
151 | } | ||
152 | |||
153 | void gfs2_lm_cancel(struct gfs2_sbd *sdp, void *lock) | ||
154 | { | ||
155 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
156 | sdp->sd_lockstruct.ls_ops->lm_cancel(lock); | ||
157 | } | ||
158 | |||
159 | int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp) | ||
160 | { | ||
161 | int error = -EIO; | ||
162 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
163 | error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp); | ||
164 | return error; | ||
165 | } | ||
166 | |||
167 | void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, void *lock, char *lvb) | ||
168 | { | ||
169 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
170 | sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(lock, lvb); | ||
171 | } | ||
172 | |||
173 | int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
174 | struct file *file, struct file_lock *fl) | ||
175 | { | ||
176 | int error = -EIO; | ||
177 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
178 | error = sdp->sd_lockstruct.ls_ops->lm_plock_get( | ||
179 | sdp->sd_lockstruct.ls_lockspace, name, file, fl); | ||
180 | return error; | ||
181 | } | ||
182 | |||
183 | int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
184 | struct file *file, int cmd, struct file_lock *fl) | ||
185 | { | ||
186 | int error = -EIO; | ||
187 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
188 | error = sdp->sd_lockstruct.ls_ops->lm_plock( | ||
189 | sdp->sd_lockstruct.ls_lockspace, name, file, cmd, fl); | ||
190 | return error; | ||
191 | } | ||
192 | |||
193 | int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
194 | struct file *file, struct file_lock *fl) | ||
195 | { | ||
196 | int error = -EIO; | ||
197 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
198 | error = sdp->sd_lockstruct.ls_ops->lm_punlock( | ||
199 | sdp->sd_lockstruct.ls_lockspace, name, file, fl); | ||
200 | return error; | ||
201 | } | ||
202 | |||
203 | void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid, | ||
204 | unsigned int message) | ||
205 | { | ||
206 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
207 | sdp->sd_lockstruct.ls_ops->lm_recovery_done( | ||
208 | sdp->sd_lockstruct.ls_lockspace, jid, message); | ||
209 | } | ||
210 | |||
diff --git a/fs/gfs2/lm.h b/fs/gfs2/lm.h deleted file mode 100644 index 21cdc30ee08c..000000000000 --- a/fs/gfs2/lm.h +++ /dev/null | |||
@@ -1,42 +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 | #ifndef __LM_DOT_H__ | ||
11 | #define __LM_DOT_H__ | ||
12 | |||
13 | struct gfs2_sbd; | ||
14 | |||
15 | #define GFS2_MIN_LVB_SIZE 32 | ||
16 | |||
17 | int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent); | ||
18 | void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp); | ||
19 | void gfs2_lm_unmount(struct gfs2_sbd *sdp); | ||
20 | int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) | ||
21 | __attribute__ ((format(printf, 2, 3))); | ||
22 | int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
23 | void **lockp); | ||
24 | void gfs2_lm_put_lock(struct gfs2_sbd *sdp, void *lock); | ||
25 | unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, | ||
26 | unsigned int cur_state, unsigned int req_state, | ||
27 | unsigned int flags); | ||
28 | unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, void *lock, | ||
29 | unsigned int cur_state); | ||
30 | void gfs2_lm_cancel(struct gfs2_sbd *sdp, void *lock); | ||
31 | int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp); | ||
32 | void gfs2_lm_unhold_lvb(struct gfs2_sbd *sdp, void *lock, char *lvb); | ||
33 | int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
34 | struct file *file, struct file_lock *fl); | ||
35 | int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
36 | struct file *file, int cmd, struct file_lock *fl); | ||
37 | int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
38 | struct file *file, struct file_lock *fl); | ||
39 | void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid, | ||
40 | unsigned int message); | ||
41 | |||
42 | #endif /* __LM_DOT_H__ */ | ||
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index f4842f2548cd..f97a8b86c485 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include "glock.h" | 30 | #include "glock.h" |
31 | #include "glops.h" | 31 | #include "glops.h" |
32 | #include "inode.h" | 32 | #include "inode.h" |
33 | #include "lm.h" | ||
34 | #include "log.h" | 33 | #include "log.h" |
35 | #include "meta_io.h" | 34 | #include "meta_io.h" |
36 | #include "quota.h" | 35 | #include "quota.h" |
@@ -596,6 +595,36 @@ static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl) | |||
596 | return generic_setlease(file, arg, fl); | 595 | return generic_setlease(file, arg, fl); |
597 | } | 596 | } |
598 | 597 | ||
598 | static int gfs2_lm_plock_get(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
599 | struct file *file, struct file_lock *fl) | ||
600 | { | ||
601 | int error = -EIO; | ||
602 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
603 | error = sdp->sd_lockstruct.ls_ops->lm_plock_get( | ||
604 | sdp->sd_lockstruct.ls_lockspace, name, file, fl); | ||
605 | return error; | ||
606 | } | ||
607 | |||
608 | static int gfs2_lm_plock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
609 | struct file *file, int cmd, struct file_lock *fl) | ||
610 | { | ||
611 | int error = -EIO; | ||
612 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
613 | error = sdp->sd_lockstruct.ls_ops->lm_plock( | ||
614 | sdp->sd_lockstruct.ls_lockspace, name, file, cmd, fl); | ||
615 | return error; | ||
616 | } | ||
617 | |||
618 | static int gfs2_lm_punlock(struct gfs2_sbd *sdp, struct lm_lockname *name, | ||
619 | struct file *file, struct file_lock *fl) | ||
620 | { | ||
621 | int error = -EIO; | ||
622 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
623 | error = sdp->sd_lockstruct.ls_ops->lm_punlock( | ||
624 | sdp->sd_lockstruct.ls_lockspace, name, file, fl); | ||
625 | return error; | ||
626 | } | ||
627 | |||
599 | /** | 628 | /** |
600 | * gfs2_lock - acquire/release a posix lock on a file | 629 | * gfs2_lock - acquire/release a posix lock on a file |
601 | * @file: the file pointer | 630 | * @file: the file pointer |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 4bee6aa845e4..5b6a34517167 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "glock.h" | 26 | #include "glock.h" |
27 | #include "glops.h" | 27 | #include "glops.h" |
28 | #include "inode.h" | 28 | #include "inode.h" |
29 | #include "lm.h" | ||
30 | #include "mount.h" | 29 | #include "mount.h" |
31 | #include "ops_fstype.h" | 30 | #include "ops_fstype.h" |
32 | #include "ops_dentry.h" | 31 | #include "ops_dentry.h" |
@@ -363,6 +362,13 @@ static int map_journal_extents(struct gfs2_sbd *sdp) | |||
363 | return rc; | 362 | return rc; |
364 | } | 363 | } |
365 | 364 | ||
365 | static void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp) | ||
366 | { | ||
367 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
368 | sdp->sd_lockstruct.ls_ops->lm_others_may_mount( | ||
369 | sdp->sd_lockstruct.ls_lockspace); | ||
370 | } | ||
371 | |||
366 | static int init_journal(struct gfs2_sbd *sdp, int undo) | 372 | static int init_journal(struct gfs2_sbd *sdp, int undo) |
367 | { | 373 | { |
368 | struct gfs2_holder ji_gh; | 374 | struct gfs2_holder ji_gh; |
@@ -705,6 +711,69 @@ fail: | |||
705 | } | 711 | } |
706 | 712 | ||
707 | /** | 713 | /** |
714 | * gfs2_lm_mount - mount a locking protocol | ||
715 | * @sdp: the filesystem | ||
716 | * @args: mount arguements | ||
717 | * @silent: if 1, don't complain if the FS isn't a GFS2 fs | ||
718 | * | ||
719 | * Returns: errno | ||
720 | */ | ||
721 | |||
722 | static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) | ||
723 | { | ||
724 | char *proto = sdp->sd_proto_name; | ||
725 | char *table = sdp->sd_table_name; | ||
726 | int flags = 0; | ||
727 | int error; | ||
728 | |||
729 | if (sdp->sd_args.ar_spectator) | ||
730 | flags |= LM_MFLAG_SPECTATOR; | ||
731 | |||
732 | fs_info(sdp, "Trying to join cluster \"%s\", \"%s\"\n", proto, table); | ||
733 | |||
734 | error = gfs2_mount_lockproto(proto, table, sdp->sd_args.ar_hostdata, | ||
735 | gfs2_glock_cb, sdp, | ||
736 | GFS2_MIN_LVB_SIZE, flags, | ||
737 | &sdp->sd_lockstruct, &sdp->sd_kobj); | ||
738 | if (error) { | ||
739 | fs_info(sdp, "can't mount proto=%s, table=%s, hostdata=%s\n", | ||
740 | proto, table, sdp->sd_args.ar_hostdata); | ||
741 | goto out; | ||
742 | } | ||
743 | |||
744 | if (gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lockspace) || | ||
745 | gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_ops) || | ||
746 | gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lvb_size >= | ||
747 | GFS2_MIN_LVB_SIZE)) { | ||
748 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); | ||
749 | goto out; | ||
750 | } | ||
751 | |||
752 | if (sdp->sd_args.ar_spectator) | ||
753 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.s", table); | ||
754 | else | ||
755 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.%u", table, | ||
756 | sdp->sd_lockstruct.ls_jid); | ||
757 | |||
758 | fs_info(sdp, "Joined cluster. Now mounting FS...\n"); | ||
759 | |||
760 | if ((sdp->sd_lockstruct.ls_flags & LM_LSFLAG_LOCAL) && | ||
761 | !sdp->sd_args.ar_ignore_local_fs) { | ||
762 | sdp->sd_args.ar_localflocks = 1; | ||
763 | sdp->sd_args.ar_localcaching = 1; | ||
764 | } | ||
765 | |||
766 | out: | ||
767 | return error; | ||
768 | } | ||
769 | |||
770 | void gfs2_lm_unmount(struct gfs2_sbd *sdp) | ||
771 | { | ||
772 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
773 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); | ||
774 | } | ||
775 | |||
776 | /** | ||
708 | * fill_super - Read in superblock | 777 | * fill_super - Read in superblock |
709 | * @sb: The VFS superblock | 778 | * @sb: The VFS superblock |
710 | * @data: Mount options | 779 | * @data: Mount options |
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 5e524217944a..2278c68b7e35 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include "incore.h" | 25 | #include "incore.h" |
26 | #include "glock.h" | 26 | #include "glock.h" |
27 | #include "inode.h" | 27 | #include "inode.h" |
28 | #include "lm.h" | ||
29 | #include "log.h" | 28 | #include "log.h" |
30 | #include "mount.h" | 29 | #include "mount.h" |
31 | #include "ops_super.h" | 30 | #include "ops_super.h" |
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 6fb07d67ca8a..b17d3b8b2321 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include "bmap.h" | 20 | #include "bmap.h" |
21 | #include "glock.h" | 21 | #include "glock.h" |
22 | #include "glops.h" | 22 | #include "glops.h" |
23 | #include "lm.h" | ||
24 | #include "lops.h" | 23 | #include "lops.h" |
25 | #include "meta_io.h" | 24 | #include "meta_io.h" |
26 | #include "recovery.h" | 25 | #include "recovery.h" |
@@ -425,6 +424,16 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header_host *hea | |||
425 | return error; | 424 | return error; |
426 | } | 425 | } |
427 | 426 | ||
427 | |||
428 | static void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid, | ||
429 | unsigned int message) | ||
430 | { | ||
431 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
432 | sdp->sd_lockstruct.ls_ops->lm_recovery_done( | ||
433 | sdp->sd_lockstruct.ls_lockspace, jid, message); | ||
434 | } | ||
435 | |||
436 | |||
428 | /** | 437 | /** |
429 | * gfs2_recover_journal - recovery a given journal | 438 | * gfs2_recover_journal - recovery a given journal |
430 | * @jd: the struct gfs2_jdesc describing the journal | 439 | * @jd: the struct gfs2_jdesc describing the journal |
diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h index 60a870e430be..44361ecc44f7 100644 --- a/fs/gfs2/super.h +++ b/fs/gfs2/super.h | |||
@@ -17,6 +17,7 @@ void gfs2_tune_init(struct gfs2_tune *gt); | |||
17 | int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb_host *sb, int silent); | 17 | int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb_host *sb, int silent); |
18 | int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent); | 18 | int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent); |
19 | int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector); | 19 | int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector); |
20 | void gfs2_lm_unmount(struct gfs2_sbd *sdp); | ||
20 | 21 | ||
21 | static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp) | 22 | static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp) |
22 | { | 23 | { |
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index eaa3b7b2f99e..cc35ec862ee8 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
@@ -20,7 +20,6 @@ | |||
20 | 20 | ||
21 | #include "gfs2.h" | 21 | #include "gfs2.h" |
22 | #include "incore.h" | 22 | #include "incore.h" |
23 | #include "lm.h" | ||
24 | #include "sys.h" | 23 | #include "sys.h" |
25 | #include "super.h" | 24 | #include "super.h" |
26 | #include "glock.h" | 25 | #include "glock.h" |
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c index fe9c28ef77b0..d31e355c61fb 100644 --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include "gfs2.h" | 19 | #include "gfs2.h" |
20 | #include "incore.h" | 20 | #include "incore.h" |
21 | #include "glock.h" | 21 | #include "glock.h" |
22 | #include "lm.h" | ||
23 | #include "util.h" | 22 | #include "util.h" |
24 | 23 | ||
25 | struct kmem_cache *gfs2_glock_cachep __read_mostly; | 24 | struct kmem_cache *gfs2_glock_cachep __read_mostly; |
@@ -33,6 +32,28 @@ void gfs2_assert_i(struct gfs2_sbd *sdp) | |||
33 | sdp->sd_fsname); | 32 | sdp->sd_fsname); |
34 | } | 33 | } |
35 | 34 | ||
35 | int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...) | ||
36 | { | ||
37 | va_list args; | ||
38 | |||
39 | if (test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags)) | ||
40 | return 0; | ||
41 | |||
42 | va_start(args, fmt); | ||
43 | vprintk(fmt, args); | ||
44 | va_end(args); | ||
45 | |||
46 | fs_err(sdp, "about to withdraw this file system\n"); | ||
47 | BUG_ON(sdp->sd_args.ar_debug); | ||
48 | |||
49 | fs_err(sdp, "telling LM to withdraw\n"); | ||
50 | gfs2_withdraw_lockproto(&sdp->sd_lockstruct); | ||
51 | fs_err(sdp, "withdrawn\n"); | ||
52 | dump_stack(); | ||
53 | |||
54 | return -1; | ||
55 | } | ||
56 | |||
36 | /** | 57 | /** |
37 | * gfs2_assert_withdraw_i - Cause the machine to withdraw if @assertion is false | 58 | * gfs2_assert_withdraw_i - Cause the machine to withdraw if @assertion is false |
38 | * Returns: -1 if this call withdrew the machine, | 59 | * Returns: -1 if this call withdrew the machine, |
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h index ac0c567ebc36..509c5d60bd80 100644 --- a/fs/gfs2/util.h +++ b/fs/gfs2/util.h | |||
@@ -164,6 +164,7 @@ gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field) | |||
164 | 164 | ||
165 | void gfs2_icbit_munge(struct gfs2_sbd *sdp, unsigned char **bitmap, | 165 | void gfs2_icbit_munge(struct gfs2_sbd *sdp, unsigned char **bitmap, |
166 | unsigned int bit, int new_value); | 166 | unsigned int bit, int new_value); |
167 | int gfs2_lm_withdraw(struct gfs2_sbd *sdp, char *fmt, ...); | ||
167 | 168 | ||
168 | #endif /* __UTIL_DOT_H__ */ | 169 | #endif /* __UTIL_DOT_H__ */ |
169 | 170 | ||