|
15 | 15 |
|
16 | 16 | #define LVB_SIZE 64
|
17 | 17 | #define NEW_DEV_TIMEOUT 5000
|
| 18 | +#define WAIT_DLM_LOCK_TIMEOUT (30 * HZ) |
18 | 19 |
|
19 | 20 | struct dlm_lock_resource {
|
20 | 21 | dlm_lockspace_t *ls;
|
@@ -130,8 +131,13 @@ static int dlm_lock_sync(struct dlm_lock_resource *res, int mode)
|
130 | 131 | 0, sync_ast, res, res->bast);
|
131 | 132 | if (ret)
|
132 | 133 | return ret;
|
133 |
| - wait_event(res->sync_locking, res->sync_locking_done); |
| 134 | + ret = wait_event_timeout(res->sync_locking, res->sync_locking_done, |
| 135 | + WAIT_DLM_LOCK_TIMEOUT); |
134 | 136 | res->sync_locking_done = false;
|
| 137 | + if (!ret) { |
| 138 | + pr_err("locking DLM '%s' timeout!\n", res->name); |
| 139 | + return -EBUSY; |
| 140 | + } |
135 | 141 | if (res->lksb.sb_status == 0)
|
136 | 142 | res->mode = mode;
|
137 | 143 | return res->lksb.sb_status;
|
@@ -743,15 +749,15 @@ static void unlock_comm(struct md_cluster_info *cinfo)
|
743 | 749 | */
|
744 | 750 | static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg)
|
745 | 751 | {
|
746 |
| - int error; |
| 752 | + int error, unlock_error; |
747 | 753 | int slot = cinfo->slot_number - 1;
|
748 | 754 |
|
749 | 755 | cmsg->slot = cpu_to_le32(slot);
|
750 | 756 | /*get EX on Message*/
|
751 | 757 | error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_EX);
|
752 | 758 | if (error) {
|
753 | 759 | pr_err("md-cluster: failed to get EX on MESSAGE (%d)\n", error);
|
754 |
| - goto failed_message; |
| 760 | + return error; |
755 | 761 | }
|
756 | 762 |
|
757 | 763 | memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg,
|
@@ -781,14 +787,10 @@ static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg)
|
781 | 787 | }
|
782 | 788 |
|
783 | 789 | failed_ack:
|
784 |
| - error = dlm_unlock_sync(cinfo->message_lockres); |
785 |
| - if (unlikely(error != 0)) { |
| 790 | + while ((unlock_error = dlm_unlock_sync(cinfo->message_lockres))) |
786 | 791 | pr_err("md-cluster: failed convert to NL on MESSAGE(%d)\n",
|
787 |
| - error); |
788 |
| - /* in case the message can't be released due to some reason */ |
789 |
| - goto failed_ack; |
790 |
| - } |
791 |
| -failed_message: |
| 792 | + unlock_error); |
| 793 | + |
792 | 794 | return error;
|
793 | 795 | }
|
794 | 796 |
|
|
0 commit comments