don't rely upon subsequent bio_add_pc_page() calls failing
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 23 Sep 2017 20:16:06 +0000 (16:16 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 11 Oct 2017 21:23:38 +0000 (17:23 -0400)
... they might actually succeed in some cases (when we are at the
queue-imposed segments limit, the next page is not mergable with
the last one we'd got in, but the first page covered by the next
iovec *is* mergable).  Make sure that once it's failed, we are
done with that bio.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
block/bio.c

index 5dbc5e90d71688feb0028ba46261664effa33ce4..fe40948d62afd7d4e02b8833e211ee900dd29d9d 100644 (file)
@@ -1380,10 +1380,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
                        if (n > bytes)
                                n = bytes;
 
-                       /*
-                        * sorry...
-                        */
-                       if (bio_add_pc_page(q, bio, pages[j], n, offs) < n)
+                       if (!bio_add_pc_page(q, bio, pages[j], n, offs))
                                break;
 
                        /*
@@ -1405,6 +1402,9 @@ struct bio *bio_map_user_iov(struct request_queue *q,
                while (j < npages)
                        put_page(pages[j++]);
                kvfree(pages);
+               /* couldn't stuff something into bio? */
+               if (bytes)
+                       break;
        }
 
        bio_set_flag(bio, BIO_USER_MAPPED);