diff options
Diffstat (limited to 'fs/ocfs2/dlmglue.c')
-rw-r--r-- | fs/ocfs2/dlmglue.c | 284 |
1 files changed, 161 insertions, 123 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index e044019cb3b1..8298608d4165 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c | |||
@@ -297,6 +297,11 @@ static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres) | |||
297 | lockres->l_type == OCFS2_LOCK_TYPE_OPEN; | 297 | lockres->l_type == OCFS2_LOCK_TYPE_OPEN; |
298 | } | 298 | } |
299 | 299 | ||
300 | static inline struct ocfs2_lock_res *ocfs2_lksb_to_lock_res(struct ocfs2_dlm_lksb *lksb) | ||
301 | { | ||
302 | return container_of(lksb, struct ocfs2_lock_res, l_lksb); | ||
303 | } | ||
304 | |||
300 | static inline struct inode *ocfs2_lock_res_inode(struct ocfs2_lock_res *lockres) | 305 | static inline struct inode *ocfs2_lock_res_inode(struct ocfs2_lock_res *lockres) |
301 | { | 306 | { |
302 | BUG_ON(!ocfs2_is_inode_lock(lockres)); | 307 | BUG_ON(!ocfs2_is_inode_lock(lockres)); |
@@ -927,6 +932,10 @@ static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, | |||
927 | lockres->l_blocking = level; | 932 | lockres->l_blocking = level; |
928 | } | 933 | } |
929 | 934 | ||
935 | mlog(ML_BASTS, "lockres %s, block %d, level %d, l_block %d, dwn %d\n", | ||
936 | lockres->l_name, level, lockres->l_level, lockres->l_blocking, | ||
937 | needs_downconvert); | ||
938 | |||
930 | if (needs_downconvert) | 939 | if (needs_downconvert) |
931 | lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); | 940 | lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); |
932 | 941 | ||
@@ -1040,18 +1049,17 @@ static unsigned int lockres_set_pending(struct ocfs2_lock_res *lockres) | |||
1040 | return lockres->l_pending_gen; | 1049 | return lockres->l_pending_gen; |
1041 | } | 1050 | } |
1042 | 1051 | ||
1043 | 1052 | static void ocfs2_blocking_ast(struct ocfs2_dlm_lksb *lksb, int level) | |
1044 | static void ocfs2_blocking_ast(void *opaque, int level) | ||
1045 | { | 1053 | { |
1046 | struct ocfs2_lock_res *lockres = opaque; | 1054 | struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); |
1047 | struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); | 1055 | struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); |
1048 | int needs_downconvert; | 1056 | int needs_downconvert; |
1049 | unsigned long flags; | 1057 | unsigned long flags; |
1050 | 1058 | ||
1051 | BUG_ON(level <= DLM_LOCK_NL); | 1059 | BUG_ON(level <= DLM_LOCK_NL); |
1052 | 1060 | ||
1053 | mlog(0, "BAST fired for lockres %s, blocking %d, level %d type %s\n", | 1061 | mlog(ML_BASTS, "BAST fired for lockres %s, blocking %d, level %d, " |
1054 | lockres->l_name, level, lockres->l_level, | 1062 | "type %s\n", lockres->l_name, level, lockres->l_level, |
1055 | ocfs2_lock_type_string(lockres->l_type)); | 1063 | ocfs2_lock_type_string(lockres->l_type)); |
1056 | 1064 | ||
1057 | /* | 1065 | /* |
@@ -1072,9 +1080,9 @@ static void ocfs2_blocking_ast(void *opaque, int level) | |||
1072 | ocfs2_wake_downconvert_thread(osb); | 1080 | ocfs2_wake_downconvert_thread(osb); |
1073 | } | 1081 | } |
1074 | 1082 | ||
1075 | static void ocfs2_locking_ast(void *opaque) | 1083 | static void ocfs2_locking_ast(struct ocfs2_dlm_lksb *lksb) |
1076 | { | 1084 | { |
1077 | struct ocfs2_lock_res *lockres = opaque; | 1085 | struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); |
1078 | struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); | 1086 | struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); |
1079 | unsigned long flags; | 1087 | unsigned long flags; |
1080 | int status; | 1088 | int status; |
@@ -1095,6 +1103,10 @@ static void ocfs2_locking_ast(void *opaque) | |||
1095 | return; | 1103 | return; |
1096 | } | 1104 | } |
1097 | 1105 | ||
1106 | mlog(ML_BASTS, "AST fired for lockres %s, action %d, unlock %d, " | ||
1107 | "level %d => %d\n", lockres->l_name, lockres->l_action, | ||
1108 | lockres->l_unlock_action, lockres->l_level, lockres->l_requested); | ||
1109 | |||
1098 | switch(lockres->l_action) { | 1110 | switch(lockres->l_action) { |
1099 | case OCFS2_AST_ATTACH: | 1111 | case OCFS2_AST_ATTACH: |
1100 | ocfs2_generic_handle_attach_action(lockres); | 1112 | ocfs2_generic_handle_attach_action(lockres); |
@@ -1107,8 +1119,8 @@ static void ocfs2_locking_ast(void *opaque) | |||
1107 | ocfs2_generic_handle_downconvert_action(lockres); | 1119 | ocfs2_generic_handle_downconvert_action(lockres); |
1108 | break; | 1120 | break; |
1109 | default: | 1121 | default: |
1110 | mlog(ML_ERROR, "lockres %s: ast fired with invalid action: %u " | 1122 | mlog(ML_ERROR, "lockres %s: AST fired with invalid action: %u, " |
1111 | "lockres flags = 0x%lx, unlock action: %u\n", | 1123 | "flags 0x%lx, unlock: %u\n", |
1112 | lockres->l_name, lockres->l_action, lockres->l_flags, | 1124 | lockres->l_name, lockres->l_action, lockres->l_flags, |
1113 | lockres->l_unlock_action); | 1125 | lockres->l_unlock_action); |
1114 | BUG(); | 1126 | BUG(); |
@@ -1134,6 +1146,88 @@ out: | |||
1134 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 1146 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
1135 | } | 1147 | } |
1136 | 1148 | ||
1149 | static void ocfs2_unlock_ast(struct ocfs2_dlm_lksb *lksb, int error) | ||
1150 | { | ||
1151 | struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); | ||
1152 | unsigned long flags; | ||
1153 | |||
1154 | mlog_entry_void(); | ||
1155 | |||
1156 | mlog(ML_BASTS, "UNLOCK AST fired for lockres %s, action = %d\n", | ||
1157 | lockres->l_name, lockres->l_unlock_action); | ||
1158 | |||
1159 | spin_lock_irqsave(&lockres->l_lock, flags); | ||
1160 | if (error) { | ||
1161 | mlog(ML_ERROR, "Dlm passes error %d for lock %s, " | ||
1162 | "unlock_action %d\n", error, lockres->l_name, | ||
1163 | lockres->l_unlock_action); | ||
1164 | spin_unlock_irqrestore(&lockres->l_lock, flags); | ||
1165 | mlog_exit_void(); | ||
1166 | return; | ||
1167 | } | ||
1168 | |||
1169 | switch(lockres->l_unlock_action) { | ||
1170 | case OCFS2_UNLOCK_CANCEL_CONVERT: | ||
1171 | mlog(0, "Cancel convert success for %s\n", lockres->l_name); | ||
1172 | lockres->l_action = OCFS2_AST_INVALID; | ||
1173 | /* Downconvert thread may have requeued this lock, we | ||
1174 | * need to wake it. */ | ||
1175 | if (lockres->l_flags & OCFS2_LOCK_BLOCKED) | ||
1176 | ocfs2_wake_downconvert_thread(ocfs2_get_lockres_osb(lockres)); | ||
1177 | break; | ||
1178 | case OCFS2_UNLOCK_DROP_LOCK: | ||
1179 | lockres->l_level = DLM_LOCK_IV; | ||
1180 | break; | ||
1181 | default: | ||
1182 | BUG(); | ||
1183 | } | ||
1184 | |||
1185 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); | ||
1186 | lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; | ||
1187 | wake_up(&lockres->l_event); | ||
1188 | spin_unlock_irqrestore(&lockres->l_lock, flags); | ||
1189 | |||
1190 | mlog_exit_void(); | ||
1191 | } | ||
1192 | |||
1193 | /* | ||
1194 | * This is the filesystem locking protocol. It provides the lock handling | ||
1195 | * hooks for the underlying DLM. It has a maximum version number. | ||
1196 | * The version number allows interoperability with systems running at | ||
1197 | * the same major number and an equal or smaller minor number. | ||
1198 | * | ||
1199 | * Whenever the filesystem does new things with locks (adds or removes a | ||
1200 | * lock, orders them differently, does different things underneath a lock), | ||
1201 | * the version must be changed. The protocol is negotiated when joining | ||
1202 | * the dlm domain. A node may join the domain if its major version is | ||
1203 | * identical to all other nodes and its minor version is greater than | ||
1204 | * or equal to all other nodes. When its minor version is greater than | ||
1205 | * the other nodes, it will run at the minor version specified by the | ||
1206 | * other nodes. | ||
1207 | * | ||
1208 | * If a locking change is made that will not be compatible with older | ||
1209 | * versions, the major number must be increased and the minor version set | ||
1210 | * to zero. If a change merely adds a behavior that can be disabled when | ||
1211 | * speaking to older versions, the minor version must be increased. If a | ||
1212 | * change adds a fully backwards compatible change (eg, LVB changes that | ||
1213 | * are just ignored by older versions), the version does not need to be | ||
1214 | * updated. | ||
1215 | */ | ||
1216 | static struct ocfs2_locking_protocol lproto = { | ||
1217 | .lp_max_version = { | ||
1218 | .pv_major = OCFS2_LOCKING_PROTOCOL_MAJOR, | ||
1219 | .pv_minor = OCFS2_LOCKING_PROTOCOL_MINOR, | ||
1220 | }, | ||
1221 | .lp_lock_ast = ocfs2_locking_ast, | ||
1222 | .lp_blocking_ast = ocfs2_blocking_ast, | ||
1223 | .lp_unlock_ast = ocfs2_unlock_ast, | ||
1224 | }; | ||
1225 | |||
1226 | void ocfs2_set_locking_protocol(void) | ||
1227 | { | ||
1228 | ocfs2_stack_glue_set_max_proto_version(&lproto.lp_max_version); | ||
1229 | } | ||
1230 | |||
1137 | static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, | 1231 | static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, |
1138 | int convert) | 1232 | int convert) |
1139 | { | 1233 | { |
@@ -1189,8 +1283,7 @@ static int ocfs2_lock_create(struct ocfs2_super *osb, | |||
1189 | &lockres->l_lksb, | 1283 | &lockres->l_lksb, |
1190 | dlm_flags, | 1284 | dlm_flags, |
1191 | lockres->l_name, | 1285 | lockres->l_name, |
1192 | OCFS2_LOCK_ID_MAX_LEN - 1, | 1286 | OCFS2_LOCK_ID_MAX_LEN - 1); |
1193 | lockres); | ||
1194 | lockres_clear_pending(lockres, gen, osb); | 1287 | lockres_clear_pending(lockres, gen, osb); |
1195 | if (ret) { | 1288 | if (ret) { |
1196 | ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); | 1289 | ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); |
@@ -1412,7 +1505,7 @@ again: | |||
1412 | BUG_ON(level == DLM_LOCK_IV); | 1505 | BUG_ON(level == DLM_LOCK_IV); |
1413 | BUG_ON(level == DLM_LOCK_NL); | 1506 | BUG_ON(level == DLM_LOCK_NL); |
1414 | 1507 | ||
1415 | mlog(0, "lock %s, convert from %d to level = %d\n", | 1508 | mlog(ML_BASTS, "lockres %s, convert from %d to %d\n", |
1416 | lockres->l_name, lockres->l_level, level); | 1509 | lockres->l_name, lockres->l_level, level); |
1417 | 1510 | ||
1418 | /* call dlm_lock to upgrade lock now */ | 1511 | /* call dlm_lock to upgrade lock now */ |
@@ -1421,8 +1514,7 @@ again: | |||
1421 | &lockres->l_lksb, | 1514 | &lockres->l_lksb, |
1422 | lkm_flags, | 1515 | lkm_flags, |
1423 | lockres->l_name, | 1516 | lockres->l_name, |
1424 | OCFS2_LOCK_ID_MAX_LEN - 1, | 1517 | OCFS2_LOCK_ID_MAX_LEN - 1); |
1425 | lockres); | ||
1426 | lockres_clear_pending(lockres, gen, osb); | 1518 | lockres_clear_pending(lockres, gen, osb); |
1427 | if (ret) { | 1519 | if (ret) { |
1428 | if (!(lkm_flags & DLM_LKF_NOQUEUE) || | 1520 | if (!(lkm_flags & DLM_LKF_NOQUEUE) || |
@@ -1859,8 +1951,7 @@ int ocfs2_file_lock(struct file *file, int ex, int trylock) | |||
1859 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 1951 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
1860 | 1952 | ||
1861 | ret = ocfs2_dlm_lock(osb->cconn, level, &lockres->l_lksb, lkm_flags, | 1953 | ret = ocfs2_dlm_lock(osb->cconn, level, &lockres->l_lksb, lkm_flags, |
1862 | lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1, | 1954 | lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1); |
1863 | lockres); | ||
1864 | if (ret) { | 1955 | if (ret) { |
1865 | if (!trylock || (ret != -EAGAIN)) { | 1956 | if (!trylock || (ret != -EAGAIN)) { |
1866 | ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); | 1957 | ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); |
@@ -2989,7 +3080,7 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) | |||
2989 | status = ocfs2_cluster_connect(osb->osb_cluster_stack, | 3080 | status = ocfs2_cluster_connect(osb->osb_cluster_stack, |
2990 | osb->uuid_str, | 3081 | osb->uuid_str, |
2991 | strlen(osb->uuid_str), | 3082 | strlen(osb->uuid_str), |
2992 | ocfs2_do_node_down, osb, | 3083 | &lproto, ocfs2_do_node_down, osb, |
2993 | &conn); | 3084 | &conn); |
2994 | if (status) { | 3085 | if (status) { |
2995 | mlog_errno(status); | 3086 | mlog_errno(status); |
@@ -3056,50 +3147,6 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb, | |||
3056 | mlog_exit_void(); | 3147 | mlog_exit_void(); |
3057 | } | 3148 | } |
3058 | 3149 | ||
3059 | static void ocfs2_unlock_ast(void *opaque, int error) | ||
3060 | { | ||
3061 | struct ocfs2_lock_res *lockres = opaque; | ||
3062 | unsigned long flags; | ||
3063 | |||
3064 | mlog_entry_void(); | ||
3065 | |||
3066 | mlog(0, "UNLOCK AST called on lock %s, action = %d\n", lockres->l_name, | ||
3067 | lockres->l_unlock_action); | ||
3068 | |||
3069 | spin_lock_irqsave(&lockres->l_lock, flags); | ||
3070 | if (error) { | ||
3071 | mlog(ML_ERROR, "Dlm passes error %d for lock %s, " | ||
3072 | "unlock_action %d\n", error, lockres->l_name, | ||
3073 | lockres->l_unlock_action); | ||
3074 | spin_unlock_irqrestore(&lockres->l_lock, flags); | ||
3075 | mlog_exit_void(); | ||
3076 | return; | ||
3077 | } | ||
3078 | |||
3079 | switch(lockres->l_unlock_action) { | ||
3080 | case OCFS2_UNLOCK_CANCEL_CONVERT: | ||
3081 | mlog(0, "Cancel convert success for %s\n", lockres->l_name); | ||
3082 | lockres->l_action = OCFS2_AST_INVALID; | ||
3083 | /* Downconvert thread may have requeued this lock, we | ||
3084 | * need to wake it. */ | ||
3085 | if (lockres->l_flags & OCFS2_LOCK_BLOCKED) | ||
3086 | ocfs2_wake_downconvert_thread(ocfs2_get_lockres_osb(lockres)); | ||
3087 | break; | ||
3088 | case OCFS2_UNLOCK_DROP_LOCK: | ||
3089 | lockres->l_level = DLM_LOCK_IV; | ||
3090 | break; | ||
3091 | default: | ||
3092 | BUG(); | ||
3093 | } | ||
3094 | |||
3095 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); | ||
3096 | lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; | ||
3097 | wake_up(&lockres->l_event); | ||
3098 | spin_unlock_irqrestore(&lockres->l_lock, flags); | ||
3099 | |||
3100 | mlog_exit_void(); | ||
3101 | } | ||
3102 | |||
3103 | static int ocfs2_drop_lock(struct ocfs2_super *osb, | 3150 | static int ocfs2_drop_lock(struct ocfs2_super *osb, |
3104 | struct ocfs2_lock_res *lockres) | 3151 | struct ocfs2_lock_res *lockres) |
3105 | { | 3152 | { |
@@ -3167,8 +3214,7 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb, | |||
3167 | 3214 | ||
3168 | mlog(0, "lock %s\n", lockres->l_name); | 3215 | mlog(0, "lock %s\n", lockres->l_name); |
3169 | 3216 | ||
3170 | ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags, | 3217 | ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags); |
3171 | lockres); | ||
3172 | if (ret) { | 3218 | if (ret) { |
3173 | ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); | 3219 | ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); |
3174 | mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); | 3220 | mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); |
@@ -3276,13 +3322,20 @@ static unsigned int ocfs2_prepare_downconvert(struct ocfs2_lock_res *lockres, | |||
3276 | BUG_ON(lockres->l_blocking <= DLM_LOCK_NL); | 3322 | BUG_ON(lockres->l_blocking <= DLM_LOCK_NL); |
3277 | 3323 | ||
3278 | if (lockres->l_level <= new_level) { | 3324 | if (lockres->l_level <= new_level) { |
3279 | mlog(ML_ERROR, "lockres->l_level (%d) <= new_level (%d)\n", | 3325 | mlog(ML_ERROR, "lockres %s, lvl %d <= %d, blcklst %d, mask %d, " |
3280 | lockres->l_level, new_level); | 3326 | "type %d, flags 0x%lx, hold %d %d, act %d %d, req %d, " |
3327 | "block %d, pgen %d\n", lockres->l_name, lockres->l_level, | ||
3328 | new_level, list_empty(&lockres->l_blocked_list), | ||
3329 | list_empty(&lockres->l_mask_waiters), lockres->l_type, | ||
3330 | lockres->l_flags, lockres->l_ro_holders, | ||
3331 | lockres->l_ex_holders, lockres->l_action, | ||
3332 | lockres->l_unlock_action, lockres->l_requested, | ||
3333 | lockres->l_blocking, lockres->l_pending_gen); | ||
3281 | BUG(); | 3334 | BUG(); |
3282 | } | 3335 | } |
3283 | 3336 | ||
3284 | mlog(0, "lock %s, new_level = %d, l_blocking = %d\n", | 3337 | mlog(ML_BASTS, "lockres %s, level %d => %d, blocking %d\n", |
3285 | lockres->l_name, new_level, lockres->l_blocking); | 3338 | lockres->l_name, lockres->l_level, new_level, lockres->l_blocking); |
3286 | 3339 | ||
3287 | lockres->l_action = OCFS2_AST_DOWNCONVERT; | 3340 | lockres->l_action = OCFS2_AST_DOWNCONVERT; |
3288 | lockres->l_requested = new_level; | 3341 | lockres->l_requested = new_level; |
@@ -3301,6 +3354,9 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb, | |||
3301 | 3354 | ||
3302 | mlog_entry_void(); | 3355 | mlog_entry_void(); |
3303 | 3356 | ||
3357 | mlog(ML_BASTS, "lockres %s, level %d => %d\n", lockres->l_name, | ||
3358 | lockres->l_level, new_level); | ||
3359 | |||
3304 | if (lvb) | 3360 | if (lvb) |
3305 | dlm_flags |= DLM_LKF_VALBLK; | 3361 | dlm_flags |= DLM_LKF_VALBLK; |
3306 | 3362 | ||
@@ -3309,8 +3365,7 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb, | |||
3309 | &lockres->l_lksb, | 3365 | &lockres->l_lksb, |
3310 | dlm_flags, | 3366 | dlm_flags, |
3311 | lockres->l_name, | 3367 | lockres->l_name, |
3312 | OCFS2_LOCK_ID_MAX_LEN - 1, | 3368 | OCFS2_LOCK_ID_MAX_LEN - 1); |
3313 | lockres); | ||
3314 | lockres_clear_pending(lockres, generation, osb); | 3369 | lockres_clear_pending(lockres, generation, osb); |
3315 | if (ret) { | 3370 | if (ret) { |
3316 | ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); | 3371 | ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); |
@@ -3331,14 +3386,12 @@ static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb, | |||
3331 | assert_spin_locked(&lockres->l_lock); | 3386 | assert_spin_locked(&lockres->l_lock); |
3332 | 3387 | ||
3333 | mlog_entry_void(); | 3388 | mlog_entry_void(); |
3334 | mlog(0, "lock %s\n", lockres->l_name); | ||
3335 | 3389 | ||
3336 | if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { | 3390 | if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { |
3337 | /* If we're already trying to cancel a lock conversion | 3391 | /* If we're already trying to cancel a lock conversion |
3338 | * then just drop the spinlock and allow the caller to | 3392 | * then just drop the spinlock and allow the caller to |
3339 | * requeue this lock. */ | 3393 | * requeue this lock. */ |
3340 | 3394 | mlog(ML_BASTS, "lockres %s, skip convert\n", lockres->l_name); | |
3341 | mlog(0, "Lockres %s, skip convert\n", lockres->l_name); | ||
3342 | return 0; | 3395 | return 0; |
3343 | } | 3396 | } |
3344 | 3397 | ||
@@ -3353,6 +3406,8 @@ static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb, | |||
3353 | "lock %s, invalid flags: 0x%lx\n", | 3406 | "lock %s, invalid flags: 0x%lx\n", |
3354 | lockres->l_name, lockres->l_flags); | 3407 | lockres->l_name, lockres->l_flags); |
3355 | 3408 | ||
3409 | mlog(ML_BASTS, "lockres %s\n", lockres->l_name); | ||
3410 | |||
3356 | return 1; | 3411 | return 1; |
3357 | } | 3412 | } |
3358 | 3413 | ||
@@ -3362,16 +3417,15 @@ static int ocfs2_cancel_convert(struct ocfs2_super *osb, | |||
3362 | int ret; | 3417 | int ret; |
3363 | 3418 | ||
3364 | mlog_entry_void(); | 3419 | mlog_entry_void(); |
3365 | mlog(0, "lock %s\n", lockres->l_name); | ||
3366 | 3420 | ||
3367 | ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, | 3421 | ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, |
3368 | DLM_LKF_CANCEL, lockres); | 3422 | DLM_LKF_CANCEL); |
3369 | if (ret) { | 3423 | if (ret) { |
3370 | ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); | 3424 | ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); |
3371 | ocfs2_recover_from_dlm_error(lockres, 0); | 3425 | ocfs2_recover_from_dlm_error(lockres, 0); |
3372 | } | 3426 | } |
3373 | 3427 | ||
3374 | mlog(0, "lock %s return from ocfs2_dlm_unlock\n", lockres->l_name); | 3428 | mlog(ML_BASTS, "lockres %s\n", lockres->l_name); |
3375 | 3429 | ||
3376 | mlog_exit(ret); | 3430 | mlog_exit(ret); |
3377 | return ret; | 3431 | return ret; |
@@ -3428,8 +3482,11 @@ recheck: | |||
3428 | * at the same time they set OCFS2_DLM_BUSY. They must | 3482 | * at the same time they set OCFS2_DLM_BUSY. They must |
3429 | * clear OCFS2_DLM_PENDING after dlm_lock() returns. | 3483 | * clear OCFS2_DLM_PENDING after dlm_lock() returns. |
3430 | */ | 3484 | */ |
3431 | if (lockres->l_flags & OCFS2_LOCK_PENDING) | 3485 | if (lockres->l_flags & OCFS2_LOCK_PENDING) { |
3486 | mlog(ML_BASTS, "lockres %s, ReQ: Pending\n", | ||
3487 | lockres->l_name); | ||
3432 | goto leave_requeue; | 3488 | goto leave_requeue; |
3489 | } | ||
3433 | 3490 | ||
3434 | ctl->requeue = 1; | 3491 | ctl->requeue = 1; |
3435 | ret = ocfs2_prepare_cancel_convert(osb, lockres); | 3492 | ret = ocfs2_prepare_cancel_convert(osb, lockres); |
@@ -3461,6 +3518,7 @@ recheck: | |||
3461 | */ | 3518 | */ |
3462 | if (lockres->l_level == DLM_LOCK_NL) { | 3519 | if (lockres->l_level == DLM_LOCK_NL) { |
3463 | BUG_ON(lockres->l_ex_holders || lockres->l_ro_holders); | 3520 | BUG_ON(lockres->l_ex_holders || lockres->l_ro_holders); |
3521 | mlog(ML_BASTS, "lockres %s, Aborting dc\n", lockres->l_name); | ||
3464 | lockres->l_blocking = DLM_LOCK_NL; | 3522 | lockres->l_blocking = DLM_LOCK_NL; |
3465 | lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); | 3523 | lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); |
3466 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 3524 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
@@ -3470,28 +3528,41 @@ recheck: | |||
3470 | /* if we're blocking an exclusive and we have *any* holders, | 3528 | /* if we're blocking an exclusive and we have *any* holders, |
3471 | * then requeue. */ | 3529 | * then requeue. */ |
3472 | if ((lockres->l_blocking == DLM_LOCK_EX) | 3530 | if ((lockres->l_blocking == DLM_LOCK_EX) |
3473 | && (lockres->l_ex_holders || lockres->l_ro_holders)) | 3531 | && (lockres->l_ex_holders || lockres->l_ro_holders)) { |
3532 | mlog(ML_BASTS, "lockres %s, ReQ: EX/PR Holders %u,%u\n", | ||
3533 | lockres->l_name, lockres->l_ex_holders, | ||
3534 | lockres->l_ro_holders); | ||
3474 | goto leave_requeue; | 3535 | goto leave_requeue; |
3536 | } | ||
3475 | 3537 | ||
3476 | /* If it's a PR we're blocking, then only | 3538 | /* If it's a PR we're blocking, then only |
3477 | * requeue if we've got any EX holders */ | 3539 | * requeue if we've got any EX holders */ |
3478 | if (lockres->l_blocking == DLM_LOCK_PR && | 3540 | if (lockres->l_blocking == DLM_LOCK_PR && |
3479 | lockres->l_ex_holders) | 3541 | lockres->l_ex_holders) { |
3542 | mlog(ML_BASTS, "lockres %s, ReQ: EX Holders %u\n", | ||
3543 | lockres->l_name, lockres->l_ex_holders); | ||
3480 | goto leave_requeue; | 3544 | goto leave_requeue; |
3545 | } | ||
3481 | 3546 | ||
3482 | /* | 3547 | /* |
3483 | * Can we get a lock in this state if the holder counts are | 3548 | * Can we get a lock in this state if the holder counts are |
3484 | * zero? The meta data unblock code used to check this. | 3549 | * zero? The meta data unblock code used to check this. |
3485 | */ | 3550 | */ |
3486 | if ((lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) | 3551 | if ((lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) |
3487 | && (lockres->l_flags & OCFS2_LOCK_REFRESHING)) | 3552 | && (lockres->l_flags & OCFS2_LOCK_REFRESHING)) { |
3553 | mlog(ML_BASTS, "lockres %s, ReQ: Lock Refreshing\n", | ||
3554 | lockres->l_name); | ||
3488 | goto leave_requeue; | 3555 | goto leave_requeue; |
3556 | } | ||
3489 | 3557 | ||
3490 | new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking); | 3558 | new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking); |
3491 | 3559 | ||
3492 | if (lockres->l_ops->check_downconvert | 3560 | if (lockres->l_ops->check_downconvert |
3493 | && !lockres->l_ops->check_downconvert(lockres, new_level)) | 3561 | && !lockres->l_ops->check_downconvert(lockres, new_level)) { |
3562 | mlog(ML_BASTS, "lockres %s, ReQ: Checkpointing\n", | ||
3563 | lockres->l_name); | ||
3494 | goto leave_requeue; | 3564 | goto leave_requeue; |
3565 | } | ||
3495 | 3566 | ||
3496 | /* If we get here, then we know that there are no more | 3567 | /* If we get here, then we know that there are no more |
3497 | * incompatible holders (and anyone asking for an incompatible | 3568 | * incompatible holders (and anyone asking for an incompatible |
@@ -3509,13 +3580,19 @@ recheck: | |||
3509 | 3580 | ||
3510 | ctl->unblock_action = lockres->l_ops->downconvert_worker(lockres, blocking); | 3581 | ctl->unblock_action = lockres->l_ops->downconvert_worker(lockres, blocking); |
3511 | 3582 | ||
3512 | if (ctl->unblock_action == UNBLOCK_STOP_POST) | 3583 | if (ctl->unblock_action == UNBLOCK_STOP_POST) { |
3584 | mlog(ML_BASTS, "lockres %s, UNBLOCK_STOP_POST\n", | ||
3585 | lockres->l_name); | ||
3513 | goto leave; | 3586 | goto leave; |
3587 | } | ||
3514 | 3588 | ||
3515 | spin_lock_irqsave(&lockres->l_lock, flags); | 3589 | spin_lock_irqsave(&lockres->l_lock, flags); |
3516 | if ((blocking != lockres->l_blocking) || (level != lockres->l_level)) { | 3590 | if ((blocking != lockres->l_blocking) || (level != lockres->l_level)) { |
3517 | /* If this changed underneath us, then we can't drop | 3591 | /* If this changed underneath us, then we can't drop |
3518 | * it just yet. */ | 3592 | * it just yet. */ |
3593 | mlog(ML_BASTS, "lockres %s, block=%d:%d, level=%d:%d, " | ||
3594 | "Recheck\n", lockres->l_name, blocking, | ||
3595 | lockres->l_blocking, level, lockres->l_level); | ||
3519 | goto recheck; | 3596 | goto recheck; |
3520 | } | 3597 | } |
3521 | 3598 | ||
@@ -3910,45 +3987,6 @@ void ocfs2_refcount_unlock(struct ocfs2_refcount_tree *ref_tree, int ex) | |||
3910 | ocfs2_cluster_unlock(osb, lockres, level); | 3987 | ocfs2_cluster_unlock(osb, lockres, level); |
3911 | } | 3988 | } |
3912 | 3989 | ||
3913 | /* | ||
3914 | * This is the filesystem locking protocol. It provides the lock handling | ||
3915 | * hooks for the underlying DLM. It has a maximum version number. | ||
3916 | * The version number allows interoperability with systems running at | ||
3917 | * the same major number and an equal or smaller minor number. | ||
3918 | * | ||
3919 | * Whenever the filesystem does new things with locks (adds or removes a | ||
3920 | * lock, orders them differently, does different things underneath a lock), | ||
3921 | * the version must be changed. The protocol is negotiated when joining | ||
3922 | * the dlm domain. A node may join the domain if its major version is | ||
3923 | * identical to all other nodes and its minor version is greater than | ||
3924 | * or equal to all other nodes. When its minor version is greater than | ||
3925 | * the other nodes, it will run at the minor version specified by the | ||
3926 | * other nodes. | ||
3927 | * | ||
3928 | * If a locking change is made that will not be compatible with older | ||
3929 | * versions, the major number must be increased and the minor version set | ||
3930 | * to zero. If a change merely adds a behavior that can be disabled when | ||
3931 | * speaking to older versions, the minor version must be increased. If a | ||
3932 | * change adds a fully backwards compatible change (eg, LVB changes that | ||
3933 | * are just ignored by older versions), the version does not need to be | ||
3934 | * updated. | ||
3935 | */ | ||
3936 | static struct ocfs2_locking_protocol lproto = { | ||
3937 | .lp_max_version = { | ||
3938 | .pv_major = OCFS2_LOCKING_PROTOCOL_MAJOR, | ||
3939 | .pv_minor = OCFS2_LOCKING_PROTOCOL_MINOR, | ||
3940 | }, | ||
3941 | .lp_lock_ast = ocfs2_locking_ast, | ||
3942 | .lp_blocking_ast = ocfs2_blocking_ast, | ||
3943 | .lp_unlock_ast = ocfs2_unlock_ast, | ||
3944 | }; | ||
3945 | |||
3946 | void ocfs2_set_locking_protocol(void) | ||
3947 | { | ||
3948 | ocfs2_stack_glue_set_locking_protocol(&lproto); | ||
3949 | } | ||
3950 | |||
3951 | |||
3952 | static void ocfs2_process_blocked_lock(struct ocfs2_super *osb, | 3990 | static void ocfs2_process_blocked_lock(struct ocfs2_super *osb, |
3953 | struct ocfs2_lock_res *lockres) | 3991 | struct ocfs2_lock_res *lockres) |
3954 | { | 3992 | { |
@@ -3965,7 +4003,7 @@ static void ocfs2_process_blocked_lock(struct ocfs2_super *osb, | |||
3965 | BUG_ON(!lockres); | 4003 | BUG_ON(!lockres); |
3966 | BUG_ON(!lockres->l_ops); | 4004 | BUG_ON(!lockres->l_ops); |
3967 | 4005 | ||
3968 | mlog(0, "lockres %s blocked.\n", lockres->l_name); | 4006 | mlog(ML_BASTS, "lockres %s blocked\n", lockres->l_name); |
3969 | 4007 | ||
3970 | /* Detect whether a lock has been marked as going away while | 4008 | /* Detect whether a lock has been marked as going away while |
3971 | * the downconvert thread was processing other things. A lock can | 4009 | * the downconvert thread was processing other things. A lock can |
@@ -3988,7 +4026,7 @@ unqueue: | |||
3988 | } else | 4026 | } else |
3989 | ocfs2_schedule_blocked_lock(osb, lockres); | 4027 | ocfs2_schedule_blocked_lock(osb, lockres); |
3990 | 4028 | ||
3991 | mlog(0, "lockres %s, requeue = %s.\n", lockres->l_name, | 4029 | mlog(ML_BASTS, "lockres %s, requeue = %s.\n", lockres->l_name, |
3992 | ctl.requeue ? "yes" : "no"); | 4030 | ctl.requeue ? "yes" : "no"); |
3993 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 4031 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
3994 | 4032 | ||
@@ -4010,7 +4048,7 @@ static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb, | |||
4010 | /* Do not schedule a lock for downconvert when it's on | 4048 | /* Do not schedule a lock for downconvert when it's on |
4011 | * the way to destruction - any nodes wanting access | 4049 | * the way to destruction - any nodes wanting access |
4012 | * to the resource will get it soon. */ | 4050 | * to the resource will get it soon. */ |
4013 | mlog(0, "Lockres %s won't be scheduled: flags 0x%lx\n", | 4051 | mlog(ML_BASTS, "lockres %s won't be scheduled: flags 0x%lx\n", |
4014 | lockres->l_name, lockres->l_flags); | 4052 | lockres->l_name, lockres->l_flags); |
4015 | return; | 4053 | return; |
4016 | } | 4054 | } |