aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2007-05-18 09:58:15 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2007-07-09 03:22:31 -0400
commit85e86edf951a8a39954c0ba1edbe4a58827dcd5c (patch)
tree0d605cdea61d8301c20a87784456a660aba89017 /fs/dlm
parent916297aad5de2363dccd531873eda55d4d6afb57 (diff)
[DLM] block scand during recovery [1/6]
Don't let dlm_scand run during recovery since it may try to do a resource directory removal while the directory nodes are changing. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/dlm')
-rw-r--r--fs/dlm/lock.c47
-rw-r--r--fs/dlm/lock.h2
-rw-r--r--fs/dlm/lockspace.c8
3 files changed, 31 insertions, 26 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index d8d6e729f96b..09668ec2e279 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -194,17 +194,17 @@ void dlm_dump_rsb(struct dlm_rsb *r)
194 194
195/* Threads cannot use the lockspace while it's being recovered */ 195/* Threads cannot use the lockspace while it's being recovered */
196 196
197static inline void lock_recovery(struct dlm_ls *ls) 197static inline void dlm_lock_recovery(struct dlm_ls *ls)
198{ 198{
199 down_read(&ls->ls_in_recovery); 199 down_read(&ls->ls_in_recovery);
200} 200}
201 201
202static inline void unlock_recovery(struct dlm_ls *ls) 202void dlm_unlock_recovery(struct dlm_ls *ls)
203{ 203{
204 up_read(&ls->ls_in_recovery); 204 up_read(&ls->ls_in_recovery);
205} 205}
206 206
207static inline int lock_recovery_try(struct dlm_ls *ls) 207int dlm_lock_recovery_try(struct dlm_ls *ls)
208{ 208{
209 return down_read_trylock(&ls->ls_in_recovery); 209 return down_read_trylock(&ls->ls_in_recovery);
210} 210}
@@ -985,11 +985,10 @@ void dlm_scan_rsbs(struct dlm_ls *ls)
985{ 985{
986 int i; 986 int i;
987 987
988 if (dlm_locking_stopped(ls))
989 return;
990
991 for (i = 0; i < ls->ls_rsbtbl_size; i++) { 988 for (i = 0; i < ls->ls_rsbtbl_size; i++) {
992 shrink_bucket(ls, i); 989 shrink_bucket(ls, i);
990 if (dlm_locking_stopped(ls))
991 break;
993 cond_resched(); 992 cond_resched();
994 } 993 }
995} 994}
@@ -2274,7 +2273,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
2274 if (!ls) 2273 if (!ls)
2275 return -EINVAL; 2274 return -EINVAL;
2276 2275
2277 lock_recovery(ls); 2276 dlm_lock_recovery(ls);
2278 2277
2279 if (convert) 2278 if (convert)
2280 error = find_lkb(ls, lksb->sb_lkid, &lkb); 2279 error = find_lkb(ls, lksb->sb_lkid, &lkb);
@@ -2302,7 +2301,7 @@ int dlm_lock(dlm_lockspace_t *lockspace,
2302 if (error == -EAGAIN) 2301 if (error == -EAGAIN)
2303 error = 0; 2302 error = 0;
2304 out: 2303 out:
2305 unlock_recovery(ls); 2304 dlm_unlock_recovery(ls);
2306 dlm_put_lockspace(ls); 2305 dlm_put_lockspace(ls);
2307 return error; 2306 return error;
2308} 2307}
@@ -2322,7 +2321,7 @@ int dlm_unlock(dlm_lockspace_t *lockspace,
2322 if (!ls) 2321 if (!ls)
2323 return -EINVAL; 2322 return -EINVAL;
2324 2323
2325 lock_recovery(ls); 2324 dlm_lock_recovery(ls);
2326 2325
2327 error = find_lkb(ls, lkid, &lkb); 2326 error = find_lkb(ls, lkid, &lkb);
2328 if (error) 2327 if (error)
@@ -2344,7 +2343,7 @@ int dlm_unlock(dlm_lockspace_t *lockspace,
2344 out_put: 2343 out_put:
2345 dlm_put_lkb(lkb); 2344 dlm_put_lkb(lkb);
2346 out: 2345 out:
2347 unlock_recovery(ls); 2346 dlm_unlock_recovery(ls);
2348 dlm_put_lockspace(ls); 2347 dlm_put_lockspace(ls);
2349 return error; 2348 return error;
2350} 2349}
@@ -3424,7 +3423,7 @@ int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
3424 } 3423 }
3425 } 3424 }
3426 3425
3427 if (lock_recovery_try(ls)) 3426 if (dlm_lock_recovery_try(ls))
3428 break; 3427 break;
3429 schedule(); 3428 schedule();
3430 } 3429 }
@@ -3503,7 +3502,7 @@ int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
3503 log_error(ls, "unknown message type %d", ms->m_type); 3502 log_error(ls, "unknown message type %d", ms->m_type);
3504 } 3503 }
3505 3504
3506 unlock_recovery(ls); 3505 dlm_unlock_recovery(ls);
3507 out: 3506 out:
3508 dlm_put_lockspace(ls); 3507 dlm_put_lockspace(ls);
3509 dlm_astd_wake(); 3508 dlm_astd_wake();
@@ -4040,7 +4039,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
4040 struct dlm_args args; 4039 struct dlm_args args;
4041 int error; 4040 int error;
4042 4041
4043 lock_recovery(ls); 4042 dlm_lock_recovery(ls);
4044 4043
4045 error = create_lkb(ls, &lkb); 4044 error = create_lkb(ls, &lkb);
4046 if (error) { 4045 if (error) {
@@ -4094,7 +4093,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
4094 list_add_tail(&lkb->lkb_ownqueue, &ua->proc->locks); 4093 list_add_tail(&lkb->lkb_ownqueue, &ua->proc->locks);
4095 spin_unlock(&ua->proc->locks_spin); 4094 spin_unlock(&ua->proc->locks_spin);
4096 out: 4095 out:
4097 unlock_recovery(ls); 4096 dlm_unlock_recovery(ls);
4098 return error; 4097 return error;
4099} 4098}
4100 4099
@@ -4106,7 +4105,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4106 struct dlm_user_args *ua; 4105 struct dlm_user_args *ua;
4107 int error; 4106 int error;
4108 4107
4109 lock_recovery(ls); 4108 dlm_lock_recovery(ls);
4110 4109
4111 error = find_lkb(ls, lkid, &lkb); 4110 error = find_lkb(ls, lkid, &lkb);
4112 if (error) 4111 if (error)
@@ -4146,7 +4145,7 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4146 out_put: 4145 out_put:
4147 dlm_put_lkb(lkb); 4146 dlm_put_lkb(lkb);
4148 out: 4147 out:
4149 unlock_recovery(ls); 4148 dlm_unlock_recovery(ls);
4150 kfree(ua_tmp); 4149 kfree(ua_tmp);
4151 return error; 4150 return error;
4152} 4151}
@@ -4159,7 +4158,7 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4159 struct dlm_user_args *ua; 4158 struct dlm_user_args *ua;
4160 int error; 4159 int error;
4161 4160
4162 lock_recovery(ls); 4161 dlm_lock_recovery(ls);
4163 4162
4164 error = find_lkb(ls, lkid, &lkb); 4163 error = find_lkb(ls, lkid, &lkb);
4165 if (error) 4164 if (error)
@@ -4194,7 +4193,7 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4194 out_put: 4193 out_put:
4195 dlm_put_lkb(lkb); 4194 dlm_put_lkb(lkb);
4196 out: 4195 out:
4197 unlock_recovery(ls); 4196 dlm_unlock_recovery(ls);
4198 kfree(ua_tmp); 4197 kfree(ua_tmp);
4199 return error; 4198 return error;
4200} 4199}
@@ -4207,7 +4206,7 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4207 struct dlm_user_args *ua; 4206 struct dlm_user_args *ua;
4208 int error; 4207 int error;
4209 4208
4210 lock_recovery(ls); 4209 dlm_lock_recovery(ls);
4211 4210
4212 error = find_lkb(ls, lkid, &lkb); 4211 error = find_lkb(ls, lkid, &lkb);
4213 if (error) 4212 if (error)
@@ -4231,7 +4230,7 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
4231 out_put: 4230 out_put:
4232 dlm_put_lkb(lkb); 4231 dlm_put_lkb(lkb);
4233 out: 4232 out:
4234 unlock_recovery(ls); 4233 dlm_unlock_recovery(ls);
4235 kfree(ua_tmp); 4234 kfree(ua_tmp);
4236 return error; 4235 return error;
4237} 4236}
@@ -4314,7 +4313,7 @@ void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc)
4314{ 4313{
4315 struct dlm_lkb *lkb, *safe; 4314 struct dlm_lkb *lkb, *safe;
4316 4315
4317 lock_recovery(ls); 4316 dlm_lock_recovery(ls);
4318 4317
4319 while (1) { 4318 while (1) {
4320 lkb = del_proc_lock(ls, proc); 4319 lkb = del_proc_lock(ls, proc);
@@ -4347,7 +4346,7 @@ void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc)
4347 } 4346 }
4348 4347
4349 mutex_unlock(&ls->ls_clear_proc_locks); 4348 mutex_unlock(&ls->ls_clear_proc_locks);
4350 unlock_recovery(ls); 4349 dlm_unlock_recovery(ls);
4351} 4350}
4352 4351
4353static void purge_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc) 4352static void purge_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc)
@@ -4429,12 +4428,12 @@ int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc,
4429 if (nodeid != dlm_our_nodeid()) { 4428 if (nodeid != dlm_our_nodeid()) {
4430 error = send_purge(ls, nodeid, pid); 4429 error = send_purge(ls, nodeid, pid);
4431 } else { 4430 } else {
4432 lock_recovery(ls); 4431 dlm_lock_recovery(ls);
4433 if (pid == current->pid) 4432 if (pid == current->pid)
4434 purge_proc_locks(ls, proc); 4433 purge_proc_locks(ls, proc);
4435 else 4434 else
4436 do_purge(ls, nodeid, pid); 4435 do_purge(ls, nodeid, pid);
4437 unlock_recovery(ls); 4436 dlm_unlock_recovery(ls);
4438 } 4437 }
4439 return error; 4438 return error;
4440} 4439}
diff --git a/fs/dlm/lock.h b/fs/dlm/lock.h
index 64fc4ec40668..19403aa08739 100644
--- a/fs/dlm/lock.h
+++ b/fs/dlm/lock.h
@@ -24,6 +24,8 @@ void dlm_put_rsb(struct dlm_rsb *r);
24void dlm_hold_rsb(struct dlm_rsb *r); 24void dlm_hold_rsb(struct dlm_rsb *r);
25int dlm_put_lkb(struct dlm_lkb *lkb); 25int dlm_put_lkb(struct dlm_lkb *lkb);
26void dlm_scan_rsbs(struct dlm_ls *ls); 26void dlm_scan_rsbs(struct dlm_ls *ls);
27int dlm_lock_recovery_try(struct dlm_ls *ls);
28void dlm_unlock_recovery(struct dlm_ls *ls);
27 29
28int dlm_purge_locks(struct dlm_ls *ls); 30int dlm_purge_locks(struct dlm_ls *ls);
29void dlm_purge_mstcpy_locks(struct dlm_rsb *r); 31void dlm_purge_mstcpy_locks(struct dlm_rsb *r);
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index a677b2a5eed4..414a108df934 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -234,8 +234,12 @@ static int dlm_scand(void *data)
234 struct dlm_ls *ls; 234 struct dlm_ls *ls;
235 235
236 while (!kthread_should_stop()) { 236 while (!kthread_should_stop()) {
237 list_for_each_entry(ls, &lslist, ls_list) 237 list_for_each_entry(ls, &lslist, ls_list) {
238 dlm_scan_rsbs(ls); 238 if (dlm_lock_recovery_try(ls)) {
239 dlm_scan_rsbs(ls);
240 dlm_unlock_recovery(ls);
241 }
242 }
239 schedule_timeout_interruptible(dlm_config.ci_scan_secs * HZ); 243 schedule_timeout_interruptible(dlm_config.ci_scan_secs * HZ);
240 } 244 }
241 return 0; 245 return 0;