@@ -1775,15 +1775,30 @@ struct btrfs_root *open_ctree(struct super_block *sb,
fs_info->endio_write_workers.idle_thresh = 2;
fs_info->endio_meta_write_workers.idle_thresh = 2;
- btrfs_start_workers(&fs_info->workers, 1);
- btrfs_start_workers(&fs_info->generic_worker, 1);
- btrfs_start_workers(&fs_info->submit_workers, 1);
- btrfs_start_workers(&fs_info->delalloc_workers, 1);
- btrfs_start_workers(&fs_info->fixup_workers, 1);
- btrfs_start_workers(&fs_info->endio_workers, 1);
- btrfs_start_workers(&fs_info->endio_meta_workers, 1);
- btrfs_start_workers(&fs_info->endio_meta_write_workers, 1);
- btrfs_start_workers(&fs_info->endio_write_workers, 1);
+ /*
+ * We must start generic_worker first because it is used to create
+ * other workers.
+ */
+ ret = btrfs_start_workers(&fs_info->generic_worker, 1);
+ if (ret) {
+ printk(KERN_INFO "btrfs: start generic workers failed on %s\n",
+ sb->s_id);
+ goto fail_iput;
+ }
+
+ ret |= btrfs_start_workers(&fs_info->workers, 1);
+ ret |= btrfs_start_workers(&fs_info->submit_workers, 1);
+ ret |= btrfs_start_workers(&fs_info->delalloc_workers, 1);
+ ret |= btrfs_start_workers(&fs_info->fixup_workers, 1);
+ ret |= btrfs_start_workers(&fs_info->endio_workers, 1);
+ ret |= btrfs_start_workers(&fs_info->endio_meta_workers, 1);
+ ret |= btrfs_start_workers(&fs_info->endio_meta_write_workers, 1);
+ ret |= btrfs_start_workers(&fs_info->endio_write_workers, 1);
+ if (ret) {
+ printk(KERN_INFO "btrfs: start other workers failed on %s\n",
+ sb->s_id);
+ goto fail_sb_buffer;
+ }
fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super);
fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages,