Commit 573c24c4af6664ffcd9aa7ba617a35fde2b95534
1 parent
a8a8a669ea
Exists in
master
and in
4 other branches
dlm: always use GFP_NOFS
Replace all GFP_KERNEL and ls_allocation with GFP_NOFS. ls_allocation would be GFP_KERNEL for userland lockspaces and GFP_NOFS for file system lockspaces. It was discovered that any lockspaces on the system can affect all others by triggering memory reclaim in the file system which could in turn call back into the dlm to acquire locks, deadlocking dlm threads that were shared by all lockspaces, like dlm_recv. Signed-off-by: David Teigland <teigland@redhat.com>
Showing 14 changed files with 46 additions and 53 deletions Side-by-side Diff
fs/dlm/config.c
... | ... | @@ -410,10 +410,10 @@ |
410 | 410 | struct dlm_comms *cms = NULL; |
411 | 411 | void *gps = NULL; |
412 | 412 | |
413 | - cl = kzalloc(sizeof(struct dlm_cluster), GFP_KERNEL); | |
414 | - gps = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); | |
415 | - sps = kzalloc(sizeof(struct dlm_spaces), GFP_KERNEL); | |
416 | - cms = kzalloc(sizeof(struct dlm_comms), GFP_KERNEL); | |
413 | + cl = kzalloc(sizeof(struct dlm_cluster), GFP_NOFS); | |
414 | + gps = kcalloc(3, sizeof(struct config_group *), GFP_NOFS); | |
415 | + sps = kzalloc(sizeof(struct dlm_spaces), GFP_NOFS); | |
416 | + cms = kzalloc(sizeof(struct dlm_comms), GFP_NOFS); | |
417 | 417 | |
418 | 418 | if (!cl || !gps || !sps || !cms) |
419 | 419 | goto fail; |
... | ... | @@ -482,9 +482,9 @@ |
482 | 482 | struct dlm_nodes *nds = NULL; |
483 | 483 | void *gps = NULL; |
484 | 484 | |
485 | - sp = kzalloc(sizeof(struct dlm_space), GFP_KERNEL); | |
486 | - gps = kcalloc(2, sizeof(struct config_group *), GFP_KERNEL); | |
487 | - nds = kzalloc(sizeof(struct dlm_nodes), GFP_KERNEL); | |
485 | + sp = kzalloc(sizeof(struct dlm_space), GFP_NOFS); | |
486 | + gps = kcalloc(2, sizeof(struct config_group *), GFP_NOFS); | |
487 | + nds = kzalloc(sizeof(struct dlm_nodes), GFP_NOFS); | |
488 | 488 | |
489 | 489 | if (!sp || !gps || !nds) |
490 | 490 | goto fail; |
... | ... | @@ -536,7 +536,7 @@ |
536 | 536 | { |
537 | 537 | struct dlm_comm *cm; |
538 | 538 | |
539 | - cm = kzalloc(sizeof(struct dlm_comm), GFP_KERNEL); | |
539 | + cm = kzalloc(sizeof(struct dlm_comm), GFP_NOFS); | |
540 | 540 | if (!cm) |
541 | 541 | return ERR_PTR(-ENOMEM); |
542 | 542 | |
... | ... | @@ -569,7 +569,7 @@ |
569 | 569 | struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent); |
570 | 570 | struct dlm_node *nd; |
571 | 571 | |
572 | - nd = kzalloc(sizeof(struct dlm_node), GFP_KERNEL); | |
572 | + nd = kzalloc(sizeof(struct dlm_node), GFP_NOFS); | |
573 | 573 | if (!nd) |
574 | 574 | return ERR_PTR(-ENOMEM); |
575 | 575 | |
... | ... | @@ -705,7 +705,7 @@ |
705 | 705 | if (cm->addr_count >= DLM_MAX_ADDR_COUNT) |
706 | 706 | return -ENOSPC; |
707 | 707 | |
708 | - addr = kzalloc(sizeof(*addr), GFP_KERNEL); | |
708 | + addr = kzalloc(sizeof(*addr), GFP_NOFS); | |
709 | 709 | if (!addr) |
710 | 710 | return -ENOMEM; |
711 | 711 | |
... | ... | @@ -868,7 +868,7 @@ |
868 | 868 | |
869 | 869 | ids_count = sp->members_count; |
870 | 870 | |
871 | - ids = kcalloc(ids_count, sizeof(int), GFP_KERNEL); | |
871 | + ids = kcalloc(ids_count, sizeof(int), GFP_NOFS); | |
872 | 872 | if (!ids) { |
873 | 873 | rv = -ENOMEM; |
874 | 874 | goto out; |
... | ... | @@ -886,7 +886,7 @@ |
886 | 886 | if (!new_count) |
887 | 887 | goto out_ids; |
888 | 888 | |
889 | - new = kcalloc(new_count, sizeof(int), GFP_KERNEL); | |
889 | + new = kcalloc(new_count, sizeof(int), GFP_NOFS); | |
890 | 890 | if (!new) { |
891 | 891 | kfree(ids); |
892 | 892 | rv = -ENOMEM; |
fs/dlm/debug_fs.c
fs/dlm/dir.c
... | ... | @@ -49,8 +49,7 @@ |
49 | 49 | spin_unlock(&ls->ls_recover_list_lock); |
50 | 50 | |
51 | 51 | if (!found) |
52 | - de = kzalloc(sizeof(struct dlm_direntry) + len, | |
53 | - ls->ls_allocation); | |
52 | + de = kzalloc(sizeof(struct dlm_direntry) + len, GFP_NOFS); | |
54 | 53 | return de; |
55 | 54 | } |
56 | 55 | |
... | ... | @@ -212,7 +211,7 @@ |
212 | 211 | |
213 | 212 | dlm_dir_clear(ls); |
214 | 213 | |
215 | - last_name = kmalloc(DLM_RESNAME_MAXLEN, ls->ls_allocation); | |
214 | + last_name = kmalloc(DLM_RESNAME_MAXLEN, GFP_NOFS); | |
216 | 215 | if (!last_name) |
217 | 216 | goto out; |
218 | 217 | |
... | ... | @@ -323,7 +322,7 @@ |
323 | 322 | if (namelen > DLM_RESNAME_MAXLEN) |
324 | 323 | return -EINVAL; |
325 | 324 | |
326 | - de = kzalloc(sizeof(struct dlm_direntry) + namelen, ls->ls_allocation); | |
325 | + de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_NOFS); | |
327 | 326 | if (!de) |
328 | 327 | return -ENOMEM; |
329 | 328 |
fs/dlm/dlm_internal.h
fs/dlm/lock.c
... | ... | @@ -2689,7 +2689,7 @@ |
2689 | 2689 | pass into lowcomms_commit and a message buffer (mb) that we |
2690 | 2690 | write our data into */ |
2691 | 2691 | |
2692 | - mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, ls->ls_allocation, &mb); | |
2692 | + mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_NOFS, &mb); | |
2693 | 2693 | if (!mh) |
2694 | 2694 | return -ENOBUFS; |
2695 | 2695 | |
... | ... | @@ -4512,7 +4512,7 @@ |
4512 | 4512 | } |
4513 | 4513 | |
4514 | 4514 | if (flags & DLM_LKF_VALBLK) { |
4515 | - ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL); | |
4515 | + ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_NOFS); | |
4516 | 4516 | if (!ua->lksb.sb_lvbptr) { |
4517 | 4517 | kfree(ua); |
4518 | 4518 | __put_lkb(ls, lkb); |
... | ... | @@ -4582,7 +4582,7 @@ |
4582 | 4582 | ua = lkb->lkb_ua; |
4583 | 4583 | |
4584 | 4584 | if (flags & DLM_LKF_VALBLK && !ua->lksb.sb_lvbptr) { |
4585 | - ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_KERNEL); | |
4585 | + ua->lksb.sb_lvbptr = kzalloc(DLM_USER_LVB_LEN, GFP_NOFS); | |
4586 | 4586 | if (!ua->lksb.sb_lvbptr) { |
4587 | 4587 | error = -ENOMEM; |
4588 | 4588 | goto out_put; |
fs/dlm/lockspace.c
... | ... | @@ -430,7 +430,7 @@ |
430 | 430 | |
431 | 431 | error = -ENOMEM; |
432 | 432 | |
433 | - ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_KERNEL); | |
433 | + ls = kzalloc(sizeof(struct dlm_ls) + namelen, GFP_NOFS); | |
434 | 434 | if (!ls) |
435 | 435 | goto out; |
436 | 436 | memcpy(ls->ls_name, name, namelen); |
... | ... | @@ -443,11 +443,6 @@ |
443 | 443 | if (flags & DLM_LSFL_TIMEWARN) |
444 | 444 | set_bit(LSFL_TIMEWARN, &ls->ls_flags); |
445 | 445 | |
446 | - if (flags & DLM_LSFL_FS) | |
447 | - ls->ls_allocation = GFP_NOFS; | |
448 | - else | |
449 | - ls->ls_allocation = GFP_KERNEL; | |
450 | - | |
451 | 446 | /* ls_exflags are forced to match among nodes, and we don't |
452 | 447 | need to require all nodes to have some flags set */ |
453 | 448 | ls->ls_exflags = (flags & ~(DLM_LSFL_TIMEWARN | DLM_LSFL_FS | |
... | ... | @@ -456,7 +451,7 @@ |
456 | 451 | size = dlm_config.ci_rsbtbl_size; |
457 | 452 | ls->ls_rsbtbl_size = size; |
458 | 453 | |
459 | - ls->ls_rsbtbl = kmalloc(sizeof(struct dlm_rsbtable) * size, GFP_KERNEL); | |
454 | + ls->ls_rsbtbl = kmalloc(sizeof(struct dlm_rsbtable) * size, GFP_NOFS); | |
460 | 455 | if (!ls->ls_rsbtbl) |
461 | 456 | goto out_lsfree; |
462 | 457 | for (i = 0; i < size; i++) { |
... | ... | @@ -468,7 +463,7 @@ |
468 | 463 | size = dlm_config.ci_lkbtbl_size; |
469 | 464 | ls->ls_lkbtbl_size = size; |
470 | 465 | |
471 | - ls->ls_lkbtbl = kmalloc(sizeof(struct dlm_lkbtable) * size, GFP_KERNEL); | |
466 | + ls->ls_lkbtbl = kmalloc(sizeof(struct dlm_lkbtable) * size, GFP_NOFS); | |
472 | 467 | if (!ls->ls_lkbtbl) |
473 | 468 | goto out_rsbfree; |
474 | 469 | for (i = 0; i < size; i++) { |
... | ... | @@ -480,7 +475,7 @@ |
480 | 475 | size = dlm_config.ci_dirtbl_size; |
481 | 476 | ls->ls_dirtbl_size = size; |
482 | 477 | |
483 | - ls->ls_dirtbl = kmalloc(sizeof(struct dlm_dirtable) * size, GFP_KERNEL); | |
478 | + ls->ls_dirtbl = kmalloc(sizeof(struct dlm_dirtable) * size, GFP_NOFS); | |
484 | 479 | if (!ls->ls_dirtbl) |
485 | 480 | goto out_lkbfree; |
486 | 481 | for (i = 0; i < size; i++) { |
... | ... | @@ -527,7 +522,7 @@ |
527 | 522 | mutex_init(&ls->ls_requestqueue_mutex); |
528 | 523 | mutex_init(&ls->ls_clear_proc_locks); |
529 | 524 | |
530 | - ls->ls_recover_buf = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL); | |
525 | + ls->ls_recover_buf = kmalloc(dlm_config.ci_buffer_size, GFP_NOFS); | |
531 | 526 | if (!ls->ls_recover_buf) |
532 | 527 | goto out_dirfree; |
533 | 528 |
fs/dlm/lowcomms.c
... | ... | @@ -1060,7 +1060,7 @@ |
1060 | 1060 | if (dlm_our_addr(&sas, i)) |
1061 | 1061 | break; |
1062 | 1062 | |
1063 | - addr = kmalloc(sizeof(*addr), GFP_KERNEL); | |
1063 | + addr = kmalloc(sizeof(*addr), GFP_NOFS); | |
1064 | 1064 | if (!addr) |
1065 | 1065 | break; |
1066 | 1066 | memcpy(addr, &sas, sizeof(*addr)); |
... | ... | @@ -1099,7 +1099,7 @@ |
1099 | 1099 | struct sockaddr_storage localaddr; |
1100 | 1100 | struct sctp_event_subscribe subscribe; |
1101 | 1101 | int result = -EINVAL, num = 1, i, addr_len; |
1102 | - struct connection *con = nodeid2con(0, GFP_KERNEL); | |
1102 | + struct connection *con = nodeid2con(0, GFP_NOFS); | |
1103 | 1103 | int bufsize = NEEDED_RMEM; |
1104 | 1104 | |
1105 | 1105 | if (!con) |
... | ... | @@ -1171,7 +1171,7 @@ |
1171 | 1171 | static int tcp_listen_for_all(void) |
1172 | 1172 | { |
1173 | 1173 | struct socket *sock = NULL; |
1174 | - struct connection *con = nodeid2con(0, GFP_KERNEL); | |
1174 | + struct connection *con = nodeid2con(0, GFP_NOFS); | |
1175 | 1175 | int result = -EINVAL; |
1176 | 1176 | |
1177 | 1177 | if (!con) |
fs/dlm/member.c
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | struct dlm_member *memb; |
49 | 49 | int w, error; |
50 | 50 | |
51 | - memb = kzalloc(sizeof(struct dlm_member), ls->ls_allocation); | |
51 | + memb = kzalloc(sizeof(struct dlm_member), GFP_NOFS); | |
52 | 52 | if (!memb) |
53 | 53 | return -ENOMEM; |
54 | 54 | |
... | ... | @@ -143,7 +143,7 @@ |
143 | 143 | |
144 | 144 | ls->ls_total_weight = total; |
145 | 145 | |
146 | - array = kmalloc(sizeof(int) * total, ls->ls_allocation); | |
146 | + array = kmalloc(sizeof(int) * total, GFP_NOFS); | |
147 | 147 | if (!array) |
148 | 148 | return; |
149 | 149 | |
... | ... | @@ -226,7 +226,7 @@ |
226 | 226 | continue; |
227 | 227 | log_debug(ls, "new nodeid %d is a re-added member", rv->new[i]); |
228 | 228 | |
229 | - memb = kzalloc(sizeof(struct dlm_member), ls->ls_allocation); | |
229 | + memb = kzalloc(sizeof(struct dlm_member), GFP_NOFS); | |
230 | 230 | if (!memb) |
231 | 231 | return -ENOMEM; |
232 | 232 | memb->nodeid = rv->new[i]; |
... | ... | @@ -341,7 +341,7 @@ |
341 | 341 | int *ids = NULL, *new = NULL; |
342 | 342 | int error, ids_count = 0, new_count = 0; |
343 | 343 | |
344 | - rv = kzalloc(sizeof(struct dlm_recover), ls->ls_allocation); | |
344 | + rv = kzalloc(sizeof(struct dlm_recover), GFP_NOFS); | |
345 | 345 | if (!rv) |
346 | 346 | return -ENOMEM; |
347 | 347 |
fs/dlm/memory.c
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | { |
40 | 40 | char *p; |
41 | 41 | |
42 | - p = kzalloc(ls->ls_lvblen, ls->ls_allocation); | |
42 | + p = kzalloc(ls->ls_lvblen, GFP_NOFS); | |
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, ls->ls_allocation); | |
60 | + r = kzalloc(sizeof(*r) + namelen, GFP_NOFS); | |
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, ls->ls_allocation); | |
75 | + lkb = kmem_cache_zalloc(lkb_cache, GFP_NOFS); | |
76 | 76 | return lkb; |
77 | 77 | } |
78 | 78 |
fs/dlm/netlink.c
fs/dlm/plock.c
... | ... | @@ -82,7 +82,7 @@ |
82 | 82 | if (!ls) |
83 | 83 | return -EINVAL; |
84 | 84 | |
85 | - xop = kzalloc(sizeof(*xop), GFP_KERNEL); | |
85 | + xop = kzalloc(sizeof(*xop), GFP_NOFS); | |
86 | 86 | if (!xop) { |
87 | 87 | rv = -ENOMEM; |
88 | 88 | goto out; |
... | ... | @@ -211,7 +211,7 @@ |
211 | 211 | if (!ls) |
212 | 212 | return -EINVAL; |
213 | 213 | |
214 | - op = kzalloc(sizeof(*op), GFP_KERNEL); | |
214 | + op = kzalloc(sizeof(*op), GFP_NOFS); | |
215 | 215 | if (!op) { |
216 | 216 | rv = -ENOMEM; |
217 | 217 | goto out; |
... | ... | @@ -266,7 +266,7 @@ |
266 | 266 | if (!ls) |
267 | 267 | return -EINVAL; |
268 | 268 | |
269 | - op = kzalloc(sizeof(*op), GFP_KERNEL); | |
269 | + op = kzalloc(sizeof(*op), GFP_NOFS); | |
270 | 270 | if (!op) { |
271 | 271 | rv = -ENOMEM; |
272 | 272 | goto out; |
fs/dlm/rcom.c
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | char *mb; |
39 | 39 | int mb_len = sizeof(struct dlm_rcom) + len; |
40 | 40 | |
41 | - mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, ls->ls_allocation, &mb); | |
41 | + mh = dlm_lowcomms_get_buffer(to_nodeid, mb_len, GFP_NOFS, &mb); | |
42 | 42 | if (!mh) { |
43 | 43 | log_print("create_rcom to %d type %d len %d ENOBUFS", |
44 | 44 | to_nodeid, type, len); |
fs/dlm/requestqueue.c
... | ... | @@ -35,7 +35,7 @@ |
35 | 35 | struct rq_entry *e; |
36 | 36 | int length = ms->m_header.h_length - sizeof(struct dlm_message); |
37 | 37 | |
38 | - e = kmalloc(sizeof(struct rq_entry) + length, ls->ls_allocation); | |
38 | + e = kmalloc(sizeof(struct rq_entry) + length, GFP_NOFS); | |
39 | 39 | if (!e) { |
40 | 40 | log_print("dlm_add_requestqueue: out of memory len %d", length); |
41 | 41 | return; |
fs/dlm/user.c
... | ... | @@ -267,7 +267,7 @@ |
267 | 267 | goto out; |
268 | 268 | } |
269 | 269 | |
270 | - ua = kzalloc(sizeof(struct dlm_user_args), GFP_KERNEL); | |
270 | + ua = kzalloc(sizeof(struct dlm_user_args), GFP_NOFS); | |
271 | 271 | if (!ua) |
272 | 272 | goto out; |
273 | 273 | ua->proc = proc; |
... | ... | @@ -307,7 +307,7 @@ |
307 | 307 | if (!ls) |
308 | 308 | return -ENOENT; |
309 | 309 | |
310 | - ua = kzalloc(sizeof(struct dlm_user_args), GFP_KERNEL); | |
310 | + ua = kzalloc(sizeof(struct dlm_user_args), GFP_NOFS); | |
311 | 311 | if (!ua) |
312 | 312 | goto out; |
313 | 313 | ua->proc = proc; |
... | ... | @@ -352,7 +352,7 @@ |
352 | 352 | |
353 | 353 | error = -ENOMEM; |
354 | 354 | len = strlen(name) + strlen(name_prefix) + 2; |
355 | - ls->ls_device.name = kzalloc(len, GFP_KERNEL); | |
355 | + ls->ls_device.name = kzalloc(len, GFP_NOFS); | |
356 | 356 | if (!ls->ls_device.name) |
357 | 357 | goto fail; |
358 | 358 | |
... | ... | @@ -520,7 +520,7 @@ |
520 | 520 | #endif |
521 | 521 | return -EINVAL; |
522 | 522 | |
523 | - kbuf = kzalloc(count + 1, GFP_KERNEL); | |
523 | + kbuf = kzalloc(count + 1, GFP_NOFS); | |
524 | 524 | if (!kbuf) |
525 | 525 | return -ENOMEM; |
526 | 526 | |
... | ... | @@ -546,7 +546,7 @@ |
546 | 546 | |
547 | 547 | /* add 1 after namelen so that the name string is terminated */ |
548 | 548 | kbuf = kzalloc(sizeof(struct dlm_write_request) + namelen + 1, |
549 | - GFP_KERNEL); | |
549 | + GFP_NOFS); | |
550 | 550 | if (!kbuf) { |
551 | 551 | kfree(k32buf); |
552 | 552 | return -ENOMEM; |
... | ... | @@ -648,7 +648,7 @@ |
648 | 648 | if (!ls) |
649 | 649 | return -ENOENT; |
650 | 650 | |
651 | - proc = kzalloc(sizeof(struct dlm_user_proc), GFP_KERNEL); | |
651 | + proc = kzalloc(sizeof(struct dlm_user_proc), GFP_NOFS); | |
652 | 652 | if (!proc) { |
653 | 653 | dlm_put_lockspace(ls); |
654 | 654 | return -ENOMEM; |