aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dlmglue.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/dlmglue.c')
-rw-r--r--fs/ocfs2/dlmglue.c116
1 files changed, 50 insertions, 66 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index b8ac903ef8ef..6a222a5c81da 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -329,10 +329,9 @@ static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb,
329 struct ocfs2_lock_res *lockres); 329 struct ocfs2_lock_res *lockres);
330static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, 330static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres,
331 int convert); 331 int convert);
332#define ocfs2_log_dlm_error(_func, _stat, _lockres) do { \ 332#define ocfs2_log_dlm_error(_func, _err, _lockres) do { \
333 mlog(ML_ERROR, "Dlm error \"%s\" while calling %s on " \ 333 mlog(ML_ERROR, "DLM error %d while calling %s on resource %s\n", \
334 "resource %s: %s\n", dlm_errname(_stat), _func, \ 334 _err, _func, _lockres->l_name); \
335 _lockres->l_name, dlm_errmsg(_stat)); \
336} while (0) 335} while (0)
337static int ocfs2_downconvert_thread(void *arg); 336static int ocfs2_downconvert_thread(void *arg);
338static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb, 337static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb,
@@ -867,7 +866,6 @@ static int ocfs2_lock_create(struct ocfs2_super *osb,
867 u32 dlm_flags) 866 u32 dlm_flags)
868{ 867{
869 int ret = 0; 868 int ret = 0;
870 enum dlm_status status = DLM_NORMAL;
871 unsigned long flags; 869 unsigned long flags;
872 870
873 mlog_entry_void(); 871 mlog_entry_void();
@@ -887,21 +885,19 @@ static int ocfs2_lock_create(struct ocfs2_super *osb,
887 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); 885 lockres_or_flags(lockres, OCFS2_LOCK_BUSY);
888 spin_unlock_irqrestore(&lockres->l_lock, flags); 886 spin_unlock_irqrestore(&lockres->l_lock, flags);
889 887
890 status = ocfs2_dlm_lock(osb->dlm, 888 ret = ocfs2_dlm_lock(osb->dlm,
891 level, 889 level,
892 &lockres->l_lksb, 890 &lockres->l_lksb,
893 dlm_flags, 891 dlm_flags,
894 lockres->l_name, 892 lockres->l_name,
895 OCFS2_LOCK_ID_MAX_LEN - 1, 893 OCFS2_LOCK_ID_MAX_LEN - 1,
896 lockres); 894 lockres);
897 if (status != DLM_NORMAL) { 895 if (ret) {
898 ocfs2_log_dlm_error("ocfs2_dlm_lock", status, lockres); 896 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres);
899 ret = -EINVAL;
900 ocfs2_recover_from_dlm_error(lockres, 1); 897 ocfs2_recover_from_dlm_error(lockres, 1);
901 } 898 }
902 899
903 mlog(0, "lock %s, successfull return from ocfs2_dlm_lock\n", 900 mlog(0, "lock %s, return from ocfs2_dlm_lock\n", lockres->l_name);
904 lockres->l_name);
905 901
906bail: 902bail:
907 mlog_exit(ret); 903 mlog_exit(ret);
@@ -1018,7 +1014,6 @@ static int ocfs2_cluster_lock(struct ocfs2_super *osb,
1018 int arg_flags) 1014 int arg_flags)
1019{ 1015{
1020 struct ocfs2_mask_waiter mw; 1016 struct ocfs2_mask_waiter mw;
1021 enum dlm_status status;
1022 int wait, catch_signals = !(osb->s_mount_opt & OCFS2_MOUNT_NOINTR); 1017 int wait, catch_signals = !(osb->s_mount_opt & OCFS2_MOUNT_NOINTR);
1023 int ret = 0; /* gcc doesn't realize wait = 1 guarantees ret is set */ 1018 int ret = 0; /* gcc doesn't realize wait = 1 guarantees ret is set */
1024 unsigned long flags; 1019 unsigned long flags;
@@ -1089,21 +1084,18 @@ again:
1089 lockres->l_name, lockres->l_level, level); 1084 lockres->l_name, lockres->l_level, level);
1090 1085
1091 /* call dlm_lock to upgrade lock now */ 1086 /* call dlm_lock to upgrade lock now */
1092 status = ocfs2_dlm_lock(osb->dlm, 1087 ret = ocfs2_dlm_lock(osb->dlm,
1093 level, 1088 level,
1094 &lockres->l_lksb, 1089 &lockres->l_lksb,
1095 lkm_flags, 1090 lkm_flags,
1096 lockres->l_name, 1091 lockres->l_name,
1097 OCFS2_LOCK_ID_MAX_LEN - 1, 1092 OCFS2_LOCK_ID_MAX_LEN - 1,
1098 lockres); 1093 lockres);
1099 if (status != DLM_NORMAL) { 1094 if (ret) {
1100 if ((lkm_flags & DLM_LKF_NOQUEUE) && 1095 if (!(lkm_flags & DLM_LKF_NOQUEUE) ||
1101 (status == DLM_NOTQUEUED)) 1096 (ret != -EAGAIN)) {
1102 ret = -EAGAIN;
1103 else {
1104 ocfs2_log_dlm_error("ocfs2_dlm_lock", 1097 ocfs2_log_dlm_error("ocfs2_dlm_lock",
1105 status, lockres); 1098 ret, lockres);
1106 ret = -EINVAL;
1107 } 1099 }
1108 ocfs2_recover_from_dlm_error(lockres, 1); 1100 ocfs2_recover_from_dlm_error(lockres, 1);
1109 goto out; 1101 goto out;
@@ -1502,10 +1494,8 @@ int ocfs2_file_lock(struct file *file, int ex, int trylock)
1502 ret = ocfs2_dlm_lock(osb->dlm, level, &lockres->l_lksb, lkm_flags, 1494 ret = ocfs2_dlm_lock(osb->dlm, level, &lockres->l_lksb, lkm_flags,
1503 lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1, 1495 lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1,
1504 lockres); 1496 lockres);
1505 if (ret != DLM_NORMAL) { 1497 if (ret) {
1506 if (trylock && ret == DLM_NOTQUEUED) 1498 if (!trylock || (ret != -EAGAIN)) {
1507 ret = -EAGAIN;
1508 else {
1509 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); 1499 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres);
1510 ret = -EINVAL; 1500 ret = -EINVAL;
1511 } 1501 }
@@ -2573,7 +2563,7 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb)
2573 mlog_exit_void(); 2563 mlog_exit_void();
2574} 2564}
2575 2565
2576static void ocfs2_unlock_ast(void *opaque, enum dlm_status status) 2566static void ocfs2_unlock_ast(void *opaque, int error)
2577{ 2567{
2578 struct ocfs2_lock_res *lockres = opaque; 2568 struct ocfs2_lock_res *lockres = opaque;
2579 unsigned long flags; 2569 unsigned long flags;
@@ -2589,7 +2579,7 @@ static void ocfs2_unlock_ast(void *opaque, enum dlm_status status)
2589 * state. The wake_up call done at the bottom is redundant 2579 * state. The wake_up call done at the bottom is redundant
2590 * (ocfs2_prepare_cancel_convert doesn't sleep on this) but doesn't 2580 * (ocfs2_prepare_cancel_convert doesn't sleep on this) but doesn't
2591 * hurt anything anyway */ 2581 * hurt anything anyway */
2592 if (status == DLM_CANCELGRANT && 2582 if (error == -DLM_ECANCEL &&
2593 lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { 2583 lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) {
2594 mlog(0, "Got cancelgrant for %s\n", lockres->l_name); 2584 mlog(0, "Got cancelgrant for %s\n", lockres->l_name);
2595 2585
@@ -2599,9 +2589,10 @@ static void ocfs2_unlock_ast(void *opaque, enum dlm_status status)
2599 goto complete_unlock; 2589 goto complete_unlock;
2600 } 2590 }
2601 2591
2602 if (status != DLM_NORMAL) { 2592 /* DLM_EUNLOCK is the success code for unlock */
2603 mlog(ML_ERROR, "Dlm passes status %d for lock %s, " 2593 if (error != -DLM_EUNLOCK) {
2604 "unlock_action %d\n", status, lockres->l_name, 2594 mlog(ML_ERROR, "Dlm passes error %d for lock %s, "
2595 "unlock_action %d\n", error, lockres->l_name,
2605 lockres->l_unlock_action); 2596 lockres->l_unlock_action);
2606 spin_unlock_irqrestore(&lockres->l_lock, flags); 2597 spin_unlock_irqrestore(&lockres->l_lock, flags);
2607 return; 2598 return;
@@ -2632,7 +2623,7 @@ complete_unlock:
2632static int ocfs2_drop_lock(struct ocfs2_super *osb, 2623static int ocfs2_drop_lock(struct ocfs2_super *osb,
2633 struct ocfs2_lock_res *lockres) 2624 struct ocfs2_lock_res *lockres)
2634{ 2625{
2635 enum dlm_status status; 2626 int ret;
2636 unsigned long flags; 2627 unsigned long flags;
2637 u32 lkm_flags = 0; 2628 u32 lkm_flags = 0;
2638 2629
@@ -2696,10 +2687,10 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb,
2696 2687
2697 mlog(0, "lock %s\n", lockres->l_name); 2688 mlog(0, "lock %s\n", lockres->l_name);
2698 2689
2699 status = ocfs2_dlm_unlock(osb->dlm, &lockres->l_lksb, lkm_flags, 2690 ret = ocfs2_dlm_unlock(osb->dlm, &lockres->l_lksb, lkm_flags,
2700 lockres); 2691 lockres);
2701 if (status != DLM_NORMAL) { 2692 if (ret) {
2702 ocfs2_log_dlm_error("ocfs2_dlm_unlock", status, lockres); 2693 ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres);
2703 mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); 2694 mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags);
2704 dlm_print_one_lock(lockres->l_lksb.lockid); 2695 dlm_print_one_lock(lockres->l_lksb.lockid);
2705 BUG(); 2696 BUG();
@@ -2823,23 +2814,21 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
2823{ 2814{
2824 int ret; 2815 int ret;
2825 u32 dlm_flags = DLM_LKF_CONVERT; 2816 u32 dlm_flags = DLM_LKF_CONVERT;
2826 enum dlm_status status;
2827 2817
2828 mlog_entry_void(); 2818 mlog_entry_void();
2829 2819
2830 if (lvb) 2820 if (lvb)
2831 dlm_flags |= DLM_LKF_VALBLK; 2821 dlm_flags |= DLM_LKF_VALBLK;
2832 2822
2833 status = ocfs2_dlm_lock(osb->dlm, 2823 ret = ocfs2_dlm_lock(osb->dlm,
2834 new_level, 2824 new_level,
2835 &lockres->l_lksb, 2825 &lockres->l_lksb,
2836 dlm_flags, 2826 dlm_flags,
2837 lockres->l_name, 2827 lockres->l_name,
2838 OCFS2_LOCK_ID_MAX_LEN - 1, 2828 OCFS2_LOCK_ID_MAX_LEN - 1,
2839 lockres); 2829 lockres);
2840 if (status != DLM_NORMAL) { 2830 if (ret) {
2841 ocfs2_log_dlm_error("ocfs2_dlm_lock", status, lockres); 2831 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres);
2842 ret = -EINVAL;
2843 ocfs2_recover_from_dlm_error(lockres, 1); 2832 ocfs2_recover_from_dlm_error(lockres, 1);
2844 goto bail; 2833 goto bail;
2845 } 2834 }
@@ -2886,19 +2875,14 @@ static int ocfs2_cancel_convert(struct ocfs2_super *osb,
2886 struct ocfs2_lock_res *lockres) 2875 struct ocfs2_lock_res *lockres)
2887{ 2876{
2888 int ret; 2877 int ret;
2889 enum dlm_status status;
2890 2878
2891 mlog_entry_void(); 2879 mlog_entry_void();
2892 mlog(0, "lock %s\n", lockres->l_name); 2880 mlog(0, "lock %s\n", lockres->l_name);
2893 2881
2894 ret = 0; 2882 ret = ocfs2_dlm_unlock(osb->dlm, &lockres->l_lksb,
2895 status = ocfs2_dlm_unlock(osb->dlm, 2883 DLM_LKF_CANCEL, lockres);
2896 &lockres->l_lksb, 2884 if (ret) {
2897 DLM_LKF_CANCEL, 2885 ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres);
2898 lockres);
2899 if (status != DLM_NORMAL) {
2900 ocfs2_log_dlm_error("ocfs2_dlm_unlock", status, lockres);
2901 ret = -EINVAL;
2902 ocfs2_recover_from_dlm_error(lockres, 0); 2886 ocfs2_recover_from_dlm_error(lockres, 0);
2903 } 2887 }
2904 2888