Skip to content

Commit

Permalink
fs: simplify dio_bio_complete
Browse files Browse the repository at this point in the history
Only read bio->bi_error once in the common path.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@sandisk.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Jun 9, 2017
1 parent 4055351 commit d5245d7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fs/direct-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,12 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio)
{
struct bio_vec *bvec;
unsigned i;
int err;
int err = bio->bi_error;

if (bio->bi_error)
if (err)
dio->io_error = -EIO;

if (dio->is_async && dio->op == REQ_OP_READ && dio->should_dirty) {
err = bio->bi_error;
bio_check_pages_dirty(bio); /* transfers ownership */
} else {
bio_for_each_segment_all(bvec, bio, i) {
Expand All @@ -494,7 +493,6 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio)
set_page_dirty_lock(page);
put_page(page);
}
err = bio->bi_error;
bio_put(bio);
}
return err;
Expand Down

0 comments on commit d5245d7

Please sign in to comment.