ceph: Convert to separately allocated bdi
[sfrench/cifs-2.6.git] / fs / ceph / super.c
index 6bd20d707bfd885aff2f89a4b7266cc1c05fd5c8..a8c81b2052ca9052f67cd217785f1c77a510d788 100644 (file)
@@ -579,10 +579,6 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
 
        atomic_long_set(&fsc->writeback_count, 0);
 
-       err = bdi_init(&fsc->backing_dev_info);
-       if (err < 0)
-               goto fail_client;
-
        err = -ENOMEM;
        /*
         * The number of concurrent works can be high but they don't need
@@ -590,7 +586,7 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
         */
        fsc->wb_wq = alloc_workqueue("ceph-writeback", 0, 1);
        if (fsc->wb_wq == NULL)
-               goto fail_bdi;
+               goto fail_client;
        fsc->pg_inv_wq = alloc_workqueue("ceph-pg-invalid", 0, 1);
        if (fsc->pg_inv_wq == NULL)
                goto fail_wb_wq;
@@ -624,8 +620,6 @@ fail_pg_inv_wq:
        destroy_workqueue(fsc->pg_inv_wq);
 fail_wb_wq:
        destroy_workqueue(fsc->wb_wq);
-fail_bdi:
-       bdi_destroy(&fsc->backing_dev_info);
 fail_client:
        ceph_destroy_client(fsc->client);
 fail:
@@ -643,8 +637,6 @@ static void destroy_fs_client(struct ceph_fs_client *fsc)
        destroy_workqueue(fsc->pg_inv_wq);
        destroy_workqueue(fsc->trunc_wq);
 
-       bdi_destroy(&fsc->backing_dev_info);
-
        mempool_destroy(fsc->wb_pagevec_pool);
 
        destroy_mount_options(fsc->mount_options);
@@ -757,7 +749,6 @@ static const struct super_operations ceph_super_ops = {
        .destroy_inode  = ceph_destroy_inode,
        .write_inode    = ceph_write_inode,
        .drop_inode     = ceph_drop_inode,
-       .evict_inode    = ceph_evict_inode,
        .sync_fs        = ceph_sync_fs,
        .put_super      = ceph_put_super,
        .show_options   = ceph_show_options,
@@ -938,25 +929,32 @@ static int ceph_compare_super(struct super_block *sb, void *data)
  */
 static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
 
-static int ceph_register_bdi(struct super_block *sb,
-                            struct ceph_fs_client *fsc)
+static int ceph_setup_bdi(struct super_block *sb, struct ceph_fs_client *fsc)
 {
        int err;
 
+       err = super_setup_bdi_name(sb, "ceph-%ld",
+                                  atomic_long_inc_return(&bdi_seq));
+       if (err)
+               return err;
+
        /* set ra_pages based on rasize mount option? */
        if (fsc->mount_options->rasize >= PAGE_SIZE)
-               fsc->backing_dev_info.ra_pages =
+               sb->s_bdi->ra_pages =
                        (fsc->mount_options->rasize + PAGE_SIZE - 1)
                        >> PAGE_SHIFT;
        else
-               fsc->backing_dev_info.ra_pages =
-                       VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
+               sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
 
-       err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
-                          atomic_long_inc_return(&bdi_seq));
-       if (!err)
-               sb->s_bdi = &fsc->backing_dev_info;
-       return err;
+       if (fsc->mount_options->rsize > fsc->mount_options->rasize &&
+           fsc->mount_options->rsize >= PAGE_SIZE)
+               sb->s_bdi->io_pages =
+                       (fsc->mount_options->rsize + PAGE_SIZE - 1)
+                       >> PAGE_SHIFT;
+       else if (fsc->mount_options->rsize == 0)
+               sb->s_bdi->io_pages = ULONG_MAX;
+
+       return 0;
 }
 
 static struct dentry *ceph_mount(struct file_system_type *fs_type,
@@ -1011,7 +1009,7 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type,
                dout("get_sb got existing client %p\n", fsc);
        } else {
                dout("get_sb using new client %p\n", fsc);
-               err = ceph_register_bdi(sb, fsc);
+               err = ceph_setup_bdi(sb, fsc);
                if (err < 0) {
                        res = ERR_PTR(err);
                        goto out_splat;