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 b50764bef141..131d82800b3a 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c | |||
@@ -333,7 +333,6 @@ static void btrfsic_release_block_ctx(struct btrfsic_block_data_ctx *block_ctx); | |||
333 | static int btrfsic_read_block(struct btrfsic_state *state, | 333 | static int btrfsic_read_block(struct btrfsic_state *state, |
334 | struct btrfsic_block_data_ctx *block_ctx); | 334 | struct btrfsic_block_data_ctx *block_ctx); |
335 | static void btrfsic_dump_database(struct btrfsic_state *state); | 335 | static void btrfsic_dump_database(struct btrfsic_state *state); |
336 | static void btrfsic_complete_bio_end_io(struct bio *bio, int err); | ||
337 | static int btrfsic_test_for_metadata(struct btrfsic_state *state, | 336 | static int btrfsic_test_for_metadata(struct btrfsic_state *state, |
338 | char **datav, unsigned int num_pages); | 337 | char **datav, unsigned int num_pages); |
339 | static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, | 338 | static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, |
@@ -1687,7 +1686,6 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1687 | for (i = 0; i < num_pages;) { | 1686 | for (i = 0; i < num_pages;) { |
1688 | struct bio *bio; | 1687 | struct bio *bio; |
1689 | unsigned int j; | 1688 | unsigned int j; |
1690 | DECLARE_COMPLETION_ONSTACK(complete); | ||
1691 | 1689 | ||
1692 | bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i); | 1690 | bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i); |
1693 | if (!bio) { | 1691 | if (!bio) { |
@@ -1698,8 +1696,6 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1698 | } | 1696 | } |
1699 | bio->bi_bdev = block_ctx->dev->bdev; | 1697 | bio->bi_bdev = block_ctx->dev->bdev; |
1700 | bio->bi_sector = dev_bytenr >> 9; | 1698 | bio->bi_sector = dev_bytenr >> 9; |
1701 | bio->bi_end_io = btrfsic_complete_bio_end_io; | ||
1702 | bio->bi_private = &complete; | ||
1703 | 1699 | ||
1704 | for (j = i; j < num_pages; j++) { | 1700 | for (j = i; j < num_pages; j++) { |
1705 | ret = bio_add_page(bio, block_ctx->pagev[j], | 1701 | ret = bio_add_page(bio, block_ctx->pagev[j], |
@@ -1712,12 +1708,7 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1712 | "btrfsic: error, failed to add a single page!\n"); | 1708 | "btrfsic: error, failed to add a single page!\n"); |
1713 | return -1; | 1709 | return -1; |
1714 | } | 1710 | } |
1715 | submit_bio(READ, bio); | 1711 | if (submit_bio_wait(READ, bio)) { |
1716 | |||
1717 | /* this will also unplug the queue */ | ||
1718 | wait_for_completion(&complete); | ||
1719 | |||
1720 | if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) { | ||
1721 | printk(KERN_INFO | 1712 | printk(KERN_INFO |
1722 | "btrfsic: read error at logical %llu dev %s!\n", | 1713 | "btrfsic: read error at logical %llu dev %s!\n", |
1723 | block_ctx->start, block_ctx->dev->name); | 1714 | block_ctx->start, block_ctx->dev->name); |
@@ -1740,11 +1731,6 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
1740 | return block_ctx->len; | 1731 | return block_ctx->len; |
1741 | } | 1732 | } |
1742 | 1733 | ||
1743 | static void btrfsic_complete_bio_end_io(struct bio *bio, int err) | ||
1744 | { | ||
1745 | complete((struct completion *)bio->bi_private); | ||
1746 | } | ||
1747 | |||
1748 | static void btrfsic_dump_database(struct btrfsic_state *state) | 1734 | static void btrfsic_dump_database(struct btrfsic_state *state) |
1749 | { | 1735 | { |
1750 | struct list_head *elem_all; | 1736 | struct list_head *elem_all; |
@@ -3008,14 +2994,12 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh) | |||
3008 | return submit_bh(rw, bh); | 2994 | return submit_bh(rw, bh); |
3009 | } | 2995 | } |
3010 | 2996 | ||
3011 | void btrfsic_submit_bio(int rw, struct bio *bio) | 2997 | static void __btrfsic_submit_bio(int rw, struct bio *bio) |
3012 | { | 2998 | { |
3013 | struct btrfsic_dev_state *dev_state; | 2999 | struct btrfsic_dev_state *dev_state; |
3014 | 3000 | ||
3015 | if (!btrfsic_is_initialized) { | 3001 | if (!btrfsic_is_initialized) |
3016 | submit_bio(rw, bio); | ||
3017 | return; | 3002 | return; |
3018 | } | ||
3019 | 3003 | ||
3020 | mutex_lock(&btrfsic_mutex); | 3004 | mutex_lock(&btrfsic_mutex); |
3021 | /* since btrfsic_submit_bio() is also called before | 3005 | /* since btrfsic_submit_bio() is also called before |
@@ -3106,10 +3090,20 @@ void btrfsic_submit_bio(int rw, struct bio *bio) | |||
3106 | } | 3090 | } |
3107 | leave: | 3091 | leave: |
3108 | mutex_unlock(&btrfsic_mutex); | 3092 | mutex_unlock(&btrfsic_mutex); |
3093 | } | ||
3109 | 3094 | ||
3095 | void btrfsic_submit_bio(int rw, struct bio *bio) | ||
3096 | { | ||
3097 | __btrfsic_submit_bio(rw, bio); | ||
3110 | submit_bio(rw, bio); | 3098 | submit_bio(rw, bio); |
3111 | } | 3099 | } |
3112 | 3100 | ||
3101 | int btrfsic_submit_bio_wait(int rw, struct bio *bio) | ||
3102 | { | ||
3103 | __btrfsic_submit_bio(rw, bio); | ||
3104 | return submit_bio_wait(rw, bio); | ||
3105 | } | ||
3106 | |||
3113 | int btrfsic_mount(struct btrfs_root *root, | 3107 | int btrfsic_mount(struct btrfs_root *root, |
3114 | struct btrfs_fs_devices *fs_devices, | 3108 | struct btrfs_fs_devices *fs_devices, |
3115 | int including_extent_data, u32 print_mask) | 3109 | int including_extent_data, u32 print_mask) |