From patchwork Fri Nov 20 14:19:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 11920339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC7ACC56201 for ; Fri, 20 Nov 2020 14:19:19 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B9352222A for ; Fri, 20 Nov 2020 14:19:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DPUTzUxp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B9352222A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605881957; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=U8or99Cy0Va96DSLDd+r1LiGBbDFy8+n2tl9Nv06d0I=; b=DPUTzUxpDnbVp0PWJ/xagjffJlyI9aDkjAdvPQS9YXFjxAWb2abOiT4gzKZBqAWRKJCXju j+yeYRUqlMPVw84yj2Wn5Fr/Tp4gPXnpRIS5AFjuiOvKD9IsJaW6XUIH9fsVrk0CJfTTIJ jqQmFLf4w0jh1yLQF6uE3CDmV0N9+mk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-v9C1h0bDM0e7HpnmYcBEDQ-1; Fri, 20 Nov 2020 09:19:15 -0500 X-MC-Unique: v9C1h0bDM0e7HpnmYcBEDQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23C02100945E; Fri, 20 Nov 2020 14:19:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F32719D7D; Fri, 20 Nov 2020 14:19:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1DBB0180954D; Fri, 20 Nov 2020 14:19:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AKEJ9PM003947 for ; Fri, 20 Nov 2020 09:19:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 217575D6D5; Fri, 20 Nov 2020 14:19:09 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 522605D6D1; Fri, 20 Nov 2020 14:19:02 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 0AKEJ1bW026562; Fri, 20 Nov 2020 09:19:01 -0500 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 0AKEJ169026549; Fri, 20 Nov 2020 09:19:01 -0500 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Fri, 20 Nov 2020 09:19:01 -0500 (EST) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: David Teigland , Jens Axboe , John Dorminy In-Reply-To: Message-ID: References: <20201118203127.GA30066@redhat.com> <20201118203408.GB30066@redhat.com> <20201119172807.GC1879@redhat.com> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: Mike Snitzer , heinzm@redhat.com, Marian Csontos , linux-block@vger.kernel.org, dm-devel@redhat.com, Zdenek Kabelac Subject: [dm-devel] [PATCH v2] blk-settings: make sure that max_sectors is aligned on "logical_block_size" boundary. 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com We get I/O errors when we run md-raid1 on the top of dm-integrity on the top of ramdisk. device-mapper: integrity: Bio not aligned on 8 sectors: 0xff00, 0xff device-mapper: integrity: Bio not aligned on 8 sectors: 0xff00, 0xff device-mapper: integrity: Bio not aligned on 8 sectors: 0xffff, 0x1 device-mapper: integrity: Bio not aligned on 8 sectors: 0xffff, 0x1 device-mapper: integrity: Bio not aligned on 8 sectors: 0x8048, 0xff device-mapper: integrity: Bio not aligned on 8 sectors: 0x8147, 0xff device-mapper: integrity: Bio not aligned on 8 sectors: 0x8246, 0xff device-mapper: integrity: Bio not aligned on 8 sectors: 0x8345, 0xbb The ramdisk device has logical_block_size 512 and max_sectors 255. The dm-integrity device uses logical_block_size 4096 and it doesn't affect the "max_sectors" value - thus, it inherits 255 from the ramdisk. So, we have a device with max_sectors not aligned on logical_block_size. The md-raid device sees that the underlying leg has max_sectors 255 and it will split the bios on 255-sector boundary, making the bios unaligned on logical_block_size. In order to fix the bug, we round down max_sectors to logical_block_size. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org --- block/blk-settings.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/block/blk-settings.c =================================================================== --- linux-2.6.orig/block/blk-settings.c 2020-10-29 12:20:46.000000000 +0100 +++ linux-2.6/block/blk-settings.c 2020-11-20 15:07:59.000000000 +0100 @@ -591,6 +591,16 @@ int blk_stack_limits(struct queue_limits ret = -1; } + t->max_sectors = round_down(t->max_sectors, t->logical_block_size >> SECTOR_SHIFT); + if (t->max_sectors < PAGE_SIZE >> SECTOR_SHIFT) + t->max_sectors = PAGE_SIZE >> SECTOR_SHIFT; + t->max_hw_sectors = round_down(t->max_hw_sectors, t->logical_block_size >> SECTOR_SHIFT); + if (t->max_hw_sectors < PAGE_SIZE >> SECTOR_SHIFT) + t->max_hw_sectors = PAGE_SIZE >> SECTOR_SHIFT; + t->max_dev_sectors = round_down(t->max_dev_sectors, t->logical_block_size >> SECTOR_SHIFT); + if (t->max_dev_sectors < PAGE_SIZE >> SECTOR_SHIFT) + t->max_dev_sectors = PAGE_SIZE >> SECTOR_SHIFT; + /* Discard alignment and granularity */ if (b->discard_granularity) { alignment = queue_limit_discard_alignment(b, start);