* [PATCH] Btrfs: use struct completion in scrub_submit_raid56_bio_wait
@ 2017-12-01 0:26 Liu Bo
2017-12-05 18:47 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Liu Bo @ 2017-12-01 0:26 UTC (permalink / raw)
To: linux-btrfs
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 bio so that it won't go away underneath us. So it can be
removed safely.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
fs/btrfs/scrub.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index e3f6c49..0cdf359 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1666,17 +1666,9 @@ static int scrub_setup_recheck_block(struct scrub_block *original_sblock,
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);
}
/*
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: use struct completion in scrub_submit_raid56_bio_wait
2017-12-01 0:26 [PATCH] Btrfs: use struct completion in scrub_submit_raid56_bio_wait Liu Bo
@ 2017-12-05 18:47 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2017-12-05 18:47 UTC (permalink / raw)
To: Liu Bo; +Cc: linux-btrfs
On Thu, Nov 30, 2017 at 05:26:39PM -0700, Liu Bo wrote:
> 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 bio so that it won't go away underneath us. So it can be
> removed safely.
>
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-12-05 18:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-01 0:26 [PATCH] Btrfs: use struct completion in scrub_submit_raid56_bio_wait Liu Bo
2017-12-05 18:47 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).