aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-06-12 14:46:17 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:03 -0400
commit1cc127b5d1b71453091859301de4a7dd6ee96fa8 (patch)
treecb1280305a04eb5e6838f91781e668e3bdeed208
parentdf5b5520b21d8a2554ede65c09b288833c77144d (diff)
Btrfs: Add a thread pool just for submit_bio
If a bio submission is after a lock holder waiting for the bio on the work queue, it is possible to deadlock. Move the bios into their own pool. Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/ctree.h4
-rw-r--r--fs/btrfs/disk-io.c4
-rw-r--r--fs/btrfs/volumes.c3
3 files changed, 10 insertions, 1 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 181c81d29897..dcea9d706d9b 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -529,9 +529,13 @@ struct btrfs_fs_info {
529 * can run with FS locks held, and the writers may be waiting for 529 * can run with FS locks held, and the writers may be waiting for
530 * those locks. We don't want ordering in the pending list to cause 530 * those locks. We don't want ordering in the pending list to cause
531 * deadlocks, and so the two are serviced separately. 531 * deadlocks, and so the two are serviced separately.
532 *
533 * A third pool does submit_bio to avoid deadlocking with the other
534 * two
532 */ 535 */
533 struct btrfs_workers workers; 536 struct btrfs_workers workers;
534 struct btrfs_workers endio_workers; 537 struct btrfs_workers endio_workers;
538 struct btrfs_workers submit_workers;
535 int thread_pool_size; 539 int thread_pool_size;
536 540
537#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) 541#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index c6a710a668cb..e5c758e306d5 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1233,8 +1233,10 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1233 * cannot dynamically grow. 1233 * cannot dynamically grow.
1234 */ 1234 */
1235 btrfs_init_workers(&fs_info->workers, fs_info->thread_pool_size); 1235 btrfs_init_workers(&fs_info->workers, fs_info->thread_pool_size);
1236 btrfs_init_workers(&fs_info->submit_workers, fs_info->thread_pool_size);
1236 btrfs_init_workers(&fs_info->endio_workers, fs_info->thread_pool_size); 1237 btrfs_init_workers(&fs_info->endio_workers, fs_info->thread_pool_size);
1237 btrfs_start_workers(&fs_info->workers, 1); 1238 btrfs_start_workers(&fs_info->workers, 1);
1239 btrfs_start_workers(&fs_info->submit_workers, 1);
1238 btrfs_start_workers(&fs_info->endio_workers, fs_info->thread_pool_size); 1240 btrfs_start_workers(&fs_info->endio_workers, fs_info->thread_pool_size);
1239 1241
1240 1242
@@ -1343,6 +1345,7 @@ fail_sb_buffer:
1343 extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree); 1345 extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree);
1344 btrfs_stop_workers(&fs_info->workers); 1346 btrfs_stop_workers(&fs_info->workers);
1345 btrfs_stop_workers(&fs_info->endio_workers); 1347 btrfs_stop_workers(&fs_info->endio_workers);
1348 btrfs_stop_workers(&fs_info->submit_workers);
1346fail_iput: 1349fail_iput:
1347 iput(fs_info->btree_inode); 1350 iput(fs_info->btree_inode);
1348fail: 1351fail:
@@ -1597,6 +1600,7 @@ int close_ctree(struct btrfs_root *root)
1597 1600
1598 btrfs_stop_workers(&fs_info->workers); 1601 btrfs_stop_workers(&fs_info->workers);
1599 btrfs_stop_workers(&fs_info->endio_workers); 1602 btrfs_stop_workers(&fs_info->endio_workers);
1603 btrfs_stop_workers(&fs_info->submit_workers);
1600 1604
1601 iput(fs_info->btree_inode); 1605 iput(fs_info->btree_inode);
1602#if 0 1606#if 0
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c57458ce6339..ba3968571024 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2112,7 +2112,8 @@ int schedule_bio(struct btrfs_root *root, struct btrfs_device *device,
2112 spin_unlock(&device->io_lock); 2112 spin_unlock(&device->io_lock);
2113 2113
2114 if (should_queue) 2114 if (should_queue)
2115 btrfs_queue_worker(&root->fs_info->workers, &device->work); 2115 btrfs_queue_worker(&root->fs_info->submit_workers,
2116 &device->work);
2116 return 0; 2117 return 0;
2117} 2118}
2118 2119