]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
md: use bio_kmalloc rather than bio_alloc when failure is acceptable.
authorNeilBrown <neilb@suse.de>
Tue, 26 Oct 2010 06:33:54 +0000 (17:33 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 28 Oct 2010 06:36:06 +0000 (17:36 +1100)
bio_alloc can never fail (as it uses a mempool) but an block
indefinitely, especially if the caller is holding a reference to a
previously allocated bio.

So these to places which both handle failure and hold multiple bios
should not use bio_alloc, they should use bio_kmalloc.

Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid1.c
drivers/md/raid10.c

index 3362cfc8073c70e7bca2a290aa5d91e842ebc2de..40f58d3b67ff1b7f737ef1b139d6ad69a2655084 100644 (file)
@@ -100,7 +100,7 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
         * Allocate bios : 1 for reading, n-1 for writing
         */
        for (j = pi->raid_disks ; j-- ; ) {
-               bio = bio_alloc(gfp_flags, RESYNC_PAGES);
+               bio = bio_kmalloc(gfp_flags, RESYNC_PAGES);
                if (!bio)
                        goto out_free_bio;
                r1_bio->bios[j] = bio;
index 8f5543a624169b237d639d6f8b57096ea8bb84c4..6709cb255200bfd744d14aa399c6a4121bc60575 100644 (file)
@@ -120,7 +120,7 @@ static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data)
         * Allocate bios.
         */
        for (j = nalloc ; j-- ; ) {
-               bio = bio_alloc(gfp_flags, RESYNC_PAGES);
+               bio = bio_kmalloc(gfp_flags, RESYNC_PAGES);
                if (!bio)
                        goto out_free_bio;
                r10_bio->devs[j].bio = bio;