]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Fix odd code in bio_add_page
authorAndrew Morton <akpm@osdl.org>
Wed, 3 Sep 2003 18:11:33 +0000 (11:11 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 3 Sep 2003 18:11:33 +0000 (11:11 -0700)
From: Neil Brown <neilb@cse.unsw.edu.au>

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.

(Jens has acked this)

fs/bio.c

index d80b7d19dc087a126a0804468c8a8039d48b6ea8..b02019be46684f5d368ccb8a14f455f3ae549d2b 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -296,7 +296,7 @@ int bio_add_page(struct bio *bio, struct page *page, unsigned int len,
                 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 page *page, unsigned int len,
         * 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;
        }
 
        /*