]> Pileus Git - ~andy/linux/blobdiff - fs/gfs2/ops_fstype.c
Merge branch 'for-3.14/core' of git://git.kernel.dk/linux-block
[~andy/linux] / fs / gfs2 / ops_fstype.c
index 16194da91652becfca5019a296f097206358e1d2..c6872d09561a2d53c8e57374eb700f4fb578ae78 100644 (file)
@@ -36,6 +36,7 @@
 #include "log.h"
 #include "quota.h"
 #include "dir.h"
+#include "meta_io.h"
 #include "trace_gfs2.h"
 
 #define DO 0
@@ -62,6 +63,7 @@ static void gfs2_tune_init(struct gfs2_tune *gt)
 static struct gfs2_sbd *init_sbd(struct super_block *sb)
 {
        struct gfs2_sbd *sdp;
+       struct address_space *mapping;
 
        sdp = kzalloc(sizeof(struct gfs2_sbd), GFP_KERNEL);
        if (!sdp)
@@ -97,6 +99,18 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
        init_waitqueue_head(&sdp->sd_quota_wait);
        INIT_LIST_HEAD(&sdp->sd_trunc_list);
        spin_lock_init(&sdp->sd_trunc_lock);
+       spin_lock_init(&sdp->sd_bitmap_lock);
+
+       mapping = &sdp->sd_aspace;
+
+       address_space_init_once(mapping);
+       mapping->a_ops = &gfs2_meta_aops;
+       mapping->host = sb->s_bdev->bd_inode;
+       mapping->flags = 0;
+       mapping_set_gfp_mask(mapping, GFP_NOFS);
+       mapping->private_data = NULL;
+       mapping->backing_dev_info = sb->s_bdi;
+       mapping->writeback_index = 0;
 
        spin_lock_init(&sdp->sd_log_lock);
        atomic_set(&sdp->sd_log_pinned, 0);
@@ -217,7 +231,7 @@ static int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector, int silent)
 
        page = alloc_page(GFP_NOFS);
        if (unlikely(!page))
-               return -ENOBUFS;
+               return -ENOMEM;
 
        ClearPageUptodate(page);
        ClearPageDirty(page);
@@ -956,40 +970,6 @@ fail:
        return error;
 }
 
-static int init_threads(struct gfs2_sbd *sdp, int undo)
-{
-       struct task_struct *p;
-       int error = 0;
-
-       if (undo)
-               goto fail_quotad;
-
-       p = kthread_run(gfs2_logd, sdp, "gfs2_logd");
-       if (IS_ERR(p)) {
-               error = PTR_ERR(p);
-               fs_err(sdp, "can't start logd thread: %d\n", error);
-               return error;
-       }
-       sdp->sd_logd_process = p;
-
-       p = kthread_run(gfs2_quotad, sdp, "gfs2_quotad");
-       if (IS_ERR(p)) {
-               error = PTR_ERR(p);
-               fs_err(sdp, "can't start quotad thread: %d\n", error);
-               goto fail;
-       }
-       sdp->sd_quotad_process = p;
-
-       return 0;
-
-
-fail_quotad:
-       kthread_stop(sdp->sd_quotad_process);
-fail:
-       kthread_stop(sdp->sd_logd_process);
-       return error;
-}
-
 static const match_table_t nolock_tokens = {
        { Opt_jid, "jid=%d\n", },
        { Opt_err, NULL },
@@ -1254,15 +1234,11 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
                goto fail_per_node;
        }
 
-       error = init_threads(sdp, DO);
-       if (error)
-               goto fail_per_node;
-
        if (!(sb->s_flags & MS_RDONLY)) {
                error = gfs2_make_fs_rw(sdp);
                if (error) {
                        fs_err(sdp, "can't make FS RW: %d\n", error);
-                       goto fail_threads;
+                       goto fail_per_node;
                }
        }
 
@@ -1270,8 +1246,6 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
        gfs2_online_uevent(sdp);
        return 0;
 
-fail_threads:
-       init_threads(sdp, UNDO);
 fail_per_node:
        init_per_node(sdp, UNDO);
 fail_inodes:
@@ -1366,8 +1340,18 @@ static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags,
        if (IS_ERR(s))
                goto error_bdev;
 
-       if (s->s_root)
+       if (s->s_root) {
+               /*
+                * s_umount nests inside bd_mutex during
+                * __invalidate_device().  blkdev_put() acquires
+                * bd_mutex and can't be called under s_umount.  Drop
+                * s_umount temporarily.  This is safe as we're
+                * holding an active reference.
+                */
+               up_write(&s->s_umount);
                blkdev_put(bdev, mode);
+               down_write(&s->s_umount);
+       }
 
        memset(&args, 0, sizeof(args));
        args.ar_quota = GFS2_QUOTA_DEFAULT;