* PATCH odd code in bio_add_page
@ 2003-08-26 2:47 Neil Brown
2003-08-26 8:07 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Neil Brown @ 2003-08-26 2:47 UTC (permalink / raw)
To: Jens Axboe, Andrew Morton; +Cc: linux-kernel
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;
}
/*
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: PATCH odd code in bio_add_page
2003-08-26 2:47 PATCH odd code in bio_add_page Neil Brown
@ 2003-08-26 8:07 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2003-08-26 8:07 UTC (permalink / raw)
To: Neil Brown; +Cc: Andrew Morton, linux-kernel
On Tue, Aug 26 2003, Neil Brown wrote:
>
> 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.
Good catch Neil, I agree with the fix.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-08-26 8:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-26 2:47 PATCH odd code in bio_add_page Neil Brown
2003-08-26 8:07 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox