Lines Matching defs:gh

63 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
64 static void __gfs2_glock_dq(struct gfs2_holder *gh);
314 * @gh: The lock request which we wish to grant
318 * @current_gh; they are all the same as far as compatibility with the new @gh
326 struct gfs2_holder *gh)
340 return gh->gh_state == LM_ST_EXCLUSIVE &&
342 (gh->gh_flags & LM_FLAG_NODE_SCOPE);
346 return gh->gh_state == current_gh->gh_state;
353 if (gl->gl_state == gh->gh_state)
355 if (gh->gh_flags & GL_EXACT)
358 return gh->gh_state == LM_ST_SHARED ||
359 gh->gh_state == LM_ST_DEFERRED;
361 if (gh->gh_flags & LM_FLAG_ANY)
366 static void gfs2_holder_wake(struct gfs2_holder *gh)
368 clear_bit(HIF_WAIT, &gh->gh_iflags);
370 wake_up_bit(&gh->gh_iflags, HIF_WAIT);
371 if (gh->gh_flags & GL_ASYNC) {
372 struct gfs2_sbd *sdp = gh->gh_gl->gl_name.ln_sbd;
386 struct gfs2_holder *gh, *tmp;
388 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) {
389 if (test_bit(HIF_HOLDER, &gh->gh_iflags))
392 gh->gh_error = -EIO;
393 else if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))
394 gh->gh_error = GLR_TRYFAILED;
397 list_del_init(&gh->gh_list);
398 trace_gfs2_glock_queue(gh, 0);
399 gfs2_holder_wake(gh);
404 * find_first_holder - find the first "holder" gh
410 struct gfs2_holder *gh;
413 gh = list_first_entry(&gl->gl_holders, struct gfs2_holder,
415 if (test_bit(HIF_HOLDER, &gh->gh_iflags))
416 return gh;
423 * @gh: The glock holder
427 int gfs2_instantiate(struct gfs2_holder *gh)
429 struct gfs2_glock *gl = gh->gh_gl;
463 return glops->go_held(gh);
476 struct gfs2_holder *gh, *current_gh;
479 list_for_each_entry(gh, &gl->gl_holders, gh_list) {
480 if (test_bit(HIF_HOLDER, &gh->gh_iflags))
482 if (!may_grant(gl, current_gh, gh)) {
489 if (list_is_first(&gh->gh_list, &gl->gl_holders))
494 set_bit(HIF_HOLDER, &gh->gh_iflags);
495 trace_gfs2_promote(gh);
496 gfs2_holder_wake(gh);
498 current_gh = gh;
504 * find_first_waiter - find the first gh that's waiting for the glock
510 struct gfs2_holder *gh;
512 list_for_each_entry(gh, &gl->gl_holders, gh_list) {
513 if (!test_bit(HIF_HOLDER, &gh->gh_iflags))
514 return gh;
520 * find_last_waiter - find the last gh that's waiting for the glock
528 struct gfs2_holder *gh;
532 gh = list_last_entry(&gl->gl_holders, struct gfs2_holder, gh_list);
533 return test_bit(HIF_HOLDER, &gh->gh_iflags) ? NULL : gh;
591 struct gfs2_holder *gh;
597 gh = find_first_waiter(gl);
606 if (gh && (ret & LM_OUT_CANCELED))
607 gfs2_holder_wake(gh);
608 if (gh && !test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags)) {
611 list_move_tail(&gh->gh_list, &gl->gl_holders);
612 gh = find_first_waiter(gl);
613 gl->gl_target = gh->gh_state;
620 (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) {
630 do_xmote(gl, gh, gl->gl_target);
635 do_xmote(gl, gh, LM_ST_UNLOCKED);
681 * @gh: The holder (only for promotes)
686 static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh,
693 unsigned int lck_flags = (unsigned int)(gh ? gh->gh_flags : 0);
697 gh && !(gh->gh_flags & LM_FLAG_NOEXP))
835 struct gfs2_holder *gh = NULL;
856 gh = find_first_waiter(gl);
857 gl->gl_target = gh->gh_state;
858 if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)))
861 do_xmote(gl, gh, gl->gl_target);
941 struct gfs2_holder gh;
944 __gfs2_holder_init(gl, LM_ST_SHARED, flags, &gh, _RET_IP_);
945 error = gfs2_glock_nq(&gh);
947 gfs2_glock_dq(&gh);
948 gfs2_holder_uninit(&gh);
1262 * @gh: the holder structure
1267 struct gfs2_holder *gh, unsigned long ip)
1269 INIT_LIST_HEAD(&gh->gh_list);
1270 gh->gh_gl = gfs2_glock_hold(gl);
1271 gh->gh_ip = ip;
1272 gh->gh_owner_pid = get_pid(task_pid(current));
1273 gh->gh_state = state;
1274 gh->gh_flags = flags;
1275 gh->gh_iflags = 0;
1282 * @gh: the holder structure
1288 void gfs2_holder_reinit(unsigned int state, u16 flags, struct gfs2_holder *gh)
1290 gh->gh_state = state;
1291 gh->gh_flags = flags;
1292 gh->gh_iflags = 0;
1293 gh->gh_ip = _RET_IP_;
1294 put_pid(gh->gh_owner_pid);
1295 gh->gh_owner_pid = get_pid(task_pid(current));
1300 * @gh: the holder structure
1304 void gfs2_holder_uninit(struct gfs2_holder *gh)
1306 put_pid(gh->gh_owner_pid);
1307 gfs2_glock_put(gh->gh_gl);
1308 gfs2_holder_mark_uninitialized(gh);
1309 gh->gh_ip = 0;
1325 * @gh: the glock holder
1332 int gfs2_glock_holder_ready(struct gfs2_holder *gh)
1334 if (gh->gh_error || (gh->gh_flags & GL_SKIP))
1335 return gh->gh_error;
1336 gh->gh_error = gfs2_instantiate(gh);
1337 if (gh->gh_error)
1338 gfs2_glock_dq(gh);
1339 return gh->gh_error;
1344 * @gh: the glock holder
1349 int gfs2_glock_wait(struct gfs2_holder *gh)
1354 wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE);
1355 gfs2_glock_update_hold_time(gh->gh_gl, start_time);
1356 return gfs2_glock_holder_ready(gh);
1400 struct gfs2_holder *gh = &ghs[i];
1403 if (test_bit(HIF_HOLDER, &gh->gh_iflags)) {
1404 gfs2_glock_update_hold_time(gh->gh_gl,
1407 ret2 = gfs2_glock_holder_ready(gh);
1415 struct gfs2_holder *gh = &ghs[i];
1417 gfs2_glock_dq(gh);
1472 static inline bool pid_is_meaningful(const struct gfs2_holder *gh)
1474 if (!(gh->gh_flags & GL_NOPID))
1476 if (gh->gh_state == LM_ST_UNLOCKED)
1483 * @gh: the holder structure to add
1491 static inline void add_to_queue(struct gfs2_holder *gh)
1495 struct gfs2_glock *gl = gh->gh_gl;
1501 GLOCK_BUG_ON(gl, gh->gh_owner_pid == NULL);
1502 if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags))
1505 if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) {
1510 try_futile = !may_grant(gl, current_gh, gh);
1517 if (likely(gh2->gh_owner_pid != gh->gh_owner_pid))
1519 if (gh->gh_gl->gl_ops->go_type == LM_TYPE_FLOCK)
1529 gh->gh_error = GLR_TRYFAILED;
1530 gfs2_holder_wake(gh);
1536 trace_gfs2_glock_queue(gh, 1);
1540 list_add_tail(&gh->gh_list, &gl->gl_holders);
1543 list_add_tail(&gh->gh_list, insert_pt);
1555 fs_err(sdp, "new: %pSR\n", (void *)gh->gh_ip);
1556 fs_err(sdp, "pid: %d\n", pid_nr(gh->gh_owner_pid));
1558 gh->gh_gl->gl_name.ln_type, gh->gh_state);
1565 * @gh: the holder structure
1567 * if (gh->gh_flags & GL_ASYNC), this never returns an error
1572 int gfs2_glock_nq(struct gfs2_holder *gh)
1574 struct gfs2_glock *gl = gh->gh_gl;
1577 if (glock_blocked_by_withdraw(gl) && !(gh->gh_flags & LM_FLAG_NOEXP))
1580 if (gh->gh_flags & GL_NOBLOCK) {
1588 if (!may_grant(gl, current_gh, gh))
1590 set_bit(HIF_HOLDER, &gh->gh_iflags);
1591 list_add_tail(&gh->gh_list, &gl->gl_holders);
1592 trace_gfs2_promote(gh);
1602 gh->gh_error = 0;
1604 add_to_queue(gh);
1605 if (unlikely((LM_FLAG_NOEXP & gh->gh_flags) &&
1615 if (!(gh->gh_flags & GL_ASYNC))
1616 error = gfs2_glock_wait(gh);
1623 * @gh: the holder
1628 int gfs2_glock_poll(struct gfs2_holder *gh)
1630 return test_bit(HIF_WAIT, &gh->gh_iflags) ? 0 : 1;
1639 static void __gfs2_glock_dq(struct gfs2_holder *gh)
1641 struct gfs2_glock *gl = gh->gh_gl;
1650 if (gh->gh_flags & GL_NOCACHE)
1653 list_del_init(&gh->gh_list);
1654 clear_bit(HIF_HOLDER, &gh->gh_iflags);
1655 trace_gfs2_glock_queue(gh, 0);
1681 * @gh: the glock holder
1684 void gfs2_glock_dq(struct gfs2_holder *gh)
1686 struct gfs2_glock *gl = gh->gh_gl;
1690 if (!gfs2_holder_queued(gh)) {
1698 if (list_is_first(&gh->gh_list, &gl->gl_holders) &&
1699 !test_bit(HIF_HOLDER, &gh->gh_iflags)) {
1702 wait_on_bit(&gh->gh_iflags, HIF_WAIT, TASK_UNINTERRUPTIBLE);
1715 gh->gh_gl != sdp->sd_jinode_gl) {
1724 __gfs2_glock_dq(gh);
1729 void gfs2_glock_dq_wait(struct gfs2_holder *gh)
1731 struct gfs2_glock *gl = gh->gh_gl;
1732 gfs2_glock_dq(gh);
1739 * @gh: the holder structure
1743 void gfs2_glock_dq_uninit(struct gfs2_holder *gh)
1745 gfs2_glock_dq(gh);
1746 gfs2_holder_uninit(gh);
1756 * @gh: the struct gfs2_holder
1763 unsigned int state, u16 flags, struct gfs2_holder *gh)
1770 error = gfs2_glock_nq_init(gl, state, flags, gh);
1916 const struct gfs2_holder *gh;
1923 list_for_each_entry(gh, &gl->gl_holders, gh_list) {
1924 if (test_bit(HIF_HOLDER, &gh->gh_iflags))
1926 if (LM_FLAG_NOEXP & gh->gh_flags)
2278 * @gh: the glock holder
2283 static void dump_holder(struct seq_file *seq, const struct gfs2_holder *gh,
2291 if (pid_is_meaningful(gh)) {
2295 owner_pid = pid_nr(gh->gh_owner_pid);
2296 gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID);
2301 fs_id_buf, state2str(gh->gh_state),
2302 hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags),
2303 gh->gh_error, (long)owner_pid, comm, (void *)gh->gh_ip);
2376 const struct gfs2_holder *gh;
2406 list_for_each_entry(gh, &gl->gl_holders, gh_list)
2407 dump_holder(seq, gh, fs_id_buf);