Commit 7d8a804c594b61a05c698126165b5dc417d94a0f

Authored by Linus Torvalds

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

Showing 12 changed files Side-by-side Diff

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