This patch uses a completion to prevent dlm's recovery process from
referencing and trying to recover a journal before a journal has been
opened.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
        struct gfs2_holder sd_sc_gh;
        struct gfs2_holder sd_qc_gh;
 
+       struct completion sd_journal_ready;
+
        /* Daemon stuff */
 
        struct task_struct *sd_logd_process;
 
        INIT_LIST_HEAD(&sdp->sd_jindex_list);
        spin_lock_init(&sdp->sd_jindex_spin);
        mutex_init(&sdp->sd_jindex_mutex);
+       init_completion(&sdp->sd_journal_ready);
 
        INIT_LIST_HEAD(&sdp->sd_quota_list);
        mutex_init(&sdp->sd_quota_mutex);
                goto fail_qinode;
 
        error = init_journal(sdp, undo);
+       complete_all(&sdp->sd_journal_ready);
        if (error)
                goto fail;
 
 fail_locking:
        init_locking(sdp, &mount_gh, UNDO);
 fail_lm:
+       complete_all(&sdp->sd_journal_ready);
        gfs2_gl_hash_clear(sdp);
        gfs2_lm_unmount(sdp);
 fail_debug:
 
        struct gfs2_jdesc *jd;
        int rv;
 
+       /* Wait for our primary journal to be initialized */
+       wait_for_completion(&sdp->sd_journal_ready);
+
        spin_lock(&sdp->sd_jindex_spin);
        rv = -EBUSY;
        if (sdp->sd_jdesc->jd_jid == jid)