aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-11-06 22:03:00 -0500
committerChris Mason <chris.mason@oracle.com>2008-11-06 22:03:00 -0500
commit4a69a41009c4ac691f7d9c289f5f37fabeddce46 (patch)
tree1dac90d2f8e4ad4114fb1f4c168925daf2769d28 /fs/btrfs/inode.c
parent537fb0671549a9a6457ce42a25ab34b29d97a256 (diff)
Btrfs: Add ordered async work queues
Btrfs uses kernel threads to create async work queues for cpu intensive operations such as checksumming and decompression. These work well, but they make it difficult to keep IO order intact. A single writepages call from pdflush or fsync will turn into a number of bios, and each bio is checksummed in parallel. Once the checksum is computed, the bio is sent down to the disk, and since we don't control the order in which the parallel operations happen, they might go down to the disk in almost any order. The code deals with this somewhat by having deep work queues for a single kernel thread, making it very likely that a single thread will process all the bios for a single inode. This patch introduces an explicitly ordered work queue. As work structs are placed into the queue they are put onto the tail of a list. They have three callbacks: ->func (cpu intensive processing here) ->ordered_func (order sensitive processing here) ->ordered_free (free the work struct, all processing is done) The work struct has three callbacks. The func callback does the cpu intensive work, and when it completes the work struct is marked as done. Every time a work struct completes, the list is checked to see if the head is marked as done. If so the ordered_func callback is used to do the order sensitive processing and the ordered_free callback is used to do any cleanup. Then we loop back and check the head of the list again. This patch also changes the checksumming code to use the ordered workqueues. One a 4 drive array, it increases streaming writes from 280MB/s to 350MB/s. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 806708dd7e38..3df0ffad976e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -881,7 +881,7 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
881 * At IO completion time the cums attached on the ordered extent record 881 * At IO completion time the cums attached on the ordered extent record
882 * are inserted into the btree 882 * are inserted into the btree
883 */ 883 */
884int __btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio, 884int __btrfs_submit_bio_start(struct inode *inode, int rw, struct bio *bio,
885 int mirror_num, unsigned long bio_flags) 885 int mirror_num, unsigned long bio_flags)
886{ 886{
887 struct btrfs_root *root = BTRFS_I(inode)->root; 887 struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -889,7 +889,21 @@ int __btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
889 889
890 ret = btrfs_csum_one_bio(root, inode, bio); 890 ret = btrfs_csum_one_bio(root, inode, bio);
891 BUG_ON(ret); 891 BUG_ON(ret);
892 return 0;
893}
892 894
895/*
896 * in order to insert checksums into the metadata in large chunks,
897 * we wait until bio submission time. All the pages in the bio are
898 * checksummed and sums are attached onto the ordered extent record.
899 *
900 * At IO completion time the cums attached on the ordered extent record
901 * are inserted into the btree
902 */
903int __btrfs_submit_bio_done(struct inode *inode, int rw, struct bio *bio,
904 int mirror_num, unsigned long bio_flags)
905{
906 struct btrfs_root *root = BTRFS_I(inode)->root;
893 return btrfs_map_bio(root, rw, bio, mirror_num, 1); 907 return btrfs_map_bio(root, rw, bio, mirror_num, 1);
894} 908}
895 909
@@ -922,7 +936,8 @@ int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
922 /* we're doing a write, do the async checksumming */ 936 /* we're doing a write, do the async checksumming */
923 return btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info, 937 return btrfs_wq_submit_bio(BTRFS_I(inode)->root->fs_info,
924 inode, rw, bio, mirror_num, 938 inode, rw, bio, mirror_num,
925 bio_flags, __btrfs_submit_bio_hook); 939 bio_flags, __btrfs_submit_bio_start,
940 __btrfs_submit_bio_done);
926 } 941 }
927 942
928mapit: 943mapit: