Lines Matching refs:lockres
73 static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres);
74 static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres);
75 static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres);
76 static struct ocfs2_super *ocfs2_get_qinfo_osb(struct ocfs2_lock_res *lockres);
103 static int ocfs2_check_meta_downconvert(struct ocfs2_lock_res *lockres,
105 static void ocfs2_set_meta_lvb(struct ocfs2_lock_res *lockres);
107 static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
110 static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
114 struct ocfs2_lock_res *lockres);
116 static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres);
118 static int ocfs2_check_refcount_downconvert(struct ocfs2_lock_res *lockres,
120 static int ocfs2_refcount_convert_worker(struct ocfs2_lock_res *lockres,
129 struct ocfs2_lock_res *lockres) in ocfs2_dump_meta_lvb_info() argument
131 struct ocfs2_meta_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_dump_meta_lvb_info()
134 lockres->l_name, function, line); in ocfs2_dump_meta_lvb_info()
301 static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres) in ocfs2_is_inode_lock() argument
303 return lockres->l_type == OCFS2_LOCK_TYPE_META || in ocfs2_is_inode_lock()
304 lockres->l_type == OCFS2_LOCK_TYPE_RW || in ocfs2_is_inode_lock()
305 lockres->l_type == OCFS2_LOCK_TYPE_OPEN; in ocfs2_is_inode_lock()
313 static inline struct inode *ocfs2_lock_res_inode(struct ocfs2_lock_res *lockres) in ocfs2_lock_res_inode() argument
315 BUG_ON(!ocfs2_is_inode_lock(lockres)); in ocfs2_lock_res_inode()
317 return (struct inode *) lockres->l_priv; in ocfs2_lock_res_inode()
320 static inline struct ocfs2_dentry_lock *ocfs2_lock_res_dl(struct ocfs2_lock_res *lockres) in ocfs2_lock_res_dl() argument
322 BUG_ON(lockres->l_type != OCFS2_LOCK_TYPE_DENTRY); in ocfs2_lock_res_dl()
324 return (struct ocfs2_dentry_lock *)lockres->l_priv; in ocfs2_lock_res_dl()
327 static inline struct ocfs2_mem_dqinfo *ocfs2_lock_res_qinfo(struct ocfs2_lock_res *lockres) in ocfs2_lock_res_qinfo() argument
329 BUG_ON(lockres->l_type != OCFS2_LOCK_TYPE_QINFO); in ocfs2_lock_res_qinfo()
331 return (struct ocfs2_mem_dqinfo *)lockres->l_priv; in ocfs2_lock_res_qinfo()
340 static inline struct ocfs2_super *ocfs2_get_lockres_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_lockres_osb() argument
342 if (lockres->l_ops->get_osb) in ocfs2_get_lockres_osb()
343 return lockres->l_ops->get_osb(lockres); in ocfs2_get_lockres_osb()
345 return (struct ocfs2_super *)lockres->l_priv; in ocfs2_get_lockres_osb()
349 struct ocfs2_lock_res *lockres,
352 static inline int ocfs2_may_continue_on_blocked_lock(struct ocfs2_lock_res *lockres,
355 struct ocfs2_lock_res *lockres,
358 struct ocfs2_lock_res *lockres, in ocfs2_cluster_unlock() argument
361 __ocfs2_cluster_unlock(osb, lockres, level, _RET_IP_); in ocfs2_cluster_unlock()
364 static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres);
365 static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres);
366 static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres);
367 static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, int level);
369 struct ocfs2_lock_res *lockres);
370 static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres,
383 struct ocfs2_lock_res *lockres);
388 static unsigned int ocfs2_prepare_downconvert(struct ocfs2_lock_res *lockres,
391 struct ocfs2_lock_res *lockres,
396 struct ocfs2_lock_res *lockres);
398 struct ocfs2_lock_res *lockres);
479 static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_refresh() argument
481 lockres->l_lock_refresh++; in ocfs2_track_lock_refresh()
496 static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) in ocfs2_track_lock_refresh() argument
573 static struct ocfs2_super *ocfs2_get_inode_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_inode_osb() argument
575 struct inode *inode = ocfs2_lock_res_inode(lockres); in ocfs2_get_inode_osb()
580 static struct ocfs2_super *ocfs2_get_qinfo_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_qinfo_osb() argument
582 struct ocfs2_mem_dqinfo *info = lockres->l_priv; in ocfs2_get_qinfo_osb()
587 static struct ocfs2_super *ocfs2_get_file_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_file_osb() argument
589 struct ocfs2_file_private *fp = lockres->l_priv; in ocfs2_get_file_osb()
594 static __u64 ocfs2_get_dentry_lock_ino(struct ocfs2_lock_res *lockres) in ocfs2_get_dentry_lock_ino() argument
598 memcpy(&inode_blkno_be, &lockres->l_name[OCFS2_DENTRY_LOCK_INO_START], in ocfs2_get_dentry_lock_ino()
604 static struct ocfs2_super *ocfs2_get_dentry_osb(struct ocfs2_lock_res *lockres) in ocfs2_get_dentry_osb() argument
606 struct ocfs2_dentry_lock *dl = lockres->l_priv; in ocfs2_get_dentry_osb()
617 struct ocfs2_lock_res *lockres = &dl->dl_lockres; in ocfs2_dentry_lock_res_init() local
619 ocfs2_lock_res_init_once(lockres); in ocfs2_dentry_lock_res_init()
636 len = snprintf(lockres->l_name, OCFS2_DENTRY_LOCK_INO_START, in ocfs2_dentry_lock_res_init()
643 memcpy(&lockres->l_name[OCFS2_DENTRY_LOCK_INO_START], &inode_blkno_be, in ocfs2_dentry_lock_res_init()
646 ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), lockres, in ocfs2_dentry_lock_res_init()
687 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_lock_res_init() local
689 ocfs2_lock_res_init_once(lockres); in ocfs2_trim_fs_lock_res_init()
690 ocfs2_build_lock_name(OCFS2_LOCK_TYPE_TRIM_FS, 0, 0, lockres->l_name); in ocfs2_trim_fs_lock_res_init()
691 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_TRIM_FS, in ocfs2_trim_fs_lock_res_init()
697 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_lock_res_uninit() local
699 ocfs2_simple_drop_lockres(osb, lockres); in ocfs2_trim_fs_lock_res_uninit()
700 ocfs2_lock_res_free(lockres); in ocfs2_trim_fs_lock_res_uninit()
712 void ocfs2_file_lock_res_init(struct ocfs2_lock_res *lockres, in ocfs2_file_lock_res_init() argument
718 ocfs2_lock_res_init_once(lockres); in ocfs2_file_lock_res_init()
720 inode->i_generation, lockres->l_name); in ocfs2_file_lock_res_init()
721 ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), lockres, in ocfs2_file_lock_res_init()
724 lockres->l_flags |= OCFS2_LOCK_NOCACHE; in ocfs2_file_lock_res_init()
727 void ocfs2_qinfo_lock_res_init(struct ocfs2_lock_res *lockres, in ocfs2_qinfo_lock_res_init() argument
730 ocfs2_lock_res_init_once(lockres); in ocfs2_qinfo_lock_res_init()
732 0, lockres->l_name); in ocfs2_qinfo_lock_res_init()
733 ocfs2_lock_res_init_common(OCFS2_SB(info->dqi_gi.dqi_sb), lockres, in ocfs2_qinfo_lock_res_init()
738 void ocfs2_refcount_lock_res_init(struct ocfs2_lock_res *lockres, in ocfs2_refcount_lock_res_init() argument
742 ocfs2_lock_res_init_once(lockres); in ocfs2_refcount_lock_res_init()
744 generation, lockres->l_name); in ocfs2_refcount_lock_res_init()
745 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_REFCOUNT, in ocfs2_refcount_lock_res_init()
782 static inline void ocfs2_add_holder(struct ocfs2_lock_res *lockres, in ocfs2_add_holder() argument
788 spin_lock(&lockres->l_lock); in ocfs2_add_holder()
789 list_add_tail(&oh->oh_list, &lockres->l_holders); in ocfs2_add_holder()
790 spin_unlock(&lockres->l_lock); in ocfs2_add_holder()
794 ocfs2_pid_holder(struct ocfs2_lock_res *lockres, in ocfs2_pid_holder() argument
799 spin_lock(&lockres->l_lock); in ocfs2_pid_holder()
800 list_for_each_entry(oh, &lockres->l_holders, oh_list) { in ocfs2_pid_holder()
802 spin_unlock(&lockres->l_lock); in ocfs2_pid_holder()
806 spin_unlock(&lockres->l_lock); in ocfs2_pid_holder()
810 static inline void ocfs2_remove_holder(struct ocfs2_lock_res *lockres, in ocfs2_remove_holder() argument
813 spin_lock(&lockres->l_lock); in ocfs2_remove_holder()
815 spin_unlock(&lockres->l_lock); in ocfs2_remove_holder()
821 static inline void ocfs2_inc_holders(struct ocfs2_lock_res *lockres, in ocfs2_inc_holders() argument
824 BUG_ON(!lockres); in ocfs2_inc_holders()
828 lockres->l_ex_holders++; in ocfs2_inc_holders()
831 lockres->l_ro_holders++; in ocfs2_inc_holders()
838 static inline void ocfs2_dec_holders(struct ocfs2_lock_res *lockres, in ocfs2_dec_holders() argument
841 BUG_ON(!lockres); in ocfs2_dec_holders()
845 BUG_ON(!lockres->l_ex_holders); in ocfs2_dec_holders()
846 lockres->l_ex_holders--; in ocfs2_dec_holders()
849 BUG_ON(!lockres->l_ro_holders); in ocfs2_dec_holders()
850 lockres->l_ro_holders--; in ocfs2_dec_holders()
871 static void lockres_set_flags(struct ocfs2_lock_res *lockres, in lockres_set_flags() argument
876 assert_spin_locked(&lockres->l_lock); in lockres_set_flags()
878 lockres->l_flags = newflags; in lockres_set_flags()
880 list_for_each_entry_safe(mw, tmp, &lockres->l_mask_waiters, mw_item) { in lockres_set_flags()
881 if ((lockres->l_flags & mw->mw_mask) != mw->mw_goal) in lockres_set_flags()
889 static void lockres_or_flags(struct ocfs2_lock_res *lockres, unsigned long or) in lockres_or_flags() argument
891 lockres_set_flags(lockres, lockres->l_flags | or); in lockres_or_flags()
893 static void lockres_clear_flags(struct ocfs2_lock_res *lockres, in lockres_clear_flags() argument
896 lockres_set_flags(lockres, lockres->l_flags & ~clear); in lockres_clear_flags()
899 static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres) in ocfs2_generic_handle_downconvert_action() argument
901 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); in ocfs2_generic_handle_downconvert_action()
902 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); in ocfs2_generic_handle_downconvert_action()
903 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); in ocfs2_generic_handle_downconvert_action()
904 BUG_ON(lockres->l_blocking <= DLM_LOCK_NL); in ocfs2_generic_handle_downconvert_action()
906 lockres->l_level = lockres->l_requested; in ocfs2_generic_handle_downconvert_action()
907 if (lockres->l_level <= in ocfs2_generic_handle_downconvert_action()
908 ocfs2_highest_compat_lock_level(lockres->l_blocking)) { in ocfs2_generic_handle_downconvert_action()
909 lockres->l_blocking = DLM_LOCK_NL; in ocfs2_generic_handle_downconvert_action()
910 lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_generic_handle_downconvert_action()
912 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_generic_handle_downconvert_action()
915 static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres) in ocfs2_generic_handle_convert_action() argument
917 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); in ocfs2_generic_handle_convert_action()
918 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); in ocfs2_generic_handle_convert_action()
924 if (lockres->l_level == DLM_LOCK_NL && in ocfs2_generic_handle_convert_action()
925 lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) in ocfs2_generic_handle_convert_action()
926 lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); in ocfs2_generic_handle_convert_action()
928 lockres->l_level = lockres->l_requested; in ocfs2_generic_handle_convert_action()
937 if (!(lockres->l_flags & OCFS2_LOCK_NONBLOCK_FINISHED)) in ocfs2_generic_handle_convert_action()
938 lockres_or_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); in ocfs2_generic_handle_convert_action()
940 lockres_clear_flags(lockres, OCFS2_LOCK_NONBLOCK_FINISHED); in ocfs2_generic_handle_convert_action()
942 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_generic_handle_convert_action()
945 static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres) in ocfs2_generic_handle_attach_action() argument
947 BUG_ON((!(lockres->l_flags & OCFS2_LOCK_BUSY))); in ocfs2_generic_handle_attach_action()
948 BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); in ocfs2_generic_handle_attach_action()
950 if (lockres->l_requested > DLM_LOCK_NL && in ocfs2_generic_handle_attach_action()
951 !(lockres->l_flags & OCFS2_LOCK_LOCAL) && in ocfs2_generic_handle_attach_action()
952 lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) in ocfs2_generic_handle_attach_action()
953 lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); in ocfs2_generic_handle_attach_action()
955 lockres->l_level = lockres->l_requested; in ocfs2_generic_handle_attach_action()
956 lockres_or_flags(lockres, OCFS2_LOCK_ATTACHED); in ocfs2_generic_handle_attach_action()
957 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_generic_handle_attach_action()
960 static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, in ocfs2_generic_handle_bast() argument
965 assert_spin_locked(&lockres->l_lock); in ocfs2_generic_handle_bast()
967 if (level > lockres->l_blocking) { in ocfs2_generic_handle_bast()
973 ocfs2_highest_compat_lock_level(lockres->l_blocking)) in ocfs2_generic_handle_bast()
976 lockres->l_blocking = level; in ocfs2_generic_handle_bast()
980 lockres->l_name, level, lockres->l_level, lockres->l_blocking, in ocfs2_generic_handle_bast()
984 lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_generic_handle_bast()
1048 static void __lockres_clear_pending(struct ocfs2_lock_res *lockres, in __lockres_clear_pending() argument
1052 assert_spin_locked(&lockres->l_lock); in __lockres_clear_pending()
1058 if (!(lockres->l_flags & OCFS2_LOCK_PENDING) || in __lockres_clear_pending()
1059 (lockres->l_pending_gen != generation)) in __lockres_clear_pending()
1062 lockres_clear_flags(lockres, OCFS2_LOCK_PENDING); in __lockres_clear_pending()
1063 lockres->l_pending_gen++; in __lockres_clear_pending()
1069 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) in __lockres_clear_pending()
1074 static void lockres_clear_pending(struct ocfs2_lock_res *lockres, in lockres_clear_pending() argument
1080 spin_lock_irqsave(&lockres->l_lock, flags); in lockres_clear_pending()
1081 __lockres_clear_pending(lockres, generation, osb); in lockres_clear_pending()
1082 spin_unlock_irqrestore(&lockres->l_lock, flags); in lockres_clear_pending()
1085 static unsigned int lockres_set_pending(struct ocfs2_lock_res *lockres) in lockres_set_pending() argument
1087 assert_spin_locked(&lockres->l_lock); in lockres_set_pending()
1088 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); in lockres_set_pending()
1090 lockres_or_flags(lockres, OCFS2_LOCK_PENDING); in lockres_set_pending()
1092 return lockres->l_pending_gen; in lockres_set_pending()
1097 struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); in ocfs2_blocking_ast() local
1098 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); in ocfs2_blocking_ast()
1105 "type %s\n", lockres->l_name, level, lockres->l_level, in ocfs2_blocking_ast()
1106 ocfs2_lock_type_string(lockres->l_type)); in ocfs2_blocking_ast()
1112 if (lockres->l_flags & OCFS2_LOCK_NOCACHE) in ocfs2_blocking_ast()
1115 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_blocking_ast()
1116 needs_downconvert = ocfs2_generic_handle_bast(lockres, level); in ocfs2_blocking_ast()
1118 ocfs2_schedule_blocked_lock(osb, lockres); in ocfs2_blocking_ast()
1119 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_blocking_ast()
1121 wake_up(&lockres->l_event); in ocfs2_blocking_ast()
1128 struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); in ocfs2_locking_ast() local
1129 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); in ocfs2_locking_ast()
1133 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_locking_ast()
1135 status = ocfs2_dlm_lock_status(&lockres->l_lksb); in ocfs2_locking_ast()
1138 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_locking_ast()
1144 lockres->l_name, status); in ocfs2_locking_ast()
1145 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_locking_ast()
1150 "level %d => %d\n", lockres->l_name, lockres->l_action, in ocfs2_locking_ast()
1151 lockres->l_unlock_action, lockres->l_level, lockres->l_requested); in ocfs2_locking_ast()
1153 switch(lockres->l_action) { in ocfs2_locking_ast()
1155 ocfs2_generic_handle_attach_action(lockres); in ocfs2_locking_ast()
1156 lockres_clear_flags(lockres, OCFS2_LOCK_LOCAL); in ocfs2_locking_ast()
1159 ocfs2_generic_handle_convert_action(lockres); in ocfs2_locking_ast()
1162 ocfs2_generic_handle_downconvert_action(lockres); in ocfs2_locking_ast()
1167 lockres->l_name, lockres->l_action, lockres->l_flags, in ocfs2_locking_ast()
1168 lockres->l_unlock_action); in ocfs2_locking_ast()
1174 lockres->l_action = OCFS2_AST_INVALID; in ocfs2_locking_ast()
1177 if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) in ocfs2_locking_ast()
1178 lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; in ocfs2_locking_ast()
1186 __lockres_clear_pending(lockres, lockres->l_pending_gen, osb); in ocfs2_locking_ast()
1188 wake_up(&lockres->l_event); in ocfs2_locking_ast()
1189 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_locking_ast()
1194 struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); in ocfs2_unlock_ast() local
1198 lockres->l_name, lockres->l_unlock_action); in ocfs2_unlock_ast()
1200 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_unlock_ast()
1203 "unlock_action %d\n", error, lockres->l_name, in ocfs2_unlock_ast()
1204 lockres->l_unlock_action); in ocfs2_unlock_ast()
1205 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unlock_ast()
1209 switch(lockres->l_unlock_action) { in ocfs2_unlock_ast()
1211 mlog(0, "Cancel convert success for %s\n", lockres->l_name); in ocfs2_unlock_ast()
1212 lockres->l_action = OCFS2_AST_INVALID; in ocfs2_unlock_ast()
1215 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) in ocfs2_unlock_ast()
1216 ocfs2_wake_downconvert_thread(ocfs2_get_lockres_osb(lockres)); in ocfs2_unlock_ast()
1219 lockres->l_level = DLM_LOCK_IV; in ocfs2_unlock_ast()
1225 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_unlock_ast()
1226 lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; in ocfs2_unlock_ast()
1227 wake_up(&lockres->l_event); in ocfs2_unlock_ast()
1228 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unlock_ast()
1269 static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, in ocfs2_recover_from_dlm_error() argument
1274 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_recover_from_dlm_error()
1275 lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_recover_from_dlm_error()
1276 lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); in ocfs2_recover_from_dlm_error()
1278 lockres->l_action = OCFS2_AST_INVALID; in ocfs2_recover_from_dlm_error()
1280 lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; in ocfs2_recover_from_dlm_error()
1281 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_recover_from_dlm_error()
1283 wake_up(&lockres->l_event); in ocfs2_recover_from_dlm_error()
1291 struct ocfs2_lock_res *lockres, in ocfs2_lock_create() argument
1299 mlog(0, "lock %s, level = %d, flags = %u\n", lockres->l_name, level, in ocfs2_lock_create()
1302 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_lock_create()
1303 if ((lockres->l_flags & OCFS2_LOCK_ATTACHED) || in ocfs2_lock_create()
1304 (lockres->l_flags & OCFS2_LOCK_BUSY)) { in ocfs2_lock_create()
1305 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_lock_create()
1309 lockres->l_action = OCFS2_AST_ATTACH; in ocfs2_lock_create()
1310 lockres->l_requested = level; in ocfs2_lock_create()
1311 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_lock_create()
1312 gen = lockres_set_pending(lockres); in ocfs2_lock_create()
1313 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_lock_create()
1317 &lockres->l_lksb, in ocfs2_lock_create()
1319 lockres->l_name, in ocfs2_lock_create()
1321 lockres_clear_pending(lockres, gen, osb); in ocfs2_lock_create()
1323 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); in ocfs2_lock_create()
1324 ocfs2_recover_from_dlm_error(lockres, 1); in ocfs2_lock_create()
1327 mlog(0, "lock %s, return from ocfs2_dlm_lock\n", lockres->l_name); in ocfs2_lock_create()
1333 static inline int ocfs2_check_wait_flag(struct ocfs2_lock_res *lockres, in ocfs2_check_wait_flag() argument
1339 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_check_wait_flag()
1340 ret = lockres->l_flags & flag; in ocfs2_check_wait_flag()
1341 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_check_wait_flag()
1346 static inline void ocfs2_wait_on_busy_lock(struct ocfs2_lock_res *lockres) in ocfs2_wait_on_busy_lock() argument
1349 wait_event(lockres->l_event, in ocfs2_wait_on_busy_lock()
1350 !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_BUSY)); in ocfs2_wait_on_busy_lock()
1353 static inline void ocfs2_wait_on_refreshing_lock(struct ocfs2_lock_res *lockres) in ocfs2_wait_on_refreshing_lock() argument
1356 wait_event(lockres->l_event, in ocfs2_wait_on_refreshing_lock()
1357 !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_REFRESHING)); in ocfs2_wait_on_refreshing_lock()
1363 static inline int ocfs2_may_continue_on_blocked_lock(struct ocfs2_lock_res *lockres, in ocfs2_may_continue_on_blocked_lock() argument
1366 BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); in ocfs2_may_continue_on_blocked_lock()
1368 return wanted <= ocfs2_highest_compat_lock_level(lockres->l_blocking); in ocfs2_may_continue_on_blocked_lock()
1386 static void lockres_add_mask_waiter(struct ocfs2_lock_res *lockres, in lockres_add_mask_waiter() argument
1393 assert_spin_locked(&lockres->l_lock); in lockres_add_mask_waiter()
1395 list_add_tail(&mw->mw_item, &lockres->l_mask_waiters); in lockres_add_mask_waiter()
1402 static int __lockres_remove_mask_waiter(struct ocfs2_lock_res *lockres, in __lockres_remove_mask_waiter() argument
1407 assert_spin_locked(&lockres->l_lock); in __lockres_remove_mask_waiter()
1409 if ((lockres->l_flags & mw->mw_mask) != mw->mw_goal) in __lockres_remove_mask_waiter()
1419 static int lockres_remove_mask_waiter(struct ocfs2_lock_res *lockres, in lockres_remove_mask_waiter() argument
1425 spin_lock_irqsave(&lockres->l_lock, flags); in lockres_remove_mask_waiter()
1426 ret = __lockres_remove_mask_waiter(lockres, mw); in lockres_remove_mask_waiter()
1427 spin_unlock_irqrestore(&lockres->l_lock, flags); in lockres_remove_mask_waiter()
1434 struct ocfs2_lock_res *lockres) in ocfs2_wait_for_mask_interruptible() argument
1440 lockres_remove_mask_waiter(lockres, mw); in ocfs2_wait_for_mask_interruptible()
1449 struct ocfs2_lock_res *lockres, in __ocfs2_cluster_lock() argument
1465 if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED)) { in __ocfs2_cluster_lock()
1472 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) in __ocfs2_cluster_lock()
1478 spin_lock_irqsave(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1485 mlog_bug_on_msg(lockres->l_flags & OCFS2_LOCK_FREEING, in __ocfs2_cluster_lock()
1487 "0x%lx\n", lockres->l_name, lockres->l_flags); in __ocfs2_cluster_lock()
1492 if (lockres->l_flags & OCFS2_LOCK_BUSY && in __ocfs2_cluster_lock()
1493 level > lockres->l_level) { in __ocfs2_cluster_lock()
1496 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in __ocfs2_cluster_lock()
1501 if (lockres->l_flags & OCFS2_LOCK_UPCONVERT_FINISHING) { in __ocfs2_cluster_lock()
1516 if (level <= lockres->l_level) in __ocfs2_cluster_lock()
1520 if (lockres->l_flags & OCFS2_LOCK_BLOCKED && in __ocfs2_cluster_lock()
1521 !ocfs2_may_continue_on_blocked_lock(lockres, level)) { in __ocfs2_cluster_lock()
1524 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BLOCKED, 0); in __ocfs2_cluster_lock()
1529 if (level > lockres->l_level) { in __ocfs2_cluster_lock()
1537 if (lockres->l_action != OCFS2_AST_INVALID) in __ocfs2_cluster_lock()
1539 lockres->l_name, lockres->l_action); in __ocfs2_cluster_lock()
1541 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { in __ocfs2_cluster_lock()
1542 lockres->l_action = OCFS2_AST_ATTACH; in __ocfs2_cluster_lock()
1545 lockres->l_action = OCFS2_AST_CONVERT; in __ocfs2_cluster_lock()
1549 lockres->l_requested = level; in __ocfs2_cluster_lock()
1550 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in __ocfs2_cluster_lock()
1551 gen = lockres_set_pending(lockres); in __ocfs2_cluster_lock()
1552 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1558 lockres->l_name, lockres->l_level, level); in __ocfs2_cluster_lock()
1563 &lockres->l_lksb, in __ocfs2_cluster_lock()
1565 lockres->l_name, in __ocfs2_cluster_lock()
1567 lockres_clear_pending(lockres, gen, osb); in __ocfs2_cluster_lock()
1572 ret, lockres); in __ocfs2_cluster_lock()
1574 ocfs2_recover_from_dlm_error(lockres, 1); in __ocfs2_cluster_lock()
1580 lockres->l_name); in __ocfs2_cluster_lock()
1592 ocfs2_inc_holders(lockres, level); in __ocfs2_cluster_lock()
1596 lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); in __ocfs2_cluster_lock()
1599 kick_dc = (lockres->l_flags & OCFS2_LOCK_BLOCKED); in __ocfs2_cluster_lock()
1601 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1616 spin_lock_irqsave(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1617 if (__lockres_remove_mask_waiter(lockres, &mw)) { in __ocfs2_cluster_lock()
1619 lockres_or_flags(lockres, in __ocfs2_cluster_lock()
1621 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1624 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_lock()
1634 ocfs2_update_lock_stats(lockres, level, &mw, ret); in __ocfs2_cluster_lock()
1637 if (!ret && lockres->l_lockdep_map.key != NULL) { in __ocfs2_cluster_lock()
1639 rwsem_acquire_read(&lockres->l_lockdep_map, l_subclass, in __ocfs2_cluster_lock()
1643 rwsem_acquire(&lockres->l_lockdep_map, l_subclass, in __ocfs2_cluster_lock()
1652 struct ocfs2_lock_res *lockres, in ocfs2_cluster_lock() argument
1657 return __ocfs2_cluster_lock(osb, lockres, level, lkm_flags, arg_flags, in ocfs2_cluster_lock()
1663 struct ocfs2_lock_res *lockres, in __ocfs2_cluster_unlock() argument
1669 spin_lock_irqsave(&lockres->l_lock, flags); in __ocfs2_cluster_unlock()
1670 ocfs2_dec_holders(lockres, level); in __ocfs2_cluster_unlock()
1671 ocfs2_downconvert_on_unlock(osb, lockres); in __ocfs2_cluster_unlock()
1672 spin_unlock_irqrestore(&lockres->l_lock, flags); in __ocfs2_cluster_unlock()
1674 if (lockres->l_lockdep_map.key != NULL) in __ocfs2_cluster_unlock()
1675 rwsem_release(&lockres->l_lockdep_map, 1, caller_ip); in __ocfs2_cluster_unlock()
1680 struct ocfs2_lock_res *lockres, in ocfs2_create_new_lock() argument
1688 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_create_new_lock()
1689 BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); in ocfs2_create_new_lock()
1690 lockres_or_flags(lockres, OCFS2_LOCK_LOCAL); in ocfs2_create_new_lock()
1691 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_create_new_lock()
1693 return ocfs2_lock_create(osb, lockres, level, lkm_flags); in ocfs2_create_new_lock()
1746 struct ocfs2_lock_res *lockres; in ocfs2_rw_lock() local
1756 lockres = &OCFS2_I(inode)->ip_rw_lockres; in ocfs2_rw_lock()
1760 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_rw_lock()
1770 struct ocfs2_lock_res *lockres; in ocfs2_try_rw_lock() local
1780 lockres = &OCFS2_I(inode)->ip_rw_lockres; in ocfs2_try_rw_lock()
1784 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0); in ocfs2_try_rw_lock()
1791 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; in ocfs2_rw_unlock() local
1799 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_rw_unlock()
1808 struct ocfs2_lock_res *lockres; in ocfs2_open_lock() local
1817 lockres = &OCFS2_I(inode)->ip_open_lockres; in ocfs2_open_lock()
1819 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_PR, 0, 0); in ocfs2_open_lock()
1830 struct ocfs2_lock_res *lockres; in ocfs2_try_open_lock() local
1846 lockres = &OCFS2_I(inode)->ip_open_lockres; in ocfs2_try_open_lock()
1856 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0); in ocfs2_try_open_lock()
1867 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_open_lockres; in ocfs2_open_unlock() local
1876 if(lockres->l_ro_holders) in ocfs2_open_unlock()
1877 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_PR); in ocfs2_open_unlock()
1878 if(lockres->l_ex_holders) in ocfs2_open_unlock()
1879 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_open_unlock()
1885 static int ocfs2_flock_handle_signal(struct ocfs2_lock_res *lockres, in ocfs2_flock_handle_signal() argument
1889 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres); in ocfs2_flock_handle_signal()
1896 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1897 if (lockres->l_flags & OCFS2_LOCK_BUSY) { in ocfs2_flock_handle_signal()
1898 ret = ocfs2_prepare_cancel_convert(osb, lockres); in ocfs2_flock_handle_signal()
1900 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1901 ret = ocfs2_cancel_convert(osb, lockres); in ocfs2_flock_handle_signal()
1908 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_flock_handle_signal()
1909 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1920 if (lockres->l_level == level) in ocfs2_flock_handle_signal()
1924 lockres->l_flags, lockres->l_level, lockres->l_action); in ocfs2_flock_handle_signal()
1926 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_flock_handle_signal()
1959 struct ocfs2_lock_res *lockres = &fp->fp_flock; in ocfs2_file_lock() local
1965 if ((lockres->l_flags & OCFS2_LOCK_BUSY) || in ocfs2_file_lock()
1966 (lockres->l_level > DLM_LOCK_NL)) { in ocfs2_file_lock()
1969 "level: %u\n", lockres->l_name, lockres->l_flags, in ocfs2_file_lock()
1970 lockres->l_level); in ocfs2_file_lock()
1974 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_file_lock()
1975 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { in ocfs2_file_lock()
1976 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_file_lock()
1977 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_file_lock()
1983 ret = ocfs2_lock_create(osb, lockres, DLM_LOCK_NL, 0); in ocfs2_file_lock()
1994 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_file_lock()
1997 lockres->l_action = OCFS2_AST_CONVERT; in ocfs2_file_lock()
1999 lockres->l_requested = level; in ocfs2_file_lock()
2000 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_file_lock()
2002 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_file_lock()
2003 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_file_lock()
2005 ret = ocfs2_dlm_lock(osb->cconn, level, &lockres->l_lksb, lkm_flags, in ocfs2_file_lock()
2006 lockres->l_name, OCFS2_LOCK_ID_MAX_LEN - 1); in ocfs2_file_lock()
2009 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); in ocfs2_file_lock()
2013 ocfs2_recover_from_dlm_error(lockres, 1); in ocfs2_file_lock()
2014 lockres_remove_mask_waiter(lockres, &mw); in ocfs2_file_lock()
2018 ret = ocfs2_wait_for_mask_interruptible(&mw, lockres); in ocfs2_file_lock()
2035 ret = ocfs2_flock_handle_signal(lockres, level); in ocfs2_file_lock()
2036 } else if (!ret && (level > lockres->l_level)) { in ocfs2_file_lock()
2045 lockres->l_name, ex, trylock, ret); in ocfs2_file_lock()
2055 struct ocfs2_lock_res *lockres = &fp->fp_flock; in ocfs2_file_unlock() local
2061 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) in ocfs2_file_unlock()
2064 if (lockres->l_level == DLM_LOCK_NL) in ocfs2_file_unlock()
2068 lockres->l_name, lockres->l_flags, lockres->l_level, in ocfs2_file_unlock()
2069 lockres->l_action); in ocfs2_file_unlock()
2071 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_file_unlock()
2075 lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_file_unlock()
2076 lockres->l_blocking = DLM_LOCK_EX; in ocfs2_file_unlock()
2078 gen = ocfs2_prepare_downconvert(lockres, DLM_LOCK_NL); in ocfs2_file_unlock()
2079 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); in ocfs2_file_unlock()
2080 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_file_unlock()
2082 ret = ocfs2_downconvert_lock(osb, lockres, DLM_LOCK_NL, 0, gen); in ocfs2_file_unlock()
2094 struct ocfs2_lock_res *lockres) in ocfs2_downconvert_on_unlock() argument
2101 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) { in ocfs2_downconvert_on_unlock()
2102 switch(lockres->l_blocking) { in ocfs2_downconvert_on_unlock()
2104 if (!lockres->l_ex_holders && !lockres->l_ro_holders) in ocfs2_downconvert_on_unlock()
2108 if (!lockres->l_ex_holders) in ocfs2_downconvert_on_unlock()
2143 struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; in __ocfs2_stuff_meta_lvb() local
2147 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in __ocfs2_stuff_meta_lvb()
2180 mlog_meta_lvb(0, lockres); in __ocfs2_stuff_meta_lvb()
2194 struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; in ocfs2_refresh_inode_from_lvb() local
2197 mlog_meta_lvb(0, lockres); in ocfs2_refresh_inode_from_lvb()
2199 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_refresh_inode_from_lvb()
2233 struct ocfs2_lock_res *lockres) in ocfs2_meta_lvb_is_trustable() argument
2235 struct ocfs2_meta_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_meta_lvb_is_trustable()
2237 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) in ocfs2_meta_lvb_is_trustable()
2251 static int ocfs2_should_refresh_lock_res(struct ocfs2_lock_res *lockres) in ocfs2_should_refresh_lock_res() argument
2257 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2258 if (!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) { in ocfs2_should_refresh_lock_res()
2259 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2263 if (lockres->l_flags & OCFS2_LOCK_REFRESHING) { in ocfs2_should_refresh_lock_res()
2264 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2266 ocfs2_wait_on_refreshing_lock(lockres); in ocfs2_should_refresh_lock_res()
2271 lockres_or_flags(lockres, OCFS2_LOCK_REFRESHING); in ocfs2_should_refresh_lock_res()
2272 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_should_refresh_lock_res()
2282 static inline void ocfs2_complete_lock_res_refresh(struct ocfs2_lock_res *lockres, in ocfs2_complete_lock_res_refresh() argument
2287 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_complete_lock_res_refresh()
2288 lockres_clear_flags(lockres, OCFS2_LOCK_REFRESHING); in ocfs2_complete_lock_res_refresh()
2290 lockres_clear_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); in ocfs2_complete_lock_res_refresh()
2291 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_complete_lock_res_refresh()
2293 wake_up(&lockres->l_event); in ocfs2_complete_lock_res_refresh()
2302 struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; in ocfs2_inode_lock_update() local
2320 if (!ocfs2_should_refresh_lock_res(lockres)) in ocfs2_inode_lock_update()
2329 if (ocfs2_meta_lvb_is_trustable(inode, lockres)) { in ocfs2_inode_lock_update()
2367 ocfs2_track_lock_refresh(lockres); in ocfs2_inode_lock_update()
2372 ocfs2_complete_lock_res_refresh(lockres, status); in ocfs2_inode_lock_update()
2411 struct ocfs2_lock_res *lockres = NULL; in ocfs2_inode_lock_full_nested() local
2436 lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_lock_full_nested()
2442 status = __ocfs2_cluster_lock(osb, lockres, level, dlm_flags, in ocfs2_inode_lock_full_nested()
2469 if (lockres) in ocfs2_inode_lock_full_nested()
2470 ocfs2_complete_lock_res_refresh(lockres, 0); in ocfs2_inode_lock_full_nested()
2601 struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_unlock() local
2610 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_inode_unlock()
2660 struct ocfs2_lock_res *lockres; in ocfs2_inode_lock_tracker() local
2665 lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_lock_tracker()
2666 tmp_oh = ocfs2_pid_holder(lockres, pid); in ocfs2_inode_lock_tracker()
2681 ocfs2_add_holder(lockres, oh); in ocfs2_inode_lock_tracker()
2716 struct ocfs2_lock_res *lockres; in ocfs2_inode_unlock_tracker() local
2718 lockres = &OCFS2_I(inode)->ip_inode_lockres; in ocfs2_inode_unlock_tracker()
2726 ocfs2_remove_holder(lockres, oh); in ocfs2_inode_unlock_tracker()
2732 struct ocfs2_lock_res *lockres; in ocfs2_orphan_scan_lock() local
2742 lockres = &osb->osb_orphan_scan.os_lockres; in ocfs2_orphan_scan_lock()
2743 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0); in ocfs2_orphan_scan_lock()
2747 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_orphan_scan_lock()
2748 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) && in ocfs2_orphan_scan_lock()
2759 struct ocfs2_lock_res *lockres; in ocfs2_orphan_scan_unlock() local
2763 lockres = &osb->osb_orphan_scan.os_lockres; in ocfs2_orphan_scan_unlock()
2764 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_orphan_scan_unlock()
2767 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_orphan_scan_unlock()
2776 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; in ocfs2_super_lock() local
2784 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_super_lock()
2794 status = ocfs2_should_refresh_lock_res(lockres); in ocfs2_super_lock()
2798 ocfs2_complete_lock_res_refresh(lockres, status); in ocfs2_super_lock()
2801 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_super_lock()
2804 ocfs2_track_lock_refresh(lockres); in ocfs2_super_lock()
2814 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; in ocfs2_super_unlock() local
2817 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_super_unlock()
2823 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; in ocfs2_rename_lock() local
2831 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0); in ocfs2_rename_lock()
2840 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; in ocfs2_rename_unlock() local
2843 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_rename_unlock()
2849 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres; in ocfs2_nfs_sync_lock() local
2857 status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE, in ocfs2_nfs_sync_lock()
2867 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres; in ocfs2_nfs_sync_unlock() local
2870 ocfs2_cluster_unlock(osb, lockres, in ocfs2_nfs_sync_unlock()
2879 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_lock() local
2890 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, in ocfs2_trim_fs_lock()
2899 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_trim_fs_lock()
2900 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) && in ocfs2_trim_fs_lock()
2919 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres; in ocfs2_trim_fs_unlock() local
2925 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_trim_fs_unlock()
2935 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX); in ocfs2_trim_fs_unlock()
3105 struct ocfs2_lock_res *lockres = v; in ocfs2_dlm_seq_show() local
3107 if (!lockres) in ocfs2_dlm_seq_show()
3112 if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY) in ocfs2_dlm_seq_show()
3114 lockres->l_name, in ocfs2_dlm_seq_show()
3115 (unsigned int)ocfs2_get_dentry_lock_ino(lockres)); in ocfs2_dlm_seq_show()
3117 seq_printf(m, "%.*s\t", OCFS2_LOCK_ID_MAX_LEN, lockres->l_name); in ocfs2_dlm_seq_show()
3127 lockres->l_level, in ocfs2_dlm_seq_show()
3128 lockres->l_flags, in ocfs2_dlm_seq_show()
3129 lockres->l_action, in ocfs2_dlm_seq_show()
3130 lockres->l_unlock_action, in ocfs2_dlm_seq_show()
3131 lockres->l_ro_holders, in ocfs2_dlm_seq_show()
3132 lockres->l_ex_holders, in ocfs2_dlm_seq_show()
3133 lockres->l_requested, in ocfs2_dlm_seq_show()
3134 lockres->l_blocking); in ocfs2_dlm_seq_show()
3137 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_dlm_seq_show()
3172 lock_num_prmode(lockres), in ocfs2_dlm_seq_show()
3173 lock_num_exmode(lockres), in ocfs2_dlm_seq_show()
3174 lock_num_prmode_failed(lockres), in ocfs2_dlm_seq_show()
3175 lock_num_exmode_failed(lockres), in ocfs2_dlm_seq_show()
3176 lock_total_prmode(lockres), in ocfs2_dlm_seq_show()
3177 lock_total_exmode(lockres), in ocfs2_dlm_seq_show()
3178 lock_max_prmode(lockres), in ocfs2_dlm_seq_show()
3179 lock_max_exmode(lockres), in ocfs2_dlm_seq_show()
3180 lock_refresh(lockres)); in ocfs2_dlm_seq_show()
3359 struct ocfs2_lock_res *lockres) in ocfs2_drop_lock() argument
3366 if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED)) in ocfs2_drop_lock()
3369 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) in ocfs2_drop_lock()
3372 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_drop_lock()
3374 mlog_bug_on_msg(!(lockres->l_flags & OCFS2_LOCK_FREEING), in ocfs2_drop_lock()
3376 lockres->l_name, lockres->l_flags); in ocfs2_drop_lock()
3378 while (lockres->l_flags & OCFS2_LOCK_BUSY) { in ocfs2_drop_lock()
3381 lockres->l_name, lockres->l_flags, lockres->l_action, in ocfs2_drop_lock()
3382 lockres->l_unlock_action); in ocfs2_drop_lock()
3384 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_drop_lock()
3389 ocfs2_wait_on_busy_lock(lockres); in ocfs2_drop_lock()
3391 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_drop_lock()
3394 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) { in ocfs2_drop_lock()
3395 if (lockres->l_flags & OCFS2_LOCK_ATTACHED && in ocfs2_drop_lock()
3396 lockres->l_level == DLM_LOCK_EX && in ocfs2_drop_lock()
3397 !(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) in ocfs2_drop_lock()
3398 lockres->l_ops->set_lvb(lockres); in ocfs2_drop_lock()
3401 if (lockres->l_flags & OCFS2_LOCK_BUSY) in ocfs2_drop_lock()
3403 lockres->l_name); in ocfs2_drop_lock()
3404 if (lockres->l_flags & OCFS2_LOCK_BLOCKED) in ocfs2_drop_lock()
3405 mlog(0, "destroying blocked lock: \"%s\"\n", lockres->l_name); in ocfs2_drop_lock()
3407 if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { in ocfs2_drop_lock()
3408 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_drop_lock()
3412 lockres_clear_flags(lockres, OCFS2_LOCK_ATTACHED); in ocfs2_drop_lock()
3416 BUG_ON(lockres->l_action != OCFS2_AST_INVALID); in ocfs2_drop_lock()
3419 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_drop_lock()
3420 lockres->l_unlock_action = OCFS2_UNLOCK_DROP_LOCK; in ocfs2_drop_lock()
3421 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_drop_lock()
3423 mlog(0, "lock %s\n", lockres->l_name); in ocfs2_drop_lock()
3425 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags); in ocfs2_drop_lock()
3427 ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); in ocfs2_drop_lock()
3428 mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); in ocfs2_drop_lock()
3429 ocfs2_dlm_dump_lksb(&lockres->l_lksb); in ocfs2_drop_lock()
3433 lockres->l_name); in ocfs2_drop_lock()
3435 ocfs2_wait_on_busy_lock(lockres); in ocfs2_drop_lock()
3441 struct ocfs2_lock_res *lockres);
3450 struct ocfs2_lock_res *lockres) in ocfs2_mark_lockres_freeing() argument
3458 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3459 lockres->l_flags |= OCFS2_LOCK_FREEING; in ocfs2_mark_lockres_freeing()
3460 if (lockres->l_flags & OCFS2_LOCK_QUEUED && current == osb->dc_task) { in ocfs2_mark_lockres_freeing()
3478 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3480 list_del_init(&lockres->l_blocked_list); in ocfs2_mark_lockres_freeing()
3489 WARN_ON_ONCE(lockres->l_ops->post_unlock); in ocfs2_mark_lockres_freeing()
3491 ocfs2_process_blocked_lock(osb, lockres); in ocfs2_mark_lockres_freeing()
3494 while (lockres->l_flags & OCFS2_LOCK_QUEUED) { in ocfs2_mark_lockres_freeing()
3495 lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_QUEUED, 0); in ocfs2_mark_lockres_freeing()
3496 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3498 mlog(0, "Waiting on lockres %s\n", lockres->l_name); in ocfs2_mark_lockres_freeing()
3504 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3506 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_mark_lockres_freeing()
3510 struct ocfs2_lock_res *lockres) in ocfs2_simple_drop_lockres() argument
3514 ocfs2_mark_lockres_freeing(osb, lockres); in ocfs2_simple_drop_lockres()
3515 ret = ocfs2_drop_lock(osb, lockres); in ocfs2_simple_drop_lockres()
3559 static unsigned int ocfs2_prepare_downconvert(struct ocfs2_lock_res *lockres, in ocfs2_prepare_downconvert() argument
3562 assert_spin_locked(&lockres->l_lock); in ocfs2_prepare_downconvert()
3564 BUG_ON(lockres->l_blocking <= DLM_LOCK_NL); in ocfs2_prepare_downconvert()
3566 if (lockres->l_level <= new_level) { in ocfs2_prepare_downconvert()
3569 "block %d, pgen %d\n", lockres->l_name, lockres->l_level, in ocfs2_prepare_downconvert()
3570 new_level, list_empty(&lockres->l_blocked_list), in ocfs2_prepare_downconvert()
3571 list_empty(&lockres->l_mask_waiters), lockres->l_type, in ocfs2_prepare_downconvert()
3572 lockres->l_flags, lockres->l_ro_holders, in ocfs2_prepare_downconvert()
3573 lockres->l_ex_holders, lockres->l_action, in ocfs2_prepare_downconvert()
3574 lockres->l_unlock_action, lockres->l_requested, in ocfs2_prepare_downconvert()
3575 lockres->l_blocking, lockres->l_pending_gen); in ocfs2_prepare_downconvert()
3580 lockres->l_name, lockres->l_level, new_level, lockres->l_blocking); in ocfs2_prepare_downconvert()
3582 lockres->l_action = OCFS2_AST_DOWNCONVERT; in ocfs2_prepare_downconvert()
3583 lockres->l_requested = new_level; in ocfs2_prepare_downconvert()
3584 lockres_or_flags(lockres, OCFS2_LOCK_BUSY); in ocfs2_prepare_downconvert()
3585 return lockres_set_pending(lockres); in ocfs2_prepare_downconvert()
3589 struct ocfs2_lock_res *lockres, in ocfs2_downconvert_lock() argument
3597 mlog(ML_BASTS, "lockres %s, level %d => %d\n", lockres->l_name, in ocfs2_downconvert_lock()
3598 lockres->l_level, new_level); in ocfs2_downconvert_lock()
3607 lockres->l_ops->flags & LOCK_TYPE_USES_LVB) in ocfs2_downconvert_lock()
3615 &lockres->l_lksb, in ocfs2_downconvert_lock()
3617 lockres->l_name, in ocfs2_downconvert_lock()
3619 lockres_clear_pending(lockres, generation, osb); in ocfs2_downconvert_lock()
3621 ocfs2_log_dlm_error("ocfs2_dlm_lock", ret, lockres); in ocfs2_downconvert_lock()
3622 ocfs2_recover_from_dlm_error(lockres, 1); in ocfs2_downconvert_lock()
3633 struct ocfs2_lock_res *lockres) in ocfs2_prepare_cancel_convert() argument
3635 assert_spin_locked(&lockres->l_lock); in ocfs2_prepare_cancel_convert()
3637 if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { in ocfs2_prepare_cancel_convert()
3641 mlog(ML_BASTS, "lockres %s, skip convert\n", lockres->l_name); in ocfs2_prepare_cancel_convert()
3646 BUG_ON(lockres->l_action != OCFS2_AST_CONVERT && in ocfs2_prepare_cancel_convert()
3647 lockres->l_action != OCFS2_AST_DOWNCONVERT); in ocfs2_prepare_cancel_convert()
3650 lockres->l_unlock_action = OCFS2_UNLOCK_CANCEL_CONVERT; in ocfs2_prepare_cancel_convert()
3652 mlog_bug_on_msg(!(lockres->l_flags & OCFS2_LOCK_BUSY), in ocfs2_prepare_cancel_convert()
3654 lockres->l_name, lockres->l_flags); in ocfs2_prepare_cancel_convert()
3656 mlog(ML_BASTS, "lockres %s\n", lockres->l_name); in ocfs2_prepare_cancel_convert()
3662 struct ocfs2_lock_res *lockres) in ocfs2_cancel_convert() argument
3666 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, in ocfs2_cancel_convert()
3669 ocfs2_log_dlm_error("ocfs2_dlm_unlock", ret, lockres); in ocfs2_cancel_convert()
3670 ocfs2_recover_from_dlm_error(lockres, 0); in ocfs2_cancel_convert()
3673 mlog(ML_BASTS, "lockres %s\n", lockres->l_name); in ocfs2_cancel_convert()
3679 struct ocfs2_lock_res *lockres, in ocfs2_unblock_lock() argument
3690 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3696 if (!(lockres->l_flags & OCFS2_LOCK_BLOCKED)) { in ocfs2_unblock_lock()
3697 BUG_ON(lockres->l_blocking != DLM_LOCK_NL); in ocfs2_unblock_lock()
3698 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3703 if (lockres->l_flags & OCFS2_LOCK_BUSY) { in ocfs2_unblock_lock()
3727 if (lockres->l_flags & OCFS2_LOCK_PENDING) { in ocfs2_unblock_lock()
3729 lockres->l_name); in ocfs2_unblock_lock()
3734 ret = ocfs2_prepare_cancel_convert(osb, lockres); in ocfs2_unblock_lock()
3735 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3737 ret = ocfs2_cancel_convert(osb, lockres); in ocfs2_unblock_lock()
3753 if (lockres->l_flags & OCFS2_LOCK_UPCONVERT_FINISHING) in ocfs2_unblock_lock()
3761 if (lockres->l_level == DLM_LOCK_NL) { in ocfs2_unblock_lock()
3762 BUG_ON(lockres->l_ex_holders || lockres->l_ro_holders); in ocfs2_unblock_lock()
3763 mlog(ML_BASTS, "lockres %s, Aborting dc\n", lockres->l_name); in ocfs2_unblock_lock()
3764 lockres->l_blocking = DLM_LOCK_NL; in ocfs2_unblock_lock()
3765 lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); in ocfs2_unblock_lock()
3766 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3772 if ((lockres->l_blocking == DLM_LOCK_EX) in ocfs2_unblock_lock()
3773 && (lockres->l_ex_holders || lockres->l_ro_holders)) { in ocfs2_unblock_lock()
3775 lockres->l_name, lockres->l_ex_holders, in ocfs2_unblock_lock()
3776 lockres->l_ro_holders); in ocfs2_unblock_lock()
3782 if (lockres->l_blocking == DLM_LOCK_PR && in ocfs2_unblock_lock()
3783 lockres->l_ex_holders) { in ocfs2_unblock_lock()
3785 lockres->l_name, lockres->l_ex_holders); in ocfs2_unblock_lock()
3793 if ((lockres->l_ops->flags & LOCK_TYPE_REQUIRES_REFRESH) in ocfs2_unblock_lock()
3794 && (lockres->l_flags & OCFS2_LOCK_REFRESHING)) { in ocfs2_unblock_lock()
3796 lockres->l_name); in ocfs2_unblock_lock()
3800 new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking); in ocfs2_unblock_lock()
3802 if (lockres->l_ops->check_downconvert in ocfs2_unblock_lock()
3803 && !lockres->l_ops->check_downconvert(lockres, new_level)) { in ocfs2_unblock_lock()
3805 lockres->l_name); in ocfs2_unblock_lock()
3812 if (!lockres->l_ops->downconvert_worker) in ocfs2_unblock_lock()
3819 blocking = lockres->l_blocking; in ocfs2_unblock_lock()
3820 level = lockres->l_level; in ocfs2_unblock_lock()
3821 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3823 ctl->unblock_action = lockres->l_ops->downconvert_worker(lockres, blocking); in ocfs2_unblock_lock()
3827 lockres->l_name); in ocfs2_unblock_lock()
3831 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3832 if ((blocking != lockres->l_blocking) || (level != lockres->l_level)) { in ocfs2_unblock_lock()
3836 "Recheck\n", lockres->l_name, blocking, in ocfs2_unblock_lock()
3837 lockres->l_blocking, level, lockres->l_level); in ocfs2_unblock_lock()
3844 if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) { in ocfs2_unblock_lock()
3845 if (lockres->l_level == DLM_LOCK_EX) in ocfs2_unblock_lock()
3854 if (set_lvb && !(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) in ocfs2_unblock_lock()
3855 lockres->l_ops->set_lvb(lockres); in ocfs2_unblock_lock()
3858 gen = ocfs2_prepare_downconvert(lockres, new_level); in ocfs2_unblock_lock()
3859 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3860 ret = ocfs2_downconvert_lock(osb, lockres, new_level, set_lvb, in ocfs2_unblock_lock()
3869 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_unblock_lock()
3875 static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres, in ocfs2_data_convert_worker() argument
3882 inode = ocfs2_lock_res_inode(lockres); in ocfs2_data_convert_worker()
3927 struct ocfs2_lock_res *lockres, in ocfs2_ci_checkpointed() argument
3933 BUG_ON(lockres->l_level != DLM_LOCK_EX && !checkpointed); in ocfs2_ci_checkpointed()
3942 static int ocfs2_check_meta_downconvert(struct ocfs2_lock_res *lockres, in ocfs2_check_meta_downconvert() argument
3945 struct inode *inode = ocfs2_lock_res_inode(lockres); in ocfs2_check_meta_downconvert()
3947 return ocfs2_ci_checkpointed(INODE_CACHE(inode), lockres, new_level); in ocfs2_check_meta_downconvert()
3950 static void ocfs2_set_meta_lvb(struct ocfs2_lock_res *lockres) in ocfs2_set_meta_lvb() argument
3952 struct inode *inode = ocfs2_lock_res_inode(lockres); in ocfs2_set_meta_lvb()
3963 struct ocfs2_lock_res *lockres) in ocfs2_dentry_post_unlock() argument
3965 struct ocfs2_dentry_lock *dl = ocfs2_lock_res_dl(lockres); in ocfs2_dentry_post_unlock()
3988 static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres, in ocfs2_dentry_convert_worker() argument
3991 struct ocfs2_dentry_lock *dl = ocfs2_lock_res_dl(lockres); in ocfs2_dentry_convert_worker()
4023 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_dentry_convert_worker()
4025 if (!(lockres->l_flags & OCFS2_LOCK_FREEING) in ocfs2_dentry_convert_worker()
4031 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_dentry_convert_worker()
4081 static int ocfs2_check_refcount_downconvert(struct ocfs2_lock_res *lockres, in ocfs2_check_refcount_downconvert() argument
4085 ocfs2_lock_res_refcount_tree(lockres); in ocfs2_check_refcount_downconvert()
4087 return ocfs2_ci_checkpointed(&tree->rf_ci, lockres, new_level); in ocfs2_check_refcount_downconvert()
4090 static int ocfs2_refcount_convert_worker(struct ocfs2_lock_res *lockres, in ocfs2_refcount_convert_worker() argument
4094 ocfs2_lock_res_refcount_tree(lockres); in ocfs2_refcount_convert_worker()
4101 static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres) in ocfs2_set_qinfo_lvb() argument
4104 struct ocfs2_mem_dqinfo *oinfo = ocfs2_lock_res_qinfo(lockres); in ocfs2_set_qinfo_lvb()
4108 lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_set_qinfo_lvb()
4120 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock; in ocfs2_qinfo_unlock() local
4125 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_qinfo_unlock()
4132 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock; in ocfs2_refresh_qinfo() local
4133 struct ocfs2_qinfo_lvb *lvb = ocfs2_dlm_lvb(&lockres->l_lksb); in ocfs2_refresh_qinfo()
4138 if (ocfs2_dlm_lvb_valid(&lockres->l_lksb) && in ocfs2_refresh_qinfo()
4164 ocfs2_track_lock_refresh(lockres); in ocfs2_refresh_qinfo()
4175 struct ocfs2_lock_res *lockres = &oinfo->dqi_gqlock; in ocfs2_qinfo_lock() local
4189 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_qinfo_lock()
4194 if (!ocfs2_should_refresh_lock_res(lockres)) in ocfs2_qinfo_lock()
4200 ocfs2_complete_lock_res_refresh(lockres, status); in ocfs2_qinfo_lock()
4209 struct ocfs2_lock_res *lockres = &ref_tree->rf_lockres; in ocfs2_refcount_lock() local
4210 struct ocfs2_super *osb = lockres->l_priv; in ocfs2_refcount_lock()
4219 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); in ocfs2_refcount_lock()
4229 struct ocfs2_lock_res *lockres = &ref_tree->rf_lockres; in ocfs2_refcount_unlock() local
4230 struct ocfs2_super *osb = lockres->l_priv; in ocfs2_refcount_unlock()
4233 ocfs2_cluster_unlock(osb, lockres, level); in ocfs2_refcount_unlock()
4237 struct ocfs2_lock_res *lockres) in ocfs2_process_blocked_lock() argument
4247 BUG_ON(!lockres); in ocfs2_process_blocked_lock()
4248 BUG_ON(!lockres->l_ops); in ocfs2_process_blocked_lock()
4250 mlog(ML_BASTS, "lockres %s blocked\n", lockres->l_name); in ocfs2_process_blocked_lock()
4257 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4258 if (lockres->l_flags & OCFS2_LOCK_FREEING) in ocfs2_process_blocked_lock()
4260 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4262 status = ocfs2_unblock_lock(osb, lockres, &ctl); in ocfs2_process_blocked_lock()
4266 spin_lock_irqsave(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4268 if (lockres->l_flags & OCFS2_LOCK_FREEING || !ctl.requeue) { in ocfs2_process_blocked_lock()
4269 lockres_clear_flags(lockres, OCFS2_LOCK_QUEUED); in ocfs2_process_blocked_lock()
4271 ocfs2_schedule_blocked_lock(osb, lockres); in ocfs2_process_blocked_lock()
4273 mlog(ML_BASTS, "lockres %s, requeue = %s.\n", lockres->l_name, in ocfs2_process_blocked_lock()
4275 spin_unlock_irqrestore(&lockres->l_lock, flags); in ocfs2_process_blocked_lock()
4278 && lockres->l_ops->post_unlock) in ocfs2_process_blocked_lock()
4279 lockres->l_ops->post_unlock(osb, lockres); in ocfs2_process_blocked_lock()
4283 struct ocfs2_lock_res *lockres) in ocfs2_schedule_blocked_lock() argument
4287 assert_spin_locked(&lockres->l_lock); in ocfs2_schedule_blocked_lock()
4289 if (lockres->l_flags & OCFS2_LOCK_FREEING) { in ocfs2_schedule_blocked_lock()
4294 lockres->l_name, lockres->l_flags); in ocfs2_schedule_blocked_lock()
4298 lockres_or_flags(lockres, OCFS2_LOCK_QUEUED); in ocfs2_schedule_blocked_lock()
4301 if (list_empty(&lockres->l_blocked_list)) { in ocfs2_schedule_blocked_lock()
4302 list_add_tail(&lockres->l_blocked_list, in ocfs2_schedule_blocked_lock()
4313 struct ocfs2_lock_res *lockres; in ocfs2_downconvert_thread_do_work() local
4328 lockres = list_entry(osb->blocked_lock_list.next, in ocfs2_downconvert_thread_do_work()
4330 list_del_init(&lockres->l_blocked_list); in ocfs2_downconvert_thread_do_work()
4337 ocfs2_process_blocked_lock(osb, lockres); in ocfs2_downconvert_thread_do_work()