Skip to content

Commit

Permalink
Only call bi_end_io once for any bio
Browse files Browse the repository at this point in the history
Currently bi_end_io can be called multiple times as sub-requests
complete.  However no ->bi_end_io function wants to know about that.
So only call when the bio is complete.

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./fs/bio.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff .prev/fs/bio.c ./fs/bio.c
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
NeilBrown authored and Jens Axboe committed Oct 10, 2007
1 parent d24517d commit 9cc54d4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,8 @@ void bio_endio(struct bio *bio, unsigned int bytes_done, int error)
{
if (error)
clear_bit(BIO_UPTODATE, &bio->bi_flags);
else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
error = -EIO;

if (unlikely(bytes_done > bio->bi_size)) {
printk("%s: want %u bytes done, only %u left\n", __FUNCTION__,
Expand All @@ -1028,7 +1030,7 @@ void bio_endio(struct bio *bio, unsigned int bytes_done, int error)
bio->bi_size -= bytes_done;
bio->bi_sector += (bytes_done >> 9);

if (bio->bi_end_io)
if (bio->bi_size && bio->bi_end_io)
bio->bi_end_io(bio, bytes_done, error);
}

Expand Down

0 comments on commit 9cc54d4

Please sign in to comment.