diff options
Diffstat (limited to 'fs/gfs2/locking/dlm/lock.c')
-rw-r--r-- | fs/gfs2/locking/dlm/lock.c | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c index daf59d504e29..d799865b64a4 100644 --- a/fs/gfs2/locking/dlm/lock.c +++ b/fs/gfs2/locking/dlm/lock.c | |||
@@ -1,15 +1,11 @@ | |||
1 | /****************************************************************************** | 1 | /* |
2 | ******************************************************************************* | 2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
3 | ** | 3 | * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. |
4 | ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 4 | * |
5 | ** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. | 5 | * This copyrighted material is made available to anyone wishing to use, |
6 | ** | 6 | * modify, copy, or redistribute it subject to the terms and conditions |
7 | ** This copyrighted material is made available to anyone wishing to use, | 7 | * of the GNU General Public License v.2. |
8 | ** modify, copy, or redistribute it subject to the terms and conditions | 8 | */ |
9 | ** of the GNU General Public License v.2. | ||
10 | ** | ||
11 | ******************************************************************************* | ||
12 | ******************************************************************************/ | ||
13 | 9 | ||
14 | #include "lock_dlm.h" | 10 | #include "lock_dlm.h" |
15 | 11 | ||
@@ -38,7 +34,7 @@ static inline void gdlm_bast(void *astarg, int mode) | |||
38 | struct gdlm_ls *ls = lp->ls; | 34 | struct gdlm_ls *ls = lp->ls; |
39 | 35 | ||
40 | if (!mode) { | 36 | if (!mode) { |
41 | printk("lock_dlm: bast mode zero %x,%"PRIx64"\n", | 37 | printk("lock_dlm: bast mode zero %x,%llx\n", |
42 | lp->lockname.ln_type, lp->lockname.ln_number); | 38 | lp->lockname.ln_type, lp->lockname.ln_number); |
43 | return; | 39 | return; |
44 | } | 40 | } |
@@ -75,9 +71,9 @@ static int16_t make_mode(int16_t lmstate) | |||
75 | return DLM_LOCK_CW; | 71 | return DLM_LOCK_CW; |
76 | case LM_ST_SHARED: | 72 | case LM_ST_SHARED: |
77 | return DLM_LOCK_PR; | 73 | return DLM_LOCK_PR; |
78 | default: | ||
79 | GDLM_ASSERT(0, printk("unknown LM state %d\n", lmstate);); | ||
80 | } | 74 | } |
75 | gdlm_assert(0, "unknown LM state %d", lmstate); | ||
76 | return -1; | ||
81 | } | 77 | } |
82 | 78 | ||
83 | /* convert dlm lock-mode to gfs lock-state */ | 79 | /* convert dlm lock-mode to gfs lock-state */ |
@@ -94,9 +90,9 @@ int16_t gdlm_make_lmstate(int16_t dlmmode) | |||
94 | return LM_ST_DEFERRED; | 90 | return LM_ST_DEFERRED; |
95 | case DLM_LOCK_PR: | 91 | case DLM_LOCK_PR: |
96 | return LM_ST_SHARED; | 92 | return LM_ST_SHARED; |
97 | default: | ||
98 | GDLM_ASSERT(0, printk("unknown DLM mode %d\n", dlmmode);); | ||
99 | } | 93 | } |
94 | gdlm_assert(0, "unknown DLM mode %d", dlmmode); | ||
95 | return -1; | ||
100 | } | 96 | } |
101 | 97 | ||
102 | /* verify agreement with GFS on the current lock state, NB: DLM_LOCK_NL and | 98 | /* verify agreement with GFS on the current lock state, NB: DLM_LOCK_NL and |
@@ -106,7 +102,7 @@ static void check_cur_state(struct gdlm_lock *lp, unsigned int cur_state) | |||
106 | { | 102 | { |
107 | int16_t cur = make_mode(cur_state); | 103 | int16_t cur = make_mode(cur_state); |
108 | if (lp->cur != DLM_LOCK_IV) | 104 | if (lp->cur != DLM_LOCK_IV) |
109 | GDLM_ASSERT(lp->cur == cur, printk("%d, %d\n", lp->cur, cur);); | 105 | gdlm_assert(lp->cur == cur, "%d, %d", lp->cur, cur); |
110 | } | 106 | } |
111 | 107 | ||
112 | static inline unsigned int make_flags(struct gdlm_lock *lp, | 108 | static inline unsigned int make_flags(struct gdlm_lock *lp, |
@@ -157,7 +153,7 @@ static inline unsigned int make_flags(struct gdlm_lock *lp, | |||
157 | static inline void make_strname(struct lm_lockname *lockname, | 153 | static inline void make_strname(struct lm_lockname *lockname, |
158 | struct gdlm_strname *str) | 154 | struct gdlm_strname *str) |
159 | { | 155 | { |
160 | sprintf(str->name, "%8x%16"PRIx64, lockname->ln_type, | 156 | sprintf(str->name, "%8x%16llx", lockname->ln_type, |
161 | lockname->ln_number); | 157 | lockname->ln_number); |
162 | str->namelen = GDLM_STRNAME_BYTES; | 158 | str->namelen = GDLM_STRNAME_BYTES; |
163 | } | 159 | } |
@@ -167,11 +163,10 @@ int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name, | |||
167 | { | 163 | { |
168 | struct gdlm_lock *lp; | 164 | struct gdlm_lock *lp; |
169 | 165 | ||
170 | lp = kmalloc(sizeof(struct gdlm_lock), GFP_KERNEL); | 166 | lp = kzalloc(sizeof(struct gdlm_lock), GFP_KERNEL); |
171 | if (!lp) | 167 | if (!lp) |
172 | return -ENOMEM; | 168 | return -ENOMEM; |
173 | 169 | ||
174 | memset(lp, 0, sizeof(struct gdlm_lock)); | ||
175 | lp->lockname = *name; | 170 | lp->lockname = *name; |
176 | lp->ls = ls; | 171 | lp->ls = ls; |
177 | lp->cur = DLM_LOCK_IV; | 172 | lp->cur = DLM_LOCK_IV; |
@@ -202,7 +197,8 @@ void gdlm_delete_lp(struct gdlm_lock *lp) | |||
202 | list_del_init(&lp->blist); | 197 | list_del_init(&lp->blist); |
203 | if (!list_empty(&lp->delay_list)) | 198 | if (!list_empty(&lp->delay_list)) |
204 | list_del_init(&lp->delay_list); | 199 | list_del_init(&lp->delay_list); |
205 | GDLM_ASSERT(!list_empty(&lp->all_list),); | 200 | gdlm_assert(!list_empty(&lp->all_list), |
201 | "%x,%llx", lp->lockname.ln_type, lp->lockname.ln_number); | ||
206 | list_del_init(&lp->all_list); | 202 | list_del_init(&lp->all_list); |
207 | ls->all_locks_count--; | 203 | ls->all_locks_count--; |
208 | spin_unlock(&ls->async_lock); | 204 | spin_unlock(&ls->async_lock); |
@@ -227,7 +223,7 @@ void gdlm_put_lock(lm_lock_t *lock) | |||
227 | gdlm_delete_lp((struct gdlm_lock *) lock); | 223 | gdlm_delete_lp((struct gdlm_lock *) lock); |
228 | } | 224 | } |
229 | 225 | ||
230 | void gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range) | 226 | unsigned int gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range) |
231 | { | 227 | { |
232 | struct gdlm_ls *ls = lp->ls; | 228 | struct gdlm_ls *ls = lp->ls; |
233 | struct gdlm_strname str; | 229 | struct gdlm_strname str; |
@@ -242,7 +238,7 @@ void gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range) | |||
242 | if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) && | 238 | if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) && |
243 | !test_bit(LFL_NOBLOCK, &lp->flags) && lp->req != DLM_LOCK_NL) { | 239 | !test_bit(LFL_NOBLOCK, &lp->flags) && lp->req != DLM_LOCK_NL) { |
244 | gdlm_queue_delayed(lp); | 240 | gdlm_queue_delayed(lp); |
245 | return; | 241 | return LM_OUT_ASYNC; |
246 | } | 242 | } |
247 | 243 | ||
248 | /* | 244 | /* |
@@ -256,7 +252,7 @@ void gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range) | |||
256 | 252 | ||
257 | set_bit(LFL_ACTIVE, &lp->flags); | 253 | set_bit(LFL_ACTIVE, &lp->flags); |
258 | 254 | ||
259 | log_debug("lk %x,%"PRIx64" id %x %d,%d %x", lp->lockname.ln_type, | 255 | log_debug("lk %x,%llx id %x %d,%d %x", lp->lockname.ln_type, |
260 | lp->lockname.ln_number, lp->lksb.sb_lkid, | 256 | lp->lockname.ln_number, lp->lksb.sb_lkid, |
261 | lp->cur, lp->req, lp->lkf); | 257 | lp->cur, lp->req, lp->lkf); |
262 | 258 | ||
@@ -270,15 +266,19 @@ void gdlm_do_lock(struct gdlm_lock *lp, struct dlm_range *range) | |||
270 | error = 0; | 266 | error = 0; |
271 | } | 267 | } |
272 | 268 | ||
273 | GDLM_ASSERT(!error, | 269 | if (error) { |
274 | printk("%s: num=%x,%"PRIx64" err=%d cur=%d req=%d lkf=%x\n", | 270 | log_debug("%s: gdlm_lock %x,%llx err=%d cur=%d req=%d lkf=%x " |
275 | ls->fsname, lp->lockname.ln_type, | 271 | "flags=%lx", ls->fsname, lp->lockname.ln_type, |
276 | lp->lockname.ln_number, error, lp->cur, lp->req, | 272 | lp->lockname.ln_number, error, lp->cur, lp->req, |
277 | lp->lkf);); | 273 | lp->lkf, lp->flags); |
274 | return LM_OUT_ERROR; | ||
275 | } | ||
276 | return LM_OUT_ASYNC; | ||
278 | } | 277 | } |
279 | 278 | ||
280 | void gdlm_do_unlock(struct gdlm_lock *lp) | 279 | unsigned int gdlm_do_unlock(struct gdlm_lock *lp) |
281 | { | 280 | { |
281 | struct gdlm_ls *ls = lp->ls; | ||
282 | unsigned int lkf = 0; | 282 | unsigned int lkf = 0; |
283 | int error; | 283 | int error; |
284 | 284 | ||
@@ -288,16 +288,19 @@ void gdlm_do_unlock(struct gdlm_lock *lp) | |||
288 | if (lp->lvb) | 288 | if (lp->lvb) |
289 | lkf = DLM_LKF_VALBLK; | 289 | lkf = DLM_LKF_VALBLK; |
290 | 290 | ||
291 | log_debug("un %x,%"PRIx64" %x %d %x", lp->lockname.ln_type, | 291 | log_debug("un %x,%llx %x %d %x", lp->lockname.ln_type, |
292 | lp->lockname.ln_number, lp->lksb.sb_lkid, lp->cur, lkf); | 292 | lp->lockname.ln_number, lp->lksb.sb_lkid, lp->cur, lkf); |
293 | 293 | ||
294 | error = dlm_unlock(lp->ls->dlm_lockspace, lp->lksb.sb_lkid, lkf, | 294 | error = dlm_unlock(ls->dlm_lockspace, lp->lksb.sb_lkid, lkf, NULL, lp); |
295 | NULL, lp); | ||
296 | 295 | ||
297 | GDLM_ASSERT(!error, | 296 | if (error) { |
298 | printk("%s: error=%d num=%x,%"PRIx64" lkf=%x flags=%lx\n", | 297 | log_debug("%s: gdlm_unlock %x,%llx err=%d cur=%d req=%d lkf=%x " |
299 | lp->ls->fsname, error, lp->lockname.ln_type, | 298 | "flags=%lx", ls->fsname, lp->lockname.ln_type, |
300 | lp->lockname.ln_number, lkf, lp->flags);); | 299 | lp->lockname.ln_number, error, lp->cur, lp->req, |
300 | lp->lkf, lp->flags); | ||
301 | return LM_OUT_ERROR; | ||
302 | } | ||
303 | return LM_OUT_ASYNC; | ||
301 | } | 304 | } |
302 | 305 | ||
303 | unsigned int gdlm_lock(lm_lock_t *lock, unsigned int cur_state, | 306 | unsigned int gdlm_lock(lm_lock_t *lock, unsigned int cur_state, |
@@ -313,8 +316,7 @@ unsigned int gdlm_lock(lm_lock_t *lock, unsigned int cur_state, | |||
313 | lp->req = make_mode(req_state); | 316 | lp->req = make_mode(req_state); |
314 | lp->lkf = make_flags(lp, flags, lp->cur, lp->req); | 317 | lp->lkf = make_flags(lp, flags, lp->cur, lp->req); |
315 | 318 | ||
316 | gdlm_do_lock(lp, NULL); | 319 | return gdlm_do_lock(lp, NULL); |
317 | return LM_OUT_ASYNC; | ||
318 | } | 320 | } |
319 | 321 | ||
320 | unsigned int gdlm_unlock(lm_lock_t *lock, unsigned int cur_state) | 322 | unsigned int gdlm_unlock(lm_lock_t *lock, unsigned int cur_state) |
@@ -324,8 +326,7 @@ unsigned int gdlm_unlock(lm_lock_t *lock, unsigned int cur_state) | |||
324 | clear_bit(LFL_DLM_CANCEL, &lp->flags); | 326 | clear_bit(LFL_DLM_CANCEL, &lp->flags); |
325 | if (lp->cur == DLM_LOCK_IV) | 327 | if (lp->cur == DLM_LOCK_IV) |
326 | return 0; | 328 | return 0; |
327 | gdlm_do_unlock(lp); | 329 | return gdlm_do_unlock(lp); |
328 | return LM_OUT_ASYNC; | ||
329 | } | 330 | } |
330 | 331 | ||
331 | void gdlm_cancel(lm_lock_t *lock) | 332 | void gdlm_cancel(lm_lock_t *lock) |
@@ -337,8 +338,8 @@ void gdlm_cancel(lm_lock_t *lock) | |||
337 | if (test_bit(LFL_DLM_CANCEL, &lp->flags)) | 338 | if (test_bit(LFL_DLM_CANCEL, &lp->flags)) |
338 | return; | 339 | return; |
339 | 340 | ||
340 | log_all("gdlm_cancel %x,%"PRIx64" flags %lx", | 341 | log_info("gdlm_cancel %x,%llx flags %lx", |
341 | lp->lockname.ln_type, lp->lockname.ln_number, lp->flags); | 342 | lp->lockname.ln_type, lp->lockname.ln_number, lp->flags); |
342 | 343 | ||
343 | spin_lock(&ls->async_lock); | 344 | spin_lock(&ls->async_lock); |
344 | if (!list_empty(&lp->delay_list)) { | 345 | if (!list_empty(&lp->delay_list)) { |
@@ -356,9 +357,9 @@ void gdlm_cancel(lm_lock_t *lock) | |||
356 | 357 | ||
357 | if (!test_bit(LFL_ACTIVE, &lp->flags) || | 358 | if (!test_bit(LFL_ACTIVE, &lp->flags) || |
358 | test_bit(LFL_DLM_UNLOCK, &lp->flags)) { | 359 | test_bit(LFL_DLM_UNLOCK, &lp->flags)) { |
359 | log_all("gdlm_cancel skip %x,%"PRIx64" flags %lx", | 360 | log_info("gdlm_cancel skip %x,%llx flags %lx", |
360 | lp->lockname.ln_type, lp->lockname.ln_number, | 361 | lp->lockname.ln_type, lp->lockname.ln_number, |
361 | lp->flags); | 362 | lp->flags); |
362 | return; | 363 | return; |
363 | } | 364 | } |
364 | 365 | ||
@@ -370,8 +371,8 @@ void gdlm_cancel(lm_lock_t *lock) | |||
370 | error = dlm_unlock(ls->dlm_lockspace, lp->lksb.sb_lkid, DLM_LKF_CANCEL, | 371 | error = dlm_unlock(ls->dlm_lockspace, lp->lksb.sb_lkid, DLM_LKF_CANCEL, |
371 | NULL, lp); | 372 | NULL, lp); |
372 | 373 | ||
373 | log_all("gdlm_cancel rv %d %x,%"PRIx64" flags %lx", error, | 374 | log_info("gdlm_cancel rv %d %x,%llx flags %lx", error, |
374 | lp->lockname.ln_type, lp->lockname.ln_number, lp->flags); | 375 | lp->lockname.ln_type, lp->lockname.ln_number, lp->flags); |
375 | 376 | ||
376 | if (error == -EBUSY) | 377 | if (error == -EBUSY) |
377 | clear_bit(LFL_DLM_CANCEL, &lp->flags); | 378 | clear_bit(LFL_DLM_CANCEL, &lp->flags); |
@@ -381,12 +382,10 @@ int gdlm_add_lvb(struct gdlm_lock *lp) | |||
381 | { | 382 | { |
382 | char *lvb; | 383 | char *lvb; |
383 | 384 | ||
384 | lvb = kmalloc(GDLM_LVB_SIZE, GFP_KERNEL); | 385 | lvb = kzalloc(GDLM_LVB_SIZE, GFP_KERNEL); |
385 | if (!lvb) | 386 | if (!lvb) |
386 | return -ENOMEM; | 387 | return -ENOMEM; |
387 | 388 | ||
388 | memset(lvb, 0, GDLM_LVB_SIZE); | ||
389 | |||
390 | lp->lksb.sb_lvbptr = lvb; | 389 | lp->lksb.sb_lvbptr = lvb; |
391 | lp->lvb = lvb; | 390 | lp->lvb = lvb; |
392 | return 0; | 391 | return 0; |
@@ -448,7 +447,8 @@ static void unhold_null_lock(struct gdlm_lock *lp) | |||
448 | { | 447 | { |
449 | struct gdlm_lock *lpn = lp->hold_null; | 448 | struct gdlm_lock *lpn = lp->hold_null; |
450 | 449 | ||
451 | GDLM_ASSERT(lpn,); | 450 | gdlm_assert(lpn, "%x,%llx", |
451 | lp->lockname.ln_type, lp->lockname.ln_number); | ||
452 | lpn->lksb.sb_lvbptr = NULL; | 452 | lpn->lksb.sb_lvbptr = NULL; |
453 | lpn->lvb = NULL; | 453 | lpn->lvb = NULL; |
454 | set_bit(LFL_UNLOCK_DELETE, &lpn->flags); | 454 | set_bit(LFL_UNLOCK_DELETE, &lpn->flags); |