Lines Matching refs:gh

60 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
61 static void __gfs2_glock_dq(struct gfs2_holder *gh);
329 struct gfs2_holder *gh) in may_grant() argument
343 return gh->gh_state == LM_ST_EXCLUSIVE && in may_grant()
345 (gh->gh_flags & LM_FLAG_NODE_SCOPE); in may_grant()
349 return gh->gh_state == current_gh->gh_state; in may_grant()
356 if (gl->gl_state == gh->gh_state) in may_grant()
358 if (gh->gh_flags & GL_EXACT) in may_grant()
361 return gh->gh_state == LM_ST_SHARED || in may_grant()
362 gh->gh_state == LM_ST_DEFERRED; in may_grant()
364 if (gh->gh_flags & LM_FLAG_ANY) in may_grant()
369 static void gfs2_holder_wake(struct gfs2_holder *gh) in gfs2_holder_wake() argument
371 clear_bit(HIF_WAIT, &gh->gh_iflags); in gfs2_holder_wake()
373 wake_up_bit(&gh->gh_iflags, HIF_WAIT); in gfs2_holder_wake()
374 if (gh->gh_flags & GL_ASYNC) { in gfs2_holder_wake()
375 struct gfs2_sbd *sdp = gh->gh_gl->gl_name.ln_sbd; in gfs2_holder_wake()
389 struct gfs2_holder *gh, *tmp; in do_error() local
391 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { in do_error()
392 if (!test_bit(HIF_WAIT, &gh->gh_iflags)) in do_error()
395 gh->gh_error = -EIO; in do_error()
396 else if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) in do_error()
397 gh->gh_error = GLR_TRYFAILED; in do_error()
400 list_del_init(&gh->gh_list); in do_error()
401 trace_gfs2_glock_queue(gh, 0); in do_error()
402 gfs2_holder_wake(gh); in do_error()
414 struct gfs2_holder *gh, *tmp; in demote_incompat_holders() local
421 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { in demote_incompat_holders()
426 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) in demote_incompat_holders()
428 if (test_bit(HIF_MAY_DEMOTE, &gh->gh_iflags) && in demote_incompat_holders()
429 !may_grant(gl, new_gh, gh)) { in demote_incompat_holders()
435 __gfs2_glock_dq(gh); in demote_incompat_holders()
447 struct gfs2_holder *gh; in find_first_holder() local
450 gh = list_first_entry(&gl->gl_holders, struct gfs2_holder, in find_first_holder()
452 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in find_first_holder()
453 return gh; in find_first_holder()
467 struct gfs2_holder *gh; in find_first_strong_holder() local
469 list_for_each_entry(gh, &gl->gl_holders, gh_list) { in find_first_strong_holder()
470 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) in find_first_strong_holder()
472 if (!test_bit(HIF_MAY_DEMOTE, &gh->gh_iflags)) in find_first_strong_holder()
473 return gh; in find_first_strong_holder()
485 int gfs2_instantiate(struct gfs2_holder *gh) in gfs2_instantiate() argument
487 struct gfs2_glock *gl = gh->gh_gl; in gfs2_instantiate()
512 ret = glops->go_instantiate(gh); in gfs2_instantiate()
531 struct gfs2_holder *gh, *tmp, *first_gh; in do_promote() local
538 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) { in do_promote()
540 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in do_promote()
542 if (!may_grant(gl, first_gh, gh)) { in do_promote()
548 if (gh->gh_list.prev == &gl->gl_holders) in do_promote()
556 first_gh = gh; in do_promote()
559 !(gh->gh_flags & GL_SKIP) && gl->gl_ops->go_instantiate) { in do_promote()
562 ret = gfs2_instantiate(gh); in do_promote()
567 gh->gh_error = ret; in do_promote()
568 list_del_init(&gh->gh_list); in do_promote()
569 trace_gfs2_glock_queue(gh, 0); in do_promote()
570 gfs2_holder_wake(gh); in do_promote()
574 set_bit(HIF_HOLDER, &gh->gh_iflags); in do_promote()
575 trace_gfs2_promote(gh); in do_promote()
576 gfs2_holder_wake(gh); in do_promote()
595 struct gfs2_holder *gh; in find_first_waiter() local
597 list_for_each_entry(gh, &gl->gl_holders, gh_list) { in find_first_waiter()
598 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) in find_first_waiter()
599 return gh; in find_first_waiter()
659 struct gfs2_holder *gh; in finish_xmote() local
666 gh = find_first_waiter(gl); in finish_xmote()
675 if (gh && !test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags)) { in finish_xmote()
678 if ((gh->gh_flags & LM_FLAG_PRIORITY) == 0) in finish_xmote()
679 list_move_tail(&gh->gh_list, &gl->gl_holders); in finish_xmote()
680 gh = find_first_waiter(gl); in finish_xmote()
681 gl->gl_target = gh->gh_state; in finish_xmote()
686 (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) { in finish_xmote()
696 do_xmote(gl, gh, gl->gl_target); in finish_xmote()
701 do_xmote(gl, gh, LM_ST_UNLOCKED); in finish_xmote()
753 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target) in do_xmote() argument
759 unsigned int lck_flags = (unsigned int)(gh ? gh->gh_flags : 0); in do_xmote()
763 gh && !(gh->gh_flags & LM_FLAG_NOEXP)) in do_xmote()
887 struct gfs2_holder *gh = NULL; in run_queue() local
912 gh = find_first_waiter(gl); in run_queue()
913 gl->gl_target = gh->gh_state; in run_queue()
914 if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) in run_queue()
917 do_xmote(gl, gh, gl->gl_target); in run_queue()
956 struct gfs2_holder gh; in gfs2_glock_poke() local
959 __gfs2_holder_init(gl, LM_ST_SHARED, flags, &gh, _RET_IP_); in gfs2_glock_poke()
960 error = gfs2_glock_nq(&gh); in gfs2_glock_poke()
962 gfs2_glock_dq(&gh); in gfs2_glock_poke()
963 gfs2_holder_uninit(&gh); in gfs2_glock_poke()
1257 struct gfs2_holder *gh, unsigned long ip) in __gfs2_holder_init() argument
1259 INIT_LIST_HEAD(&gh->gh_list); in __gfs2_holder_init()
1260 gh->gh_gl = gl; in __gfs2_holder_init()
1261 gh->gh_ip = ip; in __gfs2_holder_init()
1262 gh->gh_owner_pid = get_pid(task_pid(current)); in __gfs2_holder_init()
1263 gh->gh_state = state; in __gfs2_holder_init()
1264 gh->gh_flags = flags; in __gfs2_holder_init()
1265 gh->gh_error = 0; in __gfs2_holder_init()
1266 gh->gh_iflags = 0; in __gfs2_holder_init()
1280 void gfs2_holder_reinit(unsigned int state, u16 flags, struct gfs2_holder *gh) in gfs2_holder_reinit() argument
1282 gh->gh_state = state; in gfs2_holder_reinit()
1283 gh->gh_flags = flags; in gfs2_holder_reinit()
1284 gh->gh_iflags = 0; in gfs2_holder_reinit()
1285 gh->gh_ip = _RET_IP_; in gfs2_holder_reinit()
1286 put_pid(gh->gh_owner_pid); in gfs2_holder_reinit()
1287 gh->gh_owner_pid = get_pid(task_pid(current)); in gfs2_holder_reinit()
1296 void gfs2_holder_uninit(struct gfs2_holder *gh) in gfs2_holder_uninit() argument
1298 put_pid(gh->gh_owner_pid); in gfs2_holder_uninit()
1299 gfs2_glock_put(gh->gh_gl); in gfs2_holder_uninit()
1300 gfs2_holder_mark_uninitialized(gh); in gfs2_holder_uninit()
1301 gh->gh_ip = 0; in gfs2_holder_uninit()
1322 int gfs2_glock_wait(struct gfs2_holder *gh) in gfs2_glock_wait() argument
1327 wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE); in gfs2_glock_wait()
1328 gfs2_glock_update_hold_time(gh->gh_gl, start_time); in gfs2_glock_wait()
1329 return gh->gh_error; in gfs2_glock_wait()
1476 static inline void add_to_queue(struct gfs2_holder *gh) in add_to_queue() argument
1480 struct gfs2_glock *gl = gh->gh_gl; in add_to_queue()
1486 GLOCK_BUG_ON(gl, gh->gh_owner_pid == NULL); in add_to_queue()
1487 if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) in add_to_queue()
1490 if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) { in add_to_queue()
1495 try_futile = !may_grant(gl, first_gh, gh); in add_to_queue()
1502 if (unlikely(gh2->gh_owner_pid == gh->gh_owner_pid && in add_to_queue()
1503 (gh->gh_gl->gl_ops->go_type != LM_TYPE_FLOCK) && in add_to_queue()
1509 gh->gh_error = GLR_TRYFAILED; in add_to_queue()
1510 gfs2_holder_wake(gh); in add_to_queue()
1515 if (unlikely((gh->gh_flags & LM_FLAG_PRIORITY) && !insert_pt)) in add_to_queue()
1518 trace_gfs2_glock_queue(gh, 1); in add_to_queue()
1522 list_add_tail(&gh->gh_list, &gl->gl_holders); in add_to_queue()
1523 if (unlikely(gh->gh_flags & LM_FLAG_PRIORITY)) in add_to_queue()
1527 list_add_tail(&gh->gh_list, insert_pt); in add_to_queue()
1529 gh = list_first_entry(&gl->gl_holders, struct gfs2_holder, gh_list); in add_to_queue()
1530 if (!(gh->gh_flags & LM_FLAG_PRIORITY)) { in add_to_queue()
1543 fs_err(sdp, "new: %pSR\n", (void *)gh->gh_ip); in add_to_queue()
1544 fs_err(sdp, "pid: %d\n", pid_nr(gh->gh_owner_pid)); in add_to_queue()
1546 gh->gh_gl->gl_name.ln_type, gh->gh_state); in add_to_queue()
1560 int gfs2_glock_nq(struct gfs2_holder *gh) in gfs2_glock_nq() argument
1562 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_nq()
1565 if (glock_blocked_by_withdraw(gl) && !(gh->gh_flags & LM_FLAG_NOEXP)) in gfs2_glock_nq()
1572 add_to_queue(gh); in gfs2_glock_nq()
1573 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) && in gfs2_glock_nq()
1582 if (!(gh->gh_flags & GL_ASYNC)) in gfs2_glock_nq()
1583 error = gfs2_glock_wait(gh); in gfs2_glock_nq()
1595 int gfs2_glock_poll(struct gfs2_holder *gh) in gfs2_glock_poll() argument
1597 return test_bit(HIF_WAIT, &gh->gh_iflags) ? 0 : 1; in gfs2_glock_poll()
1606 static void __gfs2_glock_dq(struct gfs2_holder *gh) in __gfs2_glock_dq() argument
1608 struct gfs2_glock *gl = gh->gh_gl; in __gfs2_glock_dq()
1619 while (gh) { in __gfs2_glock_dq()
1629 gh->gh_gl != sdp->sd_jinode_gl) { in __gfs2_glock_dq()
1643 if (gh->gh_flags & GL_NOCACHE) in __gfs2_glock_dq()
1646 list_del_init(&gh->gh_list); in __gfs2_glock_dq()
1647 clear_bit(HIF_HOLDER, &gh->gh_iflags); in __gfs2_glock_dq()
1648 trace_gfs2_glock_queue(gh, 0); in __gfs2_glock_dq()
1671 gh = find_first_holder(gl); in __gfs2_glock_dq()
1692 void gfs2_glock_dq(struct gfs2_holder *gh) in gfs2_glock_dq() argument
1694 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_dq()
1697 __gfs2_glock_dq(gh); in gfs2_glock_dq()
1701 void gfs2_glock_dq_wait(struct gfs2_holder *gh) in gfs2_glock_dq_wait() argument
1703 struct gfs2_glock *gl = gh->gh_gl; in gfs2_glock_dq_wait()
1704 gfs2_glock_dq(gh); in gfs2_glock_dq_wait()
1715 void gfs2_glock_dq_uninit(struct gfs2_holder *gh) in gfs2_glock_dq_uninit() argument
1717 gfs2_glock_dq(gh); in gfs2_glock_dq_uninit()
1718 gfs2_holder_uninit(gh); in gfs2_glock_dq_uninit()
1735 unsigned int state, u16 flags, struct gfs2_holder *gh) in gfs2_glock_nq_num() argument
1742 error = gfs2_glock_nq_init(gl, state, flags, gh); in gfs2_glock_nq_num()
1919 const struct gfs2_holder *gh; in gfs2_should_freeze() local
1926 list_for_each_entry(gh, &gl->gl_holders, gh_list) { in gfs2_should_freeze()
1927 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) in gfs2_should_freeze()
1929 if (LM_FLAG_NOEXP & gh->gh_flags) in gfs2_should_freeze()
2308 static void dump_holder(struct seq_file *seq, const struct gfs2_holder *gh, in dump_holder() argument
2315 if (gh->gh_owner_pid) in dump_holder()
2316 gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID); in dump_holder()
2318 fs_id_buf, state2str(gh->gh_state), in dump_holder()
2319 hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags), in dump_holder()
2320 gh->gh_error, in dump_holder()
2321 gh->gh_owner_pid ? (long)pid_nr(gh->gh_owner_pid) : -1, in dump_holder()
2323 (void *)gh->gh_ip); in dump_holder()
2394 const struct gfs2_holder *gh; in gfs2_dump_glock() local
2424 list_for_each_entry(gh, &gl->gl_holders, gh_list) in gfs2_dump_glock()
2425 dump_holder(seq, gh, fs_id_buf); in gfs2_dump_glock()