diff options
Diffstat (limited to 'fs/gfs2/glock.c')
-rw-r--r-- | fs/gfs2/glock.c | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index f92c17704169..08a8beb152e6 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
@@ -541,21 +541,6 @@ out_locked: | |||
541 | spin_unlock(&gl->gl_spin); | 541 | spin_unlock(&gl->gl_spin); |
542 | } | 542 | } |
543 | 543 | ||
544 | static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock, | ||
545 | unsigned int req_state, | ||
546 | unsigned int flags) | ||
547 | { | ||
548 | int ret = LM_OUT_ERROR; | ||
549 | |||
550 | if (!sdp->sd_lockstruct.ls_ops->lm_lock) | ||
551 | return req_state == LM_ST_UNLOCKED ? 0 : req_state; | ||
552 | |||
553 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | ||
554 | ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, | ||
555 | req_state, flags); | ||
556 | return ret; | ||
557 | } | ||
558 | |||
559 | /** | 544 | /** |
560 | * do_xmote - Calls the DLM to change the state of a lock | 545 | * do_xmote - Calls the DLM to change the state of a lock |
561 | * @gl: The lock state | 546 | * @gl: The lock state |
@@ -575,13 +560,14 @@ __acquires(&gl->gl_spin) | |||
575 | 560 | ||
576 | lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP | | 561 | lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP | |
577 | LM_FLAG_PRIORITY); | 562 | LM_FLAG_PRIORITY); |
578 | BUG_ON(gl->gl_state == target); | 563 | GLOCK_BUG_ON(gl, gl->gl_state == target); |
579 | BUG_ON(gl->gl_state == gl->gl_target); | 564 | GLOCK_BUG_ON(gl, gl->gl_state == gl->gl_target); |
580 | if ((target == LM_ST_UNLOCKED || target == LM_ST_DEFERRED) && | 565 | if ((target == LM_ST_UNLOCKED || target == LM_ST_DEFERRED) && |
581 | glops->go_inval) { | 566 | glops->go_inval) { |
582 | set_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags); | 567 | set_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags); |
583 | do_error(gl, 0); /* Fail queued try locks */ | 568 | do_error(gl, 0); /* Fail queued try locks */ |
584 | } | 569 | } |
570 | gl->gl_req = target; | ||
585 | spin_unlock(&gl->gl_spin); | 571 | spin_unlock(&gl->gl_spin); |
586 | if (glops->go_xmote_th) | 572 | if (glops->go_xmote_th) |
587 | glops->go_xmote_th(gl); | 573 | glops->go_xmote_th(gl); |
@@ -594,15 +580,17 @@ __acquires(&gl->gl_spin) | |||
594 | gl->gl_state == LM_ST_DEFERRED) && | 580 | gl->gl_state == LM_ST_DEFERRED) && |
595 | !(lck_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) | 581 | !(lck_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) |
596 | lck_flags |= LM_FLAG_TRY_1CB; | 582 | lck_flags |= LM_FLAG_TRY_1CB; |
597 | ret = gfs2_lm_lock(sdp, gl, target, lck_flags); | ||
598 | 583 | ||
599 | if (!(ret & LM_OUT_ASYNC)) { | 584 | if (sdp->sd_lockstruct.ls_ops->lm_lock) { |
600 | finish_xmote(gl, ret); | 585 | /* lock_dlm */ |
586 | ret = sdp->sd_lockstruct.ls_ops->lm_lock(gl, target, lck_flags); | ||
587 | GLOCK_BUG_ON(gl, ret); | ||
588 | } else { /* lock_nolock */ | ||
589 | finish_xmote(gl, target); | ||
601 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) | 590 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) |
602 | gfs2_glock_put(gl); | 591 | gfs2_glock_put(gl); |
603 | } else { | ||
604 | GLOCK_BUG_ON(gl, ret != LM_OUT_ASYNC); | ||
605 | } | 592 | } |
593 | |||
606 | spin_lock(&gl->gl_spin); | 594 | spin_lock(&gl->gl_spin); |
607 | } | 595 | } |
608 | 596 | ||
@@ -951,17 +939,22 @@ int gfs2_glock_wait(struct gfs2_holder *gh) | |||
951 | 939 | ||
952 | void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...) | 940 | void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...) |
953 | { | 941 | { |
942 | struct va_format vaf; | ||
954 | va_list args; | 943 | va_list args; |
955 | 944 | ||
956 | va_start(args, fmt); | 945 | va_start(args, fmt); |
946 | |||
957 | if (seq) { | 947 | if (seq) { |
958 | struct gfs2_glock_iter *gi = seq->private; | 948 | struct gfs2_glock_iter *gi = seq->private; |
959 | vsprintf(gi->string, fmt, args); | 949 | vsprintf(gi->string, fmt, args); |
960 | seq_printf(seq, gi->string); | 950 | seq_printf(seq, gi->string); |
961 | } else { | 951 | } else { |
962 | printk(KERN_ERR " "); | 952 | vaf.fmt = fmt; |
963 | vprintk(fmt, args); | 953 | vaf.va = &args; |
954 | |||
955 | printk(KERN_ERR " %pV", &vaf); | ||
964 | } | 956 | } |
957 | |||
965 | va_end(args); | 958 | va_end(args); |
966 | } | 959 | } |
967 | 960 | ||
@@ -1361,24 +1354,28 @@ static int gfs2_should_freeze(const struct gfs2_glock *gl) | |||
1361 | * @gl: Pointer to the glock | 1354 | * @gl: Pointer to the glock |
1362 | * @ret: The return value from the dlm | 1355 | * @ret: The return value from the dlm |
1363 | * | 1356 | * |
1357 | * The gl_reply field is under the gl_spin lock so that it is ok | ||
1358 | * to use a bitfield shared with other glock state fields. | ||
1364 | */ | 1359 | */ |
1365 | 1360 | ||
1366 | void gfs2_glock_complete(struct gfs2_glock *gl, int ret) | 1361 | void gfs2_glock_complete(struct gfs2_glock *gl, int ret) |
1367 | { | 1362 | { |
1368 | struct lm_lockstruct *ls = &gl->gl_sbd->sd_lockstruct; | 1363 | struct lm_lockstruct *ls = &gl->gl_sbd->sd_lockstruct; |
1369 | 1364 | ||
1365 | spin_lock(&gl->gl_spin); | ||
1370 | gl->gl_reply = ret; | 1366 | gl->gl_reply = ret; |
1371 | 1367 | ||
1372 | if (unlikely(test_bit(DFL_BLOCK_LOCKS, &ls->ls_flags))) { | 1368 | if (unlikely(test_bit(DFL_BLOCK_LOCKS, &ls->ls_flags))) { |
1373 | spin_lock(&gl->gl_spin); | ||
1374 | if (gfs2_should_freeze(gl)) { | 1369 | if (gfs2_should_freeze(gl)) { |
1375 | set_bit(GLF_FROZEN, &gl->gl_flags); | 1370 | set_bit(GLF_FROZEN, &gl->gl_flags); |
1376 | spin_unlock(&gl->gl_spin); | 1371 | spin_unlock(&gl->gl_spin); |
1377 | return; | 1372 | return; |
1378 | } | 1373 | } |
1379 | spin_unlock(&gl->gl_spin); | ||
1380 | } | 1374 | } |
1375 | |||
1376 | spin_unlock(&gl->gl_spin); | ||
1381 | set_bit(GLF_REPLY_PENDING, &gl->gl_flags); | 1377 | set_bit(GLF_REPLY_PENDING, &gl->gl_flags); |
1378 | smp_wmb(); | ||
1382 | gfs2_glock_hold(gl); | 1379 | gfs2_glock_hold(gl); |
1383 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) | 1380 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) |
1384 | gfs2_glock_put(gl); | 1381 | gfs2_glock_put(gl); |
@@ -1626,18 +1623,17 @@ static const char *hflags2str(char *buf, unsigned flags, unsigned long iflags) | |||
1626 | static int dump_holder(struct seq_file *seq, const struct gfs2_holder *gh) | 1623 | static int dump_holder(struct seq_file *seq, const struct gfs2_holder *gh) |
1627 | { | 1624 | { |
1628 | struct task_struct *gh_owner = NULL; | 1625 | struct task_struct *gh_owner = NULL; |
1629 | char buffer[KSYM_SYMBOL_LEN]; | ||
1630 | char flags_buf[32]; | 1626 | char flags_buf[32]; |
1631 | 1627 | ||
1632 | sprint_symbol(buffer, gh->gh_ip); | ||
1633 | if (gh->gh_owner_pid) | 1628 | if (gh->gh_owner_pid) |
1634 | gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID); | 1629 | gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID); |
1635 | gfs2_print_dbg(seq, " H: s:%s f:%s e:%d p:%ld [%s] %s\n", | 1630 | gfs2_print_dbg(seq, " H: s:%s f:%s e:%d p:%ld [%s] %pS\n", |
1636 | state2str(gh->gh_state), | 1631 | state2str(gh->gh_state), |
1637 | hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags), | 1632 | hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags), |
1638 | gh->gh_error, | 1633 | gh->gh_error, |
1639 | gh->gh_owner_pid ? (long)pid_nr(gh->gh_owner_pid) : -1, | 1634 | gh->gh_owner_pid ? (long)pid_nr(gh->gh_owner_pid) : -1, |
1640 | gh_owner ? gh_owner->comm : "(ended)", buffer); | 1635 | gh_owner ? gh_owner->comm : "(ended)", |
1636 | (void *)gh->gh_ip); | ||
1641 | return 0; | 1637 | return 0; |
1642 | } | 1638 | } |
1643 | 1639 | ||
@@ -1782,12 +1778,13 @@ int __init gfs2_glock_init(void) | |||
1782 | } | 1778 | } |
1783 | #endif | 1779 | #endif |
1784 | 1780 | ||
1785 | glock_workqueue = alloc_workqueue("glock_workqueue", WQ_RESCUER | | 1781 | glock_workqueue = alloc_workqueue("glock_workqueue", WQ_MEM_RECLAIM | |
1786 | WQ_HIGHPRI | WQ_FREEZEABLE, 0); | 1782 | WQ_HIGHPRI | WQ_FREEZEABLE, 0); |
1787 | if (IS_ERR(glock_workqueue)) | 1783 | if (IS_ERR(glock_workqueue)) |
1788 | return PTR_ERR(glock_workqueue); | 1784 | return PTR_ERR(glock_workqueue); |
1789 | gfs2_delete_workqueue = alloc_workqueue("delete_workqueue", WQ_RESCUER | | 1785 | gfs2_delete_workqueue = alloc_workqueue("delete_workqueue", |
1790 | WQ_FREEZEABLE, 0); | 1786 | WQ_MEM_RECLAIM | WQ_FREEZEABLE, |
1787 | 0); | ||
1791 | if (IS_ERR(gfs2_delete_workqueue)) { | 1788 | if (IS_ERR(gfs2_delete_workqueue)) { |
1792 | destroy_workqueue(glock_workqueue); | 1789 | destroy_workqueue(glock_workqueue); |
1793 | return PTR_ERR(gfs2_delete_workqueue); | 1790 | return PTR_ERR(gfs2_delete_workqueue); |