diff options
Diffstat (limited to 'fs/btrfs/check-integrity.c')
-rw-r--r-- | fs/btrfs/check-integrity.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index e0aab4456974..f85b1c409003 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c | |||
@@ -323,7 +323,6 @@ static void btrfsic_release_block_ctx(struct btrfsic_block_data_ctx *block_ctx); | |||
323 | static int btrfsic_read_block(struct btrfsic_state *state, | 323 | static int btrfsic_read_block(struct btrfsic_state *state, |
324 | struct btrfsic_block_data_ctx *block_ctx); | 324 | struct btrfsic_block_data_ctx *block_ctx); |
325 | static void btrfsic_dump_database(struct btrfsic_state *state); | 325 | static void btrfsic_dump_database(struct btrfsic_state *state); |
326 | static void btrfsic_complete_bio_end_io(struct bio *bio, int err); | ||
327 | static int btrfsic_test_for_metadata(struct btrfsic_state *state, | 326 | static int btrfsic_test_for_metadata(struct btrfsic_state *state, |
328 | char **datav, unsigned int num_pages); | 327 | char **datav, unsigned int num_pages); |
329 | static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, | 328 | static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, |
@@ -1677,7 +1676,6 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1677 | for (i = 0; i < num_pages;) { | 1676 | for (i = 0; i < num_pages;) { |
1678 | struct bio *bio; | 1677 | struct bio *bio; |
1679 | unsigned int j; | 1678 | unsigned int j; |
1680 | DECLARE_COMPLETION_ONSTACK(complete); | ||
1681 | 1679 | ||
1682 | bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i); | 1680 | bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i); |
1683 | if (!bio) { | 1681 | if (!bio) { |
@@ -1688,8 +1686,6 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1688 | } | 1686 | } |
1689 | bio->bi_bdev = block_ctx->dev->bdev; | 1687 | bio->bi_bdev = block_ctx->dev->bdev; |
1690 | bio->bi_sector = dev_bytenr >> 9; | 1688 | bio->bi_sector = dev_bytenr >> 9; |
1691 | bio->bi_end_io = btrfsic_complete_bio_end_io; | ||
1692 | bio->bi_private = &complete; | ||
1693 | 1689 | ||
1694 | for (j = i; j < num_pages; j++) { | 1690 | for (j = i; j < num_pages; j++) { |
1695 | ret = bio_add_page(bio, block_ctx->pagev[j], | 1691 | ret = bio_add_page(bio, block_ctx->pagev[j], |
@@ -1702,12 +1698,7 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1702 | "btrfsic: error, failed to add a single page!\n"); | 1698 | "btrfsic: error, failed to add a single page!\n"); |
1703 | return -1; | 1699 | return -1; |
1704 | } | 1700 | } |
1705 | submit_bio(READ, bio); | 1701 | if (submit_bio_wait(READ, bio)) { |
1706 | |||
1707 | /* this will also unplug the queue */ | ||
1708 | wait_for_completion(&complete); | ||
1709 | |||
1710 | if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) { | ||
1711 | printk(KERN_INFO | 1702 | printk(KERN_INFO |
1712 | "btrfsic: read error at logical %llu dev %s!\n", | 1703 | "btrfsic: read error at logical %llu dev %s!\n", |
1713 | block_ctx->start, block_ctx->dev->name); | 1704 | block_ctx->start, block_ctx->dev->name); |
@@ -1730,11 +1721,6 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1730 | return block_ctx->len; | 1721 | return block_ctx->len; |
1731 | } | 1722 | } |
1732 | 1723 | ||
1733 | static void btrfsic_complete_bio_end_io(struct bio *bio, int err) | ||
1734 | { | ||
1735 | complete((struct completion *)bio->bi_private); | ||
1736 | } | ||
1737 | |||
1738 | static void btrfsic_dump_database(struct btrfsic_state *state) | 1724 | static void btrfsic_dump_database(struct btrfsic_state *state) |
1739 | { | 1725 | { |
1740 | struct list_head *elem_all; | 1726 | struct list_head *elem_all; |
@@ -2998,14 +2984,12 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh) | |||
2998 | return submit_bh(rw, bh); | 2984 | return submit_bh(rw, bh); |
2999 | } | 2985 | } |
3000 | 2986 | ||
3001 | void btrfsic_submit_bio(int rw, struct bio *bio) | 2987 | static void __btrfsic_submit_bio(int rw, struct bio *bio) |
3002 | { | 2988 | { |
3003 | struct btrfsic_dev_state *dev_state; | 2989 | struct btrfsic_dev_state *dev_state; |
3004 | 2990 | ||
3005 | if (!btrfsic_is_initialized) { | 2991 | if (!btrfsic_is_initialized) |
3006 | submit_bio(rw, bio); | ||
3007 | return; | 2992 | return; |
3008 | } | ||
3009 | 2993 | ||
3010 | mutex_lock(&btrfsic_mutex); | 2994 | mutex_lock(&btrfsic_mutex); |
3011 | /* since btrfsic_submit_bio() is also called before | 2995 | /* since btrfsic_submit_bio() is also called before |
@@ -3097,10 +3081,20 @@ void btrfsic_submit_bio(int rw, struct bio *bio) | |||
3097 | } | 3081 | } |
3098 | leave: | 3082 | leave: |
3099 | mutex_unlock(&btrfsic_mutex); | 3083 | mutex_unlock(&btrfsic_mutex); |
3084 | } | ||
3100 | 3085 | ||
3086 | void btrfsic_submit_bio(int rw, struct bio *bio) | ||
3087 | { | ||
3088 | __btrfsic_submit_bio(rw, bio); | ||
3101 | submit_bio(rw, bio); | 3089 | submit_bio(rw, bio); |
3102 | } | 3090 | } |
3103 | 3091 | ||
3092 | int btrfsic_submit_bio_wait(int rw, struct bio *bio) | ||
3093 | { | ||
3094 | __btrfsic_submit_bio(rw, bio); | ||
3095 | return submit_bio_wait(rw, bio); | ||
3096 | } | ||
3097 | |||
3104 | int btrfsic_mount(struct btrfs_root *root, | 3098 | int btrfsic_mount(struct btrfs_root *root, |
3105 | struct btrfs_fs_devices *fs_devices, | 3099 | struct btrfs_fs_devices *fs_devices, |
3106 | int including_extent_data, u32 print_mask) | 3100 | int including_extent_data, u32 print_mask) |