PATCH odd code in bio_add_page
From: Neil Brown
Date: Mon Aug 25 2003 - 21:58:03 EST
I was just taking a closer look at bio_add_page and there is some code
that doesn't mage sense. The following patch explains the problem and
suggests a possible fix.
NeilBrown
==================================================
Fix strange code in bio_add_page
With the current code in bio_add_page, if fail_segments is ever set,
it stays set, so bio_add_page will eventually fail having recounted
the segmentation once.
I don't think this is intended. This patch changes the code to allow
success if the recounting the segments helps.
----------- Diffstat output ------------
./fs/bio.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff ./fs/bio.c~current~ ./fs/bio.c
--- ./fs/bio.c~current~ 2003-08-26 12:38:15.000000000 +1000
+++ ./fs/bio.c 2003-08-26 12:41:45.000000000 +1000
@@ -296,7 +296,7 @@ int bio_add_page(struct bio *bio, struct
unsigned int offset)
{
request_queue_t *q = bdev_get_queue(bio->bi_bdev);
- int fail_segments = 0, retried_segments = 0;
+ int retried_segments = 0;
struct bio_vec *bvec;
/*
@@ -315,18 +315,15 @@ int bio_add_page(struct bio *bio, struct
* we might lose a segment or two here, but rather that than
* make this too complex.
*/
-retry_segments:
- if (bio_phys_segments(q, bio) >= q->max_phys_segments
- || bio_hw_segments(q, bio) >= q->max_hw_segments)
- fail_segments = 1;
- if (fail_segments) {
+ while (bio_phys_segments(q, bio) >= q->max_phys_segments
+ || bio_hw_segments(q, bio) >= q->max_hw_segments) {
+
if (retried_segments)
return 0;
bio->bi_flags &= ~(1 << BIO_SEG_VALID);
retried_segments = 1;
- goto retry_segments;
}
/*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/