gfs2: don't withdraw if init_threads() got interrupted
[linux-2.6-microblaze.git] / fs / gfs2 / ops_fstype.c
index 8a27957..73ae5fc 100644 (file)
@@ -87,7 +87,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
        set_bit(SDF_NOJOURNALID, &sdp->sd_flags);
        gfs2_tune_init(&sdp->sd_tune);
 
-       init_waitqueue_head(&sdp->sd_glock_wait);
+       init_waitqueue_head(&sdp->sd_kill_wait);
        init_waitqueue_head(&sdp->sd_async_glock_wait);
        atomic_set(&sdp->sd_glock_disposal, 0);
        init_completion(&sdp->sd_locking_init);
@@ -292,8 +292,7 @@ static int gfs2_read_sb(struct gfs2_sbd *sdp, int silent)
                return error;
        }
 
-       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift -
-                              GFS2_BASIC_BLOCK_SHIFT;
+       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9;
        sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
        sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
                          sizeof(struct gfs2_dinode)) / sizeof(u64);
@@ -648,7 +647,7 @@ static int init_statfs(struct gfs2_sbd *sdp)
        struct gfs2_jdesc *jd;
        struct gfs2_inode *ip;
 
-       sdp->sd_statfs_inode = gfs2_lookup_simple(master, "statfs");
+       sdp->sd_statfs_inode = gfs2_lookup_meta(master, "statfs");
        if (IS_ERR(sdp->sd_statfs_inode)) {
                error = PTR_ERR(sdp->sd_statfs_inode);
                fs_err(sdp, "can't read in statfs inode: %d\n", error);
@@ -657,7 +656,7 @@ static int init_statfs(struct gfs2_sbd *sdp)
        if (sdp->sd_args.ar_spectator)
                goto out;
 
-       pn = gfs2_lookup_simple(master, "per_node");
+       pn = gfs2_lookup_meta(master, "per_node");
        if (IS_ERR(pn)) {
                error = PTR_ERR(pn);
                fs_err(sdp, "can't find per_node directory: %d\n", error);
@@ -674,7 +673,7 @@ static int init_statfs(struct gfs2_sbd *sdp)
                        goto free_local;
                }
                sprintf(buf, "statfs_change%u", jd->jd_jid);
-               lsi->si_sc_inode = gfs2_lookup_simple(pn, buf);
+               lsi->si_sc_inode = gfs2_lookup_meta(pn, buf);
                if (IS_ERR(lsi->si_sc_inode)) {
                        error = PTR_ERR(lsi->si_sc_inode);
                        fs_err(sdp, "can't find local \"sc\" file#%u: %d\n",
@@ -739,7 +738,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
        if (undo)
                goto fail_statfs;
 
-       sdp->sd_jindex = gfs2_lookup_simple(master, "jindex");
+       sdp->sd_jindex = gfs2_lookup_meta(master, "jindex");
        if (IS_ERR(sdp->sd_jindex)) {
                fs_err(sdp, "can't lookup journal index: %d\n", error);
                return PTR_ERR(sdp->sd_jindex);
@@ -888,7 +887,7 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo)
                goto fail;
 
        /* Read in the resource index inode */
-       sdp->sd_rindex = gfs2_lookup_simple(master, "rindex");
+       sdp->sd_rindex = gfs2_lookup_meta(master, "rindex");
        if (IS_ERR(sdp->sd_rindex)) {
                error = PTR_ERR(sdp->sd_rindex);
                fs_err(sdp, "can't get resource index inode: %d\n", error);
@@ -897,7 +896,7 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo)
        sdp->sd_rindex_uptodate = 0;
 
        /* Read in the quota inode */
-       sdp->sd_quota_inode = gfs2_lookup_simple(master, "quota");
+       sdp->sd_quota_inode = gfs2_lookup_meta(master, "quota");
        if (IS_ERR(sdp->sd_quota_inode)) {
                error = PTR_ERR(sdp->sd_quota_inode);
                fs_err(sdp, "can't get quota file inode: %d\n", error);
@@ -941,7 +940,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo)
        if (undo)
                goto fail_qc_gh;
 
-       pn = gfs2_lookup_simple(master, "per_node");
+       pn = gfs2_lookup_meta(master, "per_node");
        if (IS_ERR(pn)) {
                error = PTR_ERR(pn);
                fs_err(sdp, "can't find per_node directory: %d\n", error);
@@ -949,7 +948,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo)
        }
 
        sprintf(buf, "quota_change%u", sdp->sd_jdesc->jd_jid);
-       sdp->sd_qc_inode = gfs2_lookup_simple(pn, buf);
+       sdp->sd_qc_inode = gfs2_lookup_meta(pn, buf);
        if (IS_ERR(sdp->sd_qc_inode)) {
                error = PTR_ERR(sdp->sd_qc_inode);
                fs_err(sdp, "can't find local \"qc\" file: %d\n", error);
@@ -1103,29 +1102,49 @@ static int init_threads(struct gfs2_sbd *sdp)
        struct task_struct *p;
        int error = 0;
 
-       p = kthread_run(gfs2_logd, sdp, "gfs2_logd");
+       p = kthread_create(gfs2_logd, sdp, "gfs2_logd/%s", sdp->sd_fsname);
        if (IS_ERR(p)) {
                error = PTR_ERR(p);
-               fs_err(sdp, "can't start logd thread: %d\n", error);
+               fs_err(sdp, "can't create logd thread: %d\n", error);
                return error;
        }
+       get_task_struct(p);
        sdp->sd_logd_process = p;
 
-       p = kthread_run(gfs2_quotad, sdp, "gfs2_quotad");
+       p = kthread_create(gfs2_quotad, sdp, "gfs2_quotad/%s", sdp->sd_fsname);
        if (IS_ERR(p)) {
                error = PTR_ERR(p);
-               fs_err(sdp, "can't start quotad thread: %d\n", error);
+               fs_err(sdp, "can't create quotad thread: %d\n", error);
                goto fail;
        }
+       get_task_struct(p);
        sdp->sd_quotad_process = p;
+
+       wake_up_process(sdp->sd_logd_process);
+       wake_up_process(sdp->sd_quotad_process);
        return 0;
 
 fail:
        kthread_stop(sdp->sd_logd_process);
+       put_task_struct(sdp->sd_logd_process);
        sdp->sd_logd_process = NULL;
        return error;
 }
 
+void gfs2_destroy_threads(struct gfs2_sbd *sdp)
+{
+       if (sdp->sd_logd_process) {
+               kthread_stop(sdp->sd_logd_process);
+               put_task_struct(sdp->sd_logd_process);
+               sdp->sd_logd_process = NULL;
+       }
+       if (sdp->sd_quotad_process) {
+               kthread_stop(sdp->sd_quotad_process);
+               put_task_struct(sdp->sd_quotad_process);
+               sdp->sd_quotad_process = NULL;
+       }
+}
+
 /**
  * gfs2_fill_super - Read in superblock
  * @sb: The VFS superblock
@@ -1170,10 +1189,9 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
 
        /* Set up the buffer cache and fill in some fake block size values
           to allow us to read-in the on-disk superblock. */
-       sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, GFS2_BASIC_BLOCK);
+       sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, 512);
        sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits;
-       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift -
-                               GFS2_BASIC_BLOCK_SHIFT;
+       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9;
        sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
 
        sdp->sd_tune.gt_logd_secs = sdp->sd_args.ar_commit;
@@ -1261,10 +1279,8 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
 
        if (!sb_rdonly(sb)) {
                error = init_threads(sdp);
-               if (error) {
-                       gfs2_withdraw_delayed(sdp);
+               if (error)
                        goto fail_per_node;
-               }
        }
 
        error = gfs2_freeze_lock_shared(sdp);
@@ -1276,12 +1292,7 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
 
        if (error) {
                gfs2_freeze_unlock(&sdp->sd_freeze_gh);
-               if (sdp->sd_quotad_process)
-                       kthread_stop(sdp->sd_quotad_process);
-               sdp->sd_quotad_process = NULL;
-               if (sdp->sd_logd_process)
-                       kthread_stop(sdp->sd_logd_process);
-               sdp->sd_logd_process = NULL;
+               gfs2_destroy_threads(sdp);
                fs_err(sdp, "can't make FS RW: %d\n", error);
                goto fail_per_node;
        }
@@ -1381,6 +1392,7 @@ static const struct constant_table gfs2_param_quota[] = {
        {"off",        GFS2_QUOTA_OFF},
        {"account",    GFS2_QUOTA_ACCOUNT},
        {"on",         GFS2_QUOTA_ON},
+       {"quiet",      GFS2_QUOTA_QUIET},
        {}
 };
 
@@ -1786,9 +1798,9 @@ static void gfs2_kill_sb(struct super_block *sb)
        /*
         * Flush and then drain the delete workqueue here (via
         * destroy_workqueue()) to ensure that any delete work that
-        * may be running will also see the SDF_DEACTIVATING flag.
+        * may be running will also see the SDF_KILL flag.
         */
-       set_bit(SDF_DEACTIVATING, &sdp->sd_flags);
+       set_bit(SDF_KILL, &sdp->sd_flags);
        gfs2_flush_delete_work(sdp);
        destroy_workqueue(sdp->sd_delete_wq);