Skip to content

Commit 5fd0204

Browse files
author
Josef Bacik
committed
Btrfs: finish ordered extents in their own thread
We noticed that the ordered extent completion doesn't really rely on having a page and that it could be done independantly of ending the writeback on a page. This patch makes us not do the threaded endio stuff for normal buffered writes and direct writes so we can end page writeback as soon as possible (in irq context) and only start threads to do the ordered work when it is actually done. Compression needs to be reworked some to take advantage of this as well, but atm it has to do a find_get_page in its endio handler so it must be done in its own thread. This makes direct writes quite a bit faster. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
1 parent 4e89915 commit 5fd0204

File tree

7 files changed

+164
-191
lines changed

7 files changed

+164
-191
lines changed

fs/btrfs/disk-io.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,23 +3671,11 @@ int btrfs_cleanup_transaction(struct btrfs_root *root)
36713671
return 0;
36723672
}
36733673

3674-
static int btree_writepage_io_failed_hook(struct bio *bio, struct page *page,
3675-
u64 start, u64 end,
3676-
struct extent_state *state)
3677-
{
3678-
struct super_block *sb = page->mapping->host->i_sb;
3679-
struct btrfs_fs_info *fs_info = btrfs_sb(sb);
3680-
btrfs_error(fs_info, -EIO,
3681-
"Error occured while writing out btree at %llu", start);
3682-
return -EIO;
3683-
}
3684-
36853674
static struct extent_io_ops btree_extent_io_ops = {
36863675
.write_cache_pages_lock_hook = btree_lock_page_hook,
36873676
.readpage_end_io_hook = btree_readpage_end_io_hook,
36883677
.readpage_io_failed_hook = btree_io_failed_hook,
36893678
.submit_bio_hook = btree_submit_bio_hook,
36903679
/* note we're sharing with inode.c for the merge bio hook */
36913680
.merge_bio_hook = btrfs_merge_bio_hook,
3692-
.writepage_io_failed_hook = btree_writepage_io_failed_hook,
36933681
};

fs/btrfs/extent_io.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,9 +1172,8 @@ int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end,
11721172
cached_state, mask);
11731173
}
11741174

1175-
static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
1176-
u64 end, struct extent_state **cached_state,
1177-
gfp_t mask)
1175+
int clear_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end,
1176+
struct extent_state **cached_state, gfp_t mask)
11781177
{
11791178
return clear_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, 0,
11801179
cached_state, mask);
@@ -2221,17 +2220,7 @@ int end_extent_writepage(struct page *page, int err, u64 start, u64 end)
22212220
uptodate = 0;
22222221
}
22232222

2224-
if (!uptodate && tree->ops &&
2225-
tree->ops->writepage_io_failed_hook) {
2226-
ret = tree->ops->writepage_io_failed_hook(NULL, page,
2227-
start, end, NULL);
2228-
/* Writeback already completed */
2229-
if (ret == 0)
2230-
return 1;
2231-
}
2232-
22332223
if (!uptodate) {
2234-
clear_extent_uptodate(tree, start, end, NULL, GFP_NOFS);
22352224
ClearPageUptodate(page);
22362225
SetPageError(page);
22372226
}

fs/btrfs/extent_io.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ struct extent_io_ops {
7575
unsigned long bio_flags);
7676
int (*readpage_io_hook)(struct page *page, u64 start, u64 end);
7777
int (*readpage_io_failed_hook)(struct page *page, int failed_mirror);
78-
int (*writepage_io_failed_hook)(struct bio *bio, struct page *page,
79-
u64 start, u64 end,
80-
struct extent_state *state);
8178
int (*readpage_end_io_hook)(struct page *page, u64 start, u64 end,
8279
struct extent_state *state, int mirror);
8380
int (*writepage_end_io_hook)(struct page *page, u64 start, u64 end,
@@ -225,6 +222,8 @@ int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
225222
struct extent_state **cached_state, gfp_t mask);
226223
int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end,
227224
struct extent_state **cached_state, gfp_t mask);
225+
int clear_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end,
226+
struct extent_state **cached_state, gfp_t mask);
228227
int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end,
229228
gfp_t mask);
230229
int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end,

fs/btrfs/free-space-cache.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,7 @@ int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
972972
goto out;
973973

974974

975-
ret = filemap_write_and_wait(inode->i_mapping);
976-
if (ret)
977-
goto out;
975+
btrfs_wait_ordered_range(inode, 0, (u64)-1);
978976

979977
key.objectid = BTRFS_FREE_SPACE_OBJECTID;
980978
key.offset = offset;

0 commit comments

Comments
 (0)