Lines Matching refs:lockres

58 static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres);
59 static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres);
60 static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres);
61 static struct ocfs2_super *ocfs2_get_qinfo_osb(struct ocfs2_lock_res *lockres);
88 static int ocfs2_check_meta_downconvert(struct ocfs2_lock_res *lockres,
90 static void ocfs2_set_meta_lvb(struct ocfs2_lock_res *lockres);
92 static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
95 static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
99 struct ocfs2_lock_res *lockres);
101 static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres);
103 static int ocfs2_check_refcount_downconvert(struct ocfs2_lock_res *lockres,
105 static int ocfs2_refcount_convert_worker(struct ocfs2_lock_res *lockres,
114 struct ocfs2_lock_res *lockres) in ocfs2_dump_meta_lvb_info() argument
116 struct ocfs2_meta_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_dump_meta_lvb_info()
119 lockres->l_name, function, line); in ocfs2_dump_meta_lvb_info()
286 static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres) in ocfs2_is_inode_lock() argument
288 return lockres->l_type == OCFS2_LOCK_TYPE_META || in ocfs2_is_inode_lock()
289 lockres->l_type == OCFS2_LOCK_TYPE_RW || in ocfs2_is_inode_lock()
290 lockres->l_type == OCFS2_LOCK_TYPE_OPEN; in ocfs2_is_inode_lock()
298 static inline struct inode *ocfs2_lock_res_inode(struct ocfs2_lock_res *lockres) in ocfs2_lock_res_inode() argument
300 BUG_ON(!ocfs2_is_inode_lock(lockres)); in ocfs2_lock_res_inode()
302 return (struct inode *) lockres->l_priv; in ocfs2_lock_res_inode()
305 static inline struct ocfs2_dentry_lock *ocfs2_lock_res_dl(struct ocfs2_lock_res *lockres) in ocfs2_lock_res_dl() argument
307 BUG_ON(lockres->l_type != OCFS2_LOCK_TYPE_DENTRY); in ocfs2_lock_res_dl()
309 return (struct ocfs2_dentry_lock *)lockres->l_priv; in ocfs2_lock_res_dl()
312 static inline struct ocfs2_mem_dqinfo *ocfs2_lock_res_qinfo(struct ocfs2_lock_res *lockres) in ocfs2_lock_res_qinfo() argument
314 BUG_ON(lockres->l_type != OCFS2_LOCK_TYPE_QINFO); in ocfs2_lock_res_qinfo()
316 return (struct ocfs2_mem_dqinfo *)lockres->l_priv; in ocfs2_lock_res_qinfo()
325 static inline struct ocfs2_super *ocfs2_get_lockres_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_lockres_osb() argument
327 if (lockres->l_ops->get_osb) in ocfs2_get_lockres_osb()
328 return lockres->l_ops->get_osb(lockres); in ocfs2_get_lockres_osb()
330 return (struct ocfs2_super *)lockres->l_priv; in ocfs2_get_lockres_osb()
334 struct ocfs2_lock_res *lockres,
337 static inline int ocfs2_may_continue_on_blocked_lock(struct ocfs2_lock_res *lockres,
340 struct ocfs2_lock_res *lockres,
343 struct ocfs2_lock_res *lockres, in ocfs2_cluster_unlock() argument
346 __ocfs2_cluster_unlock(osb, lockres, level, _RET_IP_); in ocfs2_cluster_unlock()
349 static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres);
350 static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres);
351 static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres);
352 static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, int level);
354 struct ocfs2_lock_res *lockres);
355 static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres,
368 struct ocfs2_lock_res *lockres);
373 static unsigned int ocfs2_prepare_downconvert(struct ocfs2_lock_res *lockres,
376 struct ocfs2_lock_res *lockres,
381 struct ocfs2_lock_res *lockres);
383 struct ocfs2_lock_res *lockres);
467 static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_refresh() argument
469 lockres->l_lock_refresh++; in ocfs2_track_lock_refresh()
472 static inline void ocfs2_track_lock_wait(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_wait() argument
476 if (list_empty(&lockres->l_mask_waiters)) { in ocfs2_track_lock_wait()
477 lockres->l_lock_wait = 0; in ocfs2_track_lock_wait()
481 mw = list_first_entry(&lockres->l_mask_waiters, in ocfs2_track_lock_wait()
483 lockres->l_lock_wait = in ocfs2_track_lock_wait()
499 static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_refresh() argument
502 static inline void ocfs2_track_lock_wait(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_wait() argument
579 static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_inode_osb() argument
581 struct inode *inode = ocfs2_lock_res_inode(lockres); in ocfs2_get_inode_osb()
586 static struct ocfs2_super *ocfs2_get_qinfo_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_qinfo_osb() argument
588 struct ocfs2_mem_dqinfo *info = lockres->l_priv; in ocfs2_get_qinfo_osb()
593 static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_file_osb() argument
595 struct ocfs2_file_private *fp = lockres->l_priv; in ocfs2_get_file_osb()
600 static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) in ocfs2_get_dentry_lock_ino() argument
604 memcpy(&inode_blkno_be, &lockres->l_name[OCFS2_DENTRY_LOCK_INO_START], in ocfs2_get_dentry_lock_ino()
610 static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_dentry_osb() argument
612 struct ocfs2_dentry_lock *dl = lockres->l_priv; in ocfs2_get_dentry_osb()
623 struct ocfs2_lock_res *lockres = &dl->dl_lockres; in ocfs2_dentry_lock_res_init() local
625 ocfs2_lock_res_init_once(lockres); in ocfs2_dentry_lock_res_init()
642 len = snprintf(lockres->l_name, OCFS2_DENTRY_LOCK_INO_START, in ocfs2_dentry_lock_res_init()
649 memcpy(&lockres->l_name[OCFS2_DENTRY_LOCK_INO_START], &inode_blkno_be, in ocfs2_dentry_lock_res_init()
652 ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), lockres, in ocfs2_dentry_lock_res_init()
699 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_lock_res_init() local
704 ocfs2_lock_res_init_once(lockres); in ocfs2_trim_fs_lock_res_init()
705 ocfs2_build_lock_name(OCFS2_LOCK_TYPE_TRIM_FS, 0, 0, lockres->l_name); in ocfs2_trim_fs_lock_res_init()
706 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_TRIM_FS, in ocfs2_trim_fs_lock_res_init()
712 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_lock_res_uninit() local
714 ocfs2_simple_drop_lockres(osb, lockres); in ocfs2_trim_fs_lock_res_uninit()
715 ocfs2_lock_res_free(lockres); in ocfs2_trim_fs_lock_res_uninit()
729 void ocfs2_file_lock_res_init(struct ocfs2_lock_res *lockres, in ocfs2_file_lock_res_init() argument
735 ocfs2_lock_res_init_once(lockres); in ocfs2_file_lock_res_init()
737 inode->i_generation, lockres->l_name); in ocfs2_file_lock_res_init()
738 ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), lockres, in ocfs2_file_lock_res_init()
741 lockres->l_flags |= OCFS2_LOCK_NOCACHE; in ocfs2_file_lock_res_init()
744 void ocfs2_qinfo_lock_res_init(struct ocfs2_lock_res *lockres, in ocfs2_qinfo_lock_res_init() argument
747 ocfs2_lock_res_init_once(lockres); in ocfs2_qinfo_lock_res_init()
749 0, lockres->l_name); in ocfs2_qinfo_lock_res_init()
750 ocfs2_lock_res_init_common(OCFS2_SB(info->dqi_gi.dqi_sb), lockres, in ocfs2_qinfo_lock_res_init()
755 void ocfs2_refcount_lock_res_init(struct ocfs2_lock_res *lockres, in ocfs2_refcount_lock_res_init() argument
759 ocfs2_lock_res_init_once(lockres); in ocfs2_refcount_lock_res_init()
761 generation, lockres->l_name); in ocfs2_refcount_lock_res_init()
762 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_REFCOUNT, in ocfs2_refcount_lock_res_init()
799 static inline void ocfs2_add_holder(struct ocfs2_lock_res *lockres, in ocfs2_add_holder() argument
805 spin_lock(&lockres->l_lock); in ocfs2_add_holder()
806 list_add_tail(&oh->oh_list, &lockres->l_holders); in ocfs2_add_holder()
807 spin_unlock(&lockres->l_lock); in ocfs2_add_holder()
811 ocfs2_pid_holder(struct ocfs2_lock_res *lockres, in ocfs2_pid_holder() argument
816 spin_lock(&lockres->l_lock); in ocfs2_pid_holder()
817 list_for_each_entry(oh, &lockres->l_holders, oh_list) { in ocfs2_pid_holder()
819 spin_unlock(&lockres->l_lock); in ocfs2_pid_holder()
823 spin_unlock(&lockres->l_lock); in ocfs2_pid_holder()
827 static inline void ocfs2_remove_holder(struct ocfs2_lock_res *lockres, in ocfs2_remove_holder() argument
830 spin_lock(&lockres->l_lock); in ocfs2_remove_holder()
832 spin_unlock(&lockres->l_lock); in ocfs2_remove_holder()
838 static inline void ocfs2_inc_holders(struct ocfs2_lock_res *lockres, in ocfs2_inc_holders() argument
841 BUG_ON(!lockres); in ocfs2_inc_holders()
845 lockres->l_ex_holders++; in ocfs2_inc_holders()
848 lockres->l_ro_holders++; in ocfs2_inc_holders()
855 static inline void ocfs2_dec_holders(struct ocfs2_lock_res *lockres, in ocfs2_dec_holders() argument
858 BUG_ON(!lockres); in ocfs2_dec_holders()
862 BUG_ON(!lockres->l_ex_holders); in ocfs2_dec_holders()
863 lockres->l_ex_holders--; in ocfs2_dec_holders()
866 BUG_ON(!lockres->l_ro_holders); in ocfs2_dec_holders()
867 lockres->l_ro_holders--; in ocfs2_dec_holders()
888 static void lockres_set_flags(struct ocfs2_lock_res *lockres, in lockres_set_flags() argument
893 assert_spin_locked(&lockres->l_lock); in lockres_set_flags()
895 lockres->l_flags = newflags; in lockres_set_flags()
897 list_for_each_entry_safe(mw, tmp, &lockres->l_mask_waiters, mw_item) { in lockres_set_flags()
898 if ((lockres->l_flags & mw->mw_mask) != mw->mw_goal) in lockres_set_flags()
904 ocfs2_track_lock_wait(lockres); in lockres_set_flags()
907 static void lockres_or_flags(struct ocfs2_lock_res *lockres, unsigned long or) in lockres_or_flags() argument
909 lockres_set_flags(lockres, lockres->l_flags | or); in lockres_or_flags()
911 static void lockres_clear_flags(struct ocfs2_lock_res *lockres, in lockres_clear_flags() argument
914 lockres_set_flags(lockres, lockres->l_flags & ~clear); in lockres_clear_flags()
917 static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres) in ocfs2_generic_handle_downconvert_action() argument
919 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); in ocfs2_generic_handle_downconvert_action()
920 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); in ocfs2_generic_handle_downconvert_action()
921 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); in ocfs2_generic_handle_downconvert_action()
922 BUG_ON(lockres->l_blocking <= DLM_LOCK_NL); in ocfs2_generic_handle_downconvert_action()
924 lockres->l_level = lockres->l_requested; in ocfs2_generic_handle_downconvert_action()
925 if (lockres->l_level <= in ocfs2_generic_handle_downconvert_action()
926 ocfs2_highest_compat_lock_level(lockres->l_blocking)) { in ocfs2_generic_handle_downconvert_action()
927 lockres->l_blocking = DLM_LOCK_NL; in ocfs2_generic_handle_downconvert_action()
928 lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_generic_handle_downconvert_action()
930 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_generic_handle_downconvert_action()
933 static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres) in ocfs2_generic_handle_convert_action() argument
935 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); in ocfs2_generic_handle_convert_action()
936 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); in ocfs2_generic_handle_convert_action()
942 if (lockres->l_level == DLM_LOCK_NL && in ocfs2_generic_handle_convert_action()
943 lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) in ocfs2_generic_handle_convert_action()
944 lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); in ocfs2_generic_handle_convert_action()
946 lockres->l_level = lockres->l_requested; in ocfs2_generic_handle_convert_action()
955 if (!(lockres->l_flags & OCFS2_LOCK_NONBLOCK_FINISHED)) in ocfs2_generic_handle_convert_action()
956 lockres_or_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); in ocfs2_generic_handle_convert_action()
958 lockres_clear_flags(lockres, OCFS2_LOCK_NONBLOCK_FINISHED); in ocfs2_generic_handle_convert_action()
960 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_generic_handle_convert_action()
963 static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres) in ocfs2_generic_handle_attach_action() argument
965 BUG_ON((!(lockres->l_flags & OCFS2_LOCK_BUSY))); in ocfs2_generic_handle_attach_action()
966 BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); in ocfs2_generic_handle_attach_action()
968 if (lockres->l_requested > DLM_LOCK_NL && in ocfs2_generic_handle_attach_action()
969 !(lockres->l_flags & OCFS2_LOCK_LOCAL) && in ocfs2_generic_handle_attach_action()
970 lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) in ocfs2_generic_handle_attach_action()
971 lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); in ocfs2_generic_handle_attach_action()
973 lockres->l_level = lockres->l_requested; in ocfs2_generic_handle_attach_action()
974 lockres_or_flags(lockres, OCFS2_LOCK_ATTACHED); in ocfs2_generic_handle_attach_action()
975 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_generic_handle_attach_action()
978 static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, in ocfs2_generic_handle_bast() argument
983 assert_spin_locked(&lockres->l_lock); in ocfs2_generic_handle_bast()
985 if (level > lockres->l_blocking) { in ocfs2_generic_handle_bast()
991 ocfs2_highest_compat_lock_level(lockres->l_blocking)) in ocfs2_generic_handle_bast()
994 lockres->l_blocking = level; in ocfs2_generic_handle_bast()
998 lockres->l_name, level, lockres->l_level, lockres->l_blocking, in ocfs2_generic_handle_bast()
1002 lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_generic_handle_bast()
1066 static void __lockres_clear_pending(struct ocfs2_lock_res *lockres, in __lockres_clear_pending() argument
1070 assert_spin_locked(&lockres->l_lock); in __lockres_clear_pending()
1076 if (!(lockres->l_flags & OCFS2_LOCK_PENDING) || in __lockres_clear_pending()
1077 (lockres->l_pending_gen != generation)) in __lockres_clear_pending()
1080 lockres_clear_flags(lockres, OCFS2_LOCK_PENDING); in __lockres_clear_pending()
1081 lockres->l_pending_gen++; in __lockres_clear_pending()
1087 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) in __lockres_clear_pending()
1092 static void lockres_clear_pending(struct ocfs2_lock_res *lockres, in lockres_clear_pending() argument
1098 spin_lock_irqsave(&lockres->l_lock, flags); in lockres_clear_pending()
1099 __lockres_clear_pending(lockres, generation, osb); in lockres_clear_pending()
1100 spin_unlock_irqrestore(&lockres->l_lock, flags); in lockres_clear_pending()
1103 static unsigned int lockres_set_pending(struct ocfs2_lock_res *lockres) in lockres_set_pending() argument
1105 assert_spin_locked(&lockres->l_lock); in lockres_set_pending()
1106 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); in lockres_set_pending()
1108 lockres_or_flags(lockres, OCFS2_LOCK_PENDING); in lockres_set_pending()
1110 return lockres->l_pending_gen; in lockres_set_pending()
1115 struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); in ocfs2_blocking_ast() local
1116 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); in ocfs2_blocking_ast()
1123 "type %s\n", lockres->l_name, level, lockres->l_level, in ocfs2_blocking_ast()
1124 ocfs2_lock_type_string(lockres->l_type)); in ocfs2_blocking_ast()
1130 if (lockres->l_flags & OCFS2_LOCK_NOCACHE) in ocfs2_blocking_ast()
1133 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_blocking_ast()
1134 needs_downconvert = ocfs2_generic_handle_bast(lockres, level); in ocfs2_blocking_ast()
1136 ocfs2_schedule_blocked_lock(osb, lockres); in ocfs2_blocking_ast()
1137 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_blocking_ast()
1139 wake_up(&lockres->l_event); in ocfs2_blocking_ast()
1146 struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); in ocfs2_locking_ast() local
1147 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); in ocfs2_locking_ast()
1151 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_locking_ast()
1153 status = ocfs2_dlm_lock_status(&lockres->l_lksb); in ocfs2_locking_ast()
1156 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_locking_ast()
1162 lockres->l_name, status); in ocfs2_locking_ast()
1163 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_locking_ast()
1168 "level %d => %d\n", lockres->l_name, lockres->l_action, in ocfs2_locking_ast()
1169 lockres->l_unlock_action, lockres->l_level, lockres->l_requested); in ocfs2_locking_ast()
1171 switch(lockres->l_action) { in ocfs2_locking_ast()
1173 ocfs2_generic_handle_attach_action(lockres); in ocfs2_locking_ast()
1174 lockres_clear_flags(lockres, OCFS2_LOCK_LOCAL); in ocfs2_locking_ast()
1177 ocfs2_generic_handle_convert_action(lockres); in ocfs2_locking_ast()
1180 ocfs2_generic_handle_downconvert_action(lockres); in ocfs2_locking_ast()
1185 lockres->l_name, lockres->l_action, lockres->l_flags, in ocfs2_locking_ast()
1186 lockres->l_unlock_action); in ocfs2_locking_ast()
1192 lockres->l_action = OCFS2_AST_INVALID; in ocfs2_locking_ast()
1195 if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) in ocfs2_locking_ast()
1196 lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; in ocfs2_locking_ast()
1204 __lockres_clear_pending(lockres, lockres->l_pending_gen, osb); in ocfs2_locking_ast()
1206 wake_up(&lockres->l_event); in ocfs2_locking_ast()
1207 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_locking_ast()
1212 struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); in ocfs2_unlock_ast() local
1216 lockres->l_name, lockres->l_unlock_action); in ocfs2_unlock_ast()
1218 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_unlock_ast()
1221 "unlock_action %d\n", error, lockres->l_name, in ocfs2_unlock_ast()
1222 lockres->l_unlock_action); in ocfs2_unlock_ast()
1223 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unlock_ast()
1227 switch(lockres->l_unlock_action) { in ocfs2_unlock_ast()
1229 mlog(0, "Cancel convert success for %s\n", lockres->l_name); in ocfs2_unlock_ast()
1230 lockres->l_action = OCFS2_AST_INVALID; in ocfs2_unlock_ast()
1233 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) in ocfs2_unlock_ast()
1234 ocfs2_wake_downconvert_thread(ocfs2_get_lockres_osb(lockres)); in ocfs2_unlock_ast()
1237 lockres->l_level = DLM_LOCK_IV; in ocfs2_unlock_ast()
1243 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_unlock_ast()
1244 lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; in ocfs2_unlock_ast()
1245 wake_up(&lockres->l_event); in ocfs2_unlock_ast()
1246 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unlock_ast()
1287 static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, in ocfs2_recover_from_dlm_error() argument
1292 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_recover_from_dlm_error()
1293 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_recover_from_dlm_error()
1294 lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); in ocfs2_recover_from_dlm_error()
1296 lockres->l_action = OCFS2_AST_INVALID; in ocfs2_recover_from_dlm_error()
1298 lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; in ocfs2_recover_from_dlm_error()
1299 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_recover_from_dlm_error()
1301 wake_up(&lockres->l_event); in ocfs2_recover_from_dlm_error()
1309 struct ocfs2_lock_res *lockres, in ocfs2_lock_create() argument
1317 mlog(0, "lock %s, level = %d, flags = %u\n", lockres->l_name, level, in ocfs2_lock_create()
1320 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_lock_create()
1321 if ((lockres->l_flags & OCFS2_LOCK_ATTACHED) || in ocfs2_lock_create()
1322 (lockres->l_flags & OCFS2_LOCK_BUSY)) { in ocfs2_lock_create()
1323 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_lock_create()
1327 lockres->l_action = OCFS2_AST_ATTACH; in ocfs2_lock_create()
1328 lockres->l_requested = level; in ocfs2_lock_create()
1329 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_lock_create()
1330 gen = lockres_set_pending(lockres); in ocfs2_lock_create()
1331 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_lock_create()
1335 &lockres->l_lksb, in ocfs2_lock_create()
1337 lockres->l_name, in ocfs2_lock_create()
1339 lockres_clear_pending(lockres, gen, osb); in ocfs2_lock_create()
1341 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); in ocfs2_lock_create()
1342 ocfs2_recover_from_dlm_error(lockres, 1); in ocfs2_lock_create()
1345 mlog(0, "lock %s, return from ocfs2_dlm_lock\n", lockres->l_name); in ocfs2_lock_create()
1351 static inline int ocfs2_check_wait_flag(struct ocfs2_lock_res *lockres, in ocfs2_check_wait_flag() argument
1357 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_check_wait_flag()
1358 ret = lockres->l_flags & flag; in ocfs2_check_wait_flag()
1359 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_check_wait_flag()
1364 static inline void ocfs2_wait_on_busy_lock(struct ocfs2_lock_res *lockres) in ocfs2_wait_on_busy_lock() argument
1367 wait_event(lockres->l_event, in ocfs2_wait_on_busy_lock()
1368 !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_BUSY)); in ocfs2_wait_on_busy_lock()
1371 static inline void ocfs2_wait_on_refreshing_lock(struct ocfs2_lock_res *lockres) in ocfs2_wait_on_refreshing_lock() argument
1374 wait_event(lockres->l_event, in ocfs2_wait_on_refreshing_lock()
1375 !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_REFRESHING)); in ocfs2_wait_on_refreshing_lock()
1381 static inline int ocfs2_may_continue_on_blocked_lock(struct ocfs2_lock_res *lockres, in ocfs2_may_continue_on_blocked_lock() argument
1384 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); in ocfs2_may_continue_on_blocked_lock()
1386 return wanted <= ocfs2_highest_compat_lock_level(lockres->l_blocking); in ocfs2_may_continue_on_blocked_lock()
1404 static void lockres_add_mask_waiter(struct ocfs2_lock_res *lockres, in lockres_add_mask_waiter() argument
1411 assert_spin_locked(&lockres->l_lock); in lockres_add_mask_waiter()
1413 list_add_tail(&mw->mw_item, &lockres->l_mask_waiters); in lockres_add_mask_waiter()
1416 ocfs2_track_lock_wait(lockres); in lockres_add_mask_waiter()
1421 static int __lockres_remove_mask_waiter(struct ocfs2_lock_res *lockres, in __lockres_remove_mask_waiter() argument
1426 assert_spin_locked(&lockres->l_lock); in __lockres_remove_mask_waiter()
1428 if ((lockres->l_flags & mw->mw_mask) != mw->mw_goal) in __lockres_remove_mask_waiter()
1433 ocfs2_track_lock_wait(lockres); in __lockres_remove_mask_waiter()
1439 static int lockres_remove_mask_waiter(struct ocfs2_lock_res *lockres, in lockres_remove_mask_waiter() argument
1445 spin_lock_irqsave(&lockres->l_lock, flags); in lockres_remove_mask_waiter()
1446 ret = __lockres_remove_mask_waiter(lockres, mw); in lockres_remove_mask_waiter()
1447 spin_unlock_irqrestore(&lockres->l_lock, flags); in lockres_remove_mask_waiter()
1454 struct ocfs2_lock_res *lockres) in ocfs2_wait_for_mask_interruptible() argument
1460 lockres_remove_mask_waiter(lockres, mw); in ocfs2_wait_for_mask_interruptible()
1469 struct ocfs2_lock_res *lockres, in __ocfs2_cluster_lock() argument
1485 if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED)) { in __ocfs2_cluster_lock()
1492 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) in __ocfs2_cluster_lock()
1498 spin_lock_irqsave(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1505 mlog_bug_on_msg(lockres->l_flags & OCFS2_LOCK_FREEING, in __ocfs2_cluster_lock()
1507 "0x%lx\n", lockres->l_name, lockres->l_flags); in __ocfs2_cluster_lock()
1512 if (lockres->l_flags & OCFS2_LOCK_BUSY && in __ocfs2_cluster_lock()
1513 level > lockres->l_level) { in __ocfs2_cluster_lock()
1516 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in __ocfs2_cluster_lock()
1521 if (lockres->l_flags & OCFS2_LOCK_UPCONVERT_FINISHING) { in __ocfs2_cluster_lock()
1536 if (level <= lockres->l_level) in __ocfs2_cluster_lock()
1540 if (lockres->l_flags & OCFS2_LOCK_BLOCKED && in __ocfs2_cluster_lock()
1541 !ocfs2_may_continue_on_blocked_lock(lockres, level)) { in __ocfs2_cluster_lock()
1544 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BLOCKED, 0); in __ocfs2_cluster_lock()
1549 if (level > lockres->l_level) { in __ocfs2_cluster_lock()
1557 if (lockres->l_action != OCFS2_AST_INVALID) in __ocfs2_cluster_lock()
1559 lockres->l_name, lockres->l_action); in __ocfs2_cluster_lock()
1561 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { in __ocfs2_cluster_lock()
1562 lockres->l_action = OCFS2_AST_ATTACH; in __ocfs2_cluster_lock()
1565 lockres->l_action = OCFS2_AST_CONVERT; in __ocfs2_cluster_lock()
1569 lockres->l_requested = level; in __ocfs2_cluster_lock()
1570 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in __ocfs2_cluster_lock()
1571 gen = lockres_set_pending(lockres); in __ocfs2_cluster_lock()
1572 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1578 lockres->l_name, lockres->l_level, level); in __ocfs2_cluster_lock()
1583 &lockres->l_lksb, in __ocfs2_cluster_lock()
1585 lockres->l_name, in __ocfs2_cluster_lock()
1587 lockres_clear_pending(lockres, gen, osb); in __ocfs2_cluster_lock()
1592 ret, lockres); in __ocfs2_cluster_lock()
1594 ocfs2_recover_from_dlm_error(lockres, 1); in __ocfs2_cluster_lock()
1600 lockres->l_name); in __ocfs2_cluster_lock()
1612 ocfs2_inc_holders(lockres, level); in __ocfs2_cluster_lock()
1616 lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); in __ocfs2_cluster_lock()
1619 kick_dc = (lockres->l_flags & OCFS2_LOCK_BLOCKED); in __ocfs2_cluster_lock()
1621 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1636 spin_lock_irqsave(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1637 if (__lockres_remove_mask_waiter(lockres, &mw)) { in __ocfs2_cluster_lock()
1639 lockres_or_flags(lockres, in __ocfs2_cluster_lock()
1641 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1644 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1654 ocfs2_update_lock_stats(lockres, level, &mw, ret); in __ocfs2_cluster_lock()
1657 if (!ret && lockres->l_lockdep_map.key != NULL) { in __ocfs2_cluster_lock()
1659 rwsem_acquire_read(&lockres->l_lockdep_map, l_subclass, in __ocfs2_cluster_lock()
1663 rwsem_acquire(&lockres->l_lockdep_map, l_subclass, in __ocfs2_cluster_lock()
1672 struct ocfs2_lock_res *lockres, in ocfs2_cluster_lock() argument
1677 return __ocfs2_cluster_lock(osb, lockres, level, lkm_flags, arg_flags, in ocfs2_cluster_lock()
1683 struct ocfs2_lock_res *lockres, in __ocfs2_cluster_unlock() argument
1689 spin_lock_irqsave(&lockres->l_lock, flags); in __ocfs2_cluster_unlock()
1690 ocfs2_dec_holders(lockres, level); in __ocfs2_cluster_unlock()
1691 ocfs2_downconvert_on_unlock(osb, lockres); in __ocfs2_cluster_unlock()
1692 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_unlock()
1694 if (lockres->l_lockdep_map.key != NULL) in __ocfs2_cluster_unlock()
1695 rwsem_release(&lockres->l_lockdep_map, caller_ip); in __ocfs2_cluster_unlock()
1700 struct ocfs2_lock_res *lockres, in ocfs2_create_new_lock() argument
1708 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_create_new_lock()
1709 BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); in ocfs2_create_new_lock()
1710 lockres_or_flags(lockres, OCFS2_LOCK_LOCAL); in ocfs2_create_new_lock()
1711 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_create_new_lock()
1713 return ocfs2_lock_create(osb, lockres, level, lkm_flags); in ocfs2_create_new_lock()
1766 struct ocfs2_lock_res *lockres; in ocfs2_rw_lock() local
1776 lockres = &OCFS2_I(inode)->ip_rw_lockres; in ocfs2_rw_lock()
1780 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_rw_lock()
1790 struct ocfs2_lock_res *lockres; in ocfs2_try_rw_lock() local
1800 lockres = &OCFS2_I(inode)->ip_rw_lockres; in ocfs2_try_rw_lock()
1804 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0); in ocfs2_try_rw_lock()
1811 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; in ocfs2_rw_unlock() local
1819 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_rw_unlock()
1828 struct ocfs2_lock_res *lockres; in ocfs2_open_lock() local
1837 lockres = &OCFS2_I(inode)->ip_open_lockres; in ocfs2_open_lock()
1839 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_PR, 0, 0); in ocfs2_open_lock()
1850 struct ocfs2_lock_res *lockres; in ocfs2_try_open_lock() local
1866 lockres = &OCFS2_I(inode)->ip_open_lockres; in ocfs2_try_open_lock()
1876 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0); in ocfs2_try_open_lock()
1887 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_open_lockres; in ocfs2_open_unlock() local
1896 if(lockres->l_ro_holders) in ocfs2_open_unlock()
1897 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_PR); in ocfs2_open_unlock()
1898 if(lockres->l_ex_holders) in ocfs2_open_unlock()
1899 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_open_unlock()
1905 static int ocfs2_flock_handle_signal(struct ocfs2_lock_res *lockres, in ocfs2_flock_handle_signal() argument
1909 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); in ocfs2_flock_handle_signal()
1916 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1917 if (lockres->l_flags & OCFS2_LOCK_BUSY) { in ocfs2_flock_handle_signal()
1918 ret = ocfs2_prepare_cancel_convert(osb, lockres); in ocfs2_flock_handle_signal()
1920 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1921 ret = ocfs2_cancel_convert(osb, lockres); in ocfs2_flock_handle_signal()
1928 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_flock_handle_signal()
1929 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1940 if (lockres->l_level == level) in ocfs2_flock_handle_signal()
1944 lockres->l_flags, lockres->l_level, lockres->l_action); in ocfs2_flock_handle_signal()
1946 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1979 struct ocfs2_lock_res *lockres = &fp->fp_flock; in ocfs2_file_lock() local
1985 if ((lockres->l_flags & OCFS2_LOCK_BUSY) || in ocfs2_file_lock()
1986 (lockres->l_level > DLM_LOCK_NL)) { in ocfs2_file_lock()
1989 "level: %u\n", lockres->l_name, lockres->l_flags, in ocfs2_file_lock()
1990 lockres->l_level); in ocfs2_file_lock()
1994 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_file_lock()
1995 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { in ocfs2_file_lock()
1996 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_file_lock()
1997 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_file_lock()
2003 ret = ocfs2_lock_create(osb, lockres, DLM_LOCK_NL, 0); in ocfs2_file_lock()
2014 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_file_lock()
2017 lockres->l_action = OCFS2_AST_CONVERT; in ocfs2_file_lock()
2019 lockres->l_requested = level; in ocfs2_file_lock()
2020 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_file_lock()
2022 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_file_lock()
2023 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_file_lock()
2025 ret = ocfs2_dlm_lock(osb->cconn, level, &lockres->l_lksb, lkm_flags, in ocfs2_file_lock()
2026 lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1); in ocfs2_file_lock()
2029 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); in ocfs2_file_lock()
2033 ocfs2_recover_from_dlm_error(lockres, 1); in ocfs2_file_lock()
2034 lockres_remove_mask_waiter(lockres, &mw); in ocfs2_file_lock()
2038 ret = ocfs2_wait_for_mask_interruptible(&mw, lockres); in ocfs2_file_lock()
2055 ret = ocfs2_flock_handle_signal(lockres, level); in ocfs2_file_lock()
2056 } else if (!ret && (level > lockres->l_level)) { in ocfs2_file_lock()
2065 lockres->l_name, ex, trylock, ret); in ocfs2_file_lock()
2075 struct ocfs2_lock_res *lockres = &fp->fp_flock; in ocfs2_file_unlock() local
2081 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) in ocfs2_file_unlock()
2084 if (lockres->l_level == DLM_LOCK_NL) in ocfs2_file_unlock()
2088 lockres->l_name, lockres->l_flags, lockres->l_level, in ocfs2_file_unlock()
2089 lockres->l_action); in ocfs2_file_unlock()
2091 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_file_unlock()
2095 lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_file_unlock()
2096 lockres->l_blocking = DLM_LOCK_EX; in ocfs2_file_unlock()
2098 gen = ocfs2_prepare_downconvert(lockres, DLM_LOCK_NL); in ocfs2_file_unlock()
2099 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_file_unlock()
2100 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_file_unlock()
2102 ret = ocfs2_downconvert_lock(osb, lockres, DLM_LOCK_NL, 0, gen); in ocfs2_file_unlock()
2114 struct ocfs2_lock_res *lockres) in ocfs2_downconvert_on_unlock() argument
2121 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) { in ocfs2_downconvert_on_unlock()
2122 switch(lockres->l_blocking) { in ocfs2_downconvert_on_unlock()
2124 if (!lockres->l_ex_holders && !lockres->l_ro_holders) in ocfs2_downconvert_on_unlock()
2128 if (!lockres->l_ex_holders) in ocfs2_downconvert_on_unlock()
2163 struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; in __ocfs2_stuff_meta_lvb() local
2166 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in __ocfs2_stuff_meta_lvb()
2196 mlog_meta_lvb(0, lockres); in __ocfs2_stuff_meta_lvb()
2209 struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; in ocfs2_refresh_inode_from_lvb() local
2212 mlog_meta_lvb(0, lockres); in ocfs2_refresh_inode_from_lvb()
2214 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_refresh_inode_from_lvb()
2248 struct ocfs2_lock_res *lockres) in ocfs2_meta_lvb_is_trustable() argument
2250 struct ocfs2_meta_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_meta_lvb_is_trustable()
2252 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) in ocfs2_meta_lvb_is_trustable()
2266 static int ocfs2_should_refresh_lock_res(struct ocfs2_lock_res *lockres) in ocfs2_should_refresh_lock_res() argument
2272 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2273 if (!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) { in ocfs2_should_refresh_lock_res()
2274 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2278 if (lockres->l_flags & OCFS2_LOCK_REFRESHING) { in ocfs2_should_refresh_lock_res()
2279 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2281 ocfs2_wait_on_refreshing_lock(lockres); in ocfs2_should_refresh_lock_res()
2286 lockres_or_flags(lockres, OCFS2_LOCK_REFRESHING); in ocfs2_should_refresh_lock_res()
2287 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2297 static inline void ocfs2_complete_lock_res_refresh(struct ocfs2_lock_res *lockres, in ocfs2_complete_lock_res_refresh() argument
2302 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_complete_lock_res_refresh()
2303 lockres_clear_flags(lockres, OCFS2_LOCK_REFRESHING); in ocfs2_complete_lock_res_refresh()
2305 lockres_clear_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); in ocfs2_complete_lock_res_refresh()
2306 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_complete_lock_res_refresh()
2308 wake_up(&lockres->l_event); in ocfs2_complete_lock_res_refresh()
2317 struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; in ocfs2_inode_lock_update() local
2335 if (!ocfs2_should_refresh_lock_res(lockres)) in ocfs2_inode_lock_update()
2344 if (ocfs2_meta_lvb_is_trustable(inode, lockres)) { in ocfs2_inode_lock_update()
2387 ocfs2_track_lock_refresh(lockres); in ocfs2_inode_lock_update()
2392 ocfs2_complete_lock_res_refresh(lockres, status); in ocfs2_inode_lock_update()
2431 struct ocfs2_lock_res *lockres = NULL; in ocfs2_inode_lock_full_nested() local
2456 lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_lock_full_nested()
2462 status = __ocfs2_cluster_lock(osb, lockres, level, dlm_flags, in ocfs2_inode_lock_full_nested()
2489 if (lockres) in ocfs2_inode_lock_full_nested()
2490 ocfs2_complete_lock_res_refresh(lockres, 0); in ocfs2_inode_lock_full_nested()
2618 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_unlock() local
2627 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_inode_unlock()
2677 struct ocfs2_lock_res *lockres; in ocfs2_inode_lock_tracker() local
2682 lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_lock_tracker()
2683 tmp_oh = ocfs2_pid_holder(lockres, pid); in ocfs2_inode_lock_tracker()
2698 ocfs2_add_holder(lockres, oh); in ocfs2_inode_lock_tracker()
2733 struct ocfs2_lock_res *lockres; in ocfs2_inode_unlock_tracker() local
2735 lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_unlock_tracker()
2743 ocfs2_remove_holder(lockres, oh); in ocfs2_inode_unlock_tracker()
2749 struct ocfs2_lock_res *lockres; in ocfs2_orphan_scan_lock() local
2759 lockres = &osb->osb_orphan_scan.os_lockres; in ocfs2_orphan_scan_lock()
2760 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0); in ocfs2_orphan_scan_lock()
2764 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_orphan_scan_lock()
2765 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) && in ocfs2_orphan_scan_lock()
2776 struct ocfs2_lock_res *lockres; in ocfs2_orphan_scan_unlock() local
2780 lockres = &osb->osb_orphan_scan.os_lockres; in ocfs2_orphan_scan_unlock()
2781 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_orphan_scan_unlock()
2784 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_orphan_scan_unlock()
2793 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; in ocfs2_super_lock() local
2801 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_super_lock()
2811 status = ocfs2_should_refresh_lock_res(lockres); in ocfs2_super_lock()
2815 ocfs2_complete_lock_res_refresh(lockres, status); in ocfs2_super_lock()
2818 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_super_lock()
2821 ocfs2_track_lock_refresh(lockres); in ocfs2_super_lock()
2831 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; in ocfs2_super_unlock() local
2834 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_super_unlock()
2840 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; in ocfs2_rename_lock() local
2848 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0); in ocfs2_rename_lock()
2857 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; in ocfs2_rename_unlock() local
2860 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_rename_unlock()
2866 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres; in ocfs2_nfs_sync_lock() local
2879 status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE, in ocfs2_nfs_sync_lock()
2895 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres; in ocfs2_nfs_sync_unlock() local
2898 ocfs2_cluster_unlock(osb, lockres, in ocfs2_nfs_sync_unlock()
2911 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_lock() local
2922 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, in ocfs2_trim_fs_lock()
2931 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_trim_fs_lock()
2932 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) && in ocfs2_trim_fs_lock()
2951 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_unlock() local
2957 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_trim_fs_unlock()
2967 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_trim_fs_unlock()
3139 struct ocfs2_lock_res *lockres = v; in ocfs2_dlm_seq_show() local
3146 if (!lockres) in ocfs2_dlm_seq_show()
3150 if (!lockres->l_lock_wait && dlm_debug->d_filter_secs) { in ocfs2_dlm_seq_show()
3152 if (lockres->l_lock_prmode.ls_last > in ocfs2_dlm_seq_show()
3153 lockres->l_lock_exmode.ls_last) in ocfs2_dlm_seq_show()
3154 last = lockres->l_lock_prmode.ls_last; in ocfs2_dlm_seq_show()
3156 last = lockres->l_lock_exmode.ls_last; in ocfs2_dlm_seq_show()
3170 if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY) in ocfs2_dlm_seq_show()
3172 lockres->l_name, in ocfs2_dlm_seq_show()
3173 (unsigned int)ocfs2_get_dentry_lock_ino(lockres)); in ocfs2_dlm_seq_show()
3175 seq_printf(m, "%.*s\t", OCFS2_LOCK_ID_MAX_LEN, lockres->l_name); in ocfs2_dlm_seq_show()
3185 lockres->l_level, in ocfs2_dlm_seq_show()
3186 lockres->l_flags, in ocfs2_dlm_seq_show()
3187 lockres->l_action, in ocfs2_dlm_seq_show()
3188 lockres->l_unlock_action, in ocfs2_dlm_seq_show()
3189 lockres->l_ro_holders, in ocfs2_dlm_seq_show()
3190 lockres->l_ex_holders, in ocfs2_dlm_seq_show()
3191 lockres->l_requested, in ocfs2_dlm_seq_show()
3192 lockres->l_blocking); in ocfs2_dlm_seq_show()
3195 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_dlm_seq_show()
3239 lock_num_prmode(lockres), in ocfs2_dlm_seq_show()
3240 lock_num_exmode(lockres), in ocfs2_dlm_seq_show()
3241 lock_num_prmode_failed(lockres), in ocfs2_dlm_seq_show()
3242 lock_num_exmode_failed(lockres), in ocfs2_dlm_seq_show()
3243 lock_total_prmode(lockres), in ocfs2_dlm_seq_show()
3244 lock_total_exmode(lockres), in ocfs2_dlm_seq_show()
3245 lock_max_prmode(lockres), in ocfs2_dlm_seq_show()
3246 lock_max_exmode(lockres), in ocfs2_dlm_seq_show()
3247 lock_refresh(lockres), in ocfs2_dlm_seq_show()
3248 lock_last_prmode(lockres), in ocfs2_dlm_seq_show()
3249 lock_last_exmode(lockres), in ocfs2_dlm_seq_show()
3250 lock_wait(lockres)); in ocfs2_dlm_seq_show()
3415 struct ocfs2_lock_res *lockres) in ocfs2_drop_lock() argument
3422 if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED)) in ocfs2_drop_lock()
3425 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) in ocfs2_drop_lock()
3428 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_drop_lock()
3430 mlog_bug_on_msg(!(lockres->l_flags & OCFS2_LOCK_FREEING), in ocfs2_drop_lock()
3432 lockres->l_name, lockres->l_flags); in ocfs2_drop_lock()
3434 while (lockres->l_flags & OCFS2_LOCK_BUSY) { in ocfs2_drop_lock()
3437 lockres->l_name, lockres->l_flags, lockres->l_action, in ocfs2_drop_lock()
3438 lockres->l_unlock_action); in ocfs2_drop_lock()
3440 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_drop_lock()
3445 ocfs2_wait_on_busy_lock(lockres); in ocfs2_drop_lock()
3447 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_drop_lock()
3450 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) { in ocfs2_drop_lock()
3451 if (lockres->l_flags & OCFS2_LOCK_ATTACHED && in ocfs2_drop_lock()
3452 lockres->l_level == DLM_LOCK_EX && in ocfs2_drop_lock()
3453 !(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) in ocfs2_drop_lock()
3454 lockres->l_ops->set_lvb(lockres); in ocfs2_drop_lock()
3457 if (lockres->l_flags & OCFS2_LOCK_BUSY) in ocfs2_drop_lock()
3459 lockres->l_name); in ocfs2_drop_lock()
3460 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) in ocfs2_drop_lock()
3461 mlog(0, "destroying blocked lock: \"%s\"\n", lockres->l_name); in ocfs2_drop_lock()
3463 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { in ocfs2_drop_lock()
3464 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_drop_lock()
3468 lockres_clear_flags(lockres, OCFS2_LOCK_ATTACHED); in ocfs2_drop_lock()
3472 BUG_ON(lockres->l_action != OCFS2_AST_INVALID); in ocfs2_drop_lock()
3475 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_drop_lock()
3476 lockres->l_unlock_action = OCFS2_UNLOCK_DROP_LOCK; in ocfs2_drop_lock()
3477 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_drop_lock()
3479 mlog(0, "lock %s\n", lockres->l_name); in ocfs2_drop_lock()
3481 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags); in ocfs2_drop_lock()
3483 ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); in ocfs2_drop_lock()
3484 mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); in ocfs2_drop_lock()
3485 ocfs2_dlm_dump_lksb(&lockres->l_lksb); in ocfs2_drop_lock()
3489 lockres->l_name); in ocfs2_drop_lock()
3491 ocfs2_wait_on_busy_lock(lockres); in ocfs2_drop_lock()
3497 struct ocfs2_lock_res *lockres);
3506 struct ocfs2_lock_res *lockres) in ocfs2_mark_lockres_freeing() argument
3514 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3515 lockres->l_flags |= OCFS2_LOCK_FREEING; in ocfs2_mark_lockres_freeing()
3516 if (lockres->l_flags & OCFS2_LOCK_QUEUED && current == osb->dc_task) { in ocfs2_mark_lockres_freeing()
3534 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3536 list_del_init(&lockres->l_blocked_list); in ocfs2_mark_lockres_freeing()
3545 WARN_ON_ONCE(lockres->l_ops->post_unlock); in ocfs2_mark_lockres_freeing()
3547 ocfs2_process_blocked_lock(osb, lockres); in ocfs2_mark_lockres_freeing()
3550 while (lockres->l_flags & OCFS2_LOCK_QUEUED) { in ocfs2_mark_lockres_freeing()
3551 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_QUEUED, 0); in ocfs2_mark_lockres_freeing()
3552 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3554 mlog(0, "Waiting on lockres %s\n", lockres->l_name); in ocfs2_mark_lockres_freeing()
3560 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3562 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3566 struct ocfs2_lock_res *lockres) in ocfs2_simple_drop_lockres() argument
3570 ocfs2_mark_lockres_freeing(osb, lockres); in ocfs2_simple_drop_lockres()
3571 ret = ocfs2_drop_lock(osb, lockres); in ocfs2_simple_drop_lockres()
3615 static unsigned int ocfs2_prepare_downconvert(struct ocfs2_lock_res *lockres, in ocfs2_prepare_downconvert() argument
3618 assert_spin_locked(&lockres->l_lock); in ocfs2_prepare_downconvert()
3620 BUG_ON(lockres->l_blocking <= DLM_LOCK_NL); in ocfs2_prepare_downconvert()
3622 if (lockres->l_level <= new_level) { in ocfs2_prepare_downconvert()
3625 "block %d, pgen %d\n", lockres->l_name, lockres->l_level, in ocfs2_prepare_downconvert()
3626 new_level, list_empty(&lockres->l_blocked_list), in ocfs2_prepare_downconvert()
3627 list_empty(&lockres->l_mask_waiters), lockres->l_type, in ocfs2_prepare_downconvert()
3628 lockres->l_flags, lockres->l_ro_holders, in ocfs2_prepare_downconvert()
3629 lockres->l_ex_holders, lockres->l_action, in ocfs2_prepare_downconvert()
3630 lockres->l_unlock_action, lockres->l_requested, in ocfs2_prepare_downconvert()
3631 lockres->l_blocking, lockres->l_pending_gen); in ocfs2_prepare_downconvert()
3636 lockres->l_name, lockres->l_level, new_level, lockres->l_blocking); in ocfs2_prepare_downconvert()
3638 lockres->l_action = OCFS2_AST_DOWNCONVERT; in ocfs2_prepare_downconvert()
3639 lockres->l_requested = new_level; in ocfs2_prepare_downconvert()
3640 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_prepare_downconvert()
3641 return lockres_set_pending(lockres); in ocfs2_prepare_downconvert()
3645 struct ocfs2_lock_res *lockres, in ocfs2_downconvert_lock() argument
3653 mlog(ML_BASTS, "lockres %s, level %d => %d\n", lockres->l_name, in ocfs2_downconvert_lock()
3654 lockres->l_level, new_level); in ocfs2_downconvert_lock()
3663 lockres->l_ops->flags & LOCK_TYPE_USES_LVB) in ocfs2_downconvert_lock()
3671 &lockres->l_lksb, in ocfs2_downconvert_lock()
3673 lockres->l_name, in ocfs2_downconvert_lock()
3675 lockres_clear_pending(lockres, generation, osb); in ocfs2_downconvert_lock()
3677 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); in ocfs2_downconvert_lock()
3678 ocfs2_recover_from_dlm_error(lockres, 1); in ocfs2_downconvert_lock()
3689 struct ocfs2_lock_res *lockres) in ocfs2_prepare_cancel_convert() argument
3691 assert_spin_locked(&lockres->l_lock); in ocfs2_prepare_cancel_convert()
3693 if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { in ocfs2_prepare_cancel_convert()
3697 mlog(ML_BASTS, "lockres %s, skip convert\n", lockres->l_name); in ocfs2_prepare_cancel_convert()
3702 BUG_ON(lockres->l_action != OCFS2_AST_CONVERT && in ocfs2_prepare_cancel_convert()
3703 lockres->l_action != OCFS2_AST_DOWNCONVERT); in ocfs2_prepare_cancel_convert()
3706 lockres->l_unlock_action = OCFS2_UNLOCK_CANCEL_CONVERT; in ocfs2_prepare_cancel_convert()
3708 mlog_bug_on_msg(!(lockres->l_flags & OCFS2_LOCK_BUSY), in ocfs2_prepare_cancel_convert()
3710 lockres->l_name, lockres->l_flags); in ocfs2_prepare_cancel_convert()
3712 mlog(ML_BASTS, "lockres %s\n", lockres->l_name); in ocfs2_prepare_cancel_convert()
3718 struct ocfs2_lock_res *lockres) in ocfs2_cancel_convert() argument
3722 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, in ocfs2_cancel_convert()
3725 ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); in ocfs2_cancel_convert()
3726 ocfs2_recover_from_dlm_error(lockres, 0); in ocfs2_cancel_convert()
3729 mlog(ML_BASTS, "lockres %s\n", lockres->l_name); in ocfs2_cancel_convert()
3735 struct ocfs2_lock_res *lockres, in ocfs2_unblock_lock() argument
3746 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3752 if (!(lockres->l_flags & OCFS2_LOCK_BLOCKED)) { in ocfs2_unblock_lock()
3753 BUG_ON(lockres->l_blocking != DLM_LOCK_NL); in ocfs2_unblock_lock()
3754 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3759 if (lockres->l_flags & OCFS2_LOCK_BUSY) { in ocfs2_unblock_lock()
3783 if (lockres->l_flags & OCFS2_LOCK_PENDING) { in ocfs2_unblock_lock()
3785 lockres->l_name); in ocfs2_unblock_lock()
3790 ret = ocfs2_prepare_cancel_convert(osb, lockres); in ocfs2_unblock_lock()
3791 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3793 ret = ocfs2_cancel_convert(osb, lockres); in ocfs2_unblock_lock()
3809 if (lockres->l_flags & OCFS2_LOCK_UPCONVERT_FINISHING) in ocfs2_unblock_lock()
3817 if (lockres->l_level == DLM_LOCK_NL) { in ocfs2_unblock_lock()
3818 BUG_ON(lockres->l_ex_holders || lockres->l_ro_holders); in ocfs2_unblock_lock()
3819 mlog(ML_BASTS, "lockres %s, Aborting dc\n", lockres->l_name); in ocfs2_unblock_lock()
3820 lockres->l_blocking = DLM_LOCK_NL; in ocfs2_unblock_lock()
3821 lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_unblock_lock()
3822 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3828 if ((lockres->l_blocking == DLM_LOCK_EX) in ocfs2_unblock_lock()
3829 && (lockres->l_ex_holders || lockres->l_ro_holders)) { in ocfs2_unblock_lock()
3831 lockres->l_name, lockres->l_ex_holders, in ocfs2_unblock_lock()
3832 lockres->l_ro_holders); in ocfs2_unblock_lock()
3838 if (lockres->l_blocking == DLM_LOCK_PR && in ocfs2_unblock_lock()
3839 lockres->l_ex_holders) { in ocfs2_unblock_lock()
3841 lockres->l_name, lockres->l_ex_holders); in ocfs2_unblock_lock()
3849 if ((lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) in ocfs2_unblock_lock()
3850 && (lockres->l_flags & OCFS2_LOCK_REFRESHING)) { in ocfs2_unblock_lock()
3852 lockres->l_name); in ocfs2_unblock_lock()
3856 new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking); in ocfs2_unblock_lock()
3858 if (lockres->l_ops->check_downconvert in ocfs2_unblock_lock()
3859 && !lockres->l_ops->check_downconvert(lockres, new_level)) { in ocfs2_unblock_lock()
3861 lockres->l_name); in ocfs2_unblock_lock()
3868 if (!lockres->l_ops->downconvert_worker) in ocfs2_unblock_lock()
3875 blocking = lockres->l_blocking; in ocfs2_unblock_lock()
3876 level = lockres->l_level; in ocfs2_unblock_lock()
3877 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3879 ctl->unblock_action = lockres->l_ops->downconvert_worker(lockres, blocking); in ocfs2_unblock_lock()
3883 lockres->l_name); in ocfs2_unblock_lock()
3887 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3888 if ((blocking != lockres->l_blocking) || (level != lockres->l_level)) { in ocfs2_unblock_lock()
3892 "Recheck\n", lockres->l_name, blocking, in ocfs2_unblock_lock()
3893 lockres->l_blocking, level, lockres->l_level); in ocfs2_unblock_lock()
3900 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) { in ocfs2_unblock_lock()
3901 if (lockres->l_level == DLM_LOCK_EX) in ocfs2_unblock_lock()
3910 if (set_lvb && !(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) in ocfs2_unblock_lock()
3911 lockres->l_ops->set_lvb(lockres); in ocfs2_unblock_lock()
3914 gen = ocfs2_prepare_downconvert(lockres, new_level); in ocfs2_unblock_lock()
3915 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3916 ret = ocfs2_downconvert_lock(osb, lockres, new_level, set_lvb, in ocfs2_unblock_lock()
3925 lockres->l_name); in ocfs2_unblock_lock()
3936 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3942 static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres, in ocfs2_data_convert_worker() argument
3949 inode = ocfs2_lock_res_inode(lockres); in ocfs2_data_convert_worker()
3995 struct ocfs2_lock_res *lockres, in ocfs2_ci_checkpointed() argument
4001 BUG_ON(lockres->l_level != DLM_LOCK_EX && !checkpointed); in ocfs2_ci_checkpointed()
4010 static int ocfs2_check_meta_downconvert(struct ocfs2_lock_res *lockres, in ocfs2_check_meta_downconvert() argument
4013 struct inode *inode = ocfs2_lock_res_inode(lockres); in ocfs2_check_meta_downconvert()
4015 return ocfs2_ci_checkpointed(INODE_CACHE(inode), lockres, new_level); in ocfs2_check_meta_downconvert()
4018 static void ocfs2_set_meta_lvb(struct ocfs2_lock_res *lockres) in ocfs2_set_meta_lvb() argument
4020 struct inode *inode = ocfs2_lock_res_inode(lockres); in ocfs2_set_meta_lvb()
4031 struct ocfs2_lock_res *lockres) in ocfs2_dentry_post_unlock() argument
4033 struct ocfs2_dentry_lock *dl = ocfs2_lock_res_dl(lockres); in ocfs2_dentry_post_unlock()
4056 static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres, in ocfs2_dentry_convert_worker() argument
4059 struct ocfs2_dentry_lock *dl = ocfs2_lock_res_dl(lockres); in ocfs2_dentry_convert_worker()
4091 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_dentry_convert_worker()
4093 if (!(lockres->l_flags & OCFS2_LOCK_FREEING) in ocfs2_dentry_convert_worker()
4099 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_dentry_convert_worker()
4149 static int ocfs2_check_refcount_downconvert(struct ocfs2_lock_res *lockres, in ocfs2_check_refcount_downconvert() argument
4153 ocfs2_lock_res_refcount_tree(lockres); in ocfs2_check_refcount_downconvert()
4155 return ocfs2_ci_checkpointed(&tree->rf_ci, lockres, new_level); in ocfs2_check_refcount_downconvert()
4158 static int ocfs2_refcount_convert_worker(struct ocfs2_lock_res *lockres, in ocfs2_refcount_convert_worker() argument
4162 ocfs2_lock_res_refcount_tree(lockres); in ocfs2_refcount_convert_worker()
4169 static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres) in ocfs2_set_qinfo_lvb() argument
4172 struct ocfs2_mem_dqinfo *oinfo = ocfs2_lock_res_qinfo(lockres); in ocfs2_set_qinfo_lvb()
4176 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_set_qinfo_lvb()
4188 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock; in ocfs2_qinfo_unlock() local
4193 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_qinfo_unlock()
4200 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock; in ocfs2_refresh_qinfo() local
4201 struct ocfs2_qinfo_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_refresh_qinfo()
4206 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) && in ocfs2_refresh_qinfo()
4232 ocfs2_track_lock_refresh(lockres); in ocfs2_refresh_qinfo()
4243 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock; in ocfs2_qinfo_lock() local
4257 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_qinfo_lock()
4262 if (!ocfs2_should_refresh_lock_res(lockres)) in ocfs2_qinfo_lock()
4268 ocfs2_complete_lock_res_refresh(lockres, status); in ocfs2_qinfo_lock()
4277 struct ocfs2_lock_res *lockres = &ref_tree->rf_lockres; in ocfs2_refcount_lock() local
4278 struct ocfs2_super *osb = lockres->l_priv; in ocfs2_refcount_lock()
4287 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_refcount_lock()
4297 struct ocfs2_lock_res *lockres = &ref_tree->rf_lockres; in ocfs2_refcount_unlock() local
4298 struct ocfs2_super *osb = lockres->l_priv; in ocfs2_refcount_unlock()
4301 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_refcount_unlock()
4305 struct ocfs2_lock_res *lockres) in ocfs2_process_blocked_lock() argument
4315 BUG_ON(!lockres); in ocfs2_process_blocked_lock()
4316 BUG_ON(!lockres->l_ops); in ocfs2_process_blocked_lock()
4318 mlog(ML_BASTS, "lockres %s blocked\n", lockres->l_name); in ocfs2_process_blocked_lock()
4325 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4326 if (lockres->l_flags & OCFS2_LOCK_FREEING) in ocfs2_process_blocked_lock()
4328 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4330 status = ocfs2_unblock_lock(osb, lockres, &ctl); in ocfs2_process_blocked_lock()
4334 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4336 if (lockres->l_flags & OCFS2_LOCK_FREEING || !ctl.requeue) { in ocfs2_process_blocked_lock()
4337 lockres_clear_flags(lockres, OCFS2_LOCK_QUEUED); in ocfs2_process_blocked_lock()
4339 ocfs2_schedule_blocked_lock(osb, lockres); in ocfs2_process_blocked_lock()
4341 mlog(ML_BASTS, "lockres %s, requeue = %s.\n", lockres->l_name, in ocfs2_process_blocked_lock()
4343 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4346 && lockres->l_ops->post_unlock) in ocfs2_process_blocked_lock()
4347 lockres->l_ops->post_unlock(osb, lockres); in ocfs2_process_blocked_lock()
4351 struct ocfs2_lock_res *lockres) in ocfs2_schedule_blocked_lock() argument
4355 assert_spin_locked(&lockres->l_lock); in ocfs2_schedule_blocked_lock()
4357 if (lockres->l_flags & OCFS2_LOCK_FREEING) { in ocfs2_schedule_blocked_lock()
4362 lockres->l_name, lockres->l_flags); in ocfs2_schedule_blocked_lock()
4366 lockres_or_flags(lockres, OCFS2_LOCK_QUEUED); in ocfs2_schedule_blocked_lock()
4369 if (list_empty(&lockres->l_blocked_list)) { in ocfs2_schedule_blocked_lock()
4370 list_add_tail(&lockres->l_blocked_list, in ocfs2_schedule_blocked_lock()
4381 struct ocfs2_lock_res *lockres; in ocfs2_downconvert_thread_do_work() local
4396 lockres = list_entry(osb->blocked_lock_list.next, in ocfs2_downconvert_thread_do_work()
4398 list_del_init(&lockres->l_blocked_list); in ocfs2_downconvert_thread_do_work()
4405 ocfs2_process_blocked_lock(osb, lockres); in ocfs2_downconvert_thread_do_work()