diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 0e8d31274c92733af7ea1de54fb61bdcb0bf888c..8d03e4a3c4e934a876f390f609599e3bf2bc6889 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -538,15 +538,9 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode, async->work.flags = 0; async->bio_flags = bio_flags; - while(atomic_read(&fs_info->async_submit_draining) && - atomic_read(&fs_info->nr_async_submits)) { - wait_event(fs_info->async_submit_wait, - (atomic_read(&fs_info->nr_async_submits) == 0)); - } - atomic_inc(&fs_info->nr_async_submits); btrfs_queue_worker(&fs_info->workers, &async->work); - +#if 0 if (atomic_read(&fs_info->nr_async_submits) > limit) { wait_event_timeout(fs_info->async_submit_wait, (atomic_read(&fs_info->nr_async_submits) < limit), @@ -556,7 +550,7 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode, (atomic_read(&fs_info->nr_async_bios) < limit), HZ/10); } - +#endif while(atomic_read(&fs_info->async_submit_draining) && atomic_read(&fs_info->nr_async_submits)) { wait_event(fs_info->async_submit_wait, @@ -1765,11 +1759,11 @@ struct btrfs_root *open_ctree(struct super_block *sb, ret = btrfs_cleanup_reloc_trees(tree_root); BUG_ON(ret); +read_fs_root: location.objectid = BTRFS_FS_TREE_OBJECTID; location.type = BTRFS_ROOT_ITEM_KEY; location.offset = (u64)-1; -read_fs_root: fs_info->fs_root = btrfs_read_fs_root_no_name(fs_info, &location); if (!fs_info->fs_root) goto fail_cleaner; diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 54d013c3bb883eacd3528d295978b9bb80e9583e..a0f3804efe4f36e46ebaa4a1fe1ac5d0b0ca9153 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2398,7 +2398,8 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc, int extent_write_cache_pages(struct extent_io_tree *tree, struct address_space *mapping, struct writeback_control *wbc, - writepage_t writepage, void *data) + writepage_t writepage, void *data, + void (*flush_fn)(void *)) { struct backing_dev_info *bdi = mapping->backing_dev_info; int ret = 0; @@ -2460,8 +2461,10 @@ int extent_write_cache_pages(struct extent_io_tree *tree, continue; } - if (wbc->sync_mode != WB_SYNC_NONE) + if (wbc->sync_mode != WB_SYNC_NONE) { + flush_fn(data); wait_on_page_writeback(page); + } if (PageWriteback(page) || !clear_page_dirty_for_io(page)) { @@ -2498,6 +2501,15 @@ int extent_write_cache_pages(struct extent_io_tree *tree, } EXPORT_SYMBOL(extent_write_cache_pages); +static noinline void flush_write_bio(void *data) +{ + struct extent_page_data *epd = data; + if (epd->bio) { + submit_one_bio(WRITE, epd->bio, 0, 0); + epd->bio = NULL; + } +} + int extent_write_full_page(struct extent_io_tree *tree, struct page *page, get_extent_t *get_extent, struct writeback_control *wbc) @@ -2523,7 +2535,7 @@ int extent_write_full_page(struct extent_io_tree *tree, struct page *page, ret = __extent_writepage(page, wbc, &epd); extent_write_cache_pages(tree, mapping, &wbc_writepages, - __extent_writepage, &epd); + __extent_writepage, &epd, flush_write_bio); if (epd.bio) { submit_one_bio(WRITE, epd.bio, 0, 0); } @@ -2592,7 +2604,8 @@ int extent_writepages(struct extent_io_tree *tree, }; ret = extent_write_cache_pages(tree, mapping, wbc, - __extent_writepage, &epd); + __extent_writepage, &epd, + flush_write_bio); if (epd.bio) { submit_one_bio(WRITE, epd.bio, 0, 0); } @@ -3087,6 +3100,9 @@ int clear_extent_buffer_dirty(struct extent_io_tree *tree, for (i = 0; i < num_pages; i++) { page = extent_buffer_page(eb, i); + if (!set && !PageDirty(page)) + continue; + lock_page(page); if (i == 0) set_page_extent_head(page, eb->len); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 6854bf41856ab52982e1b4af2a16529ef681a45a..806caacff86c79d12f74dfbf80d7e9e1c0f5298b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -883,13 +883,6 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page, async_cow->work.ordered_free = async_cow_free; async_cow->work.flags = 0; - while(atomic_read(&root->fs_info->async_submit_draining) && - atomic_read(&root->fs_info->async_delalloc_pages)) { - wait_event(root->fs_info->async_submit_wait, - (atomic_read(&root->fs_info->async_delalloc_pages) - == 0)); - } - nr_pages = (cur_end - start + PAGE_CACHE_SIZE) >> PAGE_CACHE_SHIFT; atomic_add(nr_pages, &root->fs_info->async_delalloc_pages);