]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/gfs2/ops_fstype.c
Merge remote-tracking branch 'md/for-next'
[karo-tx-linux.git] / fs / gfs2 / ops_fstype.c
index 0262c190b6f95c6c7dec1da9a8937db4e0701724..82303b4749582cd3c00d402a9f42b9972b1de677 100644 (file)
@@ -51,7 +51,6 @@ static void gfs2_tune_init(struct gfs2_tune *gt)
 {
        spin_lock_init(&gt->gt_spin);
 
-       gt->gt_quota_simul_sync = 64;
        gt->gt_quota_warn_period = 10;
        gt->gt_quota_scale_num = 1;
        gt->gt_quota_scale_den = 1;
@@ -94,6 +93,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
 
        INIT_LIST_HEAD(&sdp->sd_quota_list);
        mutex_init(&sdp->sd_quota_mutex);
+       mutex_init(&sdp->sd_quota_sync_mutex);
        init_waitqueue_head(&sdp->sd_quota_wait);
        INIT_LIST_HEAD(&sdp->sd_trunc_list);
        spin_lock_init(&sdp->sd_trunc_lock);
@@ -646,6 +646,48 @@ static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
        return error;
 }
 
+/**
+ * check_journal_clean - Make sure a journal is clean for a spectator mount
+ * @sdp: The GFS2 superblock
+ * @jd: The journal descriptor
+ *
+ * Returns: 0 if the journal is clean or locked, else an error
+ */
+static int check_journal_clean(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd)
+{
+       int error;
+       struct gfs2_holder j_gh;
+       struct gfs2_log_header_host head;
+       struct gfs2_inode *ip;
+
+       ip = GFS2_I(jd->jd_inode);
+       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_NOEXP |
+                                  GL_EXACT | GL_NOCACHE, &j_gh);
+       if (error) {
+               fs_err(sdp, "Error locking journal for spectator mount.\n");
+               return -EPERM;
+       }
+       error = gfs2_jdesc_check(jd);
+       if (error) {
+               fs_err(sdp, "Error checking journal for spectator mount.\n");
+               goto out_unlock;
+       }
+       error = gfs2_find_jhead(jd, &head);
+       if (error) {
+               fs_err(sdp, "Error parsing journal for spectator mount.\n");
+               goto out_unlock;
+       }
+       if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
+               error = -EPERM;
+               fs_err(sdp, "jid=%u: Journal is dirty, so the first mounter "
+                      "must not be a spectator.\n", jd->jd_jid);
+       }
+
+out_unlock:
+       gfs2_glock_dq_uninit(&j_gh);
+       return error;
+}
+
 static int init_journal(struct gfs2_sbd *sdp, int undo)
 {
        struct inode *master = sdp->sd_master_dir->d_inode;
@@ -732,8 +774,15 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
        if (sdp->sd_lockstruct.ls_first) {
                unsigned int x;
                for (x = 0; x < sdp->sd_journals; x++) {
-                       error = gfs2_recover_journal(gfs2_jdesc_find(sdp, x),
-                                                    true);
+                       struct gfs2_jdesc *jd = gfs2_jdesc_find(sdp, x);
+
+                       if (sdp->sd_args.ar_spectator) {
+                               error = check_journal_clean(sdp, jd);
+                               if (error)
+                                       goto fail_jinode_gh;
+                               continue;
+                       }
+                       error = gfs2_recover_journal(jd, true);
                        if (error) {
                                fs_err(sdp, "error recovering journal %u: %d\n",
                                       x, error);