From patchwork Mon Feb 16 02:23:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 7412 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 n1G2NgbD016166 for ; Mon, 16 Feb 2009 02:23:43 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id D811561A5B4; Sun, 15 Feb 2009 21:23:41 -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 n1G2Ndeb013675 for ; Sun, 15 Feb 2009 21:23:40 -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 n1G2NcOw016429; Sun, 15 Feb 2009 21:23:38 -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 n1G2NdG0019211; Sun, 15 Feb 2009 21:23:39 -0500 Received: from localhost (mpatocka@localhost) by hs20-bc2-1.build.redhat.com (8.13.1/8.13.1/Submit) with ESMTP id n1G2Nd0Z019205; Sun, 15 Feb 2009 21:23:39 -0500 X-Authentication-Warning: hs20-bc2-1.build.redhat.com: mpatocka owned process doing -bs Date: Sun, 15 Feb 2009 21:23:39 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@hs20-bc2-1.build.redhat.com To: dm-devel@redhat.com In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-loop: dm-devel@redhat.com Cc: Pete Zaitcev , Alasdair G Kergon Subject: [dm-devel] [PATCH 1/2]: save/restore bio vector (version 2) 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 Hi I've made an update on this patch that consumes 4 times less memory. This is accomplished by not saving the page (as suggested by Pete Zaitcev ) and using 16-bit entries if the page size is less than 16 bits. Mikulas On Wed, 4 Feb 2009, Mikulas Patocka wrote: > Hi > > This patch should fix bug 472796 in upstream kernel. > > --- Bio layer modifies the vector list when the request partially succeeds. Device mapper saves and restores various fields in the bio, but it doesn't save the vector. So, when the block driver modifies the vector on partially succeeded request, dm-raid1 and dm-multipath will attempt to resubmit a bio that has mismatching bi_size and the size of vector. That will cause BUG() in the block layer. To make requests resubmittable in dm-raid1 and dm-multipath, we must save and restore the bio vector as well. To consume per-request memory, do not save the pages in a vector. Also, use only 16-bit field size if the page size is less than 65536. Signed-off-by: Mikulas Patocka --- drivers/md/dm-bio-record.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6.29-rc3-devel/drivers/md/dm-bio-record.h =================================================================== --- linux-2.6.29-rc3-devel.orig/drivers/md/dm-bio-record.h 2009-02-05 03:55:56.000000000 +0100 +++ linux-2.6.29-rc3-devel/drivers/md/dm-bio-record.h 2009-02-16 03:13:07.000000000 +0100 @@ -16,30 +16,52 @@ * functions in this file help the target record and restore the * original bio state. */ + +struct dm_bio_vec_details { +#if PAGE_SIZE < 65536 + __u16 bv_len; + __u16 bv_offset; +#else + unsigned int bv_len; + unsigned int bv_offset; +#endif +}; + struct dm_bio_details { sector_t bi_sector; struct block_device *bi_bdev; unsigned int bi_size; unsigned short bi_idx; unsigned long bi_flags; + struct dm_bio_vec_details bi_io_vec[BIO_MAX_PAGES]; }; static inline void dm_bio_record(struct dm_bio_details *bd, struct bio *bio) { + unsigned i; bd->bi_sector = bio->bi_sector; bd->bi_bdev = bio->bi_bdev; bd->bi_size = bio->bi_size; bd->bi_idx = bio->bi_idx; bd->bi_flags = bio->bi_flags; + for (i = 0; i < bio->bi_vcnt; i++) { + bd->bi_io_vec[i].bv_len = bio->bi_io_vec[i].bv_len; + bd->bi_io_vec[i].bv_offset = bio->bi_io_vec[i].bv_offset; + } } static inline void dm_bio_restore(struct dm_bio_details *bd, struct bio *bio) { + unsigned i; bio->bi_sector = bd->bi_sector; bio->bi_bdev = bd->bi_bdev; bio->bi_size = bd->bi_size; bio->bi_idx = bd->bi_idx; bio->bi_flags = bd->bi_flags; + for (i = 0; i < bio->bi_vcnt; i++) { + bio->bi_io_vec[i].bv_len = bd->bi_io_vec[i].bv_len; + bio->bi_io_vec[i].bv_offset = bd->bi_io_vec[i].bv_offset; + } } #endif