diff options
Diffstat (limited to 'fs/bio.c')
-rw-r--r-- | fs/bio.c | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -1006,13 +1006,14 @@ void bio_check_pages_dirty(struct bio *bio) | |||
1006 | * @error: error, if any | 1006 | * @error: error, if any |
1007 | * | 1007 | * |
1008 | * Description: | 1008 | * Description: |
1009 | * bio_endio() will end I/O on @bytes_done number of bytes. This may be | 1009 | * bio_endio() will end I/O on @bytes_done number of bytes. This |
1010 | * just a partial part of the bio, or it may be the whole bio. bio_endio() | 1010 | * must always be the whole (remaining) bio. bio_endio() is the |
1011 | * is the preferred way to end I/O on a bio, it takes care of decrementing | 1011 | * preferred way to end I/O on a bio, it takes care of clearing |
1012 | * bi_size and clearing BIO_UPTODATE on error. @error is 0 on success, and | 1012 | * BIO_UPTODATE on error. @error is 0 on success, and and one of the |
1013 | * and one of the established -Exxxx (-EIO, for instance) error values in | 1013 | * established -Exxxx (-EIO, for instance) error values in case |
1014 | * case something went wrong. Noone should call bi_end_io() directly on | 1014 | * something went wrong. Noone should call bi_end_io() directly on a |
1015 | * a bio unless they own it and thus know that it has an end_io function. | 1015 | * bio unless they own it and thus know that it has an end_io |
1016 | * function. | ||
1016 | **/ | 1017 | **/ |
1017 | void bio_endio(struct bio *bio, unsigned int bytes_done, int error) | 1018 | void bio_endio(struct bio *bio, unsigned int bytes_done, int error) |
1018 | { | 1019 | { |
@@ -1021,16 +1022,14 @@ void bio_endio(struct bio *bio, unsigned int bytes_done, int error) | |||
1021 | else if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) | 1022 | else if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) |
1022 | error = -EIO; | 1023 | error = -EIO; |
1023 | 1024 | ||
1024 | if (unlikely(bytes_done > bio->bi_size)) { | 1025 | if (unlikely(bytes_done != bio->bi_size)) { |
1025 | printk("%s: want %u bytes done, only %u left\n", __FUNCTION__, | 1026 | printk("%s: want %u bytes done, only %u left\n", __FUNCTION__, |
1026 | bytes_done, bio->bi_size); | 1027 | bytes_done, bio->bi_size); |
1027 | bytes_done = bio->bi_size; | 1028 | bytes_done = bio->bi_size; |
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | bio->bi_size -= bytes_done; | 1031 | bio->bi_size = 0; /* expected by some callees - will be removed */ |
1031 | bio->bi_sector += (bytes_done >> 9); | 1032 | if (bio->bi_end_io) |
1032 | |||
1033 | if (bio->bi_size && bio->bi_end_io) | ||
1034 | bio->bi_end_io(bio, bytes_done, error); | 1033 | bio->bi_end_io(bio, bytes_done, error); |
1035 | } | 1034 | } |
1036 | 1035 | ||