Lines Matching refs:lockres
59 static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres);
60 static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres);
61 static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres);
62 static struct ocfs2_super *ocfs2_get_qinfo_osb(struct ocfs2_lock_res *lockres);
89 static int ocfs2_check_meta_downconvert(struct ocfs2_lock_res *lockres,
91 static void ocfs2_set_meta_lvb(struct ocfs2_lock_res *lockres);
93 static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
96 static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
100 struct ocfs2_lock_res *lockres);
102 static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres);
104 static int ocfs2_check_refcount_downconvert(struct ocfs2_lock_res *lockres,
106 static int ocfs2_refcount_convert_worker(struct ocfs2_lock_res *lockres,
115 struct ocfs2_lock_res *lockres) in ocfs2_dump_meta_lvb_info() argument
117 struct ocfs2_meta_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_dump_meta_lvb_info()
120 lockres->l_name, function, line); in ocfs2_dump_meta_lvb_info()
287 static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres) in ocfs2_is_inode_lock() argument
289 return lockres->l_type == OCFS2_LOCK_TYPE_META || in ocfs2_is_inode_lock()
290 lockres->l_type == OCFS2_LOCK_TYPE_RW || in ocfs2_is_inode_lock()
291 lockres->l_type == OCFS2_LOCK_TYPE_OPEN; in ocfs2_is_inode_lock()
299 static inline struct inode *ocfs2_lock_res_inode(struct ocfs2_lock_res *lockres) in ocfs2_lock_res_inode() argument
301 BUG_ON(!ocfs2_is_inode_lock(lockres)); in ocfs2_lock_res_inode()
303 return (struct inode *) lockres->l_priv; in ocfs2_lock_res_inode()
306 static inline struct ocfs2_dentry_lock *ocfs2_lock_res_dl(struct ocfs2_lock_res *lockres) in ocfs2_lock_res_dl() argument
308 BUG_ON(lockres->l_type != OCFS2_LOCK_TYPE_DENTRY); in ocfs2_lock_res_dl()
310 return (struct ocfs2_dentry_lock *)lockres->l_priv; in ocfs2_lock_res_dl()
313 static inline struct ocfs2_mem_dqinfo *ocfs2_lock_res_qinfo(struct ocfs2_lock_res *lockres) in ocfs2_lock_res_qinfo() argument
315 BUG_ON(lockres->l_type != OCFS2_LOCK_TYPE_QINFO); in ocfs2_lock_res_qinfo()
317 return (struct ocfs2_mem_dqinfo *)lockres->l_priv; in ocfs2_lock_res_qinfo()
326 static inline struct ocfs2_super *ocfs2_get_lockres_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_lockres_osb() argument
328 if (lockres->l_ops->get_osb) in ocfs2_get_lockres_osb()
329 return lockres->l_ops->get_osb(lockres); in ocfs2_get_lockres_osb()
331 return (struct ocfs2_super *)lockres->l_priv; in ocfs2_get_lockres_osb()
335 struct ocfs2_lock_res *lockres,
338 static inline int ocfs2_may_continue_on_blocked_lock(struct ocfs2_lock_res *lockres,
341 struct ocfs2_lock_res *lockres,
344 struct ocfs2_lock_res *lockres, in ocfs2_cluster_unlock() argument
347 __ocfs2_cluster_unlock(osb, lockres, level, _RET_IP_); in ocfs2_cluster_unlock()
350 static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres);
351 static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres);
352 static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres);
353 static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, int level);
355 struct ocfs2_lock_res *lockres);
356 static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres,
369 struct ocfs2_lock_res *lockres);
374 static unsigned int ocfs2_prepare_downconvert(struct ocfs2_lock_res *lockres,
377 struct ocfs2_lock_res *lockres,
382 struct ocfs2_lock_res *lockres);
384 struct ocfs2_lock_res *lockres);
468 static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_refresh() argument
470 lockres->l_lock_refresh++; in ocfs2_track_lock_refresh()
473 static inline void ocfs2_track_lock_wait(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_wait() argument
477 if (list_empty(&lockres->l_mask_waiters)) { in ocfs2_track_lock_wait()
478 lockres->l_lock_wait = 0; in ocfs2_track_lock_wait()
482 mw = list_first_entry(&lockres->l_mask_waiters, in ocfs2_track_lock_wait()
484 lockres->l_lock_wait = in ocfs2_track_lock_wait()
500 static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_refresh() argument
503 static inline void ocfs2_track_lock_wait(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_wait() argument
580 static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_inode_osb() argument
582 struct inode *inode = ocfs2_lock_res_inode(lockres); in ocfs2_get_inode_osb()
587 static struct ocfs2_super *ocfs2_get_qinfo_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_qinfo_osb() argument
589 struct ocfs2_mem_dqinfo *info = lockres->l_priv; in ocfs2_get_qinfo_osb()
594 static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_file_osb() argument
596 struct ocfs2_file_private *fp = lockres->l_priv; in ocfs2_get_file_osb()
601 static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) in ocfs2_get_dentry_lock_ino() argument
605 memcpy(&inode_blkno_be, &lockres->l_name[OCFS2_DENTRY_LOCK_INO_START], in ocfs2_get_dentry_lock_ino()
611 static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_dentry_osb() argument
613 struct ocfs2_dentry_lock *dl = lockres->l_priv; in ocfs2_get_dentry_osb()
624 struct ocfs2_lock_res *lockres = &dl->dl_lockres; in ocfs2_dentry_lock_res_init() local
626 ocfs2_lock_res_init_once(lockres); in ocfs2_dentry_lock_res_init()
643 len = snprintf(lockres->l_name, OCFS2_DENTRY_LOCK_INO_START, in ocfs2_dentry_lock_res_init()
650 memcpy(&lockres->l_name[OCFS2_DENTRY_LOCK_INO_START], &inode_blkno_be, in ocfs2_dentry_lock_res_init()
653 ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), lockres, in ocfs2_dentry_lock_res_init()
700 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_lock_res_init() local
705 ocfs2_lock_res_init_once(lockres); in ocfs2_trim_fs_lock_res_init()
706 ocfs2_build_lock_name(OCFS2_LOCK_TYPE_TRIM_FS, 0, 0, lockres->l_name); in ocfs2_trim_fs_lock_res_init()
707 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_TRIM_FS, in ocfs2_trim_fs_lock_res_init()
713 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_lock_res_uninit() local
715 ocfs2_simple_drop_lockres(osb, lockres); in ocfs2_trim_fs_lock_res_uninit()
716 ocfs2_lock_res_free(lockres); in ocfs2_trim_fs_lock_res_uninit()
730 void ocfs2_file_lock_res_init(struct ocfs2_lock_res *lockres, in ocfs2_file_lock_res_init() argument
736 ocfs2_lock_res_init_once(lockres); in ocfs2_file_lock_res_init()
738 inode->i_generation, lockres->l_name); in ocfs2_file_lock_res_init()
739 ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), lockres, in ocfs2_file_lock_res_init()
742 lockres->l_flags |= OCFS2_LOCK_NOCACHE; in ocfs2_file_lock_res_init()
745 void ocfs2_qinfo_lock_res_init(struct ocfs2_lock_res *lockres, in ocfs2_qinfo_lock_res_init() argument
748 ocfs2_lock_res_init_once(lockres); in ocfs2_qinfo_lock_res_init()
750 0, lockres->l_name); in ocfs2_qinfo_lock_res_init()
751 ocfs2_lock_res_init_common(OCFS2_SB(info->dqi_gi.dqi_sb), lockres, in ocfs2_qinfo_lock_res_init()
756 void ocfs2_refcount_lock_res_init(struct ocfs2_lock_res *lockres, in ocfs2_refcount_lock_res_init() argument
760 ocfs2_lock_res_init_once(lockres); in ocfs2_refcount_lock_res_init()
762 generation, lockres->l_name); in ocfs2_refcount_lock_res_init()
763 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_REFCOUNT, in ocfs2_refcount_lock_res_init()
800 static inline void ocfs2_add_holder(struct ocfs2_lock_res *lockres, in ocfs2_add_holder() argument
806 spin_lock(&lockres->l_lock); in ocfs2_add_holder()
807 list_add_tail(&oh->oh_list, &lockres->l_holders); in ocfs2_add_holder()
808 spin_unlock(&lockres->l_lock); in ocfs2_add_holder()
812 ocfs2_pid_holder(struct ocfs2_lock_res *lockres, in ocfs2_pid_holder() argument
817 spin_lock(&lockres->l_lock); in ocfs2_pid_holder()
818 list_for_each_entry(oh, &lockres->l_holders, oh_list) { in ocfs2_pid_holder()
820 spin_unlock(&lockres->l_lock); in ocfs2_pid_holder()
824 spin_unlock(&lockres->l_lock); in ocfs2_pid_holder()
828 static inline void ocfs2_remove_holder(struct ocfs2_lock_res *lockres, in ocfs2_remove_holder() argument
831 spin_lock(&lockres->l_lock); in ocfs2_remove_holder()
833 spin_unlock(&lockres->l_lock); in ocfs2_remove_holder()
839 static inline void ocfs2_inc_holders(struct ocfs2_lock_res *lockres, in ocfs2_inc_holders() argument
842 BUG_ON(!lockres); in ocfs2_inc_holders()
846 lockres->l_ex_holders++; in ocfs2_inc_holders()
849 lockres->l_ro_holders++; in ocfs2_inc_holders()
856 static inline void ocfs2_dec_holders(struct ocfs2_lock_res *lockres, in ocfs2_dec_holders() argument
859 BUG_ON(!lockres); in ocfs2_dec_holders()
863 BUG_ON(!lockres->l_ex_holders); in ocfs2_dec_holders()
864 lockres->l_ex_holders--; in ocfs2_dec_holders()
867 BUG_ON(!lockres->l_ro_holders); in ocfs2_dec_holders()
868 lockres->l_ro_holders--; in ocfs2_dec_holders()
889 static void lockres_set_flags(struct ocfs2_lock_res *lockres, in lockres_set_flags() argument
894 assert_spin_locked(&lockres->l_lock); in lockres_set_flags()
896 lockres->l_flags = newflags; in lockres_set_flags()
898 list_for_each_entry_safe(mw, tmp, &lockres->l_mask_waiters, mw_item) { in lockres_set_flags()
899 if ((lockres->l_flags & mw->mw_mask) != mw->mw_goal) in lockres_set_flags()
905 ocfs2_track_lock_wait(lockres); in lockres_set_flags()
908 static void lockres_or_flags(struct ocfs2_lock_res *lockres, unsigned long or) in lockres_or_flags() argument
910 lockres_set_flags(lockres, lockres->l_flags | or); in lockres_or_flags()
912 static void lockres_clear_flags(struct ocfs2_lock_res *lockres, in lockres_clear_flags() argument
915 lockres_set_flags(lockres, lockres->l_flags & ~clear); in lockres_clear_flags()
918 static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres) in ocfs2_generic_handle_downconvert_action() argument
920 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); in ocfs2_generic_handle_downconvert_action()
921 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); in ocfs2_generic_handle_downconvert_action()
922 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); in ocfs2_generic_handle_downconvert_action()
923 BUG_ON(lockres->l_blocking <= DLM_LOCK_NL); in ocfs2_generic_handle_downconvert_action()
925 lockres->l_level = lockres->l_requested; in ocfs2_generic_handle_downconvert_action()
926 if (lockres->l_level <= in ocfs2_generic_handle_downconvert_action()
927 ocfs2_highest_compat_lock_level(lockres->l_blocking)) { in ocfs2_generic_handle_downconvert_action()
928 lockres->l_blocking = DLM_LOCK_NL; in ocfs2_generic_handle_downconvert_action()
929 lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_generic_handle_downconvert_action()
931 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_generic_handle_downconvert_action()
934 static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres) in ocfs2_generic_handle_convert_action() argument
936 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); in ocfs2_generic_handle_convert_action()
937 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); in ocfs2_generic_handle_convert_action()
943 if (lockres->l_level == DLM_LOCK_NL && in ocfs2_generic_handle_convert_action()
944 lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) in ocfs2_generic_handle_convert_action()
945 lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); in ocfs2_generic_handle_convert_action()
947 lockres->l_level = lockres->l_requested; in ocfs2_generic_handle_convert_action()
956 if (!(lockres->l_flags & OCFS2_LOCK_NONBLOCK_FINISHED)) in ocfs2_generic_handle_convert_action()
957 lockres_or_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); in ocfs2_generic_handle_convert_action()
959 lockres_clear_flags(lockres, OCFS2_LOCK_NONBLOCK_FINISHED); in ocfs2_generic_handle_convert_action()
961 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_generic_handle_convert_action()
964 static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres) in ocfs2_generic_handle_attach_action() argument
966 BUG_ON((!(lockres->l_flags & OCFS2_LOCK_BUSY))); in ocfs2_generic_handle_attach_action()
967 BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); in ocfs2_generic_handle_attach_action()
969 if (lockres->l_requested > DLM_LOCK_NL && in ocfs2_generic_handle_attach_action()
970 !(lockres->l_flags & OCFS2_LOCK_LOCAL) && in ocfs2_generic_handle_attach_action()
971 lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) in ocfs2_generic_handle_attach_action()
972 lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); in ocfs2_generic_handle_attach_action()
974 lockres->l_level = lockres->l_requested; in ocfs2_generic_handle_attach_action()
975 lockres_or_flags(lockres, OCFS2_LOCK_ATTACHED); in ocfs2_generic_handle_attach_action()
976 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_generic_handle_attach_action()
979 static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, in ocfs2_generic_handle_bast() argument
984 assert_spin_locked(&lockres->l_lock); in ocfs2_generic_handle_bast()
986 if (level > lockres->l_blocking) { in ocfs2_generic_handle_bast()
992 ocfs2_highest_compat_lock_level(lockres->l_blocking)) in ocfs2_generic_handle_bast()
995 lockres->l_blocking = level; in ocfs2_generic_handle_bast()
999 lockres->l_name, level, lockres->l_level, lockres->l_blocking, in ocfs2_generic_handle_bast()
1003 lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_generic_handle_bast()
1067 static void __lockres_clear_pending(struct ocfs2_lock_res *lockres, in __lockres_clear_pending() argument
1071 assert_spin_locked(&lockres->l_lock); in __lockres_clear_pending()
1077 if (!(lockres->l_flags & OCFS2_LOCK_PENDING) || in __lockres_clear_pending()
1078 (lockres->l_pending_gen != generation)) in __lockres_clear_pending()
1081 lockres_clear_flags(lockres, OCFS2_LOCK_PENDING); in __lockres_clear_pending()
1082 lockres->l_pending_gen++; in __lockres_clear_pending()
1088 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) in __lockres_clear_pending()
1093 static void lockres_clear_pending(struct ocfs2_lock_res *lockres, in lockres_clear_pending() argument
1099 spin_lock_irqsave(&lockres->l_lock, flags); in lockres_clear_pending()
1100 __lockres_clear_pending(lockres, generation, osb); in lockres_clear_pending()
1101 spin_unlock_irqrestore(&lockres->l_lock, flags); in lockres_clear_pending()
1104 static unsigned int lockres_set_pending(struct ocfs2_lock_res *lockres) in lockres_set_pending() argument
1106 assert_spin_locked(&lockres->l_lock); in lockres_set_pending()
1107 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); in lockres_set_pending()
1109 lockres_or_flags(lockres, OCFS2_LOCK_PENDING); in lockres_set_pending()
1111 return lockres->l_pending_gen; in lockres_set_pending()
1116 struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); in ocfs2_blocking_ast() local
1117 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); in ocfs2_blocking_ast()
1124 "type %s\n", lockres->l_name, level, lockres->l_level, in ocfs2_blocking_ast()
1125 ocfs2_lock_type_string(lockres->l_type)); in ocfs2_blocking_ast()
1131 if (lockres->l_flags & OCFS2_LOCK_NOCACHE) in ocfs2_blocking_ast()
1134 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_blocking_ast()
1135 needs_downconvert = ocfs2_generic_handle_bast(lockres, level); in ocfs2_blocking_ast()
1137 ocfs2_schedule_blocked_lock(osb, lockres); in ocfs2_blocking_ast()
1138 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_blocking_ast()
1140 wake_up(&lockres->l_event); in ocfs2_blocking_ast()
1147 struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); in ocfs2_locking_ast() local
1148 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); in ocfs2_locking_ast()
1152 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_locking_ast()
1154 status = ocfs2_dlm_lock_status(&lockres->l_lksb); in ocfs2_locking_ast()
1157 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_locking_ast()
1163 lockres->l_name, status); in ocfs2_locking_ast()
1164 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_locking_ast()
1169 "level %d => %d\n", lockres->l_name, lockres->l_action, in ocfs2_locking_ast()
1170 lockres->l_unlock_action, lockres->l_level, lockres->l_requested); in ocfs2_locking_ast()
1172 switch(lockres->l_action) { in ocfs2_locking_ast()
1174 ocfs2_generic_handle_attach_action(lockres); in ocfs2_locking_ast()
1175 lockres_clear_flags(lockres, OCFS2_LOCK_LOCAL); in ocfs2_locking_ast()
1178 ocfs2_generic_handle_convert_action(lockres); in ocfs2_locking_ast()
1181 ocfs2_generic_handle_downconvert_action(lockres); in ocfs2_locking_ast()
1186 lockres->l_name, lockres->l_action, lockres->l_flags, in ocfs2_locking_ast()
1187 lockres->l_unlock_action); in ocfs2_locking_ast()
1193 lockres->l_action = OCFS2_AST_INVALID; in ocfs2_locking_ast()
1196 if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) in ocfs2_locking_ast()
1197 lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; in ocfs2_locking_ast()
1205 __lockres_clear_pending(lockres, lockres->l_pending_gen, osb); in ocfs2_locking_ast()
1207 wake_up(&lockres->l_event); in ocfs2_locking_ast()
1208 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_locking_ast()
1213 struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); in ocfs2_unlock_ast() local
1217 lockres->l_name, lockres->l_unlock_action); in ocfs2_unlock_ast()
1219 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_unlock_ast()
1222 "unlock_action %d\n", error, lockres->l_name, in ocfs2_unlock_ast()
1223 lockres->l_unlock_action); in ocfs2_unlock_ast()
1224 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unlock_ast()
1228 switch(lockres->l_unlock_action) { in ocfs2_unlock_ast()
1230 mlog(0, "Cancel convert success for %s\n", lockres->l_name); in ocfs2_unlock_ast()
1231 lockres->l_action = OCFS2_AST_INVALID; in ocfs2_unlock_ast()
1234 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) in ocfs2_unlock_ast()
1235 ocfs2_wake_downconvert_thread(ocfs2_get_lockres_osb(lockres)); in ocfs2_unlock_ast()
1238 lockres->l_level = DLM_LOCK_IV; in ocfs2_unlock_ast()
1244 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_unlock_ast()
1245 lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; in ocfs2_unlock_ast()
1246 wake_up(&lockres->l_event); in ocfs2_unlock_ast()
1247 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unlock_ast()
1288 static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, in ocfs2_recover_from_dlm_error() argument
1293 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_recover_from_dlm_error()
1294 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_recover_from_dlm_error()
1295 lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); in ocfs2_recover_from_dlm_error()
1297 lockres->l_action = OCFS2_AST_INVALID; in ocfs2_recover_from_dlm_error()
1299 lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; in ocfs2_recover_from_dlm_error()
1300 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_recover_from_dlm_error()
1302 wake_up(&lockres->l_event); in ocfs2_recover_from_dlm_error()
1310 struct ocfs2_lock_res *lockres, in ocfs2_lock_create() argument
1318 mlog(0, "lock %s, level = %d, flags = %u\n", lockres->l_name, level, in ocfs2_lock_create()
1321 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_lock_create()
1322 if ((lockres->l_flags & OCFS2_LOCK_ATTACHED) || in ocfs2_lock_create()
1323 (lockres->l_flags & OCFS2_LOCK_BUSY)) { in ocfs2_lock_create()
1324 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_lock_create()
1328 lockres->l_action = OCFS2_AST_ATTACH; in ocfs2_lock_create()
1329 lockres->l_requested = level; in ocfs2_lock_create()
1330 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_lock_create()
1331 gen = lockres_set_pending(lockres); in ocfs2_lock_create()
1332 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_lock_create()
1336 &lockres->l_lksb, in ocfs2_lock_create()
1338 lockres->l_name, in ocfs2_lock_create()
1340 lockres_clear_pending(lockres, gen, osb); in ocfs2_lock_create()
1342 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); in ocfs2_lock_create()
1343 ocfs2_recover_from_dlm_error(lockres, 1); in ocfs2_lock_create()
1346 mlog(0, "lock %s, return from ocfs2_dlm_lock\n", lockres->l_name); in ocfs2_lock_create()
1352 static inline int ocfs2_check_wait_flag(struct ocfs2_lock_res *lockres, in ocfs2_check_wait_flag() argument
1358 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_check_wait_flag()
1359 ret = lockres->l_flags & flag; in ocfs2_check_wait_flag()
1360 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_check_wait_flag()
1365 static inline void ocfs2_wait_on_busy_lock(struct ocfs2_lock_res *lockres) in ocfs2_wait_on_busy_lock() argument
1368 wait_event(lockres->l_event, in ocfs2_wait_on_busy_lock()
1369 !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_BUSY)); in ocfs2_wait_on_busy_lock()
1372 static inline void ocfs2_wait_on_refreshing_lock(struct ocfs2_lock_res *lockres) in ocfs2_wait_on_refreshing_lock() argument
1375 wait_event(lockres->l_event, in ocfs2_wait_on_refreshing_lock()
1376 !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_REFRESHING)); in ocfs2_wait_on_refreshing_lock()
1382 static inline int ocfs2_may_continue_on_blocked_lock(struct ocfs2_lock_res *lockres, in ocfs2_may_continue_on_blocked_lock() argument
1385 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); in ocfs2_may_continue_on_blocked_lock()
1387 return wanted <= ocfs2_highest_compat_lock_level(lockres->l_blocking); in ocfs2_may_continue_on_blocked_lock()
1405 static void lockres_add_mask_waiter(struct ocfs2_lock_res *lockres, in lockres_add_mask_waiter() argument
1412 assert_spin_locked(&lockres->l_lock); in lockres_add_mask_waiter()
1414 list_add_tail(&mw->mw_item, &lockres->l_mask_waiters); in lockres_add_mask_waiter()
1417 ocfs2_track_lock_wait(lockres); in lockres_add_mask_waiter()
1422 static int __lockres_remove_mask_waiter(struct ocfs2_lock_res *lockres, in __lockres_remove_mask_waiter() argument
1427 assert_spin_locked(&lockres->l_lock); in __lockres_remove_mask_waiter()
1429 if ((lockres->l_flags & mw->mw_mask) != mw->mw_goal) in __lockres_remove_mask_waiter()
1434 ocfs2_track_lock_wait(lockres); in __lockres_remove_mask_waiter()
1440 static int lockres_remove_mask_waiter(struct ocfs2_lock_res *lockres, in lockres_remove_mask_waiter() argument
1446 spin_lock_irqsave(&lockres->l_lock, flags); in lockres_remove_mask_waiter()
1447 ret = __lockres_remove_mask_waiter(lockres, mw); in lockres_remove_mask_waiter()
1448 spin_unlock_irqrestore(&lockres->l_lock, flags); in lockres_remove_mask_waiter()
1455 struct ocfs2_lock_res *lockres) in ocfs2_wait_for_mask_interruptible() argument
1461 lockres_remove_mask_waiter(lockres, mw); in ocfs2_wait_for_mask_interruptible()
1470 struct ocfs2_lock_res *lockres, in __ocfs2_cluster_lock() argument
1486 if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED)) { in __ocfs2_cluster_lock()
1493 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) in __ocfs2_cluster_lock()
1499 spin_lock_irqsave(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1506 mlog_bug_on_msg(lockres->l_flags & OCFS2_LOCK_FREEING, in __ocfs2_cluster_lock()
1508 "0x%lx\n", lockres->l_name, lockres->l_flags); in __ocfs2_cluster_lock()
1513 if (lockres->l_flags & OCFS2_LOCK_BUSY && in __ocfs2_cluster_lock()
1514 level > lockres->l_level) { in __ocfs2_cluster_lock()
1517 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in __ocfs2_cluster_lock()
1522 if (lockres->l_flags & OCFS2_LOCK_UPCONVERT_FINISHING) { in __ocfs2_cluster_lock()
1537 if (level <= lockres->l_level) in __ocfs2_cluster_lock()
1541 if (lockres->l_flags & OCFS2_LOCK_BLOCKED && in __ocfs2_cluster_lock()
1542 !ocfs2_may_continue_on_blocked_lock(lockres, level)) { in __ocfs2_cluster_lock()
1545 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BLOCKED, 0); in __ocfs2_cluster_lock()
1550 if (level > lockres->l_level) { in __ocfs2_cluster_lock()
1558 if (lockres->l_action != OCFS2_AST_INVALID) in __ocfs2_cluster_lock()
1560 lockres->l_name, lockres->l_action); in __ocfs2_cluster_lock()
1562 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { in __ocfs2_cluster_lock()
1563 lockres->l_action = OCFS2_AST_ATTACH; in __ocfs2_cluster_lock()
1566 lockres->l_action = OCFS2_AST_CONVERT; in __ocfs2_cluster_lock()
1570 lockres->l_requested = level; in __ocfs2_cluster_lock()
1571 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in __ocfs2_cluster_lock()
1572 gen = lockres_set_pending(lockres); in __ocfs2_cluster_lock()
1573 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1579 lockres->l_name, lockres->l_level, level); in __ocfs2_cluster_lock()
1584 &lockres->l_lksb, in __ocfs2_cluster_lock()
1586 lockres->l_name, in __ocfs2_cluster_lock()
1588 lockres_clear_pending(lockres, gen, osb); in __ocfs2_cluster_lock()
1593 ret, lockres); in __ocfs2_cluster_lock()
1595 ocfs2_recover_from_dlm_error(lockres, 1); in __ocfs2_cluster_lock()
1601 lockres->l_name); in __ocfs2_cluster_lock()
1613 ocfs2_inc_holders(lockres, level); in __ocfs2_cluster_lock()
1617 lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); in __ocfs2_cluster_lock()
1620 kick_dc = (lockres->l_flags & OCFS2_LOCK_BLOCKED); in __ocfs2_cluster_lock()
1622 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1637 spin_lock_irqsave(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1638 if (__lockres_remove_mask_waiter(lockres, &mw)) { in __ocfs2_cluster_lock()
1640 lockres_or_flags(lockres, in __ocfs2_cluster_lock()
1642 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1645 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1655 ocfs2_update_lock_stats(lockres, level, &mw, ret); in __ocfs2_cluster_lock()
1658 if (!ret && lockres->l_lockdep_map.key != NULL) { in __ocfs2_cluster_lock()
1660 rwsem_acquire_read(&lockres->l_lockdep_map, l_subclass, in __ocfs2_cluster_lock()
1664 rwsem_acquire(&lockres->l_lockdep_map, l_subclass, in __ocfs2_cluster_lock()
1673 struct ocfs2_lock_res *lockres, in ocfs2_cluster_lock() argument
1678 return __ocfs2_cluster_lock(osb, lockres, level, lkm_flags, arg_flags, in ocfs2_cluster_lock()
1684 struct ocfs2_lock_res *lockres, in __ocfs2_cluster_unlock() argument
1690 spin_lock_irqsave(&lockres->l_lock, flags); in __ocfs2_cluster_unlock()
1691 ocfs2_dec_holders(lockres, level); in __ocfs2_cluster_unlock()
1692 ocfs2_downconvert_on_unlock(osb, lockres); in __ocfs2_cluster_unlock()
1693 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_unlock()
1695 if (lockres->l_lockdep_map.key != NULL) in __ocfs2_cluster_unlock()
1696 rwsem_release(&lockres->l_lockdep_map, caller_ip); in __ocfs2_cluster_unlock()
1701 struct ocfs2_lock_res *lockres, in ocfs2_create_new_lock() argument
1709 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_create_new_lock()
1710 BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); in ocfs2_create_new_lock()
1711 lockres_or_flags(lockres, OCFS2_LOCK_LOCAL); in ocfs2_create_new_lock()
1712 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_create_new_lock()
1714 return ocfs2_lock_create(osb, lockres, level, lkm_flags); in ocfs2_create_new_lock()
1767 struct ocfs2_lock_res *lockres; in ocfs2_rw_lock() local
1777 lockres = &OCFS2_I(inode)->ip_rw_lockres; in ocfs2_rw_lock()
1781 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_rw_lock()
1791 struct ocfs2_lock_res *lockres; in ocfs2_try_rw_lock() local
1801 lockres = &OCFS2_I(inode)->ip_rw_lockres; in ocfs2_try_rw_lock()
1805 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0); in ocfs2_try_rw_lock()
1812 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; in ocfs2_rw_unlock() local
1820 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_rw_unlock()
1829 struct ocfs2_lock_res *lockres; in ocfs2_open_lock() local
1838 lockres = &OCFS2_I(inode)->ip_open_lockres; in ocfs2_open_lock()
1840 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_PR, 0, 0); in ocfs2_open_lock()
1851 struct ocfs2_lock_res *lockres; in ocfs2_try_open_lock() local
1867 lockres = &OCFS2_I(inode)->ip_open_lockres; in ocfs2_try_open_lock()
1877 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0); in ocfs2_try_open_lock()
1888 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_open_lockres; in ocfs2_open_unlock() local
1897 if(lockres->l_ro_holders) in ocfs2_open_unlock()
1898 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_PR); in ocfs2_open_unlock()
1899 if(lockres->l_ex_holders) in ocfs2_open_unlock()
1900 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_open_unlock()
1906 static int ocfs2_flock_handle_signal(struct ocfs2_lock_res *lockres, in ocfs2_flock_handle_signal() argument
1910 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); in ocfs2_flock_handle_signal()
1917 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1918 if (lockres->l_flags & OCFS2_LOCK_BUSY) { in ocfs2_flock_handle_signal()
1919 ret = ocfs2_prepare_cancel_convert(osb, lockres); in ocfs2_flock_handle_signal()
1921 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1922 ret = ocfs2_cancel_convert(osb, lockres); in ocfs2_flock_handle_signal()
1929 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_flock_handle_signal()
1930 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1941 if (lockres->l_level == level) in ocfs2_flock_handle_signal()
1945 lockres->l_flags, lockres->l_level, lockres->l_action); in ocfs2_flock_handle_signal()
1947 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1980 struct ocfs2_lock_res *lockres = &fp->fp_flock; in ocfs2_file_lock() local
1986 if ((lockres->l_flags & OCFS2_LOCK_BUSY) || in ocfs2_file_lock()
1987 (lockres->l_level > DLM_LOCK_NL)) { in ocfs2_file_lock()
1990 "level: %u\n", lockres->l_name, lockres->l_flags, in ocfs2_file_lock()
1991 lockres->l_level); in ocfs2_file_lock()
1995 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_file_lock()
1996 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { in ocfs2_file_lock()
1997 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_file_lock()
1998 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_file_lock()
2004 ret = ocfs2_lock_create(osb, lockres, DLM_LOCK_NL, 0); in ocfs2_file_lock()
2015 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_file_lock()
2018 lockres->l_action = OCFS2_AST_CONVERT; in ocfs2_file_lock()
2020 lockres->l_requested = level; in ocfs2_file_lock()
2021 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_file_lock()
2023 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_file_lock()
2024 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_file_lock()
2026 ret = ocfs2_dlm_lock(osb->cconn, level, &lockres->l_lksb, lkm_flags, in ocfs2_file_lock()
2027 lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1); in ocfs2_file_lock()
2030 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); in ocfs2_file_lock()
2034 ocfs2_recover_from_dlm_error(lockres, 1); in ocfs2_file_lock()
2035 lockres_remove_mask_waiter(lockres, &mw); in ocfs2_file_lock()
2039 ret = ocfs2_wait_for_mask_interruptible(&mw, lockres); in ocfs2_file_lock()
2056 ret = ocfs2_flock_handle_signal(lockres, level); in ocfs2_file_lock()
2057 } else if (!ret && (level > lockres->l_level)) { in ocfs2_file_lock()
2066 lockres->l_name, ex, trylock, ret); in ocfs2_file_lock()
2076 struct ocfs2_lock_res *lockres = &fp->fp_flock; in ocfs2_file_unlock() local
2082 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) in ocfs2_file_unlock()
2085 if (lockres->l_level == DLM_LOCK_NL) in ocfs2_file_unlock()
2089 lockres->l_name, lockres->l_flags, lockres->l_level, in ocfs2_file_unlock()
2090 lockres->l_action); in ocfs2_file_unlock()
2092 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_file_unlock()
2096 lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_file_unlock()
2097 lockres->l_blocking = DLM_LOCK_EX; in ocfs2_file_unlock()
2099 gen = ocfs2_prepare_downconvert(lockres, DLM_LOCK_NL); in ocfs2_file_unlock()
2100 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_file_unlock()
2101 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_file_unlock()
2103 ret = ocfs2_downconvert_lock(osb, lockres, DLM_LOCK_NL, 0, gen); in ocfs2_file_unlock()
2115 struct ocfs2_lock_res *lockres) in ocfs2_downconvert_on_unlock() argument
2122 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) { in ocfs2_downconvert_on_unlock()
2123 switch(lockres->l_blocking) { in ocfs2_downconvert_on_unlock()
2125 if (!lockres->l_ex_holders && !lockres->l_ro_holders) in ocfs2_downconvert_on_unlock()
2129 if (!lockres->l_ex_holders) in ocfs2_downconvert_on_unlock()
2164 struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; in __ocfs2_stuff_meta_lvb() local
2167 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in __ocfs2_stuff_meta_lvb()
2197 mlog_meta_lvb(0, lockres); in __ocfs2_stuff_meta_lvb()
2210 struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; in ocfs2_refresh_inode_from_lvb() local
2213 mlog_meta_lvb(0, lockres); in ocfs2_refresh_inode_from_lvb()
2215 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_refresh_inode_from_lvb()
2246 struct ocfs2_lock_res *lockres) in ocfs2_meta_lvb_is_trustable() argument
2248 struct ocfs2_meta_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_meta_lvb_is_trustable()
2250 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) in ocfs2_meta_lvb_is_trustable()
2264 static int ocfs2_should_refresh_lock_res(struct ocfs2_lock_res *lockres) in ocfs2_should_refresh_lock_res() argument
2270 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2271 if (!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) { in ocfs2_should_refresh_lock_res()
2272 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2276 if (lockres->l_flags & OCFS2_LOCK_REFRESHING) { in ocfs2_should_refresh_lock_res()
2277 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2279 ocfs2_wait_on_refreshing_lock(lockres); in ocfs2_should_refresh_lock_res()
2284 lockres_or_flags(lockres, OCFS2_LOCK_REFRESHING); in ocfs2_should_refresh_lock_res()
2285 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2295 static inline void ocfs2_complete_lock_res_refresh(struct ocfs2_lock_res *lockres, in ocfs2_complete_lock_res_refresh() argument
2300 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_complete_lock_res_refresh()
2301 lockres_clear_flags(lockres, OCFS2_LOCK_REFRESHING); in ocfs2_complete_lock_res_refresh()
2303 lockres_clear_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); in ocfs2_complete_lock_res_refresh()
2304 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_complete_lock_res_refresh()
2306 wake_up(&lockres->l_event); in ocfs2_complete_lock_res_refresh()
2315 struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; in ocfs2_inode_lock_update() local
2333 if (!ocfs2_should_refresh_lock_res(lockres)) in ocfs2_inode_lock_update()
2342 if (ocfs2_meta_lvb_is_trustable(inode, lockres)) { in ocfs2_inode_lock_update()
2380 ocfs2_track_lock_refresh(lockres); in ocfs2_inode_lock_update()
2385 ocfs2_complete_lock_res_refresh(lockres, status); in ocfs2_inode_lock_update()
2424 struct ocfs2_lock_res *lockres = NULL; in ocfs2_inode_lock_full_nested() local
2449 lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_lock_full_nested()
2455 status = __ocfs2_cluster_lock(osb, lockres, level, dlm_flags, in ocfs2_inode_lock_full_nested()
2482 if (lockres) in ocfs2_inode_lock_full_nested()
2483 ocfs2_complete_lock_res_refresh(lockres, 0); in ocfs2_inode_lock_full_nested()
2611 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_unlock() local
2620 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_inode_unlock()
2670 struct ocfs2_lock_res *lockres; in ocfs2_inode_lock_tracker() local
2675 lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_lock_tracker()
2676 tmp_oh = ocfs2_pid_holder(lockres, pid); in ocfs2_inode_lock_tracker()
2691 ocfs2_add_holder(lockres, oh); in ocfs2_inode_lock_tracker()
2726 struct ocfs2_lock_res *lockres; in ocfs2_inode_unlock_tracker() local
2728 lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_unlock_tracker()
2736 ocfs2_remove_holder(lockres, oh); in ocfs2_inode_unlock_tracker()
2742 struct ocfs2_lock_res *lockres; in ocfs2_orphan_scan_lock() local
2752 lockres = &osb->osb_orphan_scan.os_lockres; in ocfs2_orphan_scan_lock()
2753 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0); in ocfs2_orphan_scan_lock()
2757 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_orphan_scan_lock()
2758 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) && in ocfs2_orphan_scan_lock()
2769 struct ocfs2_lock_res *lockres; in ocfs2_orphan_scan_unlock() local
2773 lockres = &osb->osb_orphan_scan.os_lockres; in ocfs2_orphan_scan_unlock()
2774 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_orphan_scan_unlock()
2777 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_orphan_scan_unlock()
2786 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; in ocfs2_super_lock() local
2794 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_super_lock()
2804 status = ocfs2_should_refresh_lock_res(lockres); in ocfs2_super_lock()
2808 ocfs2_complete_lock_res_refresh(lockres, status); in ocfs2_super_lock()
2811 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_super_lock()
2814 ocfs2_track_lock_refresh(lockres); in ocfs2_super_lock()
2824 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; in ocfs2_super_unlock() local
2827 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_super_unlock()
2833 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; in ocfs2_rename_lock() local
2841 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0); in ocfs2_rename_lock()
2850 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; in ocfs2_rename_unlock() local
2853 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_rename_unlock()
2859 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres; in ocfs2_nfs_sync_lock() local
2872 status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE, in ocfs2_nfs_sync_lock()
2888 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres; in ocfs2_nfs_sync_unlock() local
2891 ocfs2_cluster_unlock(osb, lockres, in ocfs2_nfs_sync_unlock()
2904 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_lock() local
2915 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, in ocfs2_trim_fs_lock()
2924 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_trim_fs_lock()
2925 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) && in ocfs2_trim_fs_lock()
2944 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_unlock() local
2950 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_trim_fs_unlock()
2960 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_trim_fs_unlock()
3132 struct ocfs2_lock_res *lockres = v; in ocfs2_dlm_seq_show() local
3139 if (!lockres) in ocfs2_dlm_seq_show()
3143 if (!lockres->l_lock_wait && dlm_debug->d_filter_secs) { in ocfs2_dlm_seq_show()
3145 if (lockres->l_lock_prmode.ls_last > in ocfs2_dlm_seq_show()
3146 lockres->l_lock_exmode.ls_last) in ocfs2_dlm_seq_show()
3147 last = lockres->l_lock_prmode.ls_last; in ocfs2_dlm_seq_show()
3149 last = lockres->l_lock_exmode.ls_last; in ocfs2_dlm_seq_show()
3163 if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY) in ocfs2_dlm_seq_show()
3165 lockres->l_name, in ocfs2_dlm_seq_show()
3166 (unsigned int)ocfs2_get_dentry_lock_ino(lockres)); in ocfs2_dlm_seq_show()
3168 seq_printf(m, "%.*s\t", OCFS2_LOCK_ID_MAX_LEN, lockres->l_name); in ocfs2_dlm_seq_show()
3178 lockres->l_level, in ocfs2_dlm_seq_show()
3179 lockres->l_flags, in ocfs2_dlm_seq_show()
3180 lockres->l_action, in ocfs2_dlm_seq_show()
3181 lockres->l_unlock_action, in ocfs2_dlm_seq_show()
3182 lockres->l_ro_holders, in ocfs2_dlm_seq_show()
3183 lockres->l_ex_holders, in ocfs2_dlm_seq_show()
3184 lockres->l_requested, in ocfs2_dlm_seq_show()
3185 lockres->l_blocking); in ocfs2_dlm_seq_show()
3188 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_dlm_seq_show()
3232 lock_num_prmode(lockres), in ocfs2_dlm_seq_show()
3233 lock_num_exmode(lockres), in ocfs2_dlm_seq_show()
3234 lock_num_prmode_failed(lockres), in ocfs2_dlm_seq_show()
3235 lock_num_exmode_failed(lockres), in ocfs2_dlm_seq_show()
3236 lock_total_prmode(lockres), in ocfs2_dlm_seq_show()
3237 lock_total_exmode(lockres), in ocfs2_dlm_seq_show()
3238 lock_max_prmode(lockres), in ocfs2_dlm_seq_show()
3239 lock_max_exmode(lockres), in ocfs2_dlm_seq_show()
3240 lock_refresh(lockres), in ocfs2_dlm_seq_show()
3241 lock_last_prmode(lockres), in ocfs2_dlm_seq_show()
3242 lock_last_exmode(lockres), in ocfs2_dlm_seq_show()
3243 lock_wait(lockres)); in ocfs2_dlm_seq_show()
3406 struct ocfs2_lock_res *lockres) in ocfs2_drop_lock() argument
3413 if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED)) in ocfs2_drop_lock()
3416 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) in ocfs2_drop_lock()
3419 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_drop_lock()
3421 mlog_bug_on_msg(!(lockres->l_flags & OCFS2_LOCK_FREEING), in ocfs2_drop_lock()
3423 lockres->l_name, lockres->l_flags); in ocfs2_drop_lock()
3425 while (lockres->l_flags & OCFS2_LOCK_BUSY) { in ocfs2_drop_lock()
3428 lockres->l_name, lockres->l_flags, lockres->l_action, in ocfs2_drop_lock()
3429 lockres->l_unlock_action); in ocfs2_drop_lock()
3431 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_drop_lock()
3436 ocfs2_wait_on_busy_lock(lockres); in ocfs2_drop_lock()
3438 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_drop_lock()
3441 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) { in ocfs2_drop_lock()
3442 if (lockres->l_flags & OCFS2_LOCK_ATTACHED && in ocfs2_drop_lock()
3443 lockres->l_level == DLM_LOCK_EX && in ocfs2_drop_lock()
3444 !(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) in ocfs2_drop_lock()
3445 lockres->l_ops->set_lvb(lockres); in ocfs2_drop_lock()
3448 if (lockres->l_flags & OCFS2_LOCK_BUSY) in ocfs2_drop_lock()
3450 lockres->l_name); in ocfs2_drop_lock()
3451 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) in ocfs2_drop_lock()
3452 mlog(0, "destroying blocked lock: \"%s\"\n", lockres->l_name); in ocfs2_drop_lock()
3454 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { in ocfs2_drop_lock()
3455 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_drop_lock()
3459 lockres_clear_flags(lockres, OCFS2_LOCK_ATTACHED); in ocfs2_drop_lock()
3463 BUG_ON(lockres->l_action != OCFS2_AST_INVALID); in ocfs2_drop_lock()
3466 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_drop_lock()
3467 lockres->l_unlock_action = OCFS2_UNLOCK_DROP_LOCK; in ocfs2_drop_lock()
3468 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_drop_lock()
3470 mlog(0, "lock %s\n", lockres->l_name); in ocfs2_drop_lock()
3472 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags); in ocfs2_drop_lock()
3474 ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); in ocfs2_drop_lock()
3475 mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); in ocfs2_drop_lock()
3476 ocfs2_dlm_dump_lksb(&lockres->l_lksb); in ocfs2_drop_lock()
3480 lockres->l_name); in ocfs2_drop_lock()
3482 ocfs2_wait_on_busy_lock(lockres); in ocfs2_drop_lock()
3488 struct ocfs2_lock_res *lockres);
3497 struct ocfs2_lock_res *lockres) in ocfs2_mark_lockres_freeing() argument
3505 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3506 lockres->l_flags |= OCFS2_LOCK_FREEING; in ocfs2_mark_lockres_freeing()
3507 if (lockres->l_flags & OCFS2_LOCK_QUEUED && current == osb->dc_task) { in ocfs2_mark_lockres_freeing()
3525 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3527 list_del_init(&lockres->l_blocked_list); in ocfs2_mark_lockres_freeing()
3536 WARN_ON_ONCE(lockres->l_ops->post_unlock); in ocfs2_mark_lockres_freeing()
3538 ocfs2_process_blocked_lock(osb, lockres); in ocfs2_mark_lockres_freeing()
3541 while (lockres->l_flags & OCFS2_LOCK_QUEUED) { in ocfs2_mark_lockres_freeing()
3542 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_QUEUED, 0); in ocfs2_mark_lockres_freeing()
3543 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3545 mlog(0, "Waiting on lockres %s\n", lockres->l_name); in ocfs2_mark_lockres_freeing()
3551 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3553 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3557 struct ocfs2_lock_res *lockres) in ocfs2_simple_drop_lockres() argument
3561 ocfs2_mark_lockres_freeing(osb, lockres); in ocfs2_simple_drop_lockres()
3562 ret = ocfs2_drop_lock(osb, lockres); in ocfs2_simple_drop_lockres()
3606 static unsigned int ocfs2_prepare_downconvert(struct ocfs2_lock_res *lockres, in ocfs2_prepare_downconvert() argument
3609 assert_spin_locked(&lockres->l_lock); in ocfs2_prepare_downconvert()
3611 BUG_ON(lockres->l_blocking <= DLM_LOCK_NL); in ocfs2_prepare_downconvert()
3613 if (lockres->l_level <= new_level) { in ocfs2_prepare_downconvert()
3616 "block %d, pgen %d\n", lockres->l_name, lockres->l_level, in ocfs2_prepare_downconvert()
3617 new_level, list_empty(&lockres->l_blocked_list), in ocfs2_prepare_downconvert()
3618 list_empty(&lockres->l_mask_waiters), lockres->l_type, in ocfs2_prepare_downconvert()
3619 lockres->l_flags, lockres->l_ro_holders, in ocfs2_prepare_downconvert()
3620 lockres->l_ex_holders, lockres->l_action, in ocfs2_prepare_downconvert()
3621 lockres->l_unlock_action, lockres->l_requested, in ocfs2_prepare_downconvert()
3622 lockres->l_blocking, lockres->l_pending_gen); in ocfs2_prepare_downconvert()
3627 lockres->l_name, lockres->l_level, new_level, lockres->l_blocking); in ocfs2_prepare_downconvert()
3629 lockres->l_action = OCFS2_AST_DOWNCONVERT; in ocfs2_prepare_downconvert()
3630 lockres->l_requested = new_level; in ocfs2_prepare_downconvert()
3631 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_prepare_downconvert()
3632 return lockres_set_pending(lockres); in ocfs2_prepare_downconvert()
3636 struct ocfs2_lock_res *lockres, in ocfs2_downconvert_lock() argument
3644 mlog(ML_BASTS, "lockres %s, level %d => %d\n", lockres->l_name, in ocfs2_downconvert_lock()
3645 lockres->l_level, new_level); in ocfs2_downconvert_lock()
3654 lockres->l_ops->flags & LOCK_TYPE_USES_LVB) in ocfs2_downconvert_lock()
3662 &lockres->l_lksb, in ocfs2_downconvert_lock()
3664 lockres->l_name, in ocfs2_downconvert_lock()
3666 lockres_clear_pending(lockres, generation, osb); in ocfs2_downconvert_lock()
3668 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); in ocfs2_downconvert_lock()
3669 ocfs2_recover_from_dlm_error(lockres, 1); in ocfs2_downconvert_lock()
3680 struct ocfs2_lock_res *lockres) in ocfs2_prepare_cancel_convert() argument
3682 assert_spin_locked(&lockres->l_lock); in ocfs2_prepare_cancel_convert()
3684 if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { in ocfs2_prepare_cancel_convert()
3688 mlog(ML_BASTS, "lockres %s, skip convert\n", lockres->l_name); in ocfs2_prepare_cancel_convert()
3693 BUG_ON(lockres->l_action != OCFS2_AST_CONVERT && in ocfs2_prepare_cancel_convert()
3694 lockres->l_action != OCFS2_AST_DOWNCONVERT); in ocfs2_prepare_cancel_convert()
3697 lockres->l_unlock_action = OCFS2_UNLOCK_CANCEL_CONVERT; in ocfs2_prepare_cancel_convert()
3699 mlog_bug_on_msg(!(lockres->l_flags & OCFS2_LOCK_BUSY), in ocfs2_prepare_cancel_convert()
3701 lockres->l_name, lockres->l_flags); in ocfs2_prepare_cancel_convert()
3703 mlog(ML_BASTS, "lockres %s\n", lockres->l_name); in ocfs2_prepare_cancel_convert()
3709 struct ocfs2_lock_res *lockres) in ocfs2_cancel_convert() argument
3713 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, in ocfs2_cancel_convert()
3716 ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); in ocfs2_cancel_convert()
3717 ocfs2_recover_from_dlm_error(lockres, 0); in ocfs2_cancel_convert()
3720 mlog(ML_BASTS, "lockres %s\n", lockres->l_name); in ocfs2_cancel_convert()
3726 struct ocfs2_lock_res *lockres, in ocfs2_unblock_lock() argument
3737 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3743 if (!(lockres->l_flags & OCFS2_LOCK_BLOCKED)) { in ocfs2_unblock_lock()
3744 BUG_ON(lockres->l_blocking != DLM_LOCK_NL); in ocfs2_unblock_lock()
3745 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3750 if (lockres->l_flags & OCFS2_LOCK_BUSY) { in ocfs2_unblock_lock()
3774 if (lockres->l_flags & OCFS2_LOCK_PENDING) { in ocfs2_unblock_lock()
3776 lockres->l_name); in ocfs2_unblock_lock()
3781 ret = ocfs2_prepare_cancel_convert(osb, lockres); in ocfs2_unblock_lock()
3782 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3784 ret = ocfs2_cancel_convert(osb, lockres); in ocfs2_unblock_lock()
3800 if (lockres->l_flags & OCFS2_LOCK_UPCONVERT_FINISHING) in ocfs2_unblock_lock()
3808 if (lockres->l_level == DLM_LOCK_NL) { in ocfs2_unblock_lock()
3809 BUG_ON(lockres->l_ex_holders || lockres->l_ro_holders); in ocfs2_unblock_lock()
3810 mlog(ML_BASTS, "lockres %s, Aborting dc\n", lockres->l_name); in ocfs2_unblock_lock()
3811 lockres->l_blocking = DLM_LOCK_NL; in ocfs2_unblock_lock()
3812 lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_unblock_lock()
3813 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3819 if ((lockres->l_blocking == DLM_LOCK_EX) in ocfs2_unblock_lock()
3820 && (lockres->l_ex_holders || lockres->l_ro_holders)) { in ocfs2_unblock_lock()
3822 lockres->l_name, lockres->l_ex_holders, in ocfs2_unblock_lock()
3823 lockres->l_ro_holders); in ocfs2_unblock_lock()
3829 if (lockres->l_blocking == DLM_LOCK_PR && in ocfs2_unblock_lock()
3830 lockres->l_ex_holders) { in ocfs2_unblock_lock()
3832 lockres->l_name, lockres->l_ex_holders); in ocfs2_unblock_lock()
3840 if ((lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) in ocfs2_unblock_lock()
3841 && (lockres->l_flags & OCFS2_LOCK_REFRESHING)) { in ocfs2_unblock_lock()
3843 lockres->l_name); in ocfs2_unblock_lock()
3847 new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking); in ocfs2_unblock_lock()
3849 if (lockres->l_ops->check_downconvert in ocfs2_unblock_lock()
3850 && !lockres->l_ops->check_downconvert(lockres, new_level)) { in ocfs2_unblock_lock()
3852 lockres->l_name); in ocfs2_unblock_lock()
3859 if (!lockres->l_ops->downconvert_worker) in ocfs2_unblock_lock()
3866 blocking = lockres->l_blocking; in ocfs2_unblock_lock()
3867 level = lockres->l_level; in ocfs2_unblock_lock()
3868 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3870 ctl->unblock_action = lockres->l_ops->downconvert_worker(lockres, blocking); in ocfs2_unblock_lock()
3874 lockres->l_name); in ocfs2_unblock_lock()
3878 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3879 if ((blocking != lockres->l_blocking) || (level != lockres->l_level)) { in ocfs2_unblock_lock()
3883 "Recheck\n", lockres->l_name, blocking, in ocfs2_unblock_lock()
3884 lockres->l_blocking, level, lockres->l_level); in ocfs2_unblock_lock()
3891 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) { in ocfs2_unblock_lock()
3892 if (lockres->l_level == DLM_LOCK_EX) in ocfs2_unblock_lock()
3901 if (set_lvb && !(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) in ocfs2_unblock_lock()
3902 lockres->l_ops->set_lvb(lockres); in ocfs2_unblock_lock()
3905 gen = ocfs2_prepare_downconvert(lockres, new_level); in ocfs2_unblock_lock()
3906 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3907 ret = ocfs2_downconvert_lock(osb, lockres, new_level, set_lvb, in ocfs2_unblock_lock()
3916 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3922 static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres, in ocfs2_data_convert_worker() argument
3929 inode = ocfs2_lock_res_inode(lockres); in ocfs2_data_convert_worker()
3974 struct ocfs2_lock_res *lockres, in ocfs2_ci_checkpointed() argument
3980 BUG_ON(lockres->l_level != DLM_LOCK_EX && !checkpointed); in ocfs2_ci_checkpointed()
3989 static int ocfs2_check_meta_downconvert(struct ocfs2_lock_res *lockres, in ocfs2_check_meta_downconvert() argument
3992 struct inode *inode = ocfs2_lock_res_inode(lockres); in ocfs2_check_meta_downconvert()
3994 return ocfs2_ci_checkpointed(INODE_CACHE(inode), lockres, new_level); in ocfs2_check_meta_downconvert()
3997 static void ocfs2_set_meta_lvb(struct ocfs2_lock_res *lockres) in ocfs2_set_meta_lvb() argument
3999 struct inode *inode = ocfs2_lock_res_inode(lockres); in ocfs2_set_meta_lvb()
4010 struct ocfs2_lock_res *lockres) in ocfs2_dentry_post_unlock() argument
4012 struct ocfs2_dentry_lock *dl = ocfs2_lock_res_dl(lockres); in ocfs2_dentry_post_unlock()
4035 static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres, in ocfs2_dentry_convert_worker() argument
4038 struct ocfs2_dentry_lock *dl = ocfs2_lock_res_dl(lockres); in ocfs2_dentry_convert_worker()
4070 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_dentry_convert_worker()
4072 if (!(lockres->l_flags & OCFS2_LOCK_FREEING) in ocfs2_dentry_convert_worker()
4078 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_dentry_convert_worker()
4128 static int ocfs2_check_refcount_downconvert(struct ocfs2_lock_res *lockres, in ocfs2_check_refcount_downconvert() argument
4132 ocfs2_lock_res_refcount_tree(lockres); in ocfs2_check_refcount_downconvert()
4134 return ocfs2_ci_checkpointed(&tree->rf_ci, lockres, new_level); in ocfs2_check_refcount_downconvert()
4137 static int ocfs2_refcount_convert_worker(struct ocfs2_lock_res *lockres, in ocfs2_refcount_convert_worker() argument
4141 ocfs2_lock_res_refcount_tree(lockres); in ocfs2_refcount_convert_worker()
4148 static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres) in ocfs2_set_qinfo_lvb() argument
4151 struct ocfs2_mem_dqinfo *oinfo = ocfs2_lock_res_qinfo(lockres); in ocfs2_set_qinfo_lvb()
4155 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_set_qinfo_lvb()
4167 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock; in ocfs2_qinfo_unlock() local
4172 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_qinfo_unlock()
4179 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock; in ocfs2_refresh_qinfo() local
4180 struct ocfs2_qinfo_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_refresh_qinfo()
4185 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) && in ocfs2_refresh_qinfo()
4211 ocfs2_track_lock_refresh(lockres); in ocfs2_refresh_qinfo()
4222 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock; in ocfs2_qinfo_lock() local
4236 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_qinfo_lock()
4241 if (!ocfs2_should_refresh_lock_res(lockres)) in ocfs2_qinfo_lock()
4247 ocfs2_complete_lock_res_refresh(lockres, status); in ocfs2_qinfo_lock()
4256 struct ocfs2_lock_res *lockres = &ref_tree->rf_lockres; in ocfs2_refcount_lock() local
4257 struct ocfs2_super *osb = lockres->l_priv; in ocfs2_refcount_lock()
4266 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_refcount_lock()
4276 struct ocfs2_lock_res *lockres = &ref_tree->rf_lockres; in ocfs2_refcount_unlock() local
4277 struct ocfs2_super *osb = lockres->l_priv; in ocfs2_refcount_unlock()
4280 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_refcount_unlock()
4284 struct ocfs2_lock_res *lockres) in ocfs2_process_blocked_lock() argument
4294 BUG_ON(!lockres); in ocfs2_process_blocked_lock()
4295 BUG_ON(!lockres->l_ops); in ocfs2_process_blocked_lock()
4297 mlog(ML_BASTS, "lockres %s blocked\n", lockres->l_name); in ocfs2_process_blocked_lock()
4304 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4305 if (lockres->l_flags & OCFS2_LOCK_FREEING) in ocfs2_process_blocked_lock()
4307 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4309 status = ocfs2_unblock_lock(osb, lockres, &ctl); in ocfs2_process_blocked_lock()
4313 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4315 if (lockres->l_flags & OCFS2_LOCK_FREEING || !ctl.requeue) { in ocfs2_process_blocked_lock()
4316 lockres_clear_flags(lockres, OCFS2_LOCK_QUEUED); in ocfs2_process_blocked_lock()
4318 ocfs2_schedule_blocked_lock(osb, lockres); in ocfs2_process_blocked_lock()
4320 mlog(ML_BASTS, "lockres %s, requeue = %s.\n", lockres->l_name, in ocfs2_process_blocked_lock()
4322 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4325 && lockres->l_ops->post_unlock) in ocfs2_process_blocked_lock()
4326 lockres->l_ops->post_unlock(osb, lockres); in ocfs2_process_blocked_lock()
4330 struct ocfs2_lock_res *lockres) in ocfs2_schedule_blocked_lock() argument
4334 assert_spin_locked(&lockres->l_lock); in ocfs2_schedule_blocked_lock()
4336 if (lockres->l_flags & OCFS2_LOCK_FREEING) { in ocfs2_schedule_blocked_lock()
4341 lockres->l_name, lockres->l_flags); in ocfs2_schedule_blocked_lock()
4345 lockres_or_flags(lockres, OCFS2_LOCK_QUEUED); in ocfs2_schedule_blocked_lock()
4348 if (list_empty(&lockres->l_blocked_list)) { in ocfs2_schedule_blocked_lock()
4349 list_add_tail(&lockres->l_blocked_list, in ocfs2_schedule_blocked_lock()
4360 struct ocfs2_lock_res *lockres; in ocfs2_downconvert_thread_do_work() local
4375 lockres = list_entry(osb->blocked_lock_list.next, in ocfs2_downconvert_thread_do_work()
4377 list_del_init(&lockres->l_blocked_list); in ocfs2_downconvert_thread_do_work()
4384 ocfs2_process_blocked_lock(osb, lockres); in ocfs2_downconvert_thread_do_work()