Lines Matching +full:mode +full:- +full:recovery

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
4 * Copyright 2004-2011 Red Hat, Inc.
20 #include "recovery.h"
26 * gfs2_update_stats - Update time based stats
52 s64 delta = sample - s->stats[index]; in gfs2_update_stats()
53 s->stats[index] += (delta >> 3); in gfs2_update_stats()
55 s->stats[index] += (s64)(abs(delta) - s->stats[index]) >> 2; in gfs2_update_stats()
59 * gfs2_update_reply_times - Update locking statistics
62 * This assumes that gl->gl_dstamp has been set earlier.
72 * TRY_1CB flags are set are classified as non-blocking. All
78 const unsigned gltype = gl->gl_name.ln_type; in gfs2_update_reply_times()
79 unsigned index = test_bit(GLF_BLOCKING, &gl->gl_flags) ? in gfs2_update_reply_times()
84 rtt = ktime_to_ns(ktime_sub(ktime_get_real(), gl->gl_dstamp)); in gfs2_update_reply_times()
85 lks = this_cpu_ptr(gl->gl_name.ln_sbd->sd_lkstats); in gfs2_update_reply_times()
86 gfs2_update_stats(&gl->gl_stats, index, rtt); /* Local */ in gfs2_update_reply_times()
87 gfs2_update_stats(&lks->lkstats[gltype], index, rtt); /* Global */ in gfs2_update_reply_times()
94 * gfs2_update_request_times - Update locking statistics
97 * The irt (lock inter-request times) measures the average time
105 const unsigned gltype = gl->gl_name.ln_type; in gfs2_update_request_times()
110 dstamp = gl->gl_dstamp; in gfs2_update_request_times()
111 gl->gl_dstamp = ktime_get_real(); in gfs2_update_request_times()
112 irt = ktime_to_ns(ktime_sub(gl->gl_dstamp, dstamp)); in gfs2_update_request_times()
113 lks = this_cpu_ptr(gl->gl_name.ln_sbd->sd_lkstats); in gfs2_update_request_times()
114 gfs2_update_stats(&gl->gl_stats, GFS2_LKS_SIRT, irt); /* Local */ in gfs2_update_request_times()
115 gfs2_update_stats(&lks->lkstats[gltype], GFS2_LKS_SIRT, irt); /* Global */ in gfs2_update_request_times()
122 unsigned ret = gl->gl_state; in gdlm_ast()
125 if (__lockref_is_dead(&gl->gl_lockref) && in gdlm_ast()
126 gl->gl_lksb.sb_status != -DLM_EUNLOCK) in gdlm_ast()
130 BUG_ON(gl->gl_lksb.sb_flags & DLM_SBF_DEMOTED); in gdlm_ast()
132 if ((gl->gl_lksb.sb_flags & DLM_SBF_VALNOTVALID) && gl->gl_lksb.sb_lvbptr) in gdlm_ast()
133 memset(gl->gl_lksb.sb_lvbptr, 0, GDLM_LVB_SIZE); in gdlm_ast()
135 switch (gl->gl_lksb.sb_status) { in gdlm_ast()
136 case -DLM_EUNLOCK: /* Unlocked, so glock can be freed */ in gdlm_ast()
137 if (gl->gl_ops->go_unlocked) in gdlm_ast()
138 gl->gl_ops->go_unlocked(gl); in gdlm_ast()
141 case -DLM_ECANCEL: /* Cancel while getting lock */ in gdlm_ast()
144 case -EAGAIN: /* Try lock fails */ in gdlm_ast()
145 case -EDEADLK: /* Deadlock detected */ in gdlm_ast()
147 case -ETIMEDOUT: /* Canceled due to timeout */ in gdlm_ast()
156 ret = gl->gl_req; in gdlm_ast()
157 if (gl->gl_lksb.sb_flags & DLM_SBF_ALTMODE) { in gdlm_ast()
158 if (gl->gl_req == LM_ST_SHARED) in gdlm_ast()
160 else if (gl->gl_req == LM_ST_DEFERRED) in gdlm_ast()
168 * first successful new (non-conversion) request, we clear this flag to in gdlm_ast()
169 * indicate that a DLM lock exists and that gl->gl_lksb.sb_lkid is the in gdlm_ast()
173 * the gl->gl_lksb.sb_lkid values that come with such requests. in gdlm_ast()
176 clear_bit(GLF_INITIAL, &gl->gl_flags); in gdlm_ast()
180 if (test_bit(GLF_INITIAL, &gl->gl_flags)) in gdlm_ast()
181 gl->gl_lksb.sb_lkid = 0; in gdlm_ast()
185 static void gdlm_bast(void *arg, int mode) in gdlm_bast() argument
189 if (__lockref_is_dead(&gl->gl_lockref)) in gdlm_bast()
192 switch (mode) { in gdlm_bast()
203 fs_err(gl->gl_name.ln_sbd, "unknown bast mode %d\n", mode); in gdlm_bast()
208 /* convert gfs lock-state to dlm lock-mode */
224 return -1; in make_mode()
232 if (gl->gl_lksb.sb_lvbptr) in make_flags()
252 if (!test_bit(GLF_INITIAL, &gl->gl_flags)) { in make_flags()
254 if (test_bit(GLF_BLOCKING, &gl->gl_flags)) in make_flags()
265 *c-- = hex_asc[value & 0x0f]; in gfs2_reverse_hex()
273 struct lm_lockstruct *ls = &gl->gl_name.ln_sbd->sd_lockstruct; in gdlm_lock()
279 req = make_mode(gl->gl_name.ln_sbd, req_state); in gdlm_lock()
283 if (test_bit(GLF_INITIAL, &gl->gl_flags)) { in gdlm_lock()
284 memset(strname, ' ', GDLM_STRNAME_BYTES - 1); in gdlm_lock()
285 strname[GDLM_STRNAME_BYTES - 1] = '\0'; in gdlm_lock()
286 gfs2_reverse_hex(strname + 7, gl->gl_name.ln_type); in gdlm_lock()
287 gfs2_reverse_hex(strname + 23, gl->gl_name.ln_number); in gdlm_lock()
288 gl->gl_dstamp = ktime_get_real(); in gdlm_lock()
297 error = dlm_lock(ls->ls_dlm, req, &gl->gl_lksb, lkf, strname, in gdlm_lock()
298 GDLM_STRNAME_BYTES - 1, 0, gdlm_ast, gl, gdlm_bast); in gdlm_lock()
299 if (error == -EBUSY) { in gdlm_lock()
308 struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; in gdlm_put_lock()
309 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in gdlm_put_lock()
312 BUG_ON(!__lockref_is_dead(&gl->gl_lockref)); in gdlm_put_lock()
314 if (test_bit(GLF_INITIAL, &gl->gl_flags)) { in gdlm_put_lock()
319 clear_bit(GLF_BLOCKING, &gl->gl_flags); in gdlm_put_lock()
325 if (test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) { in gdlm_put_lock()
334 * DLM_LOCK_PW mode, the lock value block (LVB) will be lost. in gdlm_put_lock()
337 if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) && in gdlm_put_lock()
338 (!gl->gl_lksb.sb_lvbptr || gl->gl_state != LM_ST_EXCLUSIVE)) { in gdlm_put_lock()
344 error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK, in gdlm_put_lock()
346 if (error == -EBUSY) { in gdlm_put_lock()
353 gl->gl_name.ln_type, in gdlm_put_lock()
354 (unsigned long long)gl->gl_name.ln_number, error); in gdlm_put_lock()
360 struct lm_lockstruct *ls = &gl->gl_name.ln_sbd->sd_lockstruct; in gdlm_cancel()
361 dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_CANCEL, NULL, gl); in gdlm_cancel()
365 * dlm/gfs2 recovery coordination using dlm_recover callbacks
369 * 2. dlm_controld blocks dlm-kernel locking activity
370 * 3. dlm_controld within dlm-kernel notifies gfs2 (recover_prep)
371 * 4. dlm_controld starts and finishes its own user level recovery
372 * 5. dlm_controld starts dlm-kernel dlm_recoverd to do kernel recovery
374 * 7. dlm_recoverd does its own lock recovery
375 * 8. dlm_recoverd unblocks dlm-kernel locking activity
380 * 13. gfs2_recover provides recovery results to gfs2_control (recovery_result)
384 * - failures during recovery
399 * - more specific gfs2 steps in sequence above
411 * - parallel recovery steps across all nodes
425 * - is there a problem with clearing an lvb bit that should be set
426 * and missing a journal recovery?
437 * require recovery, because the mount in step 4 could not have
441 * and returning. The mount in step 4 waits until the recovery in
444 * - special case of first mounter: first node to mount the fs
447 * and recover any that need recovery before other nodes are allowed
457 * The mounted_lock is demoted to PR when first recovery is done, so
461 * mounter is doing first mount recovery of all journals.
462 * A mounting node needs to acquire control_lock in EX mode before
464 * the first mount recovery, blocking mounts from other nodes, then demotes
472 * do first mounter recovery
473 * mounted_lock EX->PR
474 * control_lock EX->NL, write lvb generation
477 * control_lock EX/NOQUEUE success (if fail -EAGAIN, retry)
478 * mounted_lock EX/NOQUEUE fail -EAGAIN (expected due to other mounters PR)
481 * control_lock EX->NL
484 * - mount during recovery
486 * If a node mounts while others are doing recovery (not first mounter),
495 * - control_lock lvb format
501 * GDLM_LVB_SIZE-8 bytes of jid bit map. If bit N is set, it indicates
502 * that jid N needs recovery.
511 memcpy(lvb_bits, ls->ls_control_lvb, GDLM_LVB_SIZE); in control_lvb_read()
520 memcpy(ls->ls_control_lvb, lvb_bits, GDLM_LVB_SIZE); in control_lvb_write()
522 memcpy(ls->ls_control_lvb, &gen, sizeof(__le32)); in control_lvb_write()
528 GDLM_LVB_SIZE - JID_BITMAP_OFFSET); in all_jid_bits_clear()
534 complete(&ls->ls_sync_wait); in sync_wait_cb()
539 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in sync_unlock()
542 error = dlm_unlock(ls->ls_dlm, lksb->sb_lkid, 0, lksb, ls); in sync_unlock()
545 name, lksb->sb_lkid, error); in sync_unlock()
549 wait_for_completion(&ls->ls_sync_wait); in sync_unlock()
551 if (lksb->sb_status != -DLM_EUNLOCK) { in sync_unlock()
553 name, lksb->sb_lkid, lksb->sb_status); in sync_unlock()
554 return -1; in sync_unlock()
559 static int sync_lock(struct gfs2_sbd *sdp, int mode, uint32_t flags, in sync_lock() argument
562 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in sync_lock()
569 error = dlm_lock(ls->ls_dlm, mode, lksb, flags, in sync_lock()
570 strname, GDLM_STRNAME_BYTES - 1, in sync_lock()
573 fs_err(sdp, "%s lkid %x flags %x mode %d error %d\n", in sync_lock()
574 name, lksb->sb_lkid, flags, mode, error); in sync_lock()
578 wait_for_completion(&ls->ls_sync_wait); in sync_lock()
580 status = lksb->sb_status; in sync_lock()
582 if (status && status != -EAGAIN) { in sync_lock()
583 fs_err(sdp, "%s lkid %x flags %x mode %d status %d\n", in sync_lock()
584 name, lksb->sb_lkid, flags, mode, status); in sync_lock()
592 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in mounted_unlock()
593 return sync_unlock(sdp, &ls->ls_mounted_lksb, "mounted_lock"); in mounted_unlock()
596 static int mounted_lock(struct gfs2_sbd *sdp, int mode, uint32_t flags) in mounted_lock() argument
598 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in mounted_lock()
599 return sync_lock(sdp, mode, flags, GFS2_MOUNTED_LOCK, in mounted_lock()
600 &ls->ls_mounted_lksb, "mounted_lock"); in mounted_lock()
605 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in control_unlock()
606 return sync_unlock(sdp, &ls->ls_control_lksb, "control_lock"); in control_unlock()
609 static int control_lock(struct gfs2_sbd *sdp, int mode, uint32_t flags) in control_lock() argument
611 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in control_lock()
612 return sync_lock(sdp, mode, flags, GFS2_CONTROL_LOCK, in control_lock()
613 &ls->ls_control_lksb, "control_lock"); in control_lock()
617 * remote_withdraw - react to a node withdrawing from the file system
625 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { in remote_withdraw()
626 if (jd->jd_jid == sdp->sd_lockstruct.ls_jid) in remote_withdraw()
641 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in gfs2_control_func()
649 if (test_bit(SDF_REMOTE_WITHDRAW, &sdp->sd_flags)) { in gfs2_control_func()
651 clear_bit(SDF_REMOTE_WITHDRAW, &sdp->sd_flags); in gfs2_control_func()
655 spin_lock(&ls->ls_recover_spin); in gfs2_control_func()
661 * FIRST_MOUNT means this node is doing first mounter recovery, in gfs2_control_func()
662 * for which recovery control is handled by in gfs2_control_func()
665 if (!test_bit(DFL_MOUNT_DONE, &ls->ls_recover_flags) || in gfs2_control_func()
666 test_bit(DFL_FIRST_MOUNT, &ls->ls_recover_flags)) { in gfs2_control_func()
667 spin_unlock(&ls->ls_recover_spin); in gfs2_control_func()
670 block_gen = ls->ls_recover_block; in gfs2_control_func()
671 start_gen = ls->ls_recover_start; in gfs2_control_func()
672 spin_unlock(&ls->ls_recover_spin); in gfs2_control_func()
677 * dlm recovery is in progress and dlm locking is blocked. in gfs2_control_func()
686 * dlm_recoverd adds to recover_submit[] jids needing recovery in gfs2_control_func()
687 * gfs2_recover adds to recover_result[] journal recovery results in gfs2_control_func()
693 * the journal recovery is SUCCESS in gfs2_control_func()
702 control_lvb_read(ls, &lvb_gen, ls->ls_lvb_bits); in gfs2_control_func()
704 spin_lock(&ls->ls_recover_spin); in gfs2_control_func()
705 if (block_gen != ls->ls_recover_block || in gfs2_control_func()
706 start_gen != ls->ls_recover_start) { in gfs2_control_func()
708 start_gen, block_gen, ls->ls_recover_block); in gfs2_control_func()
709 spin_unlock(&ls->ls_recover_spin); in gfs2_control_func()
714 recover_size = ls->ls_recover_size; in gfs2_control_func()
721 * in succession. Only the first will really do recovery, in gfs2_control_func()
723 * recovery. So, another node may have already recovered in gfs2_control_func()
727 if (ls->ls_recover_result[i] != LM_RD_SUCCESS) in gfs2_control_func()
730 ls->ls_recover_result[i] = 0; in gfs2_control_func()
732 if (!test_bit_le(i, ls->ls_lvb_bits + JID_BITMAP_OFFSET)) in gfs2_control_func()
735 __clear_bit_le(i, ls->ls_lvb_bits + JID_BITMAP_OFFSET); in gfs2_control_func()
745 if (!ls->ls_recover_submit[i]) in gfs2_control_func()
747 if (ls->ls_recover_submit[i] < lvb_gen) in gfs2_control_func()
748 ls->ls_recover_submit[i] = 0; in gfs2_control_func()
755 if (!ls->ls_recover_submit[i]) in gfs2_control_func()
757 if (ls->ls_recover_submit[i] < start_gen) { in gfs2_control_func()
758 ls->ls_recover_submit[i] = 0; in gfs2_control_func()
759 __set_bit_le(i, ls->ls_lvb_bits + JID_BITMAP_OFFSET); in gfs2_control_func()
770 spin_unlock(&ls->ls_recover_spin); in gfs2_control_func()
773 control_lvb_write(ls, start_gen, ls->ls_lvb_bits); in gfs2_control_func()
787 * and clear a jid bit in the lvb if the recovery is a success. in gfs2_control_func()
793 if (test_bit_le(i, ls->ls_lvb_bits + JID_BITMAP_OFFSET)) { in gfs2_control_func()
804 * No more jid bits set in lvb, all recovery is done, unblock locks in gfs2_control_func()
809 spin_lock(&ls->ls_recover_spin); in gfs2_control_func()
810 if (ls->ls_recover_block == block_gen && in gfs2_control_func()
811 ls->ls_recover_start == start_gen) { in gfs2_control_func()
812 clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); in gfs2_control_func()
813 spin_unlock(&ls->ls_recover_spin); in gfs2_control_func()
818 start_gen, block_gen, ls->ls_recover_block); in gfs2_control_func()
819 spin_unlock(&ls->ls_recover_spin); in gfs2_control_func()
825 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in control_mount()
831 memset(&ls->ls_mounted_lksb, 0, sizeof(struct dlm_lksb)); in control_mount()
832 memset(&ls->ls_control_lksb, 0, sizeof(struct dlm_lksb)); in control_mount()
833 memset(&ls->ls_control_lvb, 0, GDLM_LVB_SIZE); in control_mount()
834 ls->ls_control_lksb.sb_lvbptr = ls->ls_control_lvb; in control_mount()
835 init_completion(&ls->ls_sync_wait); in control_mount()
837 set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); in control_mount()
855 error = -EINTR; in control_mount()
872 * Other nodes need to do some work in dlm recovery and gfs2_control in control_mount()
886 if (error == -EAGAIN) { in control_mount()
895 * we cannot do the first-mount responsibility it implies: recovery. in control_mount()
897 if (sdp->sd_args.ar_spectator) in control_mount()
904 } else if (error != -EAGAIN) { in control_mount()
914 /* not even -EAGAIN should happen here */ in control_mount()
928 * lvb_gen will be non-zero. in control_mount()
931 control_lvb_read(ls, &lvb_gen, ls->ls_lvb_bits); in control_mount()
936 error = -EINVAL; in control_mount()
941 /* first mounter, keep both EX while doing first recovery */ in control_mount()
942 spin_lock(&ls->ls_recover_spin); in control_mount()
943 clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); in control_mount()
944 set_bit(DFL_MOUNT_DONE, &ls->ls_recover_flags); in control_mount()
945 set_bit(DFL_FIRST_MOUNT, &ls->ls_recover_flags); in control_mount()
946 spin_unlock(&ls->ls_recover_spin); in control_mount()
961 if (!all_jid_bits_clear(ls->ls_lvb_bits)) { in control_mount()
962 /* journals need recovery, wait until all are clear */ in control_mount()
963 fs_info(sdp, "control_mount wait for journal recovery\n"); in control_mount()
967 spin_lock(&ls->ls_recover_spin); in control_mount()
968 block_gen = ls->ls_recover_block; in control_mount()
969 start_gen = ls->ls_recover_start; in control_mount()
970 mount_gen = ls->ls_recover_mount; in control_mount()
974 generation, which might include new recovery bits set */ in control_mount()
975 if (sdp->sd_args.ar_spectator) { in control_mount()
976 fs_info(sdp, "Recovery is required. Waiting for a " in control_mount()
977 "non-spectator to mount.\n"); in control_mount()
983 ls->ls_recover_flags); in control_mount()
985 spin_unlock(&ls->ls_recover_spin); in control_mount()
991 latest recovery generation */ in control_mount()
994 lvb_gen, ls->ls_recover_flags); in control_mount()
995 spin_unlock(&ls->ls_recover_spin); in control_mount()
1000 /* dlm recovery in progress, wait for it to finish */ in control_mount()
1003 lvb_gen, ls->ls_recover_flags); in control_mount()
1004 spin_unlock(&ls->ls_recover_spin); in control_mount()
1008 clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); in control_mount()
1009 set_bit(DFL_MOUNT_DONE, &ls->ls_recover_flags); in control_mount()
1010 memset(ls->ls_recover_submit, 0, ls->ls_recover_size*sizeof(uint32_t)); in control_mount()
1011 memset(ls->ls_recover_result, 0, ls->ls_recover_size*sizeof(uint32_t)); in control_mount()
1012 spin_unlock(&ls->ls_recover_spin); in control_mount()
1023 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in control_first_done()
1028 spin_lock(&ls->ls_recover_spin); in control_first_done()
1029 start_gen = ls->ls_recover_start; in control_first_done()
1030 block_gen = ls->ls_recover_block; in control_first_done()
1032 if (test_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags) || in control_first_done()
1033 !test_bit(DFL_MOUNT_DONE, &ls->ls_recover_flags) || in control_first_done()
1034 !test_bit(DFL_FIRST_MOUNT, &ls->ls_recover_flags)) { in control_first_done()
1037 start_gen, block_gen, ls->ls_recover_flags); in control_first_done()
1038 spin_unlock(&ls->ls_recover_spin); in control_first_done()
1040 return -1; in control_first_done()
1045 * Wait for the end of a dlm recovery cycle to switch from in control_first_done()
1046 * first mounter recovery. We can ignore any recover_slot in control_first_done()
1049 * have not fully mounted, so they don't need recovery. in control_first_done()
1051 spin_unlock(&ls->ls_recover_spin); in control_first_done()
1054 wait_on_bit(&ls->ls_recover_flags, DFL_DLM_RECOVERY, in control_first_done()
1059 clear_bit(DFL_FIRST_MOUNT, &ls->ls_recover_flags); in control_first_done()
1060 set_bit(DFL_FIRST_MOUNT_DONE, &ls->ls_recover_flags); in control_first_done()
1061 memset(ls->ls_recover_submit, 0, ls->ls_recover_size*sizeof(uint32_t)); in control_first_done()
1062 memset(ls->ls_recover_result, 0, ls->ls_recover_size*sizeof(uint32_t)); in control_first_done()
1063 spin_unlock(&ls->ls_recover_spin); in control_first_done()
1065 memset(ls->ls_lvb_bits, 0, GDLM_LVB_SIZE); in control_first_done()
1066 control_lvb_write(ls, start_gen, ls->ls_lvb_bits); in control_first_done()
1082 * gfs2 jids start at 0, so jid = slot - 1)
1090 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in set_recover_size()
1096 if (!ls->ls_lvb_bits) { in set_recover_size()
1097 ls->ls_lvb_bits = kzalloc(GDLM_LVB_SIZE, GFP_NOFS); in set_recover_size()
1098 if (!ls->ls_lvb_bits) in set_recover_size()
1099 return -ENOMEM; in set_recover_size()
1104 if (max_jid < slots[i].slot - 1) in set_recover_size()
1105 max_jid = slots[i].slot - 1; in set_recover_size()
1108 old_size = ls->ls_recover_size; in set_recover_size()
1120 return -ENOMEM; in set_recover_size()
1123 spin_lock(&ls->ls_recover_spin); in set_recover_size()
1124 memcpy(submit, ls->ls_recover_submit, old_size * sizeof(uint32_t)); in set_recover_size()
1125 memcpy(result, ls->ls_recover_result, old_size * sizeof(uint32_t)); in set_recover_size()
1126 kfree(ls->ls_recover_submit); in set_recover_size()
1127 kfree(ls->ls_recover_result); in set_recover_size()
1128 ls->ls_recover_submit = submit; in set_recover_size()
1129 ls->ls_recover_result = result; in set_recover_size()
1130 ls->ls_recover_size = new_size; in set_recover_size()
1131 spin_unlock(&ls->ls_recover_spin); in set_recover_size()
1137 kfree(ls->ls_lvb_bits); in free_recover_size()
1138 kfree(ls->ls_recover_submit); in free_recover_size()
1139 kfree(ls->ls_recover_result); in free_recover_size()
1140 ls->ls_recover_submit = NULL; in free_recover_size()
1141 ls->ls_recover_result = NULL; in free_recover_size()
1142 ls->ls_recover_size = 0; in free_recover_size()
1143 ls->ls_lvb_bits = NULL; in free_recover_size()
1146 /* dlm calls before it does lock recovery */
1151 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in gdlm_recover_prep()
1157 spin_lock(&ls->ls_recover_spin); in gdlm_recover_prep()
1158 ls->ls_recover_block = ls->ls_recover_start; in gdlm_recover_prep()
1159 set_bit(DFL_DLM_RECOVERY, &ls->ls_recover_flags); in gdlm_recover_prep()
1161 if (!test_bit(DFL_MOUNT_DONE, &ls->ls_recover_flags) || in gdlm_recover_prep()
1162 test_bit(DFL_FIRST_MOUNT, &ls->ls_recover_flags)) { in gdlm_recover_prep()
1163 spin_unlock(&ls->ls_recover_spin); in gdlm_recover_prep()
1166 set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); in gdlm_recover_prep()
1167 spin_unlock(&ls->ls_recover_spin); in gdlm_recover_prep()
1176 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in gdlm_recover_slot()
1177 int jid = slot->slot - 1; in gdlm_recover_slot()
1184 spin_lock(&ls->ls_recover_spin); in gdlm_recover_slot()
1185 if (ls->ls_recover_size < jid + 1) { in gdlm_recover_slot()
1187 jid, ls->ls_recover_block, ls->ls_recover_size); in gdlm_recover_slot()
1188 spin_unlock(&ls->ls_recover_spin); in gdlm_recover_slot()
1192 if (ls->ls_recover_submit[jid]) { in gdlm_recover_slot()
1194 jid, ls->ls_recover_block, ls->ls_recover_submit[jid]); in gdlm_recover_slot()
1196 ls->ls_recover_submit[jid] = ls->ls_recover_block; in gdlm_recover_slot()
1197 spin_unlock(&ls->ls_recover_spin); in gdlm_recover_slot()
1200 /* dlm calls after recover_slot and after it completes lock recovery */
1206 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in gdlm_recover_done()
1215 spin_lock(&ls->ls_recover_spin); in gdlm_recover_done()
1216 ls->ls_recover_start = generation; in gdlm_recover_done()
1218 if (!ls->ls_recover_mount) { in gdlm_recover_done()
1219 ls->ls_recover_mount = generation; in gdlm_recover_done()
1220 ls->ls_jid = our_slot - 1; in gdlm_recover_done()
1223 if (!test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) in gdlm_recover_done()
1224 queue_delayed_work(gfs2_control_wq, &sdp->sd_control_work, 0); in gdlm_recover_done()
1226 clear_bit(DFL_DLM_RECOVERY, &ls->ls_recover_flags); in gdlm_recover_done()
1228 wake_up_bit(&ls->ls_recover_flags, DFL_DLM_RECOVERY); in gdlm_recover_done()
1229 spin_unlock(&ls->ls_recover_spin); in gdlm_recover_done()
1232 /* gfs2_recover thread has a journal recovery result */
1237 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in gdlm_recovery_result()
1244 if (test_bit(DFL_NO_DLM_OPS, &ls->ls_recover_flags)) in gdlm_recovery_result()
1247 /* don't care about the recovery of own journal during mount */ in gdlm_recovery_result()
1248 if (jid == ls->ls_jid) in gdlm_recovery_result()
1251 spin_lock(&ls->ls_recover_spin); in gdlm_recovery_result()
1252 if (test_bit(DFL_FIRST_MOUNT, &ls->ls_recover_flags)) { in gdlm_recovery_result()
1253 spin_unlock(&ls->ls_recover_spin); in gdlm_recovery_result()
1256 if (ls->ls_recover_size < jid + 1) { in gdlm_recovery_result()
1258 jid, ls->ls_recover_size); in gdlm_recovery_result()
1259 spin_unlock(&ls->ls_recover_spin); in gdlm_recovery_result()
1266 ls->ls_recover_result[jid] = result; in gdlm_recovery_result()
1272 if (!test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) in gdlm_recovery_result()
1273 queue_delayed_work(gfs2_control_wq, &sdp->sd_control_work, in gdlm_recovery_result()
1275 spin_unlock(&ls->ls_recover_spin); in gdlm_recovery_result()
1286 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in gdlm_mount()
1296 INIT_DELAYED_WORK(&sdp->sd_control_work, gfs2_control_func); in gdlm_mount()
1297 spin_lock_init(&ls->ls_recover_spin); in gdlm_mount()
1298 ls->ls_recover_flags = 0; in gdlm_mount()
1299 ls->ls_recover_mount = 0; in gdlm_mount()
1300 ls->ls_recover_start = 0; in gdlm_mount()
1301 ls->ls_recover_block = 0; in gdlm_mount()
1302 ls->ls_recover_size = 0; in gdlm_mount()
1303 ls->ls_recover_submit = NULL; in gdlm_mount()
1304 ls->ls_recover_result = NULL; in gdlm_mount()
1305 ls->ls_lvb_bits = NULL; in gdlm_mount()
1318 error = -EINVAL; in gdlm_mount()
1322 memcpy(cluster, table, strlen(table) - strlen(fsname)); in gdlm_mount()
1333 &ls->ls_dlm); in gdlm_mount()
1346 set_bit(DFL_NO_DLM_OPS, &ls->ls_recover_flags); in gdlm_mount()
1350 if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags)) { in gdlm_mount()
1352 error = -EINVAL; in gdlm_mount()
1367 ls->ls_first = !!test_bit(DFL_FIRST_MOUNT, &ls->ls_recover_flags); in gdlm_mount()
1368 clear_bit(SDF_NOJOURNALID, &sdp->sd_flags); in gdlm_mount()
1370 wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID); in gdlm_mount()
1374 dlm_release_lockspace(ls->ls_dlm, 2); in gdlm_mount()
1383 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in gdlm_first_done()
1386 if (test_bit(DFL_NO_DLM_OPS, &ls->ls_recover_flags)) in gdlm_first_done()
1396 struct lm_lockstruct *ls = &sdp->sd_lockstruct; in gdlm_unmount()
1398 if (test_bit(DFL_NO_DLM_OPS, &ls->ls_recover_flags)) in gdlm_unmount()
1403 spin_lock(&ls->ls_recover_spin); in gdlm_unmount()
1404 set_bit(DFL_UNMOUNT, &ls->ls_recover_flags); in gdlm_unmount()
1405 spin_unlock(&ls->ls_recover_spin); in gdlm_unmount()
1406 flush_delayed_work(&sdp->sd_control_work); in gdlm_unmount()
1408 /* mounted_lock and control_lock will be purged in dlm recovery */ in gdlm_unmount()
1410 if (ls->ls_dlm) { in gdlm_unmount()
1411 dlm_release_lockspace(ls->ls_dlm, 2); in gdlm_unmount()
1412 ls->ls_dlm = NULL; in gdlm_unmount()