Lines Matching refs:gh

63 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
285 static inline int may_grant(const struct gfs2_glock *gl, const struct gfs2_holder *gh) in may_grant() argument
288 if ((gh->gh_state == LM_ST_EXCLUSIVE || in may_grant()
289 gh_head->gh_state == LM_ST_EXCLUSIVE) && gh != gh_head) in may_grant()
291 if (gl->gl_state == gh->gh_state) in may_grant()
293 if (gh->gh_flags & GL_EXACT) in may_grant()
296 if (gh->gh_state == LM_ST_SHARED && gh_head->gh_state == LM_ST_SHARED) in may_grant()
298 if (gh->gh_state == LM_ST_DEFERRED && gh_head->gh_state == LM_ST_DEFERRED) in may_grant()
301 if (gl->gl_state != LM_ST_UNLOCKED && (gh->gh_flags & LM_FLAG_ANY)) in may_grant()
306 static void gfs2_holder_wake(struct gfs2_holder *gh) in gfs2_holder_wake() argument
308 clear_bit(HIF_WAIT, &gh->gh_iflags); in gfs2_holder_wake()
310 wake_up_bit(&gh->gh_iflags, HIF_WAIT); in gfs2_holder_wake()
320 struct gfs2_holder *gh, *tmp; in do_error() local
322 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { in do_error()
323 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in do_error()
326 gh->gh_error = -EIO; in do_error()
327 else if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) in do_error()
328 gh->gh_error = GLR_TRYFAILED; in do_error()
331 list_del_init(&gh->gh_list); in do_error()
332 trace_gfs2_glock_queue(gh, 0); in do_error()
333 gfs2_holder_wake(gh); in do_error()
350 struct gfs2_holder *gh, *tmp; in do_promote() local
354 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { in do_promote()
355 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in do_promote()
357 if (may_grant(gl, gh)) { in do_promote()
358 if (gh->gh_list.prev == &gl->gl_holders && in do_promote()
362 ret = glops->go_lock(gh); in do_promote()
367 gh->gh_error = ret; in do_promote()
368 list_del_init(&gh->gh_list); in do_promote()
369 trace_gfs2_glock_queue(gh, 0); in do_promote()
370 gfs2_holder_wake(gh); in do_promote()
373 set_bit(HIF_HOLDER, &gh->gh_iflags); in do_promote()
374 trace_gfs2_promote(gh, 1); in do_promote()
375 gfs2_holder_wake(gh); in do_promote()
378 set_bit(HIF_HOLDER, &gh->gh_iflags); in do_promote()
379 trace_gfs2_promote(gh, 0); in do_promote()
380 gfs2_holder_wake(gh); in do_promote()
383 if (gh->gh_list.prev == &gl->gl_holders) in do_promote()
398 struct gfs2_holder *gh; in find_first_waiter() local
400 list_for_each_entry(gh, &gl->gl_holders, gh_list) { in find_first_waiter()
401 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) in find_first_waiter()
402 return gh; in find_first_waiter()
457 struct gfs2_holder *gh; in finish_xmote() local
464 gh = find_first_waiter(gl); in finish_xmote()
473 if (gh && !test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags)) { in finish_xmote()
476 if ((gh->gh_flags & LM_FLAG_PRIORITY) == 0) in finish_xmote()
477 list_move_tail(&gh->gh_list, &gl->gl_holders); in finish_xmote()
478 gh = find_first_waiter(gl); in finish_xmote()
479 gl->gl_target = gh->gh_state; in finish_xmote()
484 (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) { in finish_xmote()
494 do_xmote(gl, gh, gl->gl_target); in finish_xmote()
499 do_xmote(gl, gh, LM_ST_UNLOCKED); in finish_xmote()
515 rv = glops->go_xmote_bh(gl, gh); in finish_xmote()
540 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target) in do_xmote() argument
546 unsigned int lck_flags = (unsigned int)(gh ? gh->gh_flags : 0); in do_xmote()
604 struct gfs2_holder *gh; in find_first_holder() local
607 gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list); in find_first_holder()
608 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in find_first_holder()
609 return gh; in find_first_holder()
625 struct gfs2_holder *gh = NULL; in run_queue() local
650 gh = find_first_waiter(gl); in run_queue()
651 gl->gl_target = gh->gh_state; in run_queue()
652 if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) in run_queue()
655 do_xmote(gl, gh, gl->gl_target); in run_queue()
890 struct gfs2_holder *gh) in gfs2_holder_init() argument
892 INIT_LIST_HEAD(&gh->gh_list); in gfs2_holder_init()
893 gh->gh_gl = gl; in gfs2_holder_init()
894 gh->gh_ip = _RET_IP_; in gfs2_holder_init()
895 gh->gh_owner_pid = get_pid(task_pid(current)); in gfs2_holder_init()
896 gh->gh_state = state; in gfs2_holder_init()
897 gh->gh_flags = flags; in gfs2_holder_init()
898 gh->gh_error = 0; in gfs2_holder_init()
899 gh->gh_iflags = 0; in gfs2_holder_init()
913 void gfs2_holder_reinit(unsigned int state, u16 flags, struct gfs2_holder *gh) in gfs2_holder_reinit() argument
915 gh->gh_state = state; in gfs2_holder_reinit()
916 gh->gh_flags = flags; in gfs2_holder_reinit()
917 gh->gh_iflags = 0; in gfs2_holder_reinit()
918 gh->gh_ip = _RET_IP_; in gfs2_holder_reinit()
919 put_pid(gh->gh_owner_pid); in gfs2_holder_reinit()
920 gh->gh_owner_pid = get_pid(task_pid(current)); in gfs2_holder_reinit()
929 void gfs2_holder_uninit(struct gfs2_holder *gh) in gfs2_holder_uninit() argument
931 put_pid(gh->gh_owner_pid); in gfs2_holder_uninit()
932 gfs2_glock_put(gh->gh_gl); in gfs2_holder_uninit()
933 gfs2_holder_mark_uninitialized(gh); in gfs2_holder_uninit()
934 gh->gh_ip = 0; in gfs2_holder_uninit()
944 int gfs2_glock_wait(struct gfs2_holder *gh) in gfs2_glock_wait() argument
949 wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE); in gfs2_glock_wait()
952 gh->gh_gl->gl_hold_time = min(gh->gh_gl->gl_hold_time + in gfs2_glock_wait()
955 return gh->gh_error; in gfs2_glock_wait()
1014 static inline void add_to_queue(struct gfs2_holder *gh) in add_to_queue() argument
1018 struct gfs2_glock *gl = gh->gh_gl; in add_to_queue()
1024 BUG_ON(gh->gh_owner_pid == NULL); in add_to_queue()
1025 if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) in add_to_queue()
1028 if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) { in add_to_queue()
1030 try_futile = !may_grant(gl, gh); in add_to_queue()
1036 if (unlikely(gh2->gh_owner_pid == gh->gh_owner_pid && in add_to_queue()
1037 (gh->gh_gl->gl_ops->go_type != LM_TYPE_FLOCK))) in add_to_queue()
1042 gh->gh_error = GLR_TRYFAILED; in add_to_queue()
1043 gfs2_holder_wake(gh); in add_to_queue()
1048 if (unlikely((gh->gh_flags & LM_FLAG_PRIORITY) && !insert_pt)) in add_to_queue()
1052 trace_gfs2_glock_queue(gh, 1); in add_to_queue()
1056 list_add_tail(&gh->gh_list, &gl->gl_holders); in add_to_queue()
1057 if (unlikely(gh->gh_flags & LM_FLAG_PRIORITY)) in add_to_queue()
1061 list_add_tail(&gh->gh_list, insert_pt); in add_to_queue()
1063 gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list); in add_to_queue()
1064 if (!(gh->gh_flags & LM_FLAG_PRIORITY)) { in add_to_queue()
1077 pr_err("new: %pSR\n", (void *)gh->gh_ip); in add_to_queue()
1078 pr_err("pid: %d\n", pid_nr(gh->gh_owner_pid)); in add_to_queue()
1080 gh->gh_gl->gl_name.ln_type, gh->gh_state); in add_to_queue()
1094 int gfs2_glock_nq(struct gfs2_holder *gh) in gfs2_glock_nq() argument
1096 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_nq()
1107 add_to_queue(gh); in gfs2_glock_nq()
1108 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) && in gfs2_glock_nq()
1117 if (!(gh->gh_flags & GL_ASYNC)) in gfs2_glock_nq()
1118 error = gfs2_glock_wait(gh); in gfs2_glock_nq()
1130 int gfs2_glock_poll(struct gfs2_holder *gh) in gfs2_glock_poll() argument
1132 return test_bit(HIF_WAIT, &gh->gh_iflags) ? 0 : 1; in gfs2_glock_poll()
1141 void gfs2_glock_dq(struct gfs2_holder *gh) in gfs2_glock_dq() argument
1143 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_dq()
1149 if (gh->gh_flags & GL_NOCACHE) in gfs2_glock_dq()
1152 list_del_init(&gh->gh_list); in gfs2_glock_dq()
1153 clear_bit(HIF_HOLDER, &gh->gh_iflags); in gfs2_glock_dq()
1158 glops->go_unlock(gh); in gfs2_glock_dq()
1170 trace_gfs2_glock_queue(gh, 0); in gfs2_glock_dq()
1182 void gfs2_glock_dq_wait(struct gfs2_holder *gh) in gfs2_glock_dq_wait() argument
1184 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_dq_wait()
1185 gfs2_glock_dq(gh); in gfs2_glock_dq_wait()
1196 void gfs2_glock_dq_uninit(struct gfs2_holder *gh) in gfs2_glock_dq_uninit() argument
1198 gfs2_glock_dq(gh); in gfs2_glock_dq_uninit()
1199 gfs2_holder_uninit(gh); in gfs2_glock_dq_uninit()
1216 unsigned int state, u16 flags, struct gfs2_holder *gh) in gfs2_glock_nq_num() argument
1223 error = gfs2_glock_nq_init(gl, state, flags, gh); in gfs2_glock_nq_num()
1373 const struct gfs2_holder *gh; in gfs2_should_freeze() local
1380 list_for_each_entry(gh, &gl->gl_holders, gh_list) { in gfs2_should_freeze()
1381 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in gfs2_should_freeze()
1383 if (LM_FLAG_NOEXP & gh->gh_flags) in gfs2_should_freeze()
1713 static void dump_holder(struct seq_file *seq, const struct gfs2_holder *gh) in dump_holder() argument
1719 if (gh->gh_owner_pid) in dump_holder()
1720 gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID); in dump_holder()
1722 state2str(gh->gh_state), in dump_holder()
1723 hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags), in dump_holder()
1724 gh->gh_error, in dump_holder()
1725 gh->gh_owner_pid ? (long)pid_nr(gh->gh_owner_pid) : -1, in dump_holder()
1727 (void *)gh->gh_ip); in dump_holder()
1789 const struct gfs2_holder *gh; in gfs2_dump_glock() local
1807 list_for_each_entry(gh, &gl->gl_holders, gh_list) in gfs2_dump_glock()
1808 dump_holder(seq, gh); in gfs2_dump_glock()