aboutsummaryrefslogtreecommitdiffstats
path: root/fs/bio.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bio.c')
-rw-r--r--fs/bio.c50
1 files changed, 15 insertions, 35 deletions
diff --git a/fs/bio.c b/fs/bio.c
index 29a44c1b64c6..5f604f269dfa 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -798,13 +798,9 @@ void bio_unmap_user(struct bio *bio)
798 bio_put(bio); 798 bio_put(bio);
799} 799}
800 800
801static int bio_map_kern_endio(struct bio *bio, unsigned int bytes_done, int err) 801static void bio_map_kern_endio(struct bio *bio, int err)
802{ 802{
803 if (bio->bi_size)
804 return 1;
805
806 bio_put(bio); 803 bio_put(bio);
807 return 0;
808} 804}
809 805
810 806
@@ -1002,34 +998,26 @@ void bio_check_pages_dirty(struct bio *bio)
1002/** 998/**
1003 * bio_endio - end I/O on a bio 999 * bio_endio - end I/O on a bio
1004 * @bio: bio 1000 * @bio: bio
1005 * @bytes_done: number of bytes completed
1006 * @error: error, if any 1001 * @error: error, if any
1007 * 1002 *
1008 * Description: 1003 * Description:
1009 * bio_endio() will end I/O on @bytes_done number of bytes. This may be 1004 * bio_endio() will end I/O on the whole bio. bio_endio() is the
1010 * just a partial part of the bio, or it may be the whole bio. bio_endio() 1005 * preferred way to end I/O on a bio, it takes care of clearing
1011 * is the preferred way to end I/O on a bio, it takes care of decrementing 1006 * BIO_UPTODATE on error. @error is 0 on success, and and one of the
1012 * bi_size and clearing BIO_UPTODATE on error. @error is 0 on success, and 1007 * established -Exxxx (-EIO, for instance) error values in case
1013 * and one of the established -Exxxx (-EIO, for instance) error values in 1008 * something went wrong. Noone should call bi_end_io() directly on a
1014 * case something went wrong. Noone should call bi_end_io() directly on 1009 * bio unless they own it and thus know that it has an end_io
1015 * a bio unless they own it and thus know that it has an end_io function. 1010 * function.
1016 **/ 1011 **/
1017void bio_endio(struct bio *bio, unsigned int bytes_done, int error) 1012void bio_endio(struct bio *bio, int error)
1018{ 1013{
1019 if (error) 1014 if (error)
1020 clear_bit(BIO_UPTODATE, &bio->bi_flags); 1015 clear_bit(BIO_UPTODATE, &bio->bi_flags);
1021 1016 else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
1022 if (unlikely(bytes_done > bio->bi_size)) { 1017 error = -EIO;
1023 printk("%s: want %u bytes done, only %u left\n", __FUNCTION__,
1024 bytes_done, bio->bi_size);
1025 bytes_done = bio->bi_size;
1026 }
1027
1028 bio->bi_size -= bytes_done;
1029 bio->bi_sector += (bytes_done >> 9);
1030 1018
1031 if (bio->bi_end_io) 1019 if (bio->bi_end_io)
1032 bio->bi_end_io(bio, bytes_done, error); 1020 bio->bi_end_io(bio, error);
1033} 1021}
1034 1022
1035void bio_pair_release(struct bio_pair *bp) 1023void bio_pair_release(struct bio_pair *bp)
@@ -1037,37 +1025,29 @@ void bio_pair_release(struct bio_pair *bp)
1037 if (atomic_dec_and_test(&bp->cnt)) { 1025 if (atomic_dec_and_test(&bp->cnt)) {
1038 struct bio *master = bp->bio1.bi_private; 1026 struct bio *master = bp->bio1.bi_private;
1039 1027
1040 bio_endio(master, master->bi_size, bp->error); 1028 bio_endio(master, bp->error);
1041 mempool_free(bp, bp->bio2.bi_private); 1029 mempool_free(bp, bp->bio2.bi_private);
1042 } 1030 }
1043} 1031}
1044 1032
1045static int bio_pair_end_1(struct bio * bi, unsigned int done, int err) 1033static void bio_pair_end_1(struct bio *bi, int err)
1046{ 1034{
1047 struct bio_pair *bp = container_of(bi, struct bio_pair, bio1); 1035 struct bio_pair *bp = container_of(bi, struct bio_pair, bio1);
1048 1036
1049 if (err) 1037 if (err)
1050 bp->error = err; 1038 bp->error = err;
1051 1039
1052 if (bi->bi_size)
1053 return 1;
1054
1055 bio_pair_release(bp); 1040 bio_pair_release(bp);
1056 return 0;
1057} 1041}
1058 1042
1059static int bio_pair_end_2(struct bio * bi, unsigned int done, int err) 1043static void bio_pair_end_2(struct bio *bi, int err)
1060{ 1044{
1061 struct bio_pair *bp = container_of(bi, struct bio_pair, bio2); 1045 struct bio_pair *bp = container_of(bi, struct bio_pair, bio2);
1062 1046
1063 if (err) 1047 if (err)
1064 bp->error = err; 1048 bp->error = err;
1065 1049
1066 if (bi->bi_size)
1067 return 1;
1068
1069 bio_pair_release(bp); 1050 bio_pair_release(bp);
1070 return 0;
1071} 1051}
1072 1052
1073/* 1053/*