Lines Matching refs:gh
60 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
313 static inline int may_grant(const struct gfs2_glock *gl, const struct gfs2_holder *gh) in may_grant() argument
316 if ((gh->gh_state == LM_ST_EXCLUSIVE || in may_grant()
317 gh_head->gh_state == LM_ST_EXCLUSIVE) && gh != gh_head) in may_grant()
319 if (gl->gl_state == gh->gh_state) in may_grant()
321 if (gh->gh_flags & GL_EXACT) in may_grant()
324 if (gh->gh_state == LM_ST_SHARED && gh_head->gh_state == LM_ST_SHARED) in may_grant()
326 if (gh->gh_state == LM_ST_DEFERRED && gh_head->gh_state == LM_ST_DEFERRED) in may_grant()
329 if (gl->gl_state != LM_ST_UNLOCKED && (gh->gh_flags & LM_FLAG_ANY)) in may_grant()
334 static void gfs2_holder_wake(struct gfs2_holder *gh) in gfs2_holder_wake() argument
336 clear_bit(HIF_WAIT, &gh->gh_iflags); in gfs2_holder_wake()
338 wake_up_bit(&gh->gh_iflags, HIF_WAIT); in gfs2_holder_wake()
339 if (gh->gh_flags & GL_ASYNC) { in gfs2_holder_wake()
340 struct gfs2_sbd *sdp = gh->gh_gl->gl_name.ln_sbd; in gfs2_holder_wake()
353 struct gfs2_holder *gh, *tmp; in do_error() local
355 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { in do_error()
356 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in do_error()
359 gh->gh_error = -EIO; in do_error()
360 else if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) in do_error()
361 gh->gh_error = GLR_TRYFAILED; in do_error()
364 list_del_init(&gh->gh_list); in do_error()
365 trace_gfs2_glock_queue(gh, 0); in do_error()
366 gfs2_holder_wake(gh); in do_error()
383 struct gfs2_holder *gh, *tmp; in do_promote() local
387 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { in do_promote()
388 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in do_promote()
390 if (may_grant(gl, gh)) { in do_promote()
391 if (gh->gh_list.prev == &gl->gl_holders && in do_promote()
395 ret = glops->go_lock(gh); in do_promote()
400 gh->gh_error = ret; in do_promote()
401 list_del_init(&gh->gh_list); in do_promote()
402 trace_gfs2_glock_queue(gh, 0); in do_promote()
403 gfs2_holder_wake(gh); in do_promote()
406 set_bit(HIF_HOLDER, &gh->gh_iflags); in do_promote()
407 trace_gfs2_promote(gh, 1); in do_promote()
408 gfs2_holder_wake(gh); in do_promote()
411 set_bit(HIF_HOLDER, &gh->gh_iflags); in do_promote()
412 trace_gfs2_promote(gh, 0); in do_promote()
413 gfs2_holder_wake(gh); in do_promote()
416 if (gh->gh_list.prev == &gl->gl_holders) in do_promote()
431 struct gfs2_holder *gh; in find_first_waiter() local
433 list_for_each_entry(gh, &gl->gl_holders, gh_list) { in find_first_waiter()
434 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) in find_first_waiter()
435 return gh; in find_first_waiter()
496 struct gfs2_holder *gh; in finish_xmote() local
503 gh = find_first_waiter(gl); in finish_xmote()
512 if (gh && !test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags)) { in finish_xmote()
515 if ((gh->gh_flags & LM_FLAG_PRIORITY) == 0) in finish_xmote()
516 list_move_tail(&gh->gh_list, &gl->gl_holders); in finish_xmote()
517 gh = find_first_waiter(gl); in finish_xmote()
518 gl->gl_target = gh->gh_state; in finish_xmote()
523 (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) { in finish_xmote()
533 do_xmote(gl, gh, gl->gl_target); in finish_xmote()
538 do_xmote(gl, gh, LM_ST_UNLOCKED); in finish_xmote()
555 rv = glops->go_xmote_bh(gl, gh); in finish_xmote()
590 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target) in do_xmote() argument
596 unsigned int lck_flags = (unsigned int)(gh ? gh->gh_flags : 0); in do_xmote()
600 gh && !(gh->gh_flags & LM_FLAG_NOEXP)) in do_xmote()
720 struct gfs2_holder *gh; in find_first_holder() local
723 gh = list_first_entry(&gl->gl_holders, struct gfs2_holder, gh_list); in find_first_holder()
724 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in find_first_holder()
725 return gh; in find_first_holder()
741 struct gfs2_holder *gh = NULL; in run_queue() local
766 gh = find_first_waiter(gl); in run_queue()
767 gl->gl_target = gh->gh_state; in run_queue()
768 if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) in run_queue()
771 do_xmote(gl, gh, gl->gl_target); in run_queue()
810 struct gfs2_holder gh; in gfs2_glock_poke() local
813 gfs2_holder_init(gl, LM_ST_SHARED, flags, &gh); in gfs2_glock_poke()
814 error = gfs2_glock_nq(&gh); in gfs2_glock_poke()
816 gfs2_glock_dq(&gh); in gfs2_glock_poke()
817 gfs2_holder_uninit(&gh); in gfs2_glock_poke()
1117 struct gfs2_holder *gh) in gfs2_holder_init() argument
1119 INIT_LIST_HEAD(&gh->gh_list); in gfs2_holder_init()
1120 gh->gh_gl = gl; in gfs2_holder_init()
1121 gh->gh_ip = _RET_IP_; in gfs2_holder_init()
1122 gh->gh_owner_pid = get_pid(task_pid(current)); in gfs2_holder_init()
1123 gh->gh_state = state; in gfs2_holder_init()
1124 gh->gh_flags = flags; in gfs2_holder_init()
1125 gh->gh_error = 0; in gfs2_holder_init()
1126 gh->gh_iflags = 0; in gfs2_holder_init()
1140 void gfs2_holder_reinit(unsigned int state, u16 flags, struct gfs2_holder *gh) in gfs2_holder_reinit() argument
1142 gh->gh_state = state; in gfs2_holder_reinit()
1143 gh->gh_flags = flags; in gfs2_holder_reinit()
1144 gh->gh_iflags = 0; in gfs2_holder_reinit()
1145 gh->gh_ip = _RET_IP_; in gfs2_holder_reinit()
1146 put_pid(gh->gh_owner_pid); in gfs2_holder_reinit()
1147 gh->gh_owner_pid = get_pid(task_pid(current)); in gfs2_holder_reinit()
1156 void gfs2_holder_uninit(struct gfs2_holder *gh) in gfs2_holder_uninit() argument
1158 put_pid(gh->gh_owner_pid); in gfs2_holder_uninit()
1159 gfs2_glock_put(gh->gh_gl); in gfs2_holder_uninit()
1160 gfs2_holder_mark_uninitialized(gh); in gfs2_holder_uninit()
1161 gh->gh_ip = 0; in gfs2_holder_uninit()
1182 int gfs2_glock_wait(struct gfs2_holder *gh) in gfs2_glock_wait() argument
1187 wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE); in gfs2_glock_wait()
1188 gfs2_glock_update_hold_time(gh->gh_gl, start_time); in gfs2_glock_wait()
1189 return gh->gh_error; in gfs2_glock_wait()
1334 static inline void add_to_queue(struct gfs2_holder *gh) in add_to_queue() argument
1338 struct gfs2_glock *gl = gh->gh_gl; in add_to_queue()
1344 GLOCK_BUG_ON(gl, gh->gh_owner_pid == NULL); in add_to_queue()
1345 if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) in add_to_queue()
1348 if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) { in add_to_queue()
1350 try_futile = !may_grant(gl, gh); in add_to_queue()
1356 if (unlikely(gh2->gh_owner_pid == gh->gh_owner_pid && in add_to_queue()
1357 (gh->gh_gl->gl_ops->go_type != LM_TYPE_FLOCK))) in add_to_queue()
1362 gh->gh_error = GLR_TRYFAILED; in add_to_queue()
1363 gfs2_holder_wake(gh); in add_to_queue()
1368 if (unlikely((gh->gh_flags & LM_FLAG_PRIORITY) && !insert_pt)) in add_to_queue()
1371 trace_gfs2_glock_queue(gh, 1); in add_to_queue()
1375 list_add_tail(&gh->gh_list, &gl->gl_holders); in add_to_queue()
1376 if (unlikely(gh->gh_flags & LM_FLAG_PRIORITY)) in add_to_queue()
1380 list_add_tail(&gh->gh_list, insert_pt); in add_to_queue()
1382 gh = list_first_entry(&gl->gl_holders, struct gfs2_holder, gh_list); in add_to_queue()
1383 if (!(gh->gh_flags & LM_FLAG_PRIORITY)) { in add_to_queue()
1396 fs_err(sdp, "new: %pSR\n", (void *)gh->gh_ip); in add_to_queue()
1397 fs_err(sdp, "pid: %d\n", pid_nr(gh->gh_owner_pid)); in add_to_queue()
1399 gh->gh_gl->gl_name.ln_type, gh->gh_state); in add_to_queue()
1413 int gfs2_glock_nq(struct gfs2_holder *gh) in gfs2_glock_nq() argument
1415 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_nq()
1418 if (glock_blocked_by_withdraw(gl) && !(gh->gh_flags & LM_FLAG_NOEXP)) in gfs2_glock_nq()
1425 add_to_queue(gh); in gfs2_glock_nq()
1426 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) && in gfs2_glock_nq()
1435 if (!(gh->gh_flags & GL_ASYNC)) in gfs2_glock_nq()
1436 error = gfs2_glock_wait(gh); in gfs2_glock_nq()
1448 int gfs2_glock_poll(struct gfs2_holder *gh) in gfs2_glock_poll() argument
1450 return test_bit(HIF_WAIT, &gh->gh_iflags) ? 0 : 1; in gfs2_glock_poll()
1459 void gfs2_glock_dq(struct gfs2_holder *gh) in gfs2_glock_dq() argument
1461 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_dq()
1476 gh->gh_gl != sdp->sd_jinode_gl) { in gfs2_glock_dq()
1484 if (gh->gh_flags & GL_NOCACHE) in gfs2_glock_dq()
1487 list_del_init(&gh->gh_list); in gfs2_glock_dq()
1488 clear_bit(HIF_HOLDER, &gh->gh_iflags); in gfs2_glock_dq()
1498 trace_gfs2_glock_queue(gh, 0); in gfs2_glock_dq()
1510 void gfs2_glock_dq_wait(struct gfs2_holder *gh) in gfs2_glock_dq_wait() argument
1512 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_dq_wait()
1513 gfs2_glock_dq(gh); in gfs2_glock_dq_wait()
1524 void gfs2_glock_dq_uninit(struct gfs2_holder *gh) in gfs2_glock_dq_uninit() argument
1526 gfs2_glock_dq(gh); in gfs2_glock_dq_uninit()
1527 gfs2_holder_uninit(gh); in gfs2_glock_dq_uninit()
1544 unsigned int state, u16 flags, struct gfs2_holder *gh) in gfs2_glock_nq_num() argument
1551 error = gfs2_glock_nq_init(gl, state, flags, gh); in gfs2_glock_nq_num()
1700 const struct gfs2_holder *gh; in gfs2_should_freeze() local
1707 list_for_each_entry(gh, &gl->gl_holders, gh_list) { in gfs2_should_freeze()
1708 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in gfs2_should_freeze()
1710 if (LM_FLAG_NOEXP & gh->gh_flags) in gfs2_should_freeze()
2085 static void dump_holder(struct seq_file *seq, const struct gfs2_holder *gh, in dump_holder() argument
2092 if (gh->gh_owner_pid) in dump_holder()
2093 gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID); in dump_holder()
2095 fs_id_buf, state2str(gh->gh_state), in dump_holder()
2096 hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags), in dump_holder()
2097 gh->gh_error, in dump_holder()
2098 gh->gh_owner_pid ? (long)pid_nr(gh->gh_owner_pid) : -1, in dump_holder()
2100 (void *)gh->gh_ip); in dump_holder()
2169 const struct gfs2_holder *gh; in gfs2_dump_glock() local
2199 list_for_each_entry(gh, &gl->gl_holders, gh_list) in gfs2_dump_glock()
2200 dump_holder(seq, gh, fs_id_buf); in gfs2_dump_glock()