Lines Matching refs:gh
62 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
249 static inline int may_grant(const struct gfs2_glock *gl, const struct gfs2_holder *gh) in may_grant() argument
252 if ((gh->gh_state == LM_ST_EXCLUSIVE || in may_grant()
253 gh_head->gh_state == LM_ST_EXCLUSIVE) && gh != gh_head) in may_grant()
255 if (gl->gl_state == gh->gh_state) in may_grant()
257 if (gh->gh_flags & GL_EXACT) in may_grant()
260 if (gh->gh_state == LM_ST_SHARED && gh_head->gh_state == LM_ST_SHARED) in may_grant()
262 if (gh->gh_state == LM_ST_DEFERRED && gh_head->gh_state == LM_ST_DEFERRED) in may_grant()
265 if (gl->gl_state != LM_ST_UNLOCKED && (gh->gh_flags & LM_FLAG_ANY)) in may_grant()
270 static void gfs2_holder_wake(struct gfs2_holder *gh) in gfs2_holder_wake() argument
272 clear_bit(HIF_WAIT, &gh->gh_iflags); in gfs2_holder_wake()
274 wake_up_bit(&gh->gh_iflags, HIF_WAIT); in gfs2_holder_wake()
284 struct gfs2_holder *gh, *tmp; in do_error() local
286 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { in do_error()
287 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in do_error()
290 gh->gh_error = -EIO; in do_error()
291 else if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) in do_error()
292 gh->gh_error = GLR_TRYFAILED; in do_error()
295 list_del_init(&gh->gh_list); in do_error()
296 trace_gfs2_glock_queue(gh, 0); in do_error()
297 gfs2_holder_wake(gh); in do_error()
314 struct gfs2_holder *gh, *tmp; in do_promote() local
318 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { in do_promote()
319 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in do_promote()
321 if (may_grant(gl, gh)) { in do_promote()
322 if (gh->gh_list.prev == &gl->gl_holders && in do_promote()
326 ret = glops->go_lock(gh); in do_promote()
331 gh->gh_error = ret; in do_promote()
332 list_del_init(&gh->gh_list); in do_promote()
333 trace_gfs2_glock_queue(gh, 0); in do_promote()
334 gfs2_holder_wake(gh); in do_promote()
337 set_bit(HIF_HOLDER, &gh->gh_iflags); in do_promote()
338 trace_gfs2_promote(gh, 1); in do_promote()
339 gfs2_holder_wake(gh); in do_promote()
342 set_bit(HIF_HOLDER, &gh->gh_iflags); in do_promote()
343 trace_gfs2_promote(gh, 0); in do_promote()
344 gfs2_holder_wake(gh); in do_promote()
347 if (gh->gh_list.prev == &gl->gl_holders) in do_promote()
362 struct gfs2_holder *gh; in find_first_waiter() local
364 list_for_each_entry(gh, &gl->gl_holders, gh_list) { in find_first_waiter()
365 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) in find_first_waiter()
366 return gh; in find_first_waiter()
421 struct gfs2_holder *gh; in finish_xmote() local
428 gh = find_first_waiter(gl); in finish_xmote()
437 if (gh && !test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags)) { in finish_xmote()
440 if ((gh->gh_flags & LM_FLAG_PRIORITY) == 0) in finish_xmote()
441 list_move_tail(&gh->gh_list, &gl->gl_holders); in finish_xmote()
442 gh = find_first_waiter(gl); in finish_xmote()
443 gl->gl_target = gh->gh_state; in finish_xmote()
448 (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) { in finish_xmote()
458 do_xmote(gl, gh, gl->gl_target); in finish_xmote()
463 do_xmote(gl, gh, LM_ST_UNLOCKED); in finish_xmote()
479 rv = glops->go_xmote_bh(gl, gh); in finish_xmote()
504 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target) in do_xmote() argument
510 unsigned int lck_flags = gh ? gh->gh_flags : 0; in do_xmote()
559 struct gfs2_holder *gh; in find_first_holder() local
562 gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list); in find_first_holder()
563 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in find_first_holder()
564 return gh; in find_first_holder()
580 struct gfs2_holder *gh = NULL; in run_queue() local
605 gh = find_first_waiter(gl); in run_queue()
606 gl->gl_target = gh->gh_state; in run_queue()
607 if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) in run_queue()
610 do_xmote(gl, gh, gl->gl_target); in run_queue()
802 struct gfs2_holder *gh) in gfs2_holder_init() argument
804 INIT_LIST_HEAD(&gh->gh_list); in gfs2_holder_init()
805 gh->gh_gl = gl; in gfs2_holder_init()
806 gh->gh_ip = _RET_IP_; in gfs2_holder_init()
807 gh->gh_owner_pid = get_pid(task_pid(current)); in gfs2_holder_init()
808 gh->gh_state = state; in gfs2_holder_init()
809 gh->gh_flags = flags; in gfs2_holder_init()
810 gh->gh_error = 0; in gfs2_holder_init()
811 gh->gh_iflags = 0; in gfs2_holder_init()
825 void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *gh) in gfs2_holder_reinit() argument
827 gh->gh_state = state; in gfs2_holder_reinit()
828 gh->gh_flags = flags; in gfs2_holder_reinit()
829 gh->gh_iflags = 0; in gfs2_holder_reinit()
830 gh->gh_ip = _RET_IP_; in gfs2_holder_reinit()
831 put_pid(gh->gh_owner_pid); in gfs2_holder_reinit()
832 gh->gh_owner_pid = get_pid(task_pid(current)); in gfs2_holder_reinit()
841 void gfs2_holder_uninit(struct gfs2_holder *gh) in gfs2_holder_uninit() argument
843 put_pid(gh->gh_owner_pid); in gfs2_holder_uninit()
844 gfs2_glock_put(gh->gh_gl); in gfs2_holder_uninit()
845 gh->gh_gl = NULL; in gfs2_holder_uninit()
846 gh->gh_ip = 0; in gfs2_holder_uninit()
856 int gfs2_glock_wait(struct gfs2_holder *gh) in gfs2_glock_wait() argument
861 wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE); in gfs2_glock_wait()
864 gh->gh_gl->gl_hold_time = min(gh->gh_gl->gl_hold_time + in gfs2_glock_wait()
867 return gh->gh_error; in gfs2_glock_wait()
926 static inline void add_to_queue(struct gfs2_holder *gh) in add_to_queue() argument
930 struct gfs2_glock *gl = gh->gh_gl; in add_to_queue()
936 BUG_ON(gh->gh_owner_pid == NULL); in add_to_queue()
937 if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) in add_to_queue()
940 if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) { in add_to_queue()
942 try_futile = !may_grant(gl, gh); in add_to_queue()
948 if (unlikely(gh2->gh_owner_pid == gh->gh_owner_pid && in add_to_queue()
949 (gh->gh_gl->gl_ops->go_type != LM_TYPE_FLOCK))) in add_to_queue()
954 gh->gh_error = GLR_TRYFAILED; in add_to_queue()
955 gfs2_holder_wake(gh); in add_to_queue()
960 if (unlikely((gh->gh_flags & LM_FLAG_PRIORITY) && !insert_pt)) in add_to_queue()
964 trace_gfs2_glock_queue(gh, 1); in add_to_queue()
968 list_add_tail(&gh->gh_list, &gl->gl_holders); in add_to_queue()
969 if (unlikely(gh->gh_flags & LM_FLAG_PRIORITY)) in add_to_queue()
973 list_add_tail(&gh->gh_list, insert_pt); in add_to_queue()
975 gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list); in add_to_queue()
976 if (!(gh->gh_flags & LM_FLAG_PRIORITY)) { in add_to_queue()
989 pr_err("new: %pSR\n", (void *)gh->gh_ip); in add_to_queue()
990 pr_err("pid: %d\n", pid_nr(gh->gh_owner_pid)); in add_to_queue()
992 gh->gh_gl->gl_name.ln_type, gh->gh_state); in add_to_queue()
1006 int gfs2_glock_nq(struct gfs2_holder *gh) in gfs2_glock_nq() argument
1008 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_nq()
1019 add_to_queue(gh); in gfs2_glock_nq()
1020 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) && in gfs2_glock_nq()
1030 if (!(gh->gh_flags & GL_ASYNC)) in gfs2_glock_nq()
1031 error = gfs2_glock_wait(gh); in gfs2_glock_nq()
1043 int gfs2_glock_poll(struct gfs2_holder *gh) in gfs2_glock_poll() argument
1045 return test_bit(HIF_WAIT, &gh->gh_iflags) ? 0 : 1; in gfs2_glock_poll()
1054 void gfs2_glock_dq(struct gfs2_holder *gh) in gfs2_glock_dq() argument
1056 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_dq()
1062 if (gh->gh_flags & GL_NOCACHE) in gfs2_glock_dq()
1065 list_del_init(&gh->gh_list); in gfs2_glock_dq()
1070 glops->go_unlock(gh); in gfs2_glock_dq()
1082 trace_gfs2_glock_queue(gh, 0); in gfs2_glock_dq()
1096 void gfs2_glock_dq_wait(struct gfs2_holder *gh) in gfs2_glock_dq_wait() argument
1098 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_dq_wait()
1099 gfs2_glock_dq(gh); in gfs2_glock_dq_wait()
1110 void gfs2_glock_dq_uninit(struct gfs2_holder *gh) in gfs2_glock_dq_uninit() argument
1112 gfs2_glock_dq(gh); in gfs2_glock_dq_uninit()
1113 gfs2_holder_uninit(gh); in gfs2_glock_dq_uninit()
1130 unsigned int state, int flags, struct gfs2_holder *gh) in gfs2_glock_nq_num() argument
1137 error = gfs2_glock_nq_init(gl, state, flags, gh); in gfs2_glock_nq_num()
1287 const struct gfs2_holder *gh; in gfs2_should_freeze() local
1294 list_for_each_entry(gh, &gl->gl_holders, gh_list) { in gfs2_should_freeze()
1295 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in gfs2_should_freeze()
1297 if (LM_FLAG_NOEXP & gh->gh_flags) in gfs2_should_freeze()
1630 static void dump_holder(struct seq_file *seq, const struct gfs2_holder *gh) in dump_holder() argument
1636 if (gh->gh_owner_pid) in dump_holder()
1637 gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID); in dump_holder()
1639 state2str(gh->gh_state), in dump_holder()
1640 hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags), in dump_holder()
1641 gh->gh_error, in dump_holder()
1642 gh->gh_owner_pid ? (long)pid_nr(gh->gh_owner_pid) : -1, in dump_holder()
1644 (void *)gh->gh_ip); in dump_holder()
1706 const struct gfs2_holder *gh; in gfs2_dump_glock() local
1724 list_for_each_entry(gh, &gl->gl_holders, gh_list) in gfs2_dump_glock()
1725 dump_holder(seq, gh); in gfs2_dump_glock()