From patchwork Thu Aug 11 03:56:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Wheeler X-Patchwork-Id: 9274427 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DAF48600CB for ; Thu, 11 Aug 2016 04:07:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC1EE284A8 for ; Thu, 11 Aug 2016 04:07:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF71E284D9; Thu, 11 Aug 2016 04:07:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2F844284A8 for ; Thu, 11 Aug 2016 04:07:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7B41wlW001498; Thu, 11 Aug 2016 00:01:59 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u7B41uA5020979 for ; Thu, 11 Aug 2016 00:01:56 -0400 Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7B41uti022905 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 11 Aug 2016 00:01:56 -0400 Received: from mail.ewheeler.net (mx.ewheeler.net [66.155.3.69]) by mx1.redhat.com (Postfix) with ESMTP id 0339E83F47; Thu, 11 Aug 2016 04:01:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.ewheeler.net (Postfix) with ESMTP id D1271A0C51; Wed, 10 Aug 2016 20:56:40 -0700 (PDT) X-Virus-Scanned: amavisd-new at ewheeler.net Received: from mail.ewheeler.net ([127.0.0.1]) by localhost (mail.ewheeler.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jjquefvbsLHe; Wed, 10 Aug 2016 20:56:40 -0700 (PDT) Received: from mx.ewheeler.net (mx.ewheeler.net [66.155.3.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.ewheeler.net (Postfix) with ESMTPSA id 311DBA0C50; Wed, 10 Aug 2016 20:56:40 -0700 (PDT) Date: Wed, 10 Aug 2016 20:56:39 -0700 (PDT) From: Eric Wheeler X-X-Sender: lists@mail.ewheeler.net To: mpatocka@redhat.com Message-ID: User-Agent: Alpine 2.11 (LRH 23 2013-08-11) MIME-Version: 1.0 X-Greylist: Delayed for 00:05:13 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 Aug 2016 04:01:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 11 Aug 2016 04:01:55 +0000 (UTC) for IP:'66.155.3.69' DOMAIN:'mx.ewheeler.net' HELO:'mail.ewheeler.net' FROM:'dm-devel@lists.ewheeler.net' RCPT:'' X-RedHat-Spam-Score: 0.449 (BAYES_50, RP_MATCHES_RCVD, URIBL_SBL_A) 66.155.3.69 mx.ewheeler.net 66.155.3.69 mx.ewheeler.net X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, johnstonj.public@codenest.com Subject: [dm-devel] [PATCH] Re: dm-crypt: Fix error with too large bios X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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 X-Virus-Scanned: ClamAV using ClamSMTP Hello Mikulas and dm-devel list, The simple patch below with is confirmed to fix James Johnston's issue and doesn't appear to be in v4.8-rc1: This references the following patchwork entry: https://patchwork.kernel.org/patch/9138595/ Can we get this pushed upstream for v4.8? --- Eric Wheeler On Fri, 27 May 2016, Mikulas Patocka wrote: > dm-crypt: Fix error with too large bios > > When dm-crypt processes writes, it allocates a new bio in the function > crypt_alloc_buffer. The bio is allocated from a bio set and it can have at > most BIO_MAX_PAGES vector entries, however the incoming bio can be larger > if it was allocated by other means. For example, bcache creates bios > larger than BIO_MAX_PAGES. If the incoming bio is larger, bio_alloc_bioset > fails and error is returned. > > To avoid the error, we test for too large bio in the function crypt_map > and dm_accept_partial_bio to split the bio. dm_accept_partial_bio trims > the current bio to the desired size and requests that the device mapper > core sends another bio with the rest of the data. > > Signed-off-by: Mikulas Patocka > Cc: stable@vger.kernel.org # v3.16+ Tested-by: James Johnston I tested this patch by: 1. Building v4.7-rc1 from Torvalds git repo. Confirmed that original bug still occurs on Ubuntu 15.10. 2. Applying your patch to v4.7-rc1. My kill sequence no longer works, and the writeback cache is now successfully flushed to disk, and the cache can be detached from the backing device. 3. To check data integrity, copied 250 MB of /dev/urandom to some file on main volume. Then, dd copy this file to /dev/bcache0. Then, detached the cache device from the backing device. Then, rebooted. Then, dd copy /dev/bcache0 to another file on main volume. Then, diff the files and confirm no changes. So it looks like it works, based on this admittedly brief testing. Thanks! Best regards, James Johnston -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Patch -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-4.6/drivers/md/dm-crypt.c =================================================================== --- linux-4.6.orig/drivers/md/dm-crypt.c +++ linux-4.6/drivers/md/dm-crypt.c @@ -2137,6 +2137,10 @@ static int crypt_map(struct dm_target *t struct dm_crypt_io *io; struct crypt_config *cc = ti->private; + if (unlikely(bio->bi_iter.bi_size > BIO_MAX_SIZE) && + (bio->bi_rw & (REQ_FLUSH | REQ_DISCARD | REQ_WRITE)) == REQ_WRITE) + dm_accept_partial_bio(bio, BIO_MAX_SIZE >> SECTOR_SHIFT); + /* * If bio is REQ_FLUSH or REQ_DISCARD, just bypass crypt queues. * - for REQ_FLUSH device-mapper core ensures that no IO is in-flight