From patchwork Thu Jan 22 03:32:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 3524 X-Patchwork-Delegate: agk@redhat.com Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n0M3RmmL012107 for ; Wed, 21 Jan 2009 19:27:50 -0800 Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 17A87618A72; Wed, 21 Jan 2009 22:32:21 -0500 (EST) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n0M3WKPB030938 for ; Wed, 21 Jan 2009 22:32:20 -0500 Received: from hs20-bc2-1.build.redhat.com (hs20-bc2-1.build.redhat.com [10.10.28.34]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n0M3WLDQ023117; Wed, 21 Jan 2009 22:32:21 -0500 Received: from hs20-bc2-1.build.redhat.com (localhost.localdomain [127.0.0.1]) by hs20-bc2-1.build.redhat.com (8.13.1/8.13.1) with ESMTP id n0M3WKXc003827; Wed, 21 Jan 2009 22:32:20 -0500 Received: from localhost (mpatocka@localhost) by hs20-bc2-1.build.redhat.com (8.13.1/8.13.1/Submit) with ESMTP id n0M3WKsD003821; Wed, 21 Jan 2009 22:32:20 -0500 X-Authentication-Warning: hs20-bc2-1.build.redhat.com: mpatocka owned process doing -bs Date: Wed, 21 Jan 2009 22:32:20 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@hs20-bc2-1.build.redhat.com To: dm-devel@redhat.com Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-loop: dm-devel@redhat.com Cc: Alasdair G Kergon Subject: [dm-devel] [PATCH] dm-io: don't allocate vector larger than BIO_MAX_PAGES X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com dm-io calls bio_get_nr_vecs to get the maximum number of pages for a given device, then adds 1 to it and allocates bio with this size. The last vector is not used for i/o, it is used to hold information about the region this i/o belongs to. If bio_get_nr_vecs returned the maximum biovec size, dm-io attempts to allocate bio with one more vector and fails. Very likely this was the reason for bug https://bugzilla.redhat.com/show_bug.cgi?id=173153 (the bug was fixed with an userspace workaround preventing lvm from creating snapshots with chunksize >512k; after this patch is applied, that limit can be dropped) Signed-off-by: Mikulas Patocka --- drivers/md/dm-io.c | 2 ++ 1 file changed, 2 insertions(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6.29-rc1-devel/drivers/md/dm-io.c =================================================================== --- linux-2.6.29-rc1-devel.orig/drivers/md/dm-io.c 2009-01-22 04:13:45.000000000 +0100 +++ linux-2.6.29-rc1-devel/drivers/md/dm-io.c 2009-01-22 04:14:13.000000000 +0100 @@ -292,6 +292,8 @@ static void do_region(int rw, unsigned r (PAGE_SIZE >> SECTOR_SHIFT)); num_bvecs = 1 + min_t(int, bio_get_nr_vecs(where->bdev), num_bvecs); + if (unlikely(num_bvecs > BIO_MAX_PAGES)) + num_bvecs = BIO_MAX_PAGES; bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios); bio->bi_sector = where->sector + (where->count - remaining); bio->bi_bdev = where->bdev;