Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'dlm-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm

Pull dlm updates from David Teigland:

- Allow blocking posix lock requests to be interrupted while waiting.
This requires a cancel request to be sent to the userspace daemon
where posix lock requests are processed across the cluster.

- Fix a posix lock patch from the previous cycle in which lock requests
from different file systems could be mixed up.

- Fix some long standing problems with nfs posix lock cancelation.

- Add a new debugfs file for printing queued callbacks.

- Stop modifying buffers that have been used to receive a message.

- Misc cleanups and some refactoring.

* tag 'dlm-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm:
dlm: fix plock lookup when using multiple lockspaces
fs: dlm: don't use RCOM_NAMES for version detection
fs: dlm: create midcomms nodes when configure
fs: dlm: constify receive buffer
fs: dlm: drop rxbuf manipulation in dlm_recover_master_copy
fs: dlm: drop rxbuf manipulation in dlm_copy_master_names
fs: dlm: get recovery sequence number as parameter
fs: dlm: cleanup lock order
fs: dlm: remove clear_members_cb
fs: dlm: add plock dev tracepoints
fs: dlm: check on plock ops when exit dlm
fs: dlm: debugfs for queued callbacks
fs: dlm: remove unused processed_nodes
fs: dlm: add missing spin_unlock
fs: dlm: fix F_CANCELLK to cancel pending request
fs: dlm: allow to F_SETLKW getting interrupted
fs: dlm: remove twice newline

+628 -420
+1 -1
fs/dlm/config.c
··· 664 664 665 665 memcpy(addr, buf, len); 666 666 667 - rv = dlm_lowcomms_addr(cm->nodeid, addr, len); 667 + rv = dlm_midcomms_addr(cm->nodeid, addr, len); 668 668 if (rv) { 669 669 kfree(addr); 670 670 return rv;
+100 -1
fs/dlm/debug_fs.c
··· 18 18 #include "dlm_internal.h" 19 19 #include "midcomms.h" 20 20 #include "lock.h" 21 + #include "ast.h" 21 22 22 23 #define DLM_DEBUG_BUF_LEN 4096 23 24 static char debug_buf[DLM_DEBUG_BUF_LEN]; ··· 366 365 unlock_rsb(r); 367 366 } 368 367 368 + static void print_format5_lock(struct seq_file *s, struct dlm_lkb *lkb) 369 + { 370 + struct dlm_callback *cb; 371 + 372 + /* lkb_id lkb_flags mode flags sb_status sb_flags */ 373 + 374 + spin_lock(&lkb->lkb_cb_lock); 375 + list_for_each_entry(cb, &lkb->lkb_callbacks, list) { 376 + seq_printf(s, "%x %x %d %x %d %x\n", 377 + lkb->lkb_id, 378 + dlm_iflags_val(lkb), 379 + cb->mode, 380 + cb->flags, 381 + cb->sb_status, 382 + cb->sb_flags); 383 + } 384 + spin_unlock(&lkb->lkb_cb_lock); 385 + } 386 + 387 + static void print_format5(struct dlm_rsb *r, struct seq_file *s) 388 + { 389 + struct dlm_lkb *lkb; 390 + 391 + lock_rsb(r); 392 + 393 + list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { 394 + print_format5_lock(s, lkb); 395 + if (seq_has_overflowed(s)) 396 + goto out; 397 + } 398 + 399 + list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { 400 + print_format5_lock(s, lkb); 401 + if (seq_has_overflowed(s)) 402 + goto out; 403 + } 404 + 405 + list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { 406 + print_format5_lock(s, lkb); 407 + if (seq_has_overflowed(s)) 408 + goto out; 409 + } 410 + out: 411 + unlock_rsb(r); 412 + } 413 + 369 414 struct rsbtbl_iter { 370 415 struct dlm_rsb *rsb; 371 416 unsigned bucket; ··· 455 408 } 456 409 print_format4(ri->rsb, seq); 457 410 break; 411 + case 5: 412 + if (ri->header) { 413 + seq_puts(seq, "lkb_id lkb_flags mode flags sb_status sb_flags\n"); 414 + ri->header = 0; 415 + } 416 + print_format5(ri->rsb, seq); 417 + break; 458 418 } 459 419 460 420 return 0; ··· 471 417 static const struct seq_operations format2_seq_ops; 472 418 static const struct seq_operations format3_seq_ops; 473 419 static const struct seq_operations format4_seq_ops; 420 + static const struct seq_operations format5_seq_ops; 474 421 475 422 static void *table_seq_start(struct seq_file *seq, loff_t *pos) 476 423 { ··· 503 448 ri->format = 3; 504 449 if (seq->op == &format4_seq_ops) 505 450 ri->format = 4; 451 + if (seq->op == &format5_seq_ops) 452 + ri->format = 5; 506 453 507 454 tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep; 508 455 ··· 659 602 .show = table_seq_show, 660 603 }; 661 604 605 + static const struct seq_operations format5_seq_ops = { 606 + .start = table_seq_start, 607 + .next = table_seq_next, 608 + .stop = table_seq_stop, 609 + .show = table_seq_show, 610 + }; 611 + 662 612 static const struct file_operations format1_fops; 663 613 static const struct file_operations format2_fops; 664 614 static const struct file_operations format3_fops; 665 615 static const struct file_operations format4_fops; 616 + static const struct file_operations format5_fops; 666 617 667 618 static int table_open1(struct inode *inode, struct file *file) 668 619 { ··· 748 683 struct seq_file *seq; 749 684 int ret; 750 685 751 - ret = seq_open(file, &format4_seq_ops); 686 + ret = seq_open(file, &format5_seq_ops); 687 + if (ret) 688 + return ret; 689 + 690 + seq = file->private_data; 691 + seq->private = inode->i_private; /* the dlm_ls */ 692 + return 0; 693 + } 694 + 695 + static int table_open5(struct inode *inode, struct file *file) 696 + { 697 + struct seq_file *seq; 698 + int ret; 699 + 700 + ret = seq_open(file, &format5_seq_ops); 752 701 if (ret) 753 702 return ret; 754 703 ··· 799 720 static const struct file_operations format4_fops = { 800 721 .owner = THIS_MODULE, 801 722 .open = table_open4, 723 + .read = seq_read, 724 + .llseek = seq_lseek, 725 + .release = seq_release 726 + }; 727 + 728 + static const struct file_operations format5_fops = { 729 + .owner = THIS_MODULE, 730 + .open = table_open5, 802 731 .read = seq_read, 803 732 .llseek = seq_lseek, 804 733 .release = seq_release ··· 880 793 debugfs_remove(ls->ls_debug_locks_dentry); 881 794 debugfs_remove(ls->ls_debug_all_dentry); 882 795 debugfs_remove(ls->ls_debug_toss_dentry); 796 + debugfs_remove(ls->ls_debug_queued_asts_dentry); 883 797 } 884 798 885 799 static int dlm_state_show(struct seq_file *file, void *offset) ··· 1024 936 dlm_root, 1025 937 ls, 1026 938 &waiters_fops); 939 + 940 + /* format 5 */ 941 + 942 + memset(name, 0, sizeof(name)); 943 + snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_queued_asts", ls->ls_name); 944 + 945 + ls->ls_debug_queued_asts_dentry = debugfs_create_file(name, 946 + 0644, 947 + dlm_root, 948 + ls, 949 + &format5_fops); 1027 950 } 1028 951 1029 952 void __init dlm_register_debugfs(void)
+7 -7
fs/dlm/dir.c
··· 58 58 up_read(&ls->ls_root_sem); 59 59 } 60 60 61 - int dlm_recover_directory(struct dlm_ls *ls) 61 + int dlm_recover_directory(struct dlm_ls *ls, uint64_t seq) 62 62 { 63 63 struct dlm_member *memb; 64 64 char *b, *last_name = NULL; ··· 90 90 } 91 91 92 92 error = dlm_rcom_names(ls, memb->nodeid, 93 - last_name, last_len); 93 + last_name, last_len, seq); 94 94 if (error) 95 95 goto out_free; 96 96 ··· 196 196 return error; 197 197 } 198 198 199 - static struct dlm_rsb *find_rsb_root(struct dlm_ls *ls, char *name, int len) 199 + static struct dlm_rsb *find_rsb_root(struct dlm_ls *ls, const char *name, 200 + int len) 200 201 { 201 202 struct dlm_rsb *r; 202 203 uint32_t hash, bucket; ··· 233 232 for rsb's we're master of and whose directory node matches the requesting 234 233 node. inbuf is the rsb name last sent, inlen is the name's length */ 235 234 236 - void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen, 235 + void dlm_copy_master_names(struct dlm_ls *ls, const char *inbuf, int inlen, 237 236 char *outbuf, int outlen, int nodeid) 238 237 { 239 238 struct list_head *list; ··· 246 245 if (inlen > 1) { 247 246 r = find_rsb_root(ls, inbuf, inlen); 248 247 if (!r) { 249 - inbuf[inlen - 1] = '\0'; 250 - log_error(ls, "copy_master_names from %d start %d %s", 251 - nodeid, inlen, inbuf); 248 + log_error(ls, "copy_master_names from %d start %d %.*s", 249 + nodeid, inlen, inlen, inbuf); 252 250 goto out; 253 251 } 254 252 list = r->res_root_list.next;
+3 -3
fs/dlm/dir.h
··· 15 15 int dlm_dir_nodeid(struct dlm_rsb *rsb); 16 16 int dlm_hash2nodeid(struct dlm_ls *ls, uint32_t hash); 17 17 void dlm_recover_dir_nodeid(struct dlm_ls *ls); 18 - int dlm_recover_directory(struct dlm_ls *ls); 19 - void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen, 20 - char *outbuf, int outlen, int nodeid); 18 + int dlm_recover_directory(struct dlm_ls *ls, uint64_t seq); 19 + void dlm_copy_master_names(struct dlm_ls *ls, const char *inbuf, int inlen, 20 + char *outbuf, int outlen, int nodeid); 21 21 22 22 #endif /* __DIR_DOT_H__ */ 23 23
+1
fs/dlm/dlm_internal.h
··· 598 598 struct dentry *ls_debug_locks_dentry; /* debugfs */ 599 599 struct dentry *ls_debug_all_dentry; /* debugfs */ 600 600 struct dentry *ls_debug_toss_dentry; /* debugfs */ 601 + struct dentry *ls_debug_queued_asts_dentry; /* debugfs */ 601 602 602 603 wait_queue_head_t ls_uevent_wait; /* user part of join/leave */ 603 604 int ls_uevent_result;
+66 -54
fs/dlm/lock.c
··· 86 86 static int _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb); 87 87 static int _cancel_lock(struct dlm_rsb *r, struct dlm_lkb *lkb); 88 88 static void __receive_convert_reply(struct dlm_rsb *r, struct dlm_lkb *lkb, 89 - struct dlm_message *ms, bool local); 90 - static int receive_extralen(struct dlm_message *ms); 89 + const struct dlm_message *ms, bool local); 90 + static int receive_extralen(const struct dlm_message *ms); 91 91 static void do_purge(struct dlm_ls *ls, int nodeid, int pid); 92 92 static void toss_rsb(struct kref *kref); 93 93 ··· 984 984 * . dlm_master_lookup RECOVER_MASTER (fix_master 1, from_master 0) 985 985 */ 986 986 987 - int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, char *name, int len, 988 - unsigned int flags, int *r_nodeid, int *result) 987 + int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name, 988 + int len, unsigned int flags, int *r_nodeid, int *result) 989 989 { 990 990 struct dlm_rsb *r = NULL; 991 991 uint32_t hash, b; ··· 1106 1106 } 1107 1107 } 1108 1108 1109 - void dlm_dump_rsb_name(struct dlm_ls *ls, char *name, int len) 1109 + void dlm_dump_rsb_name(struct dlm_ls *ls, const char *name, int len) 1110 1110 { 1111 1111 struct dlm_rsb *r = NULL; 1112 1112 uint32_t hash, b; ··· 1459 1459 set RESEND and dlm_recover_waiters_post() */ 1460 1460 1461 1461 static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype, 1462 - struct dlm_message *ms) 1462 + const struct dlm_message *ms) 1463 1463 { 1464 1464 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 1465 1465 int overlap_done = 0; ··· 1557 1557 /* Handles situations where we might be processing a "fake" or "local" reply in 1558 1558 which we can't try to take waiters_mutex again. */ 1559 1559 1560 - static int remove_from_waiters_ms(struct dlm_lkb *lkb, struct dlm_message *ms, 1561 - bool local) 1560 + static int remove_from_waiters_ms(struct dlm_lkb *lkb, 1561 + const struct dlm_message *ms, bool local) 1562 1562 { 1563 1563 struct dlm_ls *ls = lkb->lkb_resource->res_ls; 1564 1564 int error; ··· 1800 1800 /* lkb is process copy (pc) */ 1801 1801 1802 1802 static void set_lvb_lock_pc(struct dlm_rsb *r, struct dlm_lkb *lkb, 1803 - struct dlm_message *ms) 1803 + const struct dlm_message *ms) 1804 1804 { 1805 1805 int b; 1806 1806 ··· 1907 1907 } 1908 1908 1909 1909 static void grant_lock_pc(struct dlm_rsb *r, struct dlm_lkb *lkb, 1910 - struct dlm_message *ms) 1910 + const struct dlm_message *ms) 1911 1911 { 1912 1912 set_lvb_lock_pc(r, lkb, ms); 1913 1913 _grant_lock(r, lkb); ··· 1945 1945 lkb->lkb_grmode = DLM_LOCK_NL; 1946 1946 } 1947 1947 1948 - static void munge_altmode(struct dlm_lkb *lkb, struct dlm_message *ms) 1948 + static void munge_altmode(struct dlm_lkb *lkb, const struct dlm_message *ms) 1949 1949 { 1950 1950 if (ms->m_type != cpu_to_le32(DLM_MSG_REQUEST_REPLY) && 1951 1951 ms->m_type != cpu_to_le32(DLM_MSG_GRANT)) { ··· 3641 3641 return send_common_reply(r, lkb, DLM_MSG_CANCEL_REPLY, rv); 3642 3642 } 3643 3643 3644 - static int send_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms_in, 3645 - int ret_nodeid, int rv) 3644 + static int send_lookup_reply(struct dlm_ls *ls, 3645 + const struct dlm_message *ms_in, int ret_nodeid, 3646 + int rv) 3646 3647 { 3647 3648 struct dlm_rsb *r = &ls->ls_local_rsb; 3648 3649 struct dlm_message *ms; ··· 3668 3667 of message, unlike the send side where we can safely send everything about 3669 3668 the lkb for any type of message */ 3670 3669 3671 - static void receive_flags(struct dlm_lkb *lkb, struct dlm_message *ms) 3670 + static void receive_flags(struct dlm_lkb *lkb, const struct dlm_message *ms) 3672 3671 { 3673 3672 lkb->lkb_exflags = le32_to_cpu(ms->m_exflags); 3674 3673 dlm_set_sbflags_val(lkb, le32_to_cpu(ms->m_sbflags)); 3675 3674 dlm_set_dflags_val(lkb, le32_to_cpu(ms->m_flags)); 3676 3675 } 3677 3676 3678 - static void receive_flags_reply(struct dlm_lkb *lkb, struct dlm_message *ms, 3677 + static void receive_flags_reply(struct dlm_lkb *lkb, 3678 + const struct dlm_message *ms, 3679 3679 bool local) 3680 3680 { 3681 3681 if (local) ··· 3686 3684 dlm_set_dflags_val(lkb, le32_to_cpu(ms->m_flags)); 3687 3685 } 3688 3686 3689 - static int receive_extralen(struct dlm_message *ms) 3687 + static int receive_extralen(const struct dlm_message *ms) 3690 3688 { 3691 3689 return (le16_to_cpu(ms->m_header.h_length) - 3692 3690 sizeof(struct dlm_message)); 3693 3691 } 3694 3692 3695 3693 static int receive_lvb(struct dlm_ls *ls, struct dlm_lkb *lkb, 3696 - struct dlm_message *ms) 3694 + const struct dlm_message *ms) 3697 3695 { 3698 3696 int len; 3699 3697 ··· 3721 3719 } 3722 3720 3723 3721 static int receive_request_args(struct dlm_ls *ls, struct dlm_lkb *lkb, 3724 - struct dlm_message *ms) 3722 + const struct dlm_message *ms) 3725 3723 { 3726 3724 lkb->lkb_nodeid = le32_to_cpu(ms->m_header.h_nodeid); 3727 3725 lkb->lkb_ownpid = le32_to_cpu(ms->m_pid); ··· 3743 3741 } 3744 3742 3745 3743 static int receive_convert_args(struct dlm_ls *ls, struct dlm_lkb *lkb, 3746 - struct dlm_message *ms) 3744 + const struct dlm_message *ms) 3747 3745 { 3748 3746 if (lkb->lkb_status != DLM_LKSTS_GRANTED) 3749 3747 return -EBUSY; ··· 3758 3756 } 3759 3757 3760 3758 static int receive_unlock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, 3761 - struct dlm_message *ms) 3759 + const struct dlm_message *ms) 3762 3760 { 3763 3761 if (receive_lvb(ls, lkb, ms)) 3764 3762 return -ENOMEM; ··· 3768 3766 /* We fill in the local-lkb fields with the info that send_xxxx_reply() 3769 3767 uses to send a reply and that the remote end uses to process the reply. */ 3770 3768 3771 - static void setup_local_lkb(struct dlm_ls *ls, struct dlm_message *ms) 3769 + static void setup_local_lkb(struct dlm_ls *ls, const struct dlm_message *ms) 3772 3770 { 3773 3771 struct dlm_lkb *lkb = &ls->ls_local_lkb; 3774 3772 lkb->lkb_nodeid = le32_to_cpu(ms->m_header.h_nodeid); ··· 3778 3776 /* This is called after the rsb is locked so that we can safely inspect 3779 3777 fields in the lkb. */ 3780 3778 3781 - static int validate_message(struct dlm_lkb *lkb, struct dlm_message *ms) 3779 + static int validate_message(struct dlm_lkb *lkb, const struct dlm_message *ms) 3782 3780 { 3783 3781 int from = le32_to_cpu(ms->m_header.h_nodeid); 3784 3782 int error = 0; ··· 3830 3828 return error; 3831 3829 } 3832 3830 3833 - static int receive_request(struct dlm_ls *ls, struct dlm_message *ms) 3831 + static int receive_request(struct dlm_ls *ls, const struct dlm_message *ms) 3834 3832 { 3835 3833 struct dlm_lkb *lkb; 3836 3834 struct dlm_rsb *r; ··· 3909 3907 return error; 3910 3908 } 3911 3909 3912 - static int receive_convert(struct dlm_ls *ls, struct dlm_message *ms) 3910 + static int receive_convert(struct dlm_ls *ls, const struct dlm_message *ms) 3913 3911 { 3914 3912 struct dlm_lkb *lkb; 3915 3913 struct dlm_rsb *r; ··· 3965 3963 return error; 3966 3964 } 3967 3965 3968 - static int receive_unlock(struct dlm_ls *ls, struct dlm_message *ms) 3966 + static int receive_unlock(struct dlm_ls *ls, const struct dlm_message *ms) 3969 3967 { 3970 3968 struct dlm_lkb *lkb; 3971 3969 struct dlm_rsb *r; ··· 4017 4015 return error; 4018 4016 } 4019 4017 4020 - static int receive_cancel(struct dlm_ls *ls, struct dlm_message *ms) 4018 + static int receive_cancel(struct dlm_ls *ls, const struct dlm_message *ms) 4021 4019 { 4022 4020 struct dlm_lkb *lkb; 4023 4021 struct dlm_rsb *r; ··· 4053 4051 return error; 4054 4052 } 4055 4053 4056 - static int receive_grant(struct dlm_ls *ls, struct dlm_message *ms) 4054 + static int receive_grant(struct dlm_ls *ls, const struct dlm_message *ms) 4057 4055 { 4058 4056 struct dlm_lkb *lkb; 4059 4057 struct dlm_rsb *r; ··· 4084 4082 return 0; 4085 4083 } 4086 4084 4087 - static int receive_bast(struct dlm_ls *ls, struct dlm_message *ms) 4085 + static int receive_bast(struct dlm_ls *ls, const struct dlm_message *ms) 4088 4086 { 4089 4087 struct dlm_lkb *lkb; 4090 4088 struct dlm_rsb *r; ··· 4112 4110 return 0; 4113 4111 } 4114 4112 4115 - static void receive_lookup(struct dlm_ls *ls, struct dlm_message *ms) 4113 + static void receive_lookup(struct dlm_ls *ls, const struct dlm_message *ms) 4116 4114 { 4117 4115 int len, error, ret_nodeid, from_nodeid, our_nodeid; 4118 4116 ··· 4132 4130 send_lookup_reply(ls, ms, ret_nodeid, error); 4133 4131 } 4134 4132 4135 - static void receive_remove(struct dlm_ls *ls, struct dlm_message *ms) 4133 + static void receive_remove(struct dlm_ls *ls, const struct dlm_message *ms) 4136 4134 { 4137 4135 char name[DLM_RESNAME_MAXLEN+1]; 4138 4136 struct dlm_rsb *r; ··· 4220 4218 } 4221 4219 } 4222 4220 4223 - static void receive_purge(struct dlm_ls *ls, struct dlm_message *ms) 4221 + static void receive_purge(struct dlm_ls *ls, const struct dlm_message *ms) 4224 4222 { 4225 4223 do_purge(ls, le32_to_cpu(ms->m_nodeid), le32_to_cpu(ms->m_pid)); 4226 4224 } 4227 4225 4228 - static int receive_request_reply(struct dlm_ls *ls, struct dlm_message *ms) 4226 + static int receive_request_reply(struct dlm_ls *ls, 4227 + const struct dlm_message *ms) 4229 4228 { 4230 4229 struct dlm_lkb *lkb; 4231 4230 struct dlm_rsb *r; ··· 4348 4345 } 4349 4346 4350 4347 static void __receive_convert_reply(struct dlm_rsb *r, struct dlm_lkb *lkb, 4351 - struct dlm_message *ms, bool local) 4348 + const struct dlm_message *ms, bool local) 4352 4349 { 4353 4350 /* this is the value returned from do_convert() on the master */ 4354 4351 switch (from_dlm_errno(le32_to_cpu(ms->m_result))) { ··· 4391 4388 } 4392 4389 } 4393 4390 4394 - static void _receive_convert_reply(struct dlm_lkb *lkb, struct dlm_message *ms, 4395 - bool local) 4391 + static void _receive_convert_reply(struct dlm_lkb *lkb, 4392 + const struct dlm_message *ms, bool local) 4396 4393 { 4397 4394 struct dlm_rsb *r = lkb->lkb_resource; 4398 4395 int error; ··· 4415 4412 put_rsb(r); 4416 4413 } 4417 4414 4418 - static int receive_convert_reply(struct dlm_ls *ls, struct dlm_message *ms) 4415 + static int receive_convert_reply(struct dlm_ls *ls, 4416 + const struct dlm_message *ms) 4419 4417 { 4420 4418 struct dlm_lkb *lkb; 4421 4419 int error; ··· 4430 4426 return 0; 4431 4427 } 4432 4428 4433 - static void _receive_unlock_reply(struct dlm_lkb *lkb, struct dlm_message *ms, 4434 - bool local) 4429 + static void _receive_unlock_reply(struct dlm_lkb *lkb, 4430 + const struct dlm_message *ms, bool local) 4435 4431 { 4436 4432 struct dlm_rsb *r = lkb->lkb_resource; 4437 4433 int error; ··· 4467 4463 put_rsb(r); 4468 4464 } 4469 4465 4470 - static int receive_unlock_reply(struct dlm_ls *ls, struct dlm_message *ms) 4466 + static int receive_unlock_reply(struct dlm_ls *ls, 4467 + const struct dlm_message *ms) 4471 4468 { 4472 4469 struct dlm_lkb *lkb; 4473 4470 int error; ··· 4482 4477 return 0; 4483 4478 } 4484 4479 4485 - static void _receive_cancel_reply(struct dlm_lkb *lkb, struct dlm_message *ms, 4486 - bool local) 4480 + static void _receive_cancel_reply(struct dlm_lkb *lkb, 4481 + const struct dlm_message *ms, bool local) 4487 4482 { 4488 4483 struct dlm_rsb *r = lkb->lkb_resource; 4489 4484 int error; ··· 4520 4515 put_rsb(r); 4521 4516 } 4522 4517 4523 - static int receive_cancel_reply(struct dlm_ls *ls, struct dlm_message *ms) 4518 + static int receive_cancel_reply(struct dlm_ls *ls, 4519 + const struct dlm_message *ms) 4524 4520 { 4525 4521 struct dlm_lkb *lkb; 4526 4522 int error; ··· 4535 4529 return 0; 4536 4530 } 4537 4531 4538 - static void receive_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms) 4532 + static void receive_lookup_reply(struct dlm_ls *ls, 4533 + const struct dlm_message *ms) 4539 4534 { 4540 4535 struct dlm_lkb *lkb; 4541 4536 struct dlm_rsb *r; ··· 4615 4608 dlm_put_lkb(lkb); 4616 4609 } 4617 4610 4618 - static void _receive_message(struct dlm_ls *ls, struct dlm_message *ms, 4611 + static void _receive_message(struct dlm_ls *ls, const struct dlm_message *ms, 4619 4612 uint32_t saved_seq) 4620 4613 { 4621 4614 int error = 0, noent = 0; ··· 4751 4744 requestqueue, to processing all the saved messages, to processing new 4752 4745 messages as they arrive. */ 4753 4746 4754 - static void dlm_receive_message(struct dlm_ls *ls, struct dlm_message *ms, 4747 + static void dlm_receive_message(struct dlm_ls *ls, const struct dlm_message *ms, 4755 4748 int nodeid) 4756 4749 { 4757 4750 if (dlm_locking_stopped(ls)) { ··· 4774 4767 /* This is called by dlm_recoverd to process messages that were saved on 4775 4768 the requestqueue. */ 4776 4769 4777 - void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms, 4770 + void dlm_receive_message_saved(struct dlm_ls *ls, const struct dlm_message *ms, 4778 4771 uint32_t saved_seq) 4779 4772 { 4780 4773 _receive_message(ls, ms, saved_seq); ··· 4785 4778 standard locking activity) or an RCOM (recovery message sent as part of 4786 4779 lockspace recovery). */ 4787 4780 4788 - void dlm_receive_buffer(union dlm_packet *p, int nodeid) 4781 + void dlm_receive_buffer(const union dlm_packet *p, int nodeid) 4789 4782 { 4790 - struct dlm_header *hd = &p->header; 4783 + const struct dlm_header *hd = &p->header; 4791 4784 struct dlm_ls *ls; 4792 4785 int type = 0; 4793 4786 ··· 5341 5334 5342 5335 /* needs at least dlm_rcom + rcom_lock */ 5343 5336 static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb, 5344 - struct dlm_rsb *r, struct dlm_rcom *rc) 5337 + struct dlm_rsb *r, const struct dlm_rcom *rc) 5345 5338 { 5346 5339 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 5347 5340 ··· 5391 5384 back the rcom_lock struct we got but with the remid field filled in. */ 5392 5385 5393 5386 /* needs at least dlm_rcom + rcom_lock */ 5394 - int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc) 5387 + int dlm_recover_master_copy(struct dlm_ls *ls, const struct dlm_rcom *rc, 5388 + __le32 *rl_remid, __le32 *rl_result) 5395 5389 { 5396 5390 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 5397 5391 struct dlm_rsb *r; ··· 5400 5392 uint32_t remid = 0; 5401 5393 int from_nodeid = le32_to_cpu(rc->rc_header.h_nodeid); 5402 5394 int error; 5395 + 5396 + /* init rl_remid with rcom lock rl_remid */ 5397 + *rl_remid = rl->rl_remid; 5403 5398 5404 5399 if (rl->rl_parent_lkid) { 5405 5400 error = -EOPNOTSUPP; ··· 5459 5448 out_remid: 5460 5449 /* this is the new value returned to the lock holder for 5461 5450 saving in its process-copy lkb */ 5462 - rl->rl_remid = cpu_to_le32(lkb->lkb_id); 5451 + *rl_remid = cpu_to_le32(lkb->lkb_id); 5463 5452 5464 5453 lkb->lkb_recover_seq = ls->ls_recover_seq; 5465 5454 ··· 5470 5459 if (error && error != -EEXIST) 5471 5460 log_rinfo(ls, "dlm_recover_master_copy remote %d %x error %d", 5472 5461 from_nodeid, remid, error); 5473 - rl->rl_result = cpu_to_le32(error); 5462 + *rl_result = cpu_to_le32(error); 5474 5463 return error; 5475 5464 } 5476 5465 5477 5466 /* needs at least dlm_rcom + rcom_lock */ 5478 - int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc) 5467 + int dlm_recover_process_copy(struct dlm_ls *ls, const struct dlm_rcom *rc, 5468 + uint64_t seq) 5479 5469 { 5480 5470 struct rcom_lock *rl = (struct rcom_lock *) rc->rc_buf; 5481 5471 struct dlm_rsb *r; ··· 5521 5509 lkid, le32_to_cpu(rc->rc_header.h_nodeid), remid, 5522 5510 result); 5523 5511 5524 - dlm_send_rcom_lock(r, lkb); 5512 + dlm_send_rcom_lock(r, lkb, seq); 5525 5513 goto out; 5526 5514 case -EEXIST: 5527 5515 case 0:
+9 -7
fs/dlm/lock.h
··· 12 12 #define __LOCK_DOT_H__ 13 13 14 14 void dlm_dump_rsb(struct dlm_rsb *r); 15 - void dlm_dump_rsb_name(struct dlm_ls *ls, char *name, int len); 15 + void dlm_dump_rsb_name(struct dlm_ls *ls, const char *name, int len); 16 16 void dlm_print_lkb(struct dlm_lkb *lkb); 17 - void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms, 17 + void dlm_receive_message_saved(struct dlm_ls *ls, const struct dlm_message *ms, 18 18 uint32_t saved_seq); 19 - void dlm_receive_buffer(union dlm_packet *p, int nodeid); 19 + void dlm_receive_buffer(const union dlm_packet *p, int nodeid); 20 20 int dlm_modes_compat(int mode1, int mode2); 21 21 void dlm_put_rsb(struct dlm_rsb *r); 22 22 void dlm_hold_rsb(struct dlm_rsb *r); ··· 25 25 int dlm_lock_recovery_try(struct dlm_ls *ls); 26 26 void dlm_unlock_recovery(struct dlm_ls *ls); 27 27 28 - int dlm_master_lookup(struct dlm_ls *ls, int nodeid, char *name, int len, 29 - unsigned int flags, int *r_nodeid, int *result); 28 + int dlm_master_lookup(struct dlm_ls *ls, int from_nodeid, const char *name, 29 + int len, unsigned int flags, int *r_nodeid, int *result); 30 30 31 31 int dlm_search_rsb_tree(struct rb_root *tree, const void *name, int len, 32 32 struct dlm_rsb **r_ret); ··· 36 36 void dlm_recover_grant(struct dlm_ls *ls); 37 37 int dlm_recover_waiters_post(struct dlm_ls *ls); 38 38 void dlm_recover_waiters_pre(struct dlm_ls *ls); 39 - int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc); 40 - int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc); 39 + int dlm_recover_master_copy(struct dlm_ls *ls, const struct dlm_rcom *rc, 40 + __le32 *rl_remid, __le32 *rl_result); 41 + int dlm_recover_process_copy(struct dlm_ls *ls, const struct dlm_rcom *rc, 42 + uint64_t seq); 41 43 42 44 int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, int mode, 43 45 uint32_t flags, void *name, unsigned int namelen);
-1
fs/dlm/lowcomms.c
··· 863 863 static void process_dlm_messages(struct work_struct *work) 864 864 { 865 865 struct processqueue_entry *pentry; 866 - LIST_HEAD(processed_nodes); 867 866 868 867 spin_lock(&processqueue_lock); 869 868 pentry = list_first_entry_or_null(&processqueue,
+5 -10
fs/dlm/member.c
··· 18 18 #include "midcomms.h" 19 19 #include "lowcomms.h" 20 20 21 - int dlm_slots_version(struct dlm_header *h) 21 + int dlm_slots_version(const struct dlm_header *h) 22 22 { 23 23 if ((le32_to_cpu(h->h_version) & 0x0000FFFF) < DLM_HEADER_SLOTS) 24 24 return 0; ··· 393 393 dlm_midcomms_remove_member(nodeid); 394 394 } 395 395 396 - static void clear_members_cb(int nodeid) 397 - { 398 - remove_remote_member(nodeid); 399 - } 400 - 401 396 void dlm_clear_members(struct dlm_ls *ls) 402 397 { 403 - clear_memb_list(&ls->ls_nodes, clear_members_cb); 398 + clear_memb_list(&ls->ls_nodes, remove_remote_member); 404 399 ls->ls_num_nodes = 0; 405 400 } 406 401 ··· 449 454 450 455 /* send a status request to all members just to establish comms connections */ 451 456 452 - static int ping_members(struct dlm_ls *ls) 457 + static int ping_members(struct dlm_ls *ls, uint64_t seq) 453 458 { 454 459 struct dlm_member *memb; 455 460 int error = 0; ··· 459 464 error = -EINTR; 460 465 break; 461 466 } 462 - error = dlm_rcom_status(ls, memb->nodeid, 0); 467 + error = dlm_rcom_status(ls, memb->nodeid, 0, seq); 463 468 if (error) 464 469 break; 465 470 } ··· 607 612 make_member_array(ls); 608 613 *neg_out = neg; 609 614 610 - error = ping_members(ls); 615 + error = ping_members(ls, rv->seq); 611 616 log_rinfo(ls, "dlm_recover_members %d nodes", ls->ls_num_nodes); 612 617 return error; 613 618 }
+1 -1
fs/dlm/member.h
··· 18 18 int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv,int *neg_out); 19 19 int dlm_is_removed(struct dlm_ls *ls, int nodeid); 20 20 int dlm_is_member(struct dlm_ls *ls, int nodeid); 21 - int dlm_slots_version(struct dlm_header *h); 21 + int dlm_slots_version(const struct dlm_header *h); 22 22 void dlm_slot_save(struct dlm_ls *ls, struct dlm_rcom *rc, 23 23 struct dlm_member *memb); 24 24 void dlm_slots_copy_out(struct dlm_ls *ls, struct dlm_rcom *rc);
+118 -186
fs/dlm/midcomms.c
··· 330 330 wake_up(&node->shutdown_wait); 331 331 } 332 332 333 - static struct midcomms_node *nodeid2node(int nodeid, gfp_t alloc) 333 + static struct midcomms_node *nodeid2node(int nodeid) 334 334 { 335 - struct midcomms_node *node, *tmp; 336 - int r = nodeid_hash(nodeid); 335 + return __find_node(nodeid, nodeid_hash(nodeid)); 336 + } 337 337 338 - node = __find_node(nodeid, r); 339 - if (node || !alloc) 340 - return node; 338 + int dlm_midcomms_addr(int nodeid, struct sockaddr_storage *addr, int len) 339 + { 340 + int ret, r = nodeid_hash(nodeid); 341 + struct midcomms_node *node; 341 342 342 - node = kmalloc(sizeof(*node), alloc); 343 + ret = dlm_lowcomms_addr(nodeid, addr, len); 344 + if (ret) 345 + return ret; 346 + 347 + node = kmalloc(sizeof(*node), GFP_NOFS); 343 348 if (!node) 344 - return NULL; 349 + return -ENOMEM; 345 350 346 351 node->nodeid = nodeid; 347 352 spin_lock_init(&node->state_lock); ··· 358 353 midcomms_node_reset(node); 359 354 360 355 spin_lock(&nodes_lock); 361 - /* check again if there was somebody else 362 - * earlier here to add the node 363 - */ 364 - tmp = __find_node(nodeid, r); 365 - if (tmp) { 366 - spin_unlock(&nodes_lock); 367 - kfree(node); 368 - return tmp; 369 - } 370 - 371 356 hlist_add_head_rcu(&node->hlist, &node_hash[r]); 372 357 spin_unlock(&nodes_lock); 373 358 374 359 node->debugfs = dlm_create_debug_comms_file(nodeid, node); 375 - return node; 360 + return 0; 376 361 } 377 362 378 363 static int dlm_send_ack(int nodeid, uint32_t seq) ··· 494 499 spin_unlock(&node->state_lock); 495 500 } 496 501 497 - static void dlm_receive_buffer_3_2_trace(uint32_t seq, union dlm_packet *p) 502 + static void dlm_receive_buffer_3_2_trace(uint32_t seq, 503 + const union dlm_packet *p) 498 504 { 499 505 switch (p->header.h_cmd) { 500 506 case DLM_MSG: ··· 509 513 } 510 514 } 511 515 512 - static void dlm_midcomms_receive_buffer(union dlm_packet *p, 516 + static void dlm_midcomms_receive_buffer(const union dlm_packet *p, 513 517 struct midcomms_node *node, 514 518 uint32_t seq) 515 519 { ··· 598 602 } 599 603 } 600 604 601 - static struct midcomms_node * 602 - dlm_midcomms_recv_node_lookup(int nodeid, const union dlm_packet *p, 603 - uint16_t msglen, int (*cb)(struct midcomms_node *node)) 604 - { 605 - struct midcomms_node *node = NULL; 606 - gfp_t allocation = 0; 607 - int ret; 608 - 609 - switch (p->header.h_cmd) { 610 - case DLM_RCOM: 611 - if (msglen < sizeof(struct dlm_rcom)) { 612 - log_print("rcom msg too small: %u, will skip this message from node %d", 613 - msglen, nodeid); 614 - return NULL; 615 - } 616 - 617 - switch (p->rcom.rc_type) { 618 - case cpu_to_le32(DLM_RCOM_NAMES): 619 - fallthrough; 620 - case cpu_to_le32(DLM_RCOM_NAMES_REPLY): 621 - fallthrough; 622 - case cpu_to_le32(DLM_RCOM_STATUS): 623 - fallthrough; 624 - case cpu_to_le32(DLM_RCOM_STATUS_REPLY): 625 - node = nodeid2node(nodeid, 0); 626 - if (node) { 627 - spin_lock(&node->state_lock); 628 - if (node->state != DLM_ESTABLISHED) 629 - pr_debug("receive begin RCOM msg from node %d with state %s\n", 630 - node->nodeid, dlm_state_str(node->state)); 631 - 632 - switch (node->state) { 633 - case DLM_CLOSED: 634 - node->state = DLM_ESTABLISHED; 635 - pr_debug("switch node %d to state %s\n", 636 - node->nodeid, dlm_state_str(node->state)); 637 - break; 638 - case DLM_ESTABLISHED: 639 - break; 640 - default: 641 - spin_unlock(&node->state_lock); 642 - return NULL; 643 - } 644 - spin_unlock(&node->state_lock); 645 - } 646 - 647 - allocation = GFP_NOFS; 648 - break; 649 - default: 650 - break; 651 - } 652 - 653 - break; 654 - default: 655 - break; 656 - } 657 - 658 - node = nodeid2node(nodeid, allocation); 659 - if (!node) { 660 - switch (p->header.h_cmd) { 661 - case DLM_OPTS: 662 - if (msglen < sizeof(struct dlm_opts)) { 663 - log_print("opts msg too small: %u, will skip this message from node %d", 664 - msglen, nodeid); 665 - return NULL; 666 - } 667 - 668 - log_print_ratelimited("received dlm opts message nextcmd %d from node %d in an invalid sequence", 669 - p->opts.o_nextcmd, nodeid); 670 - break; 671 - default: 672 - log_print_ratelimited("received dlm message cmd %d from node %d in an invalid sequence", 673 - p->header.h_cmd, nodeid); 674 - break; 675 - } 676 - 677 - return NULL; 678 - } 679 - 680 - ret = cb(node); 681 - if (ret < 0) 682 - return NULL; 683 - 684 - return node; 685 - } 686 - 687 - static int dlm_midcomms_version_check_3_2(struct midcomms_node *node) 688 - { 689 - switch (node->version) { 690 - case DLM_VERSION_NOT_SET: 691 - node->version = DLM_VERSION_3_2; 692 - wake_up(&node->shutdown_wait); 693 - log_print("version 0x%08x for node %d detected", DLM_VERSION_3_2, 694 - node->nodeid); 695 - break; 696 - case DLM_VERSION_3_2: 697 - break; 698 - default: 699 - log_print_ratelimited("version mismatch detected, assumed 0x%08x but node %d has 0x%08x", 700 - DLM_VERSION_3_2, node->nodeid, node->version); 701 - return -1; 702 - } 703 - 704 - return 0; 705 - } 706 - 707 - static int dlm_opts_check_msglen(union dlm_packet *p, uint16_t msglen, int nodeid) 605 + static int dlm_opts_check_msglen(const union dlm_packet *p, uint16_t msglen, 606 + int nodeid) 708 607 { 709 608 int len = msglen; 710 609 ··· 648 757 return 0; 649 758 } 650 759 651 - static void dlm_midcomms_receive_buffer_3_2(union dlm_packet *p, int nodeid) 760 + static void dlm_midcomms_receive_buffer_3_2(const union dlm_packet *p, int nodeid) 652 761 { 653 762 uint16_t msglen = le16_to_cpu(p->header.h_length); 654 763 struct midcomms_node *node; ··· 656 765 int ret, idx; 657 766 658 767 idx = srcu_read_lock(&nodes_srcu); 659 - node = dlm_midcomms_recv_node_lookup(nodeid, p, msglen, 660 - dlm_midcomms_version_check_3_2); 661 - if (!node) 768 + node = nodeid2node(nodeid); 769 + if (WARN_ON_ONCE(!node)) 662 770 goto out; 771 + 772 + switch (node->version) { 773 + case DLM_VERSION_NOT_SET: 774 + node->version = DLM_VERSION_3_2; 775 + wake_up(&node->shutdown_wait); 776 + log_print("version 0x%08x for node %d detected", DLM_VERSION_3_2, 777 + node->nodeid); 778 + 779 + spin_lock(&node->state_lock); 780 + switch (node->state) { 781 + case DLM_CLOSED: 782 + node->state = DLM_ESTABLISHED; 783 + pr_debug("switch node %d to state %s\n", 784 + node->nodeid, dlm_state_str(node->state)); 785 + break; 786 + default: 787 + break; 788 + } 789 + spin_unlock(&node->state_lock); 790 + 791 + break; 792 + case DLM_VERSION_3_2: 793 + break; 794 + default: 795 + log_print_ratelimited("version mismatch detected, assumed 0x%08x but node %d has 0x%08x", 796 + DLM_VERSION_3_2, node->nodeid, node->version); 797 + goto out; 798 + } 663 799 664 800 switch (p->header.h_cmd) { 665 801 case DLM_RCOM: ··· 776 858 srcu_read_unlock(&nodes_srcu, idx); 777 859 } 778 860 779 - static int dlm_midcomms_version_check_3_1(struct midcomms_node *node) 861 + static void dlm_midcomms_receive_buffer_3_1(const union dlm_packet *p, int nodeid) 780 862 { 863 + uint16_t msglen = le16_to_cpu(p->header.h_length); 864 + struct midcomms_node *node; 865 + int idx; 866 + 867 + idx = srcu_read_lock(&nodes_srcu); 868 + node = nodeid2node(nodeid); 869 + if (WARN_ON_ONCE(!node)) { 870 + srcu_read_unlock(&nodes_srcu, idx); 871 + return; 872 + } 873 + 781 874 switch (node->version) { 782 875 case DLM_VERSION_NOT_SET: 783 876 node->version = DLM_VERSION_3_1; ··· 801 872 default: 802 873 log_print_ratelimited("version mismatch detected, assumed 0x%08x but node %d has 0x%08x", 803 874 DLM_VERSION_3_1, node->nodeid, node->version); 804 - return -1; 805 - } 806 - 807 - return 0; 808 - } 809 - 810 - static void dlm_midcomms_receive_buffer_3_1(union dlm_packet *p, int nodeid) 811 - { 812 - uint16_t msglen = le16_to_cpu(p->header.h_length); 813 - struct midcomms_node *node; 814 - int idx; 815 - 816 - idx = srcu_read_lock(&nodes_srcu); 817 - node = dlm_midcomms_recv_node_lookup(nodeid, p, msglen, 818 - dlm_midcomms_version_check_3_1); 819 - if (!node) { 820 875 srcu_read_unlock(&nodes_srcu, idx); 821 876 return; 822 877 } ··· 890 977 891 978 switch (hd->h_version) { 892 979 case cpu_to_le32(DLM_VERSION_3_1): 893 - dlm_midcomms_receive_buffer_3_1((union dlm_packet *)ptr, nodeid); 980 + dlm_midcomms_receive_buffer_3_1((const union dlm_packet *)ptr, nodeid); 894 981 break; 895 982 case cpu_to_le32(DLM_VERSION_3_2): 896 - dlm_midcomms_receive_buffer_3_2((union dlm_packet *)ptr, nodeid); 983 + dlm_midcomms_receive_buffer_3_2((const union dlm_packet *)ptr, nodeid); 897 984 break; 898 985 default: 899 986 log_print("received invalid version header: %u from node %d, will skip this message", ··· 916 1003 int idx, ret; 917 1004 918 1005 idx = srcu_read_lock(&nodes_srcu); 919 - node = nodeid2node(nodeid, 0); 920 - if (!node) { 1006 + node = nodeid2node(nodeid); 1007 + if (WARN_ON_ONCE(!node)) { 921 1008 srcu_read_unlock(&nodes_srcu, idx); 922 1009 return; 923 1010 } ··· 1003 1090 int idx; 1004 1091 1005 1092 idx = srcu_read_lock(&nodes_srcu); 1006 - node = nodeid2node(nodeid, 0); 1007 - if (!node) { 1008 - WARN_ON_ONCE(1); 1093 + node = nodeid2node(nodeid); 1094 + if (WARN_ON_ONCE(!node)) 1009 1095 goto err; 1010 - } 1011 1096 1012 1097 /* this is a bug, however we going on and hope it will be resolved */ 1013 1098 WARN_ON_ONCE(test_bit(DLM_NODE_FLAG_STOP_TX, &node->flags)); ··· 1146 1235 dlm_lowcomms_init(); 1147 1236 } 1148 1237 1238 + static void midcomms_node_release(struct rcu_head *rcu) 1239 + { 1240 + struct midcomms_node *node = container_of(rcu, struct midcomms_node, rcu); 1241 + 1242 + WARN_ON_ONCE(atomic_read(&node->send_queue_cnt)); 1243 + dlm_send_queue_flush(node); 1244 + kfree(node); 1245 + } 1246 + 1149 1247 void dlm_midcomms_exit(void) 1150 1248 { 1249 + struct midcomms_node *node; 1250 + int i, idx; 1251 + 1252 + idx = srcu_read_lock(&nodes_srcu); 1253 + for (i = 0; i < CONN_HASH_SIZE; i++) { 1254 + hlist_for_each_entry_rcu(node, &node_hash[i], hlist) { 1255 + dlm_delete_debug_comms_file(node->debugfs); 1256 + 1257 + spin_lock(&nodes_lock); 1258 + hlist_del_rcu(&node->hlist); 1259 + spin_unlock(&nodes_lock); 1260 + 1261 + call_srcu(&nodes_srcu, &node->rcu, midcomms_node_release); 1262 + } 1263 + } 1264 + srcu_read_unlock(&nodes_srcu, idx); 1265 + 1151 1266 dlm_lowcomms_exit(); 1152 1267 } 1153 1268 ··· 1214 1277 int idx; 1215 1278 1216 1279 idx = srcu_read_lock(&nodes_srcu); 1217 - node = nodeid2node(nodeid, GFP_NOFS); 1218 - if (!node) { 1280 + node = nodeid2node(nodeid); 1281 + if (WARN_ON_ONCE(!node)) { 1219 1282 srcu_read_unlock(&nodes_srcu, idx); 1220 1283 return; 1221 1284 } ··· 1259 1322 int idx; 1260 1323 1261 1324 idx = srcu_read_lock(&nodes_srcu); 1262 - node = nodeid2node(nodeid, 0); 1263 - if (!node) { 1325 + node = nodeid2node(nodeid); 1326 + if (WARN_ON_ONCE(!node)) { 1264 1327 srcu_read_unlock(&nodes_srcu, idx); 1265 1328 return; 1266 1329 } ··· 1302 1365 spin_unlock(&node->state_lock); 1303 1366 1304 1367 srcu_read_unlock(&nodes_srcu, idx); 1305 - } 1306 - 1307 - static void midcomms_node_release(struct rcu_head *rcu) 1308 - { 1309 - struct midcomms_node *node = container_of(rcu, struct midcomms_node, rcu); 1310 - 1311 - WARN_ON_ONCE(atomic_read(&node->send_queue_cnt)); 1312 - dlm_send_queue_flush(node); 1313 - kfree(node); 1314 1368 } 1315 1369 1316 1370 void dlm_midcomms_version_wait(void) ··· 1366 1438 node->state == DLM_CLOSED || 1367 1439 test_bit(DLM_NODE_FLAG_CLOSE, &node->flags), 1368 1440 DLM_SHUTDOWN_TIMEOUT); 1369 - if (!ret || test_bit(DLM_NODE_FLAG_CLOSE, &node->flags)) 1441 + if (!ret) 1370 1442 pr_debug("active shutdown timed out for node %d with state %s\n", 1371 1443 node->nodeid, dlm_state_str(node->state)); 1372 1444 else ··· 1384 1456 for (i = 0; i < CONN_HASH_SIZE; i++) { 1385 1457 hlist_for_each_entry_rcu(node, &node_hash[i], hlist) { 1386 1458 midcomms_shutdown(node); 1387 - 1388 - dlm_delete_debug_comms_file(node->debugfs); 1389 - 1390 - spin_lock(&nodes_lock); 1391 - hlist_del_rcu(&node->hlist); 1392 - spin_unlock(&nodes_lock); 1393 - 1394 - call_srcu(&nodes_srcu, &node->rcu, midcomms_node_release); 1395 1459 } 1396 1460 } 1397 1461 srcu_read_unlock(&nodes_srcu, idx); ··· 1399 1479 1400 1480 idx = srcu_read_lock(&nodes_srcu); 1401 1481 /* Abort pending close/remove operation */ 1402 - node = nodeid2node(nodeid, 0); 1482 + node = nodeid2node(nodeid); 1403 1483 if (node) { 1404 1484 /* let shutdown waiters leave */ 1405 1485 set_bit(DLM_NODE_FLAG_CLOSE, &node->flags); ··· 1409 1489 1410 1490 synchronize_srcu(&nodes_srcu); 1411 1491 1412 - idx = srcu_read_lock(&nodes_srcu); 1413 1492 mutex_lock(&close_lock); 1414 - node = nodeid2node(nodeid, 0); 1493 + idx = srcu_read_lock(&nodes_srcu); 1494 + node = nodeid2node(nodeid); 1415 1495 if (!node) { 1416 - mutex_unlock(&close_lock); 1417 1496 srcu_read_unlock(&nodes_srcu, idx); 1497 + mutex_unlock(&close_lock); 1418 1498 return dlm_lowcomms_close(nodeid); 1419 1499 } 1420 1500 1421 1501 ret = dlm_lowcomms_close(nodeid); 1422 - spin_lock(&node->state_lock); 1423 - midcomms_node_reset(node); 1424 - spin_unlock(&node->state_lock); 1502 + dlm_delete_debug_comms_file(node->debugfs); 1503 + 1504 + spin_lock(&nodes_lock); 1505 + hlist_del_rcu(&node->hlist); 1506 + spin_unlock(&nodes_lock); 1425 1507 srcu_read_unlock(&nodes_srcu, idx); 1508 + 1509 + /* wait that all readers left until flush send queue */ 1510 + synchronize_srcu(&nodes_srcu); 1511 + 1512 + /* drop all pending dlm messages, this is fine as 1513 + * this function get called when the node is fenced 1514 + */ 1515 + dlm_send_queue_flush(node); 1516 + 1517 + call_srcu(&nodes_srcu, &node->rcu, midcomms_node_release); 1426 1518 mutex_unlock(&close_lock); 1427 1519 1428 1520 return ret;
+1
fs/dlm/midcomms.h
··· 20 20 gfp_t allocation, char **ppc); 21 21 void dlm_midcomms_commit_mhandle(struct dlm_mhandle *mh, const void *name, 22 22 int namelen); 23 + int dlm_midcomms_addr(int nodeid, struct sockaddr_storage *addr, int len); 23 24 void dlm_midcomms_version_wait(void); 24 25 int dlm_midcomms_close(int nodeid); 25 26 int dlm_midcomms_start(void);
+139 -37
fs/dlm/plock.c
··· 11 11 #include <linux/dlm_plock.h> 12 12 #include <linux/slab.h> 13 13 14 + #include <trace/events/dlm.h> 15 + 14 16 #include "dlm_internal.h" 15 17 #include "lockspace.h" 16 18 ··· 42 40 info->version[0] = DLM_PLOCK_VERSION_MAJOR; 43 41 info->version[1] = DLM_PLOCK_VERSION_MINOR; 44 42 info->version[2] = DLM_PLOCK_VERSION_PATCH; 43 + } 44 + 45 + static struct plock_op *plock_lookup_waiter(const struct dlm_plock_info *info) 46 + { 47 + struct plock_op *op = NULL, *iter; 48 + 49 + list_for_each_entry(iter, &recv_list, list) { 50 + if (iter->info.fsid == info->fsid && 51 + iter->info.number == info->number && 52 + iter->info.owner == info->owner && 53 + iter->info.pid == info->pid && 54 + iter->info.start == info->start && 55 + iter->info.end == info->end && 56 + iter->info.ex == info->ex && 57 + iter->info.wait) { 58 + op = iter; 59 + break; 60 + } 61 + } 62 + 63 + return op; 45 64 } 46 65 47 66 static int check_version(struct dlm_plock_info *info) ··· 97 74 wake_up(&send_wq); 98 75 } 99 76 100 - /* If a process was killed while waiting for the only plock on a file, 101 - locks_remove_posix will not see any lock on the file so it won't 102 - send an unlock-close to us to pass on to userspace to clean up the 103 - abandoned waiter. So, we have to insert the unlock-close when the 104 - lock call is interrupted. */ 105 - 106 - static void do_unlock_close(const struct dlm_plock_info *info) 77 + static int do_lock_cancel(const struct dlm_plock_info *orig_info) 107 78 { 108 79 struct plock_op *op; 80 + int rv; 109 81 110 82 op = kzalloc(sizeof(*op), GFP_NOFS); 111 83 if (!op) 112 - return; 84 + return -ENOMEM; 113 85 114 - op->info.optype = DLM_PLOCK_OP_UNLOCK; 115 - op->info.pid = info->pid; 116 - op->info.fsid = info->fsid; 117 - op->info.number = info->number; 118 - op->info.start = 0; 119 - op->info.end = OFFSET_MAX; 120 - op->info.owner = info->owner; 86 + op->info = *orig_info; 87 + op->info.optype = DLM_PLOCK_OP_CANCEL; 88 + op->info.wait = 0; 121 89 122 - op->info.flags |= DLM_PLOCK_FL_CLOSE; 123 90 send_op(op); 91 + wait_event(recv_wq, (op->done != 0)); 92 + 93 + rv = op->info.rv; 94 + 95 + dlm_release_plock_op(op); 96 + return rv; 124 97 } 125 98 126 99 int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file, ··· 175 156 send_op(op); 176 157 177 158 if (op->info.wait) { 178 - rv = wait_event_killable(recv_wq, (op->done != 0)); 159 + rv = wait_event_interruptible(recv_wq, (op->done != 0)); 179 160 if (rv == -ERESTARTSYS) { 180 161 spin_lock(&ops_lock); 181 162 /* recheck under ops_lock if we got a done != 0, ··· 185 166 spin_unlock(&ops_lock); 186 167 goto do_lock_wait; 187 168 } 188 - list_del(&op->list); 189 169 spin_unlock(&ops_lock); 170 + 171 + rv = do_lock_cancel(&op->info); 172 + switch (rv) { 173 + case 0: 174 + /* waiter was deleted in user space, answer will never come 175 + * remove original request. The original request must be 176 + * on recv_list because the answer of do_lock_cancel() 177 + * synchronized it. 178 + */ 179 + spin_lock(&ops_lock); 180 + list_del(&op->list); 181 + spin_unlock(&ops_lock); 182 + rv = -EINTR; 183 + break; 184 + case -ENOENT: 185 + /* cancellation wasn't successful but op should be done */ 186 + fallthrough; 187 + default: 188 + /* internal error doing cancel we need to wait */ 189 + goto wait; 190 + } 190 191 191 192 log_debug(ls, "%s: wait interrupted %x %llx pid %d", 192 193 __func__, ls->ls_global_id, 193 194 (unsigned long long)number, op->info.pid); 194 - do_unlock_close(&op->info); 195 195 dlm_release_plock_op(op); 196 196 goto out; 197 197 } 198 198 } else { 199 + wait: 199 200 wait_event(recv_wq, (op->done != 0)); 200 201 } 201 202 ··· 279 240 rv = notify(fl, 0); 280 241 if (rv) { 281 242 /* XXX: We need to cancel the fs lock here: */ 282 - log_print("dlm_plock_callback: lock granted after lock request " 283 - "failed; dangling lock!\n"); 243 + log_print("%s: lock granted after lock request failed; dangling lock!", 244 + __func__); 284 245 goto out; 285 246 } 286 247 ··· 356 317 return rv; 357 318 } 358 319 EXPORT_SYMBOL_GPL(dlm_posix_unlock); 320 + 321 + /* 322 + * NOTE: This implementation can only handle async lock requests as nfs 323 + * do it. It cannot handle cancellation of a pending lock request sitting 324 + * in wait_event(), but for now only nfs is the only user local kernel 325 + * user. 326 + */ 327 + int dlm_posix_cancel(dlm_lockspace_t *lockspace, u64 number, struct file *file, 328 + struct file_lock *fl) 329 + { 330 + struct dlm_plock_info info; 331 + struct plock_op *op; 332 + struct dlm_ls *ls; 333 + int rv; 334 + 335 + /* this only works for async request for now and nfs is the only 336 + * kernel user right now. 337 + */ 338 + if (WARN_ON_ONCE(!fl->fl_lmops || !fl->fl_lmops->lm_grant)) 339 + return -EOPNOTSUPP; 340 + 341 + ls = dlm_find_lockspace_local(lockspace); 342 + if (!ls) 343 + return -EINVAL; 344 + 345 + memset(&info, 0, sizeof(info)); 346 + info.pid = fl->fl_pid; 347 + info.ex = (fl->fl_type == F_WRLCK); 348 + info.fsid = ls->ls_global_id; 349 + dlm_put_lockspace(ls); 350 + info.number = number; 351 + info.start = fl->fl_start; 352 + info.end = fl->fl_end; 353 + info.owner = (__u64)fl->fl_pid; 354 + 355 + rv = do_lock_cancel(&info); 356 + switch (rv) { 357 + case 0: 358 + spin_lock(&ops_lock); 359 + /* lock request to cancel must be on recv_list because 360 + * do_lock_cancel() synchronizes it. 361 + */ 362 + op = plock_lookup_waiter(&info); 363 + if (WARN_ON_ONCE(!op)) { 364 + spin_unlock(&ops_lock); 365 + rv = -ENOLCK; 366 + break; 367 + } 368 + 369 + list_del(&op->list); 370 + spin_unlock(&ops_lock); 371 + WARN_ON(op->info.optype != DLM_PLOCK_OP_LOCK); 372 + op->data->callback(op->data->fl, -EINTR); 373 + dlm_release_plock_op(op); 374 + rv = -EINTR; 375 + break; 376 + case -ENOENT: 377 + /* if cancel wasn't successful we probably were to late 378 + * or it was a non-blocking lock request, so just unlock it. 379 + */ 380 + rv = dlm_posix_unlock(lockspace, number, file, fl); 381 + break; 382 + default: 383 + break; 384 + } 385 + 386 + return rv; 387 + } 388 + EXPORT_SYMBOL_GPL(dlm_posix_cancel); 359 389 360 390 int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file, 361 391 struct file_lock *fl) ··· 511 403 if (!op) 512 404 return -EAGAIN; 513 405 406 + trace_dlm_plock_read(&info); 407 + 514 408 /* there is no need to get a reply from userspace for unlocks 515 409 that were generated by the vfs cleaning up for a close 516 410 (the process did not make an unlock call). */ ··· 540 430 if (copy_from_user(&info, u, sizeof(info))) 541 431 return -EFAULT; 542 432 433 + trace_dlm_plock_write(&info); 434 + 543 435 if (check_version(&info)) 544 436 return -EINVAL; 545 437 ··· 553 441 */ 554 442 spin_lock(&ops_lock); 555 443 if (info.wait) { 556 - list_for_each_entry(iter, &recv_list, list) { 557 - if (iter->info.fsid == info.fsid && 558 - iter->info.number == info.number && 559 - iter->info.owner == info.owner && 560 - iter->info.pid == info.pid && 561 - iter->info.start == info.start && 562 - iter->info.end == info.end && 563 - iter->info.ex == info.ex && 564 - iter->info.wait) { 565 - op = iter; 566 - break; 567 - } 568 - } 444 + op = plock_lookup_waiter(&info); 569 445 } else { 570 446 list_for_each_entry(iter, &recv_list, list) { 571 - if (!iter->info.wait) { 447 + if (!iter->info.wait && 448 + iter->info.fsid == info.fsid) { 572 449 op = iter; 573 450 break; 574 451 } ··· 569 468 if (info.wait) 570 469 WARN_ON(op->info.optype != DLM_PLOCK_OP_LOCK); 571 470 else 572 - WARN_ON(op->info.fsid != info.fsid || 573 - op->info.number != info.number || 471 + WARN_ON(op->info.number != info.number || 574 472 op->info.owner != info.owner || 575 473 op->info.optype != info.optype); 576 474 ··· 634 534 void dlm_plock_exit(void) 635 535 { 636 536 misc_deregister(&plock_dev_misc); 537 + WARN_ON(!list_empty(&send_list)); 538 + WARN_ON(!list_empty(&recv_list)); 637 539 } 638 540
+58 -44
fs/dlm/rcom.c
··· 28 28 } 29 29 30 30 static void _create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len, 31 - struct dlm_rcom **rc_ret, char *mb, int mb_len) 31 + struct dlm_rcom **rc_ret, char *mb, int mb_len, 32 + uint64_t seq) 32 33 { 33 34 struct dlm_rcom *rc; 34 35 ··· 42 41 rc->rc_header.h_cmd = DLM_RCOM; 43 42 44 43 rc->rc_type = cpu_to_le32(type); 45 - 46 - spin_lock(&ls->ls_recover_lock); 47 - rc->rc_seq = cpu_to_le64(ls->ls_recover_seq); 48 - spin_unlock(&ls->ls_recover_lock); 44 + rc->rc_seq = cpu_to_le64(seq); 49 45 50 46 *rc_ret = rc; 51 47 } 52 48 53 49 static int create_rcom(struct dlm_ls *ls, int to_nodeid, int type, int len, 54 - struct dlm_rcom **rc_ret, struct dlm_mhandle **mh_ret) 50 + struct dlm_rcom **rc_ret, struct dlm_mhandle **mh_ret, 51 + uint64_t seq) 55 52 { 56 53 int mb_len = sizeof(struct dlm_rcom) + len; 57 54 struct dlm_mhandle *mh; ··· 62 63 return -ENOBUFS; 63 64 } 64 65 65 - _create_rcom(ls, to_nodeid, type, len, rc_ret, mb, mb_len); 66 + _create_rcom(ls, to_nodeid, type, len, rc_ret, mb, mb_len, seq); 66 67 *mh_ret = mh; 67 68 return 0; 68 69 } 69 70 70 71 static int create_rcom_stateless(struct dlm_ls *ls, int to_nodeid, int type, 71 72 int len, struct dlm_rcom **rc_ret, 72 - struct dlm_msg **msg_ret) 73 + struct dlm_msg **msg_ret, uint64_t seq) 73 74 { 74 75 int mb_len = sizeof(struct dlm_rcom) + len; 75 76 struct dlm_msg *msg; ··· 83 84 return -ENOBUFS; 84 85 } 85 86 86 - _create_rcom(ls, to_nodeid, type, len, rc_ret, mb, mb_len); 87 + _create_rcom(ls, to_nodeid, type, len, rc_ret, mb, mb_len, seq); 87 88 *msg_ret = msg; 88 89 return 0; 89 90 } ··· 169 170 * node's rcom_config. 170 171 */ 171 172 172 - int dlm_rcom_status(struct dlm_ls *ls, int nodeid, uint32_t status_flags) 173 + int dlm_rcom_status(struct dlm_ls *ls, int nodeid, uint32_t status_flags, 174 + uint64_t seq) 173 175 { 174 176 struct dlm_rcom *rc; 175 177 struct dlm_msg *msg; ··· 186 186 187 187 retry: 188 188 error = create_rcom_stateless(ls, nodeid, DLM_RCOM_STATUS, 189 - sizeof(struct rcom_status), &rc, &msg); 189 + sizeof(struct rcom_status), &rc, &msg, 190 + seq); 190 191 if (error) 191 192 goto out; 192 193 ··· 221 220 return error; 222 221 } 223 222 224 - static void receive_rcom_status(struct dlm_ls *ls, struct dlm_rcom *rc_in) 223 + static void receive_rcom_status(struct dlm_ls *ls, 224 + const struct dlm_rcom *rc_in, 225 + uint64_t seq) 225 226 { 226 227 struct dlm_rcom *rc; 227 228 struct rcom_status *rs; ··· 254 251 255 252 do_create: 256 253 error = create_rcom_stateless(ls, nodeid, DLM_RCOM_STATUS_REPLY, 257 - len, &rc, &msg); 254 + len, &rc, &msg, seq); 258 255 if (error) 259 256 return; 260 257 ··· 284 281 send_rcom_stateless(msg, rc); 285 282 } 286 283 287 - static void receive_sync_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) 284 + static void receive_sync_reply(struct dlm_ls *ls, const struct dlm_rcom *rc_in) 288 285 { 289 286 spin_lock(&ls->ls_rcom_spin); 290 287 if (!test_bit(LSFL_RCOM_WAIT, &ls->ls_flags) || ··· 305 302 spin_unlock(&ls->ls_rcom_spin); 306 303 } 307 304 308 - int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len) 305 + int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, 306 + int last_len, uint64_t seq) 309 307 { 308 + struct dlm_mhandle *mh; 310 309 struct dlm_rcom *rc; 311 - struct dlm_msg *msg; 312 310 int error = 0; 313 311 314 312 ls->ls_recover_nodeid = nodeid; 315 313 316 314 retry: 317 - error = create_rcom_stateless(ls, nodeid, DLM_RCOM_NAMES, last_len, 318 - &rc, &msg); 315 + error = create_rcom(ls, nodeid, DLM_RCOM_NAMES, last_len, 316 + &rc, &mh, seq); 319 317 if (error) 320 318 goto out; 321 319 memcpy(rc->rc_buf, last_name, last_len); ··· 324 320 allow_sync_reply(ls, &rc->rc_id); 325 321 memset(ls->ls_recover_buf, 0, DLM_MAX_SOCKET_BUFSIZE); 326 322 327 - send_rcom_stateless(msg, rc); 323 + send_rcom(mh, rc); 328 324 329 325 error = dlm_wait_function(ls, &rcom_response); 330 326 disallow_sync_reply(ls); ··· 334 330 return error; 335 331 } 336 332 337 - static void receive_rcom_names(struct dlm_ls *ls, struct dlm_rcom *rc_in) 333 + static void receive_rcom_names(struct dlm_ls *ls, const struct dlm_rcom *rc_in, 334 + uint64_t seq) 338 335 { 336 + struct dlm_mhandle *mh; 339 337 struct dlm_rcom *rc; 340 338 int error, inlen, outlen, nodeid; 341 - struct dlm_msg *msg; 342 339 343 340 nodeid = le32_to_cpu(rc_in->rc_header.h_nodeid); 344 341 inlen = le16_to_cpu(rc_in->rc_header.h_length) - 345 342 sizeof(struct dlm_rcom); 346 343 outlen = DLM_MAX_APP_BUFSIZE - sizeof(struct dlm_rcom); 347 344 348 - error = create_rcom_stateless(ls, nodeid, DLM_RCOM_NAMES_REPLY, outlen, 349 - &rc, &msg); 345 + error = create_rcom(ls, nodeid, DLM_RCOM_NAMES_REPLY, outlen, 346 + &rc, &mh, seq); 350 347 if (error) 351 348 return; 352 349 rc->rc_id = rc_in->rc_id; ··· 355 350 356 351 dlm_copy_master_names(ls, rc_in->rc_buf, inlen, rc->rc_buf, outlen, 357 352 nodeid); 358 - send_rcom_stateless(msg, rc); 353 + send_rcom(mh, rc); 359 354 } 360 355 361 - int dlm_send_rcom_lookup(struct dlm_rsb *r, int dir_nodeid) 356 + int dlm_send_rcom_lookup(struct dlm_rsb *r, int dir_nodeid, uint64_t seq) 362 357 { 363 358 struct dlm_rcom *rc; 364 359 struct dlm_mhandle *mh; ··· 366 361 int error; 367 362 368 363 error = create_rcom(ls, dir_nodeid, DLM_RCOM_LOOKUP, r->res_length, 369 - &rc, &mh); 364 + &rc, &mh, seq); 370 365 if (error) 371 366 goto out; 372 367 memcpy(rc->rc_buf, r->res_name, r->res_length); ··· 377 372 return error; 378 373 } 379 374 380 - static void receive_rcom_lookup(struct dlm_ls *ls, struct dlm_rcom *rc_in) 375 + static void receive_rcom_lookup(struct dlm_ls *ls, 376 + const struct dlm_rcom *rc_in, uint64_t seq) 381 377 { 382 378 struct dlm_rcom *rc; 383 379 struct dlm_mhandle *mh; ··· 393 387 return; 394 388 } 395 389 396 - error = create_rcom(ls, nodeid, DLM_RCOM_LOOKUP_REPLY, 0, &rc, &mh); 390 + error = create_rcom(ls, nodeid, DLM_RCOM_LOOKUP_REPLY, 0, &rc, &mh, 391 + seq); 397 392 if (error) 398 393 return; 399 394 ··· 409 402 send_rcom(mh, rc); 410 403 } 411 404 412 - static void receive_rcom_lookup_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) 405 + static void receive_rcom_lookup_reply(struct dlm_ls *ls, 406 + const struct dlm_rcom *rc_in) 413 407 { 414 408 dlm_recover_master_reply(ls, rc_in); 415 409 } ··· 445 437 memcpy(rl->rl_lvb, lkb->lkb_lvbptr, r->res_ls->ls_lvblen); 446 438 } 447 439 448 - int dlm_send_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb) 440 + int dlm_send_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, uint64_t seq) 449 441 { 450 442 struct dlm_ls *ls = r->res_ls; 451 443 struct dlm_rcom *rc; ··· 456 448 if (lkb->lkb_lvbptr) 457 449 len += ls->ls_lvblen; 458 450 459 - error = create_rcom(ls, r->res_nodeid, DLM_RCOM_LOCK, len, &rc, &mh); 451 + error = create_rcom(ls, r->res_nodeid, DLM_RCOM_LOCK, len, &rc, &mh, 452 + seq); 460 453 if (error) 461 454 goto out; 462 455 ··· 471 462 } 472 463 473 464 /* needs at least dlm_rcom + rcom_lock */ 474 - static void receive_rcom_lock(struct dlm_ls *ls, struct dlm_rcom *rc_in) 465 + static void receive_rcom_lock(struct dlm_ls *ls, const struct dlm_rcom *rc_in, 466 + uint64_t seq) 475 467 { 468 + __le32 rl_remid, rl_result; 469 + struct rcom_lock *rl; 476 470 struct dlm_rcom *rc; 477 471 struct dlm_mhandle *mh; 478 472 int error, nodeid = le32_to_cpu(rc_in->rc_header.h_nodeid); 479 473 480 - dlm_recover_master_copy(ls, rc_in); 474 + dlm_recover_master_copy(ls, rc_in, &rl_remid, &rl_result); 481 475 482 476 error = create_rcom(ls, nodeid, DLM_RCOM_LOCK_REPLY, 483 - sizeof(struct rcom_lock), &rc, &mh); 477 + sizeof(struct rcom_lock), &rc, &mh, seq); 484 478 if (error) 485 479 return; 486 480 487 - /* We send back the same rcom_lock struct we received, but 488 - dlm_recover_master_copy() has filled in rl_remid and rl_result */ 489 - 490 481 memcpy(rc->rc_buf, rc_in->rc_buf, sizeof(struct rcom_lock)); 482 + rl = (struct rcom_lock *)rc->rc_buf; 483 + /* set rl_remid and rl_result from dlm_recover_master_copy() */ 484 + rl->rl_remid = rl_remid; 485 + rl->rl_result = rl_result; 486 + 491 487 rc->rc_id = rc_in->rc_id; 492 488 rc->rc_seq_reply = rc_in->rc_seq; 493 489 ··· 502 488 /* If the lockspace doesn't exist then still send a status message 503 489 back; it's possible that it just doesn't have its global_id yet. */ 504 490 505 - int dlm_send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in) 491 + int dlm_send_ls_not_ready(int nodeid, const struct dlm_rcom *rc_in) 506 492 { 507 493 struct dlm_rcom *rc; 508 494 struct rcom_config *rf; ··· 580 566 /* Called by dlm_recv; corresponds to dlm_receive_message() but special 581 567 recovery-only comms are sent through here. */ 582 568 583 - void dlm_receive_rcom(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid) 569 + void dlm_receive_rcom(struct dlm_ls *ls, const struct dlm_rcom *rc, int nodeid) 584 570 { 585 571 int lock_size = sizeof(struct dlm_rcom) + sizeof(struct rcom_lock); 586 572 int stop, reply = 0, names = 0, lookup = 0, lock = 0; ··· 634 620 635 621 switch (rc->rc_type) { 636 622 case cpu_to_le32(DLM_RCOM_STATUS): 637 - receive_rcom_status(ls, rc); 623 + receive_rcom_status(ls, rc, seq); 638 624 break; 639 625 640 626 case cpu_to_le32(DLM_RCOM_NAMES): 641 - receive_rcom_names(ls, rc); 627 + receive_rcom_names(ls, rc, seq); 642 628 break; 643 629 644 630 case cpu_to_le32(DLM_RCOM_LOOKUP): 645 - receive_rcom_lookup(ls, rc); 631 + receive_rcom_lookup(ls, rc, seq); 646 632 break; 647 633 648 634 case cpu_to_le32(DLM_RCOM_LOCK): 649 635 if (le16_to_cpu(rc->rc_header.h_length) < lock_size) 650 636 goto Eshort; 651 - receive_rcom_lock(ls, rc); 637 + receive_rcom_lock(ls, rc, seq); 652 638 break; 653 639 654 640 case cpu_to_le32(DLM_RCOM_STATUS_REPLY): ··· 666 652 case cpu_to_le32(DLM_RCOM_LOCK_REPLY): 667 653 if (le16_to_cpu(rc->rc_header.h_length) < lock_size) 668 654 goto Eshort; 669 - dlm_recover_process_copy(ls, rc); 655 + dlm_recover_process_copy(ls, rc, seq); 670 656 break; 671 657 672 658 default:
+9 -6
fs/dlm/rcom.h
··· 12 12 #ifndef __RCOM_DOT_H__ 13 13 #define __RCOM_DOT_H__ 14 14 15 - int dlm_rcom_status(struct dlm_ls *ls, int nodeid, uint32_t status_flags); 16 - int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name,int last_len); 17 - int dlm_send_rcom_lookup(struct dlm_rsb *r, int dir_nodeid); 18 - int dlm_send_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb); 19 - void dlm_receive_rcom(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid); 20 - int dlm_send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in); 15 + int dlm_rcom_status(struct dlm_ls *ls, int nodeid, uint32_t status_flags, 16 + uint64_t seq); 17 + int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, 18 + int last_len, uint64_t seq); 19 + int dlm_send_rcom_lookup(struct dlm_rsb *r, int dir_nodeid, uint64_t seq); 20 + int dlm_send_rcom_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, uint64_t seq); 21 + void dlm_receive_rcom(struct dlm_ls *ls, const struct dlm_rcom *rc, 22 + int nodeid); 23 + int dlm_send_ls_not_ready(int nodeid, const struct dlm_rcom *rc_in); 21 24 22 25 #endif 23 26
+31 -29
fs/dlm/recover.c
··· 93 93 } 94 94 95 95 static int wait_status_all(struct dlm_ls *ls, uint32_t wait_status, 96 - int save_slots) 96 + int save_slots, uint64_t seq) 97 97 { 98 98 struct dlm_rcom *rc = ls->ls_recover_buf; 99 99 struct dlm_member *memb; ··· 107 107 goto out; 108 108 } 109 109 110 - error = dlm_rcom_status(ls, memb->nodeid, 0); 110 + error = dlm_rcom_status(ls, memb->nodeid, 0, seq); 111 111 if (error) 112 112 goto out; 113 113 ··· 126 126 } 127 127 128 128 static int wait_status_low(struct dlm_ls *ls, uint32_t wait_status, 129 - uint32_t status_flags) 129 + uint32_t status_flags, uint64_t seq) 130 130 { 131 131 struct dlm_rcom *rc = ls->ls_recover_buf; 132 132 int error = 0, delay = 0, nodeid = ls->ls_low_nodeid; ··· 137 137 goto out; 138 138 } 139 139 140 - error = dlm_rcom_status(ls, nodeid, status_flags); 140 + error = dlm_rcom_status(ls, nodeid, status_flags, seq); 141 141 if (error) 142 142 break; 143 143 ··· 151 151 return error; 152 152 } 153 153 154 - static int wait_status(struct dlm_ls *ls, uint32_t status) 154 + static int wait_status(struct dlm_ls *ls, uint32_t status, uint64_t seq) 155 155 { 156 156 uint32_t status_all = status << 1; 157 157 int error; 158 158 159 159 if (ls->ls_low_nodeid == dlm_our_nodeid()) { 160 - error = wait_status_all(ls, status, 0); 160 + error = wait_status_all(ls, status, 0, seq); 161 161 if (!error) 162 162 dlm_set_recover_status(ls, status_all); 163 163 } else 164 - error = wait_status_low(ls, status_all, 0); 164 + error = wait_status_low(ls, status_all, 0, seq); 165 165 166 166 return error; 167 167 } 168 168 169 - int dlm_recover_members_wait(struct dlm_ls *ls) 169 + int dlm_recover_members_wait(struct dlm_ls *ls, uint64_t seq) 170 170 { 171 171 struct dlm_member *memb; 172 172 struct dlm_slot *slots; ··· 180 180 } 181 181 182 182 if (ls->ls_low_nodeid == dlm_our_nodeid()) { 183 - error = wait_status_all(ls, DLM_RS_NODES, 1); 183 + error = wait_status_all(ls, DLM_RS_NODES, 1, seq); 184 184 if (error) 185 185 goto out; 186 186 ··· 199 199 dlm_set_recover_status(ls, DLM_RS_NODES_ALL); 200 200 } 201 201 } else { 202 - error = wait_status_low(ls, DLM_RS_NODES_ALL, DLM_RSF_NEED_SLOTS); 202 + error = wait_status_low(ls, DLM_RS_NODES_ALL, 203 + DLM_RSF_NEED_SLOTS, seq); 203 204 if (error) 204 205 goto out; 205 206 ··· 210 209 return error; 211 210 } 212 211 213 - int dlm_recover_directory_wait(struct dlm_ls *ls) 212 + int dlm_recover_directory_wait(struct dlm_ls *ls, uint64_t seq) 214 213 { 215 - return wait_status(ls, DLM_RS_DIR); 214 + return wait_status(ls, DLM_RS_DIR, seq); 216 215 } 217 216 218 - int dlm_recover_locks_wait(struct dlm_ls *ls) 217 + int dlm_recover_locks_wait(struct dlm_ls *ls, uint64_t seq) 219 218 { 220 - return wait_status(ls, DLM_RS_LOCKS); 219 + return wait_status(ls, DLM_RS_LOCKS, seq); 221 220 } 222 221 223 - int dlm_recover_done_wait(struct dlm_ls *ls) 222 + int dlm_recover_done_wait(struct dlm_ls *ls, uint64_t seq) 224 223 { 225 - return wait_status(ls, DLM_RS_DONE); 224 + return wait_status(ls, DLM_RS_DONE, seq); 226 225 } 227 226 228 227 /* ··· 442 441 * equals our_nodeid below). 443 442 */ 444 443 445 - static int recover_master(struct dlm_rsb *r, unsigned int *count) 444 + static int recover_master(struct dlm_rsb *r, unsigned int *count, uint64_t seq) 446 445 { 447 446 struct dlm_ls *ls = r->res_ls; 448 447 int our_nodeid, dir_nodeid; ··· 473 472 error = 0; 474 473 } else { 475 474 recover_idr_add(r); 476 - error = dlm_send_rcom_lookup(r, dir_nodeid); 475 + error = dlm_send_rcom_lookup(r, dir_nodeid, seq); 477 476 } 478 477 479 478 (*count)++; ··· 521 520 * the correct dir node. 522 521 */ 523 522 524 - int dlm_recover_masters(struct dlm_ls *ls) 523 + int dlm_recover_masters(struct dlm_ls *ls, uint64_t seq) 525 524 { 526 525 struct dlm_rsb *r; 527 526 unsigned int total = 0; ··· 543 542 if (nodir) 544 543 error = recover_master_static(r, &count); 545 544 else 546 - error = recover_master(r, &count); 545 + error = recover_master(r, &count, seq); 547 546 unlock_rsb(r); 548 547 cond_resched(); 549 548 total++; ··· 564 563 return error; 565 564 } 566 565 567 - int dlm_recover_master_reply(struct dlm_ls *ls, struct dlm_rcom *rc) 566 + int dlm_recover_master_reply(struct dlm_ls *ls, const struct dlm_rcom *rc) 568 567 { 569 568 struct dlm_rsb *r; 570 569 int ret_nodeid, new_master; ··· 615 614 * an equal number of replies then recovery for the rsb is done 616 615 */ 617 616 618 - static int recover_locks_queue(struct dlm_rsb *r, struct list_head *head) 617 + static int recover_locks_queue(struct dlm_rsb *r, struct list_head *head, 618 + uint64_t seq) 619 619 { 620 620 struct dlm_lkb *lkb; 621 621 int error = 0; 622 622 623 623 list_for_each_entry(lkb, head, lkb_statequeue) { 624 - error = dlm_send_rcom_lock(r, lkb); 624 + error = dlm_send_rcom_lock(r, lkb, seq); 625 625 if (error) 626 626 break; 627 627 r->res_recover_locks_count++; ··· 631 629 return error; 632 630 } 633 631 634 - static int recover_locks(struct dlm_rsb *r) 632 + static int recover_locks(struct dlm_rsb *r, uint64_t seq) 635 633 { 636 634 int error = 0; 637 635 ··· 639 637 640 638 DLM_ASSERT(!r->res_recover_locks_count, dlm_dump_rsb(r);); 641 639 642 - error = recover_locks_queue(r, &r->res_grantqueue); 640 + error = recover_locks_queue(r, &r->res_grantqueue, seq); 643 641 if (error) 644 642 goto out; 645 - error = recover_locks_queue(r, &r->res_convertqueue); 643 + error = recover_locks_queue(r, &r->res_convertqueue, seq); 646 644 if (error) 647 645 goto out; 648 - error = recover_locks_queue(r, &r->res_waitqueue); 646 + error = recover_locks_queue(r, &r->res_waitqueue, seq); 649 647 if (error) 650 648 goto out; 651 649 ··· 658 656 return error; 659 657 } 660 658 661 - int dlm_recover_locks(struct dlm_ls *ls) 659 + int dlm_recover_locks(struct dlm_ls *ls, uint64_t seq) 662 660 { 663 661 struct dlm_rsb *r; 664 662 int error, count = 0; ··· 679 677 goto out; 680 678 } 681 679 682 - error = recover_locks(r); 680 + error = recover_locks(r, seq); 683 681 if (error) { 684 682 up_read(&ls->ls_root_sem); 685 683 goto out;
+7 -7
fs/dlm/recover.h
··· 15 15 int dlm_wait_function(struct dlm_ls *ls, int (*testfn) (struct dlm_ls *ls)); 16 16 uint32_t dlm_recover_status(struct dlm_ls *ls); 17 17 void dlm_set_recover_status(struct dlm_ls *ls, uint32_t status); 18 - int dlm_recover_members_wait(struct dlm_ls *ls); 19 - int dlm_recover_directory_wait(struct dlm_ls *ls); 20 - int dlm_recover_locks_wait(struct dlm_ls *ls); 21 - int dlm_recover_done_wait(struct dlm_ls *ls); 22 - int dlm_recover_masters(struct dlm_ls *ls); 23 - int dlm_recover_master_reply(struct dlm_ls *ls, struct dlm_rcom *rc); 24 - int dlm_recover_locks(struct dlm_ls *ls); 18 + int dlm_recover_members_wait(struct dlm_ls *ls, uint64_t seq); 19 + int dlm_recover_directory_wait(struct dlm_ls *ls, uint64_t seq); 20 + int dlm_recover_locks_wait(struct dlm_ls *ls, uint64_t seq); 21 + int dlm_recover_done_wait(struct dlm_ls *ls, uint64_t seq); 22 + int dlm_recover_masters(struct dlm_ls *ls, uint64_t seq); 23 + int dlm_recover_master_reply(struct dlm_ls *ls, const struct dlm_rcom *rc); 24 + int dlm_recover_locks(struct dlm_ls *ls, uint64_t seq); 25 25 void dlm_recovered_lock(struct dlm_rsb *r); 26 26 int dlm_create_root_list(struct dlm_ls *ls); 27 27 void dlm_release_root_list(struct dlm_ls *ls);
+8 -8
fs/dlm/recoverd.c
··· 90 90 91 91 dlm_set_recover_status(ls, DLM_RS_NODES); 92 92 93 - error = dlm_recover_members_wait(ls); 93 + error = dlm_recover_members_wait(ls, rv->seq); 94 94 if (error) { 95 95 log_rinfo(ls, "dlm_recover_members_wait error %d", error); 96 96 goto fail; ··· 103 103 * nodes their master rsb names that hash to us. 104 104 */ 105 105 106 - error = dlm_recover_directory(ls); 106 + error = dlm_recover_directory(ls, rv->seq); 107 107 if (error) { 108 108 log_rinfo(ls, "dlm_recover_directory error %d", error); 109 109 goto fail; ··· 111 111 112 112 dlm_set_recover_status(ls, DLM_RS_DIR); 113 113 114 - error = dlm_recover_directory_wait(ls); 114 + error = dlm_recover_directory_wait(ls, rv->seq); 115 115 if (error) { 116 116 log_rinfo(ls, "dlm_recover_directory_wait error %d", error); 117 117 goto fail; ··· 145 145 * departed nodes. 146 146 */ 147 147 148 - error = dlm_recover_masters(ls); 148 + error = dlm_recover_masters(ls, rv->seq); 149 149 if (error) { 150 150 log_rinfo(ls, "dlm_recover_masters error %d", error); 151 151 goto fail; ··· 155 155 * Send our locks on remastered rsb's to the new masters. 156 156 */ 157 157 158 - error = dlm_recover_locks(ls); 158 + error = dlm_recover_locks(ls, rv->seq); 159 159 if (error) { 160 160 log_rinfo(ls, "dlm_recover_locks error %d", error); 161 161 goto fail; ··· 163 163 164 164 dlm_set_recover_status(ls, DLM_RS_LOCKS); 165 165 166 - error = dlm_recover_locks_wait(ls); 166 + error = dlm_recover_locks_wait(ls, rv->seq); 167 167 if (error) { 168 168 log_rinfo(ls, "dlm_recover_locks_wait error %d", error); 169 169 goto fail; ··· 187 187 */ 188 188 dlm_set_recover_status(ls, DLM_RS_LOCKS); 189 189 190 - error = dlm_recover_locks_wait(ls); 190 + error = dlm_recover_locks_wait(ls, rv->seq); 191 191 if (error) { 192 192 log_rinfo(ls, "dlm_recover_locks_wait error %d", error); 193 193 goto fail; ··· 206 206 207 207 dlm_set_recover_status(ls, DLM_RS_DONE); 208 208 209 - error = dlm_recover_done_wait(ls); 209 + error = dlm_recover_done_wait(ls, rv->seq); 210 210 if (error) { 211 211 log_rinfo(ls, "dlm_recover_done_wait error %d", error); 212 212 goto fail;
+2 -1
fs/dlm/requestqueue.c
··· 30 30 * lockspace is enabled on some while still suspended on others. 31 31 */ 32 32 33 - void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms) 33 + void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, 34 + const struct dlm_message *ms) 34 35 { 35 36 struct rq_entry *e; 36 37 int length = le16_to_cpu(ms->m_header.h_length) -
+2 -1
fs/dlm/requestqueue.h
··· 11 11 #ifndef __REQUESTQUEUE_DOT_H__ 12 12 #define __REQUESTQUEUE_DOT_H__ 13 13 14 - void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_message *ms); 14 + void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, 15 + const struct dlm_message *ms); 15 16 int dlm_process_requestqueue(struct dlm_ls *ls); 16 17 void dlm_wait_requestqueue(struct dlm_ls *ls); 17 18 void dlm_purge_requestqueue(struct dlm_ls *ls);
+3 -6
fs/gfs2/file.c
··· 1436 1436 1437 1437 if (!(fl->fl_flags & FL_POSIX)) 1438 1438 return -ENOLCK; 1439 - if (cmd == F_CANCELLK) { 1440 - /* Hack: */ 1441 - cmd = F_SETLK; 1442 - fl->fl_type = F_UNLCK; 1443 - } 1444 1439 if (unlikely(gfs2_withdrawn(sdp))) { 1445 1440 if (fl->fl_type == F_UNLCK) 1446 1441 locks_lock_file_wait(file, fl); 1447 1442 return -EIO; 1448 1443 } 1449 - if (IS_GETLK(cmd)) 1444 + if (cmd == F_CANCELLK) 1445 + return dlm_posix_cancel(ls->ls_dlm, ip->i_no_addr, file, fl); 1446 + else if (IS_GETLK(cmd)) 1450 1447 return dlm_posix_get(ls->ls_dlm, ip->i_no_addr, file, fl); 1451 1448 else if (fl->fl_type == F_UNLCK) 1452 1449 return dlm_posix_unlock(ls->ls_dlm, ip->i_no_addr, file, fl);
+3 -10
fs/ocfs2/stack_user.c
··· 738 738 * 739 739 * Internally, fs/dlm will pass these to a misc device, which 740 740 * a userspace daemon will read and write to. 741 - * 742 - * For now, cancel requests (which happen internally only), 743 - * are turned into unlocks. Most of this function taken from 744 - * gfs2_lock. 745 741 */ 746 742 747 - if (cmd == F_CANCELLK) { 748 - cmd = F_SETLK; 749 - fl->fl_type = F_UNLCK; 750 - } 751 - 752 - if (IS_GETLK(cmd)) 743 + if (cmd == F_CANCELLK) 744 + return dlm_posix_cancel(conn->cc_lockspace, ino, file, fl); 745 + else if (IS_GETLK(cmd)) 753 746 return dlm_posix_get(conn->cc_lockspace, ino, file, fl); 754 747 else if (fl->fl_type == F_UNLCK) 755 748 return dlm_posix_unlock(conn->cc_lockspace, ino, file, fl);
+2
include/linux/dlm_plock.h
··· 11 11 int cmd, struct file_lock *fl); 12 12 int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file, 13 13 struct file_lock *fl); 14 + int dlm_posix_cancel(dlm_lockspace_t *lockspace, u64 number, struct file *file, 15 + struct file_lock *fl); 14 16 int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file, 15 17 struct file_lock *fl); 16 18 #endif
+51
include/trace/events/dlm.h
··· 7 7 8 8 #include <linux/dlm.h> 9 9 #include <linux/dlmconstants.h> 10 + #include <uapi/linux/dlm_plock.h> 10 11 #include <linux/tracepoint.h> 11 12 12 13 #include "../../../fs/dlm/dlm_internal.h" ··· 585 584 __get_dynamic_array_len(m_extra))) 586 585 587 586 ); 587 + 588 + DECLARE_EVENT_CLASS(dlm_plock_template, 589 + 590 + TP_PROTO(const struct dlm_plock_info *info), 591 + 592 + TP_ARGS(info), 593 + 594 + TP_STRUCT__entry( 595 + __field(uint8_t, optype) 596 + __field(uint8_t, ex) 597 + __field(uint8_t, wait) 598 + __field(uint8_t, flags) 599 + __field(uint32_t, pid) 600 + __field(int32_t, nodeid) 601 + __field(int32_t, rv) 602 + __field(uint32_t, fsid) 603 + __field(uint64_t, number) 604 + __field(uint64_t, start) 605 + __field(uint64_t, end) 606 + __field(uint64_t, owner) 607 + ), 608 + 609 + TP_fast_assign( 610 + __entry->optype = info->optype; 611 + __entry->ex = info->ex; 612 + __entry->wait = info->wait; 613 + __entry->flags = info->flags; 614 + __entry->pid = info->pid; 615 + __entry->nodeid = info->nodeid; 616 + __entry->rv = info->rv; 617 + __entry->fsid = info->fsid; 618 + __entry->number = info->number; 619 + __entry->start = info->start; 620 + __entry->end = info->end; 621 + __entry->owner = info->owner; 622 + ), 623 + 624 + TP_printk("fsid=%u number=%llx owner=%llx optype=%d ex=%d wait=%d flags=%x pid=%u nodeid=%d rv=%d start=%llx end=%llx", 625 + __entry->fsid, __entry->number, __entry->owner, 626 + __entry->optype, __entry->ex, __entry->wait, 627 + __entry->flags, __entry->pid, __entry->nodeid, 628 + __entry->rv, __entry->start, __entry->end) 629 + 630 + ); 631 + 632 + DEFINE_EVENT(dlm_plock_template, dlm_plock_read, 633 + TP_PROTO(const struct dlm_plock_info *info), TP_ARGS(info)); 634 + 635 + DEFINE_EVENT(dlm_plock_template, dlm_plock_write, 636 + TP_PROTO(const struct dlm_plock_info *info), TP_ARGS(info)); 588 637 589 638 TRACE_EVENT(dlm_send, 590 639
+1
include/uapi/linux/dlm_plock.h
··· 22 22 DLM_PLOCK_OP_LOCK = 1, 23 23 DLM_PLOCK_OP_UNLOCK, 24 24 DLM_PLOCK_OP_GET, 25 + DLM_PLOCK_OP_CANCEL, 25 26 }; 26 27 27 28 #define DLM_PLOCK_FL_CLOSE 1