diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-02-01 15:15:37 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-04-18 11:56:03 -0400 |
commit | 7431cd7e8dd0e46e9b12bd6a1ac1286f4b420371 (patch) | |
tree | 748d55c349f12ee504635748c64ee14026eda556 /fs | |
parent | bd3e76105d4478ab89951a52d1a35250d24a9f16 (diff) |
ocfs2: Use -errno instead of dlm_status for ocfs2_dlm_lock/unlock() API.
Change the ocfs2_dlm_lock/unlock() functions to return -errno values.
This is the first step towards elminiating dlm_status in
fs/ocfs2/dlmglue.c. The change also passes -errno values to
->unlock_ast().
[ Fix a return code in dlmglue.c and change the error translation table into
an array of ints. --Mark ]
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/dlmglue.c | 116 | ||||
-rw-r--r-- | fs/ocfs2/stackglue.c | 142 | ||||
-rw-r--r-- | fs/ocfs2/stackglue.h | 6 |
3 files changed, 188 insertions, 76 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); |
330 | static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, | 330 | static 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) |
337 | static int ocfs2_downconvert_thread(void *arg); | 336 | static int ocfs2_downconvert_thread(void *arg); |
338 | static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb, | 337 | static 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 | ||
906 | bail: | 902 | bail: |
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 | ||
2576 | static void ocfs2_unlock_ast(void *opaque, enum dlm_status status) | 2566 | static 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: | |||
2632 | static int ocfs2_drop_lock(struct ocfs2_super *osb, | 2623 | static 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 | ||
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c index 99538043fc17..0aec2fcf2175 100644 --- a/fs/ocfs2/stackglue.c +++ b/fs/ocfs2/stackglue.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * General Public License for more details. | 18 | * General Public License for more details. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "cluster/masklog.h" | ||
21 | #include "stackglue.h" | 22 | #include "stackglue.h" |
22 | 23 | ||
23 | static struct ocfs2_locking_protocol *lproto; | 24 | static struct ocfs2_locking_protocol *lproto; |
@@ -77,7 +78,126 @@ static int flags_to_o2dlm(u32 flags) | |||
77 | } | 78 | } |
78 | #undef map_flag | 79 | #undef map_flag |
79 | 80 | ||
80 | enum dlm_status ocfs2_dlm_lock(struct dlm_ctxt *dlm, | 81 | /* |
82 | * Map an o2dlm status to standard errno values. | ||
83 | * | ||
84 | * o2dlm only uses a handful of these, and returns even fewer to the | ||
85 | * caller. Still, we try to assign sane values to each error. | ||
86 | * | ||
87 | * The following value pairs have special meanings to dlmglue, thus | ||
88 | * the right hand side needs to stay unique - never duplicate the | ||
89 | * mapping elsewhere in the table! | ||
90 | * | ||
91 | * DLM_NORMAL: 0 | ||
92 | * DLM_NOTQUEUED: -EAGAIN | ||
93 | * DLM_CANCELGRANT: -DLM_ECANCEL | ||
94 | * DLM_CANCEL: -DLM_EUNLOCK | ||
95 | */ | ||
96 | /* Keep in sync with dlmapi.h */ | ||
97 | static int status_map[] = { | ||
98 | [DLM_NORMAL] = 0, /* Success */ | ||
99 | [DLM_GRANTED] = -EINVAL, | ||
100 | [DLM_DENIED] = -EACCES, | ||
101 | [DLM_DENIED_NOLOCKS] = -EACCES, | ||
102 | [DLM_WORKING] = -EBUSY, | ||
103 | [DLM_BLOCKED] = -EINVAL, | ||
104 | [DLM_BLOCKED_ORPHAN] = -EINVAL, | ||
105 | [DLM_DENIED_GRACE_PERIOD] = -EACCES, | ||
106 | [DLM_SYSERR] = -ENOMEM, /* It is what it is */ | ||
107 | [DLM_NOSUPPORT] = -EPROTO, | ||
108 | [DLM_CANCELGRANT] = -DLM_ECANCEL, /* Cancel after grant */ | ||
109 | [DLM_IVLOCKID] = -EINVAL, | ||
110 | [DLM_SYNC] = -EINVAL, | ||
111 | [DLM_BADTYPE] = -EINVAL, | ||
112 | [DLM_BADRESOURCE] = -EINVAL, | ||
113 | [DLM_MAXHANDLES] = -ENOMEM, | ||
114 | [DLM_NOCLINFO] = -EINVAL, | ||
115 | [DLM_NOLOCKMGR] = -EINVAL, | ||
116 | [DLM_NOPURGED] = -EINVAL, | ||
117 | [DLM_BADARGS] = -EINVAL, | ||
118 | [DLM_VOID] = -EINVAL, | ||
119 | [DLM_NOTQUEUED] = -EAGAIN, /* Trylock failed */ | ||
120 | [DLM_IVBUFLEN] = -EINVAL, | ||
121 | [DLM_CVTUNGRANT] = -EPERM, | ||
122 | [DLM_BADPARAM] = -EINVAL, | ||
123 | [DLM_VALNOTVALID] = -EINVAL, | ||
124 | [DLM_REJECTED] = -EPERM, | ||
125 | [DLM_ABORT] = -EINVAL, | ||
126 | [DLM_CANCEL] = -DLM_EUNLOCK, /* Successful cancel */ | ||
127 | [DLM_IVRESHANDLE] = -EINVAL, | ||
128 | [DLM_DEADLOCK] = -EDEADLK, | ||
129 | [DLM_DENIED_NOASTS] = -EINVAL, | ||
130 | [DLM_FORWARD] = -EINVAL, | ||
131 | [DLM_TIMEOUT] = -ETIMEDOUT, | ||
132 | [DLM_IVGROUPID] = -EINVAL, | ||
133 | [DLM_VERS_CONFLICT] = -EOPNOTSUPP, | ||
134 | [DLM_BAD_DEVICE_PATH] = -ENOENT, | ||
135 | [DLM_NO_DEVICE_PERMISSION] = -EPERM, | ||
136 | [DLM_NO_CONTROL_DEVICE] = -ENOENT, | ||
137 | [DLM_RECOVERING] = -ENOTCONN, | ||
138 | [DLM_MIGRATING] = -ERESTART, | ||
139 | [DLM_MAXSTATS] = -EINVAL, | ||
140 | }; | ||
141 | static int dlm_status_to_errno(enum dlm_status status) | ||
142 | { | ||
143 | BUG_ON(status > (sizeof(status_map) / sizeof(status_map[0]))); | ||
144 | |||
145 | return status_map[status]; | ||
146 | } | ||
147 | |||
148 | static void o2dlm_lock_ast_wrapper(void *astarg) | ||
149 | { | ||
150 | BUG_ON(lproto == NULL); | ||
151 | |||
152 | lproto->lp_lock_ast(astarg); | ||
153 | } | ||
154 | |||
155 | static void o2dlm_blocking_ast_wrapper(void *astarg, int level) | ||
156 | { | ||
157 | BUG_ON(lproto == NULL); | ||
158 | |||
159 | lproto->lp_blocking_ast(astarg, level); | ||
160 | } | ||
161 | |||
162 | static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status) | ||
163 | { | ||
164 | int error; | ||
165 | |||
166 | BUG_ON(lproto == NULL); | ||
167 | |||
168 | /* | ||
169 | * XXX: CANCEL values are sketchy. | ||
170 | * | ||
171 | * Currently we have preserved the o2dlm paradigm. You can get | ||
172 | * unlock_ast() whether the cancel succeded or not. | ||
173 | * | ||
174 | * First, we're going to pass DLM_EUNLOCK just like fs/dlm does for | ||
175 | * successful unlocks. That is a clean behavior. | ||
176 | * | ||
177 | * In o2dlm, you can get both the lock_ast() for the lock being | ||
178 | * granted and the unlock_ast() for the CANCEL failing. A | ||
179 | * successful cancel sends DLM_NORMAL here. If the | ||
180 | * lock grant happened before the cancel arrived, you get | ||
181 | * DLM_CANCELGRANT. For now, we'll use DLM_ECANCEL to signify | ||
182 | * CANCELGRANT - the CANCEL was supposed to happen but didn't. We | ||
183 | * can then use DLM_EUNLOCK to signify a successful CANCEL - | ||
184 | * effectively, the CANCEL caused the lock to roll back. | ||
185 | * | ||
186 | * In the future, we will likely move the o2dlm to send only one | ||
187 | * ast - either unlock_ast() for a successful CANCEL or lock_ast() | ||
188 | * when the grant succeeds. At that point, we'll send DLM_ECANCEL | ||
189 | * for all cancel results (CANCELGRANT will no longer exist). | ||
190 | */ | ||
191 | error = dlm_status_to_errno(status); | ||
192 | |||
193 | /* Successful unlock is DLM_EUNLOCK */ | ||
194 | if (!error) | ||
195 | error = -DLM_EUNLOCK; | ||
196 | |||
197 | lproto->lp_unlock_ast(astarg, error); | ||
198 | } | ||
199 | |||
200 | int ocfs2_dlm_lock(struct dlm_ctxt *dlm, | ||
81 | int mode, | 201 | int mode, |
82 | struct dlm_lockstatus *lksb, | 202 | struct dlm_lockstatus *lksb, |
83 | u32 flags, | 203 | u32 flags, |
@@ -85,27 +205,35 @@ enum dlm_status ocfs2_dlm_lock(struct dlm_ctxt *dlm, | |||
85 | unsigned int namelen, | 205 | unsigned int namelen, |
86 | void *astarg) | 206 | void *astarg) |
87 | { | 207 | { |
208 | enum dlm_status status; | ||
88 | int o2dlm_mode = mode_to_o2dlm(mode); | 209 | int o2dlm_mode = mode_to_o2dlm(mode); |
89 | int o2dlm_flags = flags_to_o2dlm(flags); | 210 | int o2dlm_flags = flags_to_o2dlm(flags); |
211 | int ret; | ||
90 | 212 | ||
91 | BUG_ON(lproto == NULL); | 213 | BUG_ON(lproto == NULL); |
92 | 214 | ||
93 | return dlmlock(dlm, o2dlm_mode, lksb, o2dlm_flags, name, namelen, | 215 | status = dlmlock(dlm, o2dlm_mode, lksb, o2dlm_flags, name, namelen, |
94 | lproto->lp_lock_ast, astarg, | 216 | o2dlm_lock_ast_wrapper, astarg, |
95 | lproto->lp_blocking_ast); | 217 | o2dlm_blocking_ast_wrapper); |
218 | ret = dlm_status_to_errno(status); | ||
219 | return ret; | ||
96 | } | 220 | } |
97 | 221 | ||
98 | enum dlm_status ocfs2_dlm_unlock(struct dlm_ctxt *dlm, | 222 | int ocfs2_dlm_unlock(struct dlm_ctxt *dlm, |
99 | struct dlm_lockstatus *lksb, | 223 | struct dlm_lockstatus *lksb, |
100 | u32 flags, | 224 | u32 flags, |
101 | void *astarg) | 225 | void *astarg) |
102 | { | 226 | { |
227 | enum dlm_status status; | ||
103 | int o2dlm_flags = flags_to_o2dlm(flags); | 228 | int o2dlm_flags = flags_to_o2dlm(flags); |
229 | int ret; | ||
104 | 230 | ||
105 | BUG_ON(lproto == NULL); | 231 | BUG_ON(lproto == NULL); |
106 | 232 | ||
107 | return dlmunlock(dlm, lksb, o2dlm_flags, | 233 | status = dlmunlock(dlm, lksb, o2dlm_flags, |
108 | lproto->lp_unlock_ast, astarg); | 234 | o2dlm_unlock_ast_wrapper, astarg); |
235 | ret = dlm_status_to_errno(status); | ||
236 | return ret; | ||
109 | } | 237 | } |
110 | 238 | ||
111 | 239 | ||
diff --git a/fs/ocfs2/stackglue.h b/fs/ocfs2/stackglue.h index 986d059ed1e0..8ebcfba62c7e 100644 --- a/fs/ocfs2/stackglue.h +++ b/fs/ocfs2/stackglue.h | |||
@@ -37,17 +37,17 @@ | |||
37 | struct ocfs2_locking_protocol { | 37 | struct ocfs2_locking_protocol { |
38 | void (*lp_lock_ast)(void *astarg); | 38 | void (*lp_lock_ast)(void *astarg); |
39 | void (*lp_blocking_ast)(void *astarg, int level); | 39 | void (*lp_blocking_ast)(void *astarg, int level); |
40 | void (*lp_unlock_ast)(void *astarg, enum dlm_status status); | 40 | void (*lp_unlock_ast)(void *astarg, int error); |
41 | }; | 41 | }; |
42 | 42 | ||
43 | enum dlm_status ocfs2_dlm_lock(struct dlm_ctxt *dlm, | 43 | int ocfs2_dlm_lock(struct dlm_ctxt *dlm, |
44 | int mode, | 44 | int mode, |
45 | struct dlm_lockstatus *lksb, | 45 | struct dlm_lockstatus *lksb, |
46 | u32 flags, | 46 | u32 flags, |
47 | void *name, | 47 | void *name, |
48 | unsigned int namelen, | 48 | unsigned int namelen, |
49 | void *astarg); | 49 | void *astarg); |
50 | enum dlm_status ocfs2_dlm_unlock(struct dlm_ctxt *dlm, | 50 | int ocfs2_dlm_unlock(struct dlm_ctxt *dlm, |
51 | struct dlm_lockstatus *lksb, | 51 | struct dlm_lockstatus *lksb, |
52 | u32 flags, | 52 | u32 flags, |
53 | void *astarg); | 53 | void *astarg); |