diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2017-12-01 03:26:39 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-01-22 18:08:15 +0300 |
commit | b4ff5ad72e9331aabfa92456403946d17c4959d5 (patch) | |
tree | a4872b86d6683e4edd2d4860d7e2feb587dc4487 /fs/btrfs/scrub.c | |
parent | c9f540fa6f4cab5a506b157e7bf2e5373c0241c2 (diff) | |
download | linux-b4ff5ad72e9331aabfa92456403946d17c4959d5.tar.xz |
Btrfs: use struct completion in scrub_submit_raid56_bio_wait
This changes to use struct completion directly and removes 'struct
scrub_bio_ret' along with the code using it.
This struct is used to get the return value from bio, but the caller can
access bio to get the return value directly and is holding a reference
on it so it won't go away underneath us and can be removed safely.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/scrub.c')
-rw-r--r-- | fs/btrfs/scrub.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 03da807c43cf..d766c73eb29a 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -1666,17 +1666,9 @@ leave_nomem: return 0; } -struct scrub_bio_ret { - struct completion event; - blk_status_t status; -}; - static void scrub_bio_wait_endio(struct bio *bio) { - struct scrub_bio_ret *ret = bio->bi_private; - - ret->status = bio->bi_status; - complete(&ret->event); + complete(bio->bi_private); } static inline int scrub_is_page_on_raid56(struct scrub_page *page) @@ -1689,11 +1681,9 @@ static int scrub_submit_raid56_bio_wait(struct btrfs_fs_info *fs_info, struct bio *bio, struct scrub_page *page) { - struct scrub_bio_ret done; + DECLARE_COMPLETION_ONSTACK(done); int ret; - init_completion(&done.event); - done.status = 0; bio->bi_iter.bi_sector = page->logical >> 9; bio->bi_private = &done; bio->bi_end_io = scrub_bio_wait_endio; @@ -1704,11 +1694,8 @@ static int scrub_submit_raid56_bio_wait(struct btrfs_fs_info *fs_info, if (ret) return ret; - wait_for_completion_io(&done.event); - if (done.status) - return -EIO; - - return 0; + wait_for_completion_io(&done); + return blk_status_to_errno(bio->bi_status); } /* |