Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm:
dlm: fs/dlm/ast.c: fix warning
dlm: add new debugfs entry
dlm: add time stamp of blocking callback
dlm: change lock time stamping
dlm: improve how bast mode handling
dlm: remove extra blocking callback check
dlm: replace schedule with cond_resched
dlm: remove kmap/kunmap
dlm: trivial annotation of be16 value
dlm: fix up memory allocation flags

+314 -128
+22 -30
fs/dlm/ast.c
··· 2 ******************************************************************************* 3 ** 4 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 5 - ** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. 6 ** 7 ** This copyrighted material is made available to anyone wishing to use, 8 ** modify, copy, or redistribute it subject to the terms and conditions ··· 33 spin_unlock(&ast_queue_lock); 34 } 35 36 - void dlm_add_ast(struct dlm_lkb *lkb, int type) 37 { 38 if (lkb->lkb_flags & DLM_IFL_USER) { 39 - dlm_user_add_ast(lkb, type); 40 return; 41 } 42 ··· 46 list_add_tail(&lkb->lkb_astqueue, &ast_queue); 47 } 48 lkb->lkb_ast_type |= type; 49 spin_unlock(&ast_queue_lock); 50 51 set_bit(WAKE_ASTS, &astd_wakeflags); ··· 61 struct dlm_lkb *lkb; 62 void (*cast) (void *astparam); 63 void (*bast) (void *astparam, int mode); 64 - int type = 0, found, bmode; 65 66 - for (;;) { 67 - found = 0; 68 - spin_lock(&ast_queue_lock); 69 - list_for_each_entry(lkb, &ast_queue, lkb_astqueue) { 70 - r = lkb->lkb_resource; 71 - ls = r->res_ls; 72 73 - if (dlm_locking_stopped(ls)) 74 - continue; 75 76 - list_del(&lkb->lkb_astqueue); 77 - type = lkb->lkb_ast_type; 78 - lkb->lkb_ast_type = 0; 79 - found = 1; 80 - break; 81 - } 82 spin_unlock(&ast_queue_lock); 83 - 84 - if (!found) 85 - break; 86 - 87 cast = lkb->lkb_astfn; 88 bast = lkb->lkb_bastfn; 89 - bmode = lkb->lkb_bastmode; 90 91 if ((type & AST_COMP) && cast) 92 cast(lkb->lkb_astparam); 93 94 - /* FIXME: Is it safe to look at lkb_grmode here 95 - without doing a lock_rsb() ? 96 - Look at other checks in v1 to avoid basts. */ 97 - 98 if ((type & AST_BAST) && bast) 99 - if (!dlm_modes_compat(lkb->lkb_grmode, bmode)) 100 - bast(lkb->lkb_astparam, bmode); 101 102 /* this removes the reference added by dlm_add_ast 103 and may result in the lkb being freed */ 104 dlm_put_lkb(lkb); 105 106 - schedule(); 107 } 108 } 109 110 static inline int no_asts(void)
··· 2 ******************************************************************************* 3 ** 4 ** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 5 + ** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 6 ** 7 ** This copyrighted material is made available to anyone wishing to use, 8 ** modify, copy, or redistribute it subject to the terms and conditions ··· 33 spin_unlock(&ast_queue_lock); 34 } 35 36 + void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode) 37 { 38 if (lkb->lkb_flags & DLM_IFL_USER) { 39 + dlm_user_add_ast(lkb, type, bastmode); 40 return; 41 } 42 ··· 46 list_add_tail(&lkb->lkb_astqueue, &ast_queue); 47 } 48 lkb->lkb_ast_type |= type; 49 + if (bastmode) 50 + lkb->lkb_bastmode = bastmode; 51 spin_unlock(&ast_queue_lock); 52 53 set_bit(WAKE_ASTS, &astd_wakeflags); ··· 59 struct dlm_lkb *lkb; 60 void (*cast) (void *astparam); 61 void (*bast) (void *astparam, int mode); 62 + int type = 0, bastmode; 63 64 + repeat: 65 + spin_lock(&ast_queue_lock); 66 + list_for_each_entry(lkb, &ast_queue, lkb_astqueue) { 67 + r = lkb->lkb_resource; 68 + ls = r->res_ls; 69 70 + if (dlm_locking_stopped(ls)) 71 + continue; 72 73 + list_del(&lkb->lkb_astqueue); 74 + type = lkb->lkb_ast_type; 75 + lkb->lkb_ast_type = 0; 76 + bastmode = lkb->lkb_bastmode; 77 + 78 spin_unlock(&ast_queue_lock); 79 cast = lkb->lkb_astfn; 80 bast = lkb->lkb_bastfn; 81 82 if ((type & AST_COMP) && cast) 83 cast(lkb->lkb_astparam); 84 85 if ((type & AST_BAST) && bast) 86 + bast(lkb->lkb_astparam, bastmode); 87 88 /* this removes the reference added by dlm_add_ast 89 and may result in the lkb being freed */ 90 dlm_put_lkb(lkb); 91 92 + cond_resched(); 93 + goto repeat; 94 } 95 + spin_unlock(&ast_queue_lock); 96 } 97 98 static inline int no_asts(void)
+2 -2
fs/dlm/ast.h
··· 1 /****************************************************************************** 2 ******************************************************************************* 3 ** 4 - ** Copyright (C) 2005 Red Hat, Inc. All rights reserved. 5 ** 6 ** This copyrighted material is made available to anyone wishing to use, 7 ** modify, copy, or redistribute it subject to the terms and conditions ··· 13 #ifndef __ASTD_DOT_H__ 14 #define __ASTD_DOT_H__ 15 16 - void dlm_add_ast(struct dlm_lkb *lkb, int type); 17 void dlm_del_ast(struct dlm_lkb *lkb); 18 19 void dlm_astd_wake(void);
··· 1 /****************************************************************************** 2 ******************************************************************************* 3 ** 4 + ** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 5 ** 6 ** This copyrighted material is made available to anyone wishing to use, 7 ** modify, copy, or redistribute it subject to the terms and conditions ··· 13 #ifndef __ASTD_DOT_H__ 14 #define __ASTD_DOT_H__ 15 16 + void dlm_add_ast(struct dlm_lkb *lkb, int type, int bastmode); 17 void dlm_del_ast(struct dlm_lkb *lkb); 18 19 void dlm_astd_wake(void);
+253 -57
fs/dlm/debug_fs.c
··· 1 /****************************************************************************** 2 ******************************************************************************* 3 ** 4 - ** Copyright (C) 2005 Red Hat, Inc. All rights reserved. 5 ** 6 ** This copyrighted material is made available to anyone wishing to use, 7 ** modify, copy, or redistribute it subject to the terms and conditions ··· 27 28 struct rsb_iter { 29 int entry; 30 - int locks; 31 int header; 32 struct dlm_ls *ls; 33 struct list_head *next; ··· 60 } 61 } 62 63 - static void print_resource_lock(struct seq_file *s, struct dlm_lkb *lkb, 64 - struct dlm_rsb *res) 65 { 66 seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode)); 67 ··· 83 seq_printf(s, "\n"); 84 } 85 86 - static int print_resource(struct dlm_rsb *res, struct seq_file *s) 87 { 88 struct dlm_lkb *lkb; 89 int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list; ··· 134 /* Print the locks attached to this resource */ 135 seq_printf(s, "Granted Queue\n"); 136 list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) 137 - print_resource_lock(s, lkb, res); 138 139 seq_printf(s, "Conversion Queue\n"); 140 list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) 141 - print_resource_lock(s, lkb, res); 142 143 seq_printf(s, "Waiting Queue\n"); 144 list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) 145 - print_resource_lock(s, lkb, res); 146 147 if (list_empty(&res->res_lookup)) 148 goto out; ··· 160 return 0; 161 } 162 163 - static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r) 164 { 165 - unsigned int waiting = 0; 166 - uint64_t xid = 0; 167 168 if (lkb->lkb_flags & DLM_IFL_USER) { 169 if (lkb->lkb_ua) 170 xid = lkb->lkb_ua->xid; 171 } 172 173 - if (lkb->lkb_timestamp) 174 - waiting = jiffies_to_msecs(jiffies - lkb->lkb_timestamp); 175 176 - /* id nodeid remid pid xid exflags flags sts grmode rqmode time_ms 177 r_nodeid r_len r_name */ 178 179 - seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %u %u %d \"%s\"\n", 180 lkb->lkb_id, 181 lkb->lkb_nodeid, 182 lkb->lkb_remid, ··· 188 lkb->lkb_status, 189 lkb->lkb_grmode, 190 lkb->lkb_rqmode, 191 - waiting, 192 r->res_nodeid, 193 r->res_length, 194 r->res_name); 195 } 196 197 - static int print_locks(struct dlm_rsb *r, struct seq_file *s) 198 { 199 struct dlm_lkb *lkb; 200 201 lock_rsb(r); 202 203 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) 204 - print_lock(s, lkb, r); 205 206 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) 207 - print_lock(s, lkb, r); 208 209 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) 210 - print_lock(s, lkb, r); 211 212 unlock_rsb(r); 213 return 0; ··· 320 break; 321 } 322 read_unlock(&ls->ls_rsbtbl[i].lock); 323 - } 324 ri->entry = i; 325 326 if (ri->entry >= ls->ls_rsbtbl_size) ··· 337 read_unlock(&ls->ls_rsbtbl[i].lock); 338 dlm_put_rsb(old); 339 goto top; 340 - } 341 ri->rsb = list_entry(ri->next, struct dlm_rsb, res_hashchain); 342 dlm_hold_rsb(ri->rsb); 343 read_unlock(&ls->ls_rsbtbl[i].lock); ··· 363 ri->ls = ls; 364 ri->entry = 0; 365 ri->next = NULL; 366 367 if (rsb_iter_next(ri)) { 368 rsb_iter_free(ri); ··· 415 { 416 struct rsb_iter *ri = iter_ptr; 417 418 - if (ri->locks) { 419 if (ri->header) { 420 - seq_printf(file, "id nodeid remid pid xid exflags flags " 421 - "sts grmode rqmode time_ms r_nodeid " 422 - "r_len r_name\n"); 423 ri->header = 0; 424 } 425 - print_locks(ri->rsb, file); 426 - } else { 427 - print_resource(ri->rsb, file); 428 } 429 430 return 0; ··· 485 ri->ls = ls; 486 ri->entry = 0; 487 ri->next = NULL; 488 - ri->locks = 1; 489 490 if (*pos == 0) 491 ri->header = 1; ··· 548 }; 549 550 /* 551 * dump lkb's on the ls_waiters list 552 */ 553 ··· 667 .read = waiters_read 668 }; 669 670 int dlm_create_debug_file(struct dlm_ls *ls) 671 { 672 char name[DLM_LOCKSPACE_LEN+8]; 673 674 ls->ls_debug_rsb_dentry = debugfs_create_file(ls->ls_name, 675 S_IFREG | S_IRUGO, ··· 691 ls, 692 &rsb_fops); 693 if (!ls->ls_debug_rsb_dentry) 694 - return -ENOMEM; 695 696 - memset(name, 0, sizeof(name)); 697 - snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_waiters", ls->ls_name); 698 - 699 - ls->ls_debug_waiters_dentry = debugfs_create_file(name, 700 - S_IFREG | S_IRUGO, 701 - dlm_root, 702 - ls, 703 - &waiters_fops); 704 - if (!ls->ls_debug_waiters_dentry) { 705 - debugfs_remove(ls->ls_debug_rsb_dentry); 706 - return -ENOMEM; 707 - } 708 709 memset(name, 0, sizeof(name)); 710 snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_locks", ls->ls_name); ··· 703 dlm_root, 704 ls, 705 &locks_fops); 706 - if (!ls->ls_debug_locks_dentry) { 707 - debugfs_remove(ls->ls_debug_waiters_dentry); 708 - debugfs_remove(ls->ls_debug_rsb_dentry); 709 - return -ENOMEM; 710 - } 711 712 return 0; 713 - } 714 715 - void dlm_delete_debug_file(struct dlm_ls *ls) 716 - { 717 - if (ls->ls_debug_rsb_dentry) 718 - debugfs_remove(ls->ls_debug_rsb_dentry); 719 - if (ls->ls_debug_waiters_dentry) 720 - debugfs_remove(ls->ls_debug_waiters_dentry); 721 - if (ls->ls_debug_locks_dentry) 722 - debugfs_remove(ls->ls_debug_locks_dentry); 723 } 724 725 int __init dlm_register_debugfs(void)
··· 1 /****************************************************************************** 2 ******************************************************************************* 3 ** 4 + ** Copyright (C) 2005-2008 Red Hat, Inc. All rights reserved. 5 ** 6 ** This copyrighted material is made available to anyone wishing to use, 7 ** modify, copy, or redistribute it subject to the terms and conditions ··· 27 28 struct rsb_iter { 29 int entry; 30 + int format; 31 int header; 32 struct dlm_ls *ls; 33 struct list_head *next; ··· 60 } 61 } 62 63 + static void print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb, 64 + struct dlm_rsb *res) 65 { 66 seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode)); 67 ··· 83 seq_printf(s, "\n"); 84 } 85 86 + static int print_format1(struct dlm_rsb *res, struct seq_file *s) 87 { 88 struct dlm_lkb *lkb; 89 int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list; ··· 134 /* Print the locks attached to this resource */ 135 seq_printf(s, "Granted Queue\n"); 136 list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) 137 + print_format1_lock(s, lkb, res); 138 139 seq_printf(s, "Conversion Queue\n"); 140 list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) 141 + print_format1_lock(s, lkb, res); 142 143 seq_printf(s, "Waiting Queue\n"); 144 list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) 145 + print_format1_lock(s, lkb, res); 146 147 if (list_empty(&res->res_lookup)) 148 goto out; ··· 160 return 0; 161 } 162 163 + static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, 164 + struct dlm_rsb *r) 165 { 166 + u64 xid = 0; 167 + u64 us; 168 169 if (lkb->lkb_flags & DLM_IFL_USER) { 170 if (lkb->lkb_ua) 171 xid = lkb->lkb_ua->xid; 172 } 173 174 + /* microseconds since lkb was added to current queue */ 175 + us = ktime_to_us(ktime_sub(ktime_get(), lkb->lkb_timestamp)); 176 177 + /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us 178 r_nodeid r_len r_name */ 179 180 + seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n", 181 lkb->lkb_id, 182 lkb->lkb_nodeid, 183 lkb->lkb_remid, ··· 187 lkb->lkb_status, 188 lkb->lkb_grmode, 189 lkb->lkb_rqmode, 190 + (unsigned long long)us, 191 r->res_nodeid, 192 r->res_length, 193 r->res_name); 194 } 195 196 + static int print_format2(struct dlm_rsb *r, struct seq_file *s) 197 { 198 struct dlm_lkb *lkb; 199 200 lock_rsb(r); 201 202 list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) 203 + print_format2_lock(s, lkb, r); 204 205 list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) 206 + print_format2_lock(s, lkb, r); 207 208 list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) 209 + print_format2_lock(s, lkb, r); 210 + 211 + unlock_rsb(r); 212 + return 0; 213 + } 214 + 215 + static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, 216 + int rsb_lookup) 217 + { 218 + u64 xid = 0; 219 + 220 + if (lkb->lkb_flags & DLM_IFL_USER) { 221 + if (lkb->lkb_ua) 222 + xid = lkb->lkb_ua->xid; 223 + } 224 + 225 + seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n", 226 + lkb->lkb_id, 227 + lkb->lkb_nodeid, 228 + lkb->lkb_remid, 229 + lkb->lkb_ownpid, 230 + (unsigned long long)xid, 231 + lkb->lkb_exflags, 232 + lkb->lkb_flags, 233 + lkb->lkb_status, 234 + lkb->lkb_grmode, 235 + lkb->lkb_rqmode, 236 + lkb->lkb_highbast, 237 + rsb_lookup, 238 + lkb->lkb_wait_type, 239 + lkb->lkb_lvbseq, 240 + (unsigned long long)ktime_to_ns(lkb->lkb_timestamp), 241 + (unsigned long long)ktime_to_ns(lkb->lkb_time_bast)); 242 + } 243 + 244 + static int print_format3(struct dlm_rsb *r, struct seq_file *s) 245 + { 246 + struct dlm_lkb *lkb; 247 + int i, lvblen = r->res_ls->ls_lvblen; 248 + int print_name = 1; 249 + 250 + lock_rsb(r); 251 + 252 + seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ", 253 + r, 254 + r->res_nodeid, 255 + r->res_first_lkid, 256 + r->res_flags, 257 + !list_empty(&r->res_root_list), 258 + !list_empty(&r->res_recover_list), 259 + r->res_recover_locks_count, 260 + r->res_length); 261 + 262 + for (i = 0; i < r->res_length; i++) { 263 + if (!isascii(r->res_name[i]) || !isprint(r->res_name[i])) 264 + print_name = 0; 265 + } 266 + 267 + seq_printf(s, "%s", print_name ? "str " : "hex"); 268 + 269 + for (i = 0; i < r->res_length; i++) { 270 + if (print_name) 271 + seq_printf(s, "%c", r->res_name[i]); 272 + else 273 + seq_printf(s, " %02x", (unsigned char)r->res_name[i]); 274 + } 275 + seq_printf(s, "\n"); 276 + 277 + if (!r->res_lvbptr) 278 + goto do_locks; 279 + 280 + seq_printf(s, "lvb %u %d", r->res_lvbseq, lvblen); 281 + 282 + for (i = 0; i < lvblen; i++) 283 + seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]); 284 + seq_printf(s, "\n"); 285 + 286 + do_locks: 287 + list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) 288 + print_format3_lock(s, lkb, 0); 289 + 290 + list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) 291 + print_format3_lock(s, lkb, 0); 292 + 293 + list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) 294 + print_format3_lock(s, lkb, 0); 295 + 296 + list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup) 297 + print_format3_lock(s, lkb, 1); 298 299 unlock_rsb(r); 300 return 0; ··· 231 break; 232 } 233 read_unlock(&ls->ls_rsbtbl[i].lock); 234 + } 235 ri->entry = i; 236 237 if (ri->entry >= ls->ls_rsbtbl_size) ··· 248 read_unlock(&ls->ls_rsbtbl[i].lock); 249 dlm_put_rsb(old); 250 goto top; 251 + } 252 ri->rsb = list_entry(ri->next, struct dlm_rsb, res_hashchain); 253 dlm_hold_rsb(ri->rsb); 254 read_unlock(&ls->ls_rsbtbl[i].lock); ··· 274 ri->ls = ls; 275 ri->entry = 0; 276 ri->next = NULL; 277 + ri->format = 1; 278 279 if (rsb_iter_next(ri)) { 280 rsb_iter_free(ri); ··· 325 { 326 struct rsb_iter *ri = iter_ptr; 327 328 + switch (ri->format) { 329 + case 1: 330 + print_format1(ri->rsb, file); 331 + break; 332 + case 2: 333 if (ri->header) { 334 + seq_printf(file, "id nodeid remid pid xid exflags " 335 + "flags sts grmode rqmode time_ms " 336 + "r_nodeid r_len r_name\n"); 337 ri->header = 0; 338 } 339 + print_format2(ri->rsb, file); 340 + break; 341 + case 3: 342 + if (ri->header) { 343 + seq_printf(file, "version rsb 1.1 lvb 1.1 lkb 1.1\n"); 344 + ri->header = 0; 345 + } 346 + print_format3(ri->rsb, file); 347 + break; 348 } 349 350 return 0; ··· 385 ri->ls = ls; 386 ri->entry = 0; 387 ri->next = NULL; 388 + ri->format = 2; 389 390 if (*pos == 0) 391 ri->header = 1; ··· 448 }; 449 450 /* 451 + * Dump all rsb/lvb/lkb state in compact listing, more complete than _locks 452 + * This can replace both formats 1 and 2 eventually. 453 + */ 454 + 455 + static struct rsb_iter *all_iter_init(struct dlm_ls *ls, loff_t *pos) 456 + { 457 + struct rsb_iter *ri; 458 + 459 + ri = kzalloc(sizeof *ri, GFP_KERNEL); 460 + if (!ri) 461 + return NULL; 462 + 463 + ri->ls = ls; 464 + ri->entry = 0; 465 + ri->next = NULL; 466 + ri->format = 3; 467 + 468 + if (*pos == 0) 469 + ri->header = 1; 470 + 471 + if (rsb_iter_next(ri)) { 472 + rsb_iter_free(ri); 473 + return NULL; 474 + } 475 + 476 + return ri; 477 + } 478 + 479 + static void *all_seq_start(struct seq_file *file, loff_t *pos) 480 + { 481 + struct rsb_iter *ri; 482 + loff_t n = *pos; 483 + 484 + ri = all_iter_init(file->private, pos); 485 + if (!ri) 486 + return NULL; 487 + 488 + while (n--) { 489 + if (rsb_iter_next(ri)) { 490 + rsb_iter_free(ri); 491 + return NULL; 492 + } 493 + } 494 + 495 + return ri; 496 + } 497 + 498 + static struct seq_operations all_seq_ops = { 499 + .start = all_seq_start, 500 + .next = rsb_seq_next, 501 + .stop = rsb_seq_stop, 502 + .show = rsb_seq_show, 503 + }; 504 + 505 + static int all_open(struct inode *inode, struct file *file) 506 + { 507 + struct seq_file *seq; 508 + int ret; 509 + 510 + ret = seq_open(file, &all_seq_ops); 511 + if (ret) 512 + return ret; 513 + 514 + seq = file->private_data; 515 + seq->private = inode->i_private; 516 + 517 + return 0; 518 + } 519 + 520 + static const struct file_operations all_fops = { 521 + .owner = THIS_MODULE, 522 + .open = all_open, 523 + .read = seq_read, 524 + .llseek = seq_lseek, 525 + .release = seq_release 526 + }; 527 + 528 + /* 529 * dump lkb's on the ls_waiters list 530 */ 531 ··· 489 .read = waiters_read 490 }; 491 492 + void dlm_delete_debug_file(struct dlm_ls *ls) 493 + { 494 + if (ls->ls_debug_rsb_dentry) 495 + debugfs_remove(ls->ls_debug_rsb_dentry); 496 + if (ls->ls_debug_waiters_dentry) 497 + debugfs_remove(ls->ls_debug_waiters_dentry); 498 + if (ls->ls_debug_locks_dentry) 499 + debugfs_remove(ls->ls_debug_locks_dentry); 500 + if (ls->ls_debug_all_dentry) 501 + debugfs_remove(ls->ls_debug_all_dentry); 502 + } 503 + 504 int dlm_create_debug_file(struct dlm_ls *ls) 505 { 506 char name[DLM_LOCKSPACE_LEN+8]; 507 + 508 + /* format 1 */ 509 510 ls->ls_debug_rsb_dentry = debugfs_create_file(ls->ls_name, 511 S_IFREG | S_IRUGO, ··· 499 ls, 500 &rsb_fops); 501 if (!ls->ls_debug_rsb_dentry) 502 + goto fail; 503 504 + /* format 2 */ 505 506 memset(name, 0, sizeof(name)); 507 snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_locks", ls->ls_name); ··· 522 dlm_root, 523 ls, 524 &locks_fops); 525 + if (!ls->ls_debug_locks_dentry) 526 + goto fail; 527 + 528 + /* format 3 */ 529 + 530 + memset(name, 0, sizeof(name)); 531 + snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_all", ls->ls_name); 532 + 533 + ls->ls_debug_all_dentry = debugfs_create_file(name, 534 + S_IFREG | S_IRUGO, 535 + dlm_root, 536 + ls, 537 + &all_fops); 538 + if (!ls->ls_debug_all_dentry) 539 + goto fail; 540 + 541 + memset(name, 0, sizeof(name)); 542 + snprintf(name, DLM_LOCKSPACE_LEN+8, "%s_waiters", ls->ls_name); 543 + 544 + ls->ls_debug_waiters_dentry = debugfs_create_file(name, 545 + S_IFREG | S_IRUGO, 546 + dlm_root, 547 + ls, 548 + &waiters_fops); 549 + if (!ls->ls_debug_waiters_dentry) 550 + goto fail; 551 552 return 0; 553 554 + fail: 555 + dlm_delete_debug_file(ls); 556 + return -ENOMEM; 557 } 558 559 int __init dlm_register_debugfs(void)
+9 -9
fs/dlm/dir.c
··· 374 struct list_head *list; 375 struct dlm_rsb *r; 376 int offset = 0, dir_nodeid; 377 - uint16_t be_namelen; 378 379 down_read(&ls->ls_root_sem); 380 ··· 410 411 if (offset + sizeof(uint16_t)*2 + r->res_length > outlen) { 412 /* Write end-of-block record */ 413 - be_namelen = 0; 414 - memcpy(outbuf + offset, &be_namelen, sizeof(uint16_t)); 415 - offset += sizeof(uint16_t); 416 goto out; 417 } 418 419 be_namelen = cpu_to_be16(r->res_length); 420 - memcpy(outbuf + offset, &be_namelen, sizeof(uint16_t)); 421 - offset += sizeof(uint16_t); 422 memcpy(outbuf + offset, r->res_name, r->res_length); 423 offset += r->res_length; 424 } ··· 430 431 if ((list == &ls->ls_root_list) && 432 (offset + sizeof(uint16_t) <= outlen)) { 433 - be_namelen = 0xFFFF; 434 - memcpy(outbuf + offset, &be_namelen, sizeof(uint16_t)); 435 - offset += sizeof(uint16_t); 436 } 437 438 out:
··· 374 struct list_head *list; 375 struct dlm_rsb *r; 376 int offset = 0, dir_nodeid; 377 + __be16 be_namelen; 378 379 down_read(&ls->ls_root_sem); 380 ··· 410 411 if (offset + sizeof(uint16_t)*2 + r->res_length > outlen) { 412 /* Write end-of-block record */ 413 + be_namelen = cpu_to_be16(0); 414 + memcpy(outbuf + offset, &be_namelen, sizeof(__be16)); 415 + offset += sizeof(__be16); 416 goto out; 417 } 418 419 be_namelen = cpu_to_be16(r->res_length); 420 + memcpy(outbuf + offset, &be_namelen, sizeof(__be16)); 421 + offset += sizeof(__be16); 422 memcpy(outbuf + offset, r->res_name, r->res_length); 423 offset += r->res_length; 424 } ··· 430 431 if ((list == &ls->ls_root_list) && 432 (offset + sizeof(uint16_t) <= outlen)) { 433 + be_namelen = cpu_to_be16(0xFFFF); 434 + memcpy(outbuf + offset, &be_namelen, sizeof(__be16)); 435 + offset += sizeof(__be16); 436 } 437 438 out:
+3 -1
fs/dlm/dlm_internal.h
··· 245 struct list_head lkb_astqueue; /* need ast to be sent */ 246 struct list_head lkb_ownqueue; /* list of locks for a process */ 247 struct list_head lkb_time_list; 248 - unsigned long lkb_timestamp; 249 unsigned long lkb_timeout_cs; 250 251 char *lkb_lvbptr; ··· 482 struct dentry *ls_debug_rsb_dentry; /* debugfs */ 483 struct dentry *ls_debug_waiters_dentry; /* debugfs */ 484 struct dentry *ls_debug_locks_dentry; /* debugfs */ 485 486 wait_queue_head_t ls_uevent_wait; /* user part of join/leave */ 487 int ls_uevent_result;
··· 245 struct list_head lkb_astqueue; /* need ast to be sent */ 246 struct list_head lkb_ownqueue; /* list of locks for a process */ 247 struct list_head lkb_time_list; 248 + ktime_t lkb_time_bast; /* for debugging */ 249 + ktime_t lkb_timestamp; 250 unsigned long lkb_timeout_cs; 251 252 char *lkb_lvbptr; ··· 481 struct dentry *ls_debug_rsb_dentry; /* debugfs */ 482 struct dentry *ls_debug_waiters_dentry; /* debugfs */ 483 struct dentry *ls_debug_locks_dentry; /* debugfs */ 484 + struct dentry *ls_debug_all_dentry; /* debugfs */ 485 486 wait_queue_head_t ls_uevent_wait; /* user part of join/leave */ 487 int ls_uevent_result;
+16 -15
fs/dlm/lock.c
··· 307 lkb->lkb_lksb->sb_status = rv; 308 lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags; 309 310 - dlm_add_ast(lkb, AST_COMP); 311 } 312 313 static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb) ··· 318 319 static void queue_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rqmode) 320 { 321 if (is_master_copy(lkb)) 322 send_bast(r, lkb, rqmode); 323 - else { 324 - lkb->lkb_bastmode = rqmode; 325 - dlm_add_ast(lkb, AST_BAST); 326 - } 327 } 328 329 /* ··· 744 745 DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb);); 746 747 lkb->lkb_status = status; 748 749 switch (status) { ··· 1015 { 1016 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 1017 1018 - if (is_master_copy(lkb)) { 1019 - lkb->lkb_timestamp = jiffies; 1020 return; 1021 - } 1022 1023 if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) && 1024 !(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) { ··· 1031 DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb);); 1032 mutex_lock(&ls->ls_timeout_mutex); 1033 hold_lkb(lkb); 1034 - lkb->lkb_timestamp = jiffies; 1035 list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout); 1036 mutex_unlock(&ls->ls_timeout_mutex); 1037 } ··· 1058 struct dlm_rsb *r; 1059 struct dlm_lkb *lkb; 1060 int do_cancel, do_warn; 1061 1062 for (;;) { 1063 if (dlm_locking_stopped(ls)) ··· 1069 mutex_lock(&ls->ls_timeout_mutex); 1070 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) { 1071 1072 if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) && 1073 - time_after_eq(jiffies, lkb->lkb_timestamp + 1074 - lkb->lkb_timeout_cs * HZ/100)) 1075 do_cancel = 1; 1076 1077 if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) && 1078 - time_after_eq(jiffies, lkb->lkb_timestamp + 1079 - dlm_config.ci_timewarn_cs * HZ/100)) 1080 do_warn = 1; 1081 1082 if (!do_cancel && !do_warn) ··· 1123 void dlm_adjust_timeouts(struct dlm_ls *ls) 1124 { 1125 struct dlm_lkb *lkb; 1126 - long adj = jiffies - ls->ls_recover_begin; 1127 1128 ls->ls_recover_begin = 0; 1129 mutex_lock(&ls->ls_timeout_mutex); 1130 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) 1131 - lkb->lkb_timestamp += adj; 1132 mutex_unlock(&ls->ls_timeout_mutex); 1133 } 1134
··· 307 lkb->lkb_lksb->sb_status = rv; 308 lkb->lkb_lksb->sb_flags = lkb->lkb_sbflags; 309 310 + dlm_add_ast(lkb, AST_COMP, 0); 311 } 312 313 static inline void queue_cast_overlap(struct dlm_rsb *r, struct dlm_lkb *lkb) ··· 318 319 static void queue_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int rqmode) 320 { 321 + lkb->lkb_time_bast = ktime_get(); 322 + 323 if (is_master_copy(lkb)) 324 send_bast(r, lkb, rqmode); 325 + else 326 + dlm_add_ast(lkb, AST_BAST, rqmode); 327 } 328 329 /* ··· 744 745 DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb);); 746 747 + lkb->lkb_timestamp = ktime_get(); 748 + 749 lkb->lkb_status = status; 750 751 switch (status) { ··· 1013 { 1014 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 1015 1016 + if (is_master_copy(lkb)) 1017 return; 1018 1019 if (test_bit(LSFL_TIMEWARN, &ls->ls_flags) && 1020 !(lkb->lkb_exflags & DLM_LKF_NODLCKWT)) { ··· 1031 DLM_ASSERT(list_empty(&lkb->lkb_time_list), dlm_print_lkb(lkb);); 1032 mutex_lock(&ls->ls_timeout_mutex); 1033 hold_lkb(lkb); 1034 list_add_tail(&lkb->lkb_time_list, &ls->ls_timeout); 1035 mutex_unlock(&ls->ls_timeout_mutex); 1036 } ··· 1059 struct dlm_rsb *r; 1060 struct dlm_lkb *lkb; 1061 int do_cancel, do_warn; 1062 + s64 wait_us; 1063 1064 for (;;) { 1065 if (dlm_locking_stopped(ls)) ··· 1069 mutex_lock(&ls->ls_timeout_mutex); 1070 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) { 1071 1072 + wait_us = ktime_to_us(ktime_sub(ktime_get(), 1073 + lkb->lkb_timestamp)); 1074 + 1075 if ((lkb->lkb_exflags & DLM_LKF_TIMEOUT) && 1076 + wait_us >= (lkb->lkb_timeout_cs * 10000)) 1077 do_cancel = 1; 1078 1079 if ((lkb->lkb_flags & DLM_IFL_WATCH_TIMEWARN) && 1080 + wait_us >= dlm_config.ci_timewarn_cs * 10000) 1081 do_warn = 1; 1082 1083 if (!do_cancel && !do_warn) ··· 1122 void dlm_adjust_timeouts(struct dlm_ls *ls) 1123 { 1124 struct dlm_lkb *lkb; 1125 + u64 adj_us = jiffies_to_usecs(jiffies - ls->ls_recover_begin); 1126 1127 ls->ls_recover_begin = 0; 1128 mutex_lock(&ls->ls_timeout_mutex); 1129 list_for_each_entry(lkb, &ls->ls_timeout, lkb_time_list) 1130 + lkb->lkb_timestamp = ktime_add_us(lkb->lkb_timestamp, adj_us); 1131 mutex_unlock(&ls->ls_timeout_mutex); 1132 } 1133
+1 -7
fs/dlm/lowcomms.c
··· 295 con->sock->sk->sk_write_space = lowcomms_write_space; 296 con->sock->sk->sk_state_change = lowcomms_state_change; 297 con->sock->sk->sk_user_data = con; 298 return 0; 299 } 300 ··· 824 len = e->len; 825 offset = e->offset; 826 spin_unlock(&con->writequeue_lock); 827 - kmap(e->page); 828 829 /* Send the first block off the write queue */ 830 iov[0].iov_base = page_address(e->page)+offset; ··· 854 855 if (e->len == 0 && e->users == 0) { 856 list_del(&e->list); 857 - kunmap(e->page); 858 free_entry(e); 859 } 860 spin_unlock(&con->writequeue_lock); ··· 1202 1203 if (e) { 1204 got_one: 1205 - if (users == 0) 1206 - kmap(e->page); 1207 *ppc = page_address(e->page) + offset; 1208 return e; 1209 } ··· 1230 if (users) 1231 goto out; 1232 e->len = e->end - e->offset; 1233 - kunmap(e->page); 1234 spin_unlock(&con->writequeue_lock); 1235 1236 if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) { ··· 1268 offset = e->offset; 1269 BUG_ON(len == 0 && e->users == 0); 1270 spin_unlock(&con->writequeue_lock); 1271 - kmap(e->page); 1272 1273 ret = 0; 1274 if (len) { ··· 1289 1290 if (e->len == 0 && e->users == 0) { 1291 list_del(&e->list); 1292 - kunmap(e->page); 1293 free_entry(e); 1294 continue; 1295 }
··· 295 con->sock->sk->sk_write_space = lowcomms_write_space; 296 con->sock->sk->sk_state_change = lowcomms_state_change; 297 con->sock->sk->sk_user_data = con; 298 + con->sock->sk->sk_allocation = GFP_NOFS; 299 return 0; 300 } 301 ··· 823 len = e->len; 824 offset = e->offset; 825 spin_unlock(&con->writequeue_lock); 826 827 /* Send the first block off the write queue */ 828 iov[0].iov_base = page_address(e->page)+offset; ··· 854 855 if (e->len == 0 && e->users == 0) { 856 list_del(&e->list); 857 free_entry(e); 858 } 859 spin_unlock(&con->writequeue_lock); ··· 1203 1204 if (e) { 1205 got_one: 1206 *ppc = page_address(e->page) + offset; 1207 return e; 1208 } ··· 1233 if (users) 1234 goto out; 1235 e->len = e->end - e->offset; 1236 spin_unlock(&con->writequeue_lock); 1237 1238 if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) { ··· 1272 offset = e->offset; 1273 BUG_ON(len == 0 && e->users == 0); 1274 spin_unlock(&con->writequeue_lock); 1275 1276 ret = 0; 1277 if (len) { ··· 1294 1295 if (e->len == 0 && e->users == 0) { 1296 list_del(&e->list); 1297 free_entry(e); 1298 continue; 1299 }
+3 -3
fs/dlm/memory.c
··· 39 { 40 char *p; 41 42 - p = kzalloc(ls->ls_lvblen, GFP_KERNEL); 43 return p; 44 } 45 ··· 57 58 DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,); 59 60 - r = kzalloc(sizeof(*r) + namelen, GFP_KERNEL); 61 return r; 62 } 63 ··· 72 { 73 struct dlm_lkb *lkb; 74 75 - lkb = kmem_cache_zalloc(lkb_cache, GFP_KERNEL); 76 return lkb; 77 } 78
··· 39 { 40 char *p; 41 42 + p = kzalloc(ls->ls_lvblen, ls->ls_allocation); 43 return p; 44 } 45 ··· 57 58 DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,); 59 60 + r = kzalloc(sizeof(*r) + namelen, ls->ls_allocation); 61 return r; 62 } 63 ··· 72 { 73 struct dlm_lkb *lkb; 74 75 + lkb = kmem_cache_zalloc(lkb_cache, ls->ls_allocation); 76 return lkb; 77 } 78
+1 -1
fs/dlm/midcomms.c
··· 112 ordinary messages). */ 113 114 if (msglen > sizeof(__tmp) && p == &__tmp.p) { 115 - p = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL); 116 if (p == NULL) 117 return ret; 118 }
··· 112 ordinary messages). */ 113 114 if (msglen > sizeof(__tmp) && p == &__tmp.p) { 115 + p = kmalloc(dlm_config.ci_buffer_size, GFP_NOFS); 116 if (p == NULL) 117 return ret; 118 }
-1
fs/dlm/netlink.c
··· 115 data->status = lkb->lkb_status; 116 data->grmode = lkb->lkb_grmode; 117 data->rqmode = lkb->lkb_rqmode; 118 - data->timestamp = lkb->lkb_timestamp; 119 if (lkb->lkb_ua) 120 data->xid = lkb->lkb_ua->xid; 121 if (r) {
··· 115 data->status = lkb->lkb_status; 116 data->grmode = lkb->lkb_grmode; 117 data->rqmode = lkb->lkb_rqmode; 118 if (lkb->lkb_ua) 119 data->xid = lkb->lkb_ua->xid; 120 if (r) {
+3 -1
fs/dlm/user.c
··· 175 /* we could possibly check if the cancel of an orphan has resulted in the lkb 176 being removed and then remove that lkb from the orphans list and free it */ 177 178 - void dlm_user_add_ast(struct dlm_lkb *lkb, int type) 179 { 180 struct dlm_ls *ls; 181 struct dlm_user_args *ua; ··· 208 209 ast_type = lkb->lkb_ast_type; 210 lkb->lkb_ast_type |= type; 211 212 if (!ast_type) { 213 kref_get(&lkb->lkb_ref);
··· 175 /* we could possibly check if the cancel of an orphan has resulted in the lkb 176 being removed and then remove that lkb from the orphans list and free it */ 177 178 + void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode) 179 { 180 struct dlm_ls *ls; 181 struct dlm_user_args *ua; ··· 208 209 ast_type = lkb->lkb_ast_type; 210 lkb->lkb_ast_type |= type; 211 + if (bastmode) 212 + lkb->lkb_bastmode = bastmode; 213 214 if (!ast_type) { 215 kref_get(&lkb->lkb_ref);
+1 -1
fs/dlm/user.h
··· 9 #ifndef __USER_DOT_H__ 10 #define __USER_DOT_H__ 11 12 - void dlm_user_add_ast(struct dlm_lkb *lkb, int type); 13 int dlm_user_init(void); 14 void dlm_user_exit(void); 15 int dlm_device_deregister(struct dlm_ls *ls);
··· 9 #ifndef __USER_DOT_H__ 10 #define __USER_DOT_H__ 11 12 + void dlm_user_add_ast(struct dlm_lkb *lkb, int type, int bastmode); 13 int dlm_user_init(void); 14 void dlm_user_exit(void); 15 int dlm_device_deregister(struct dlm_ls *ls);