From patchwork Wed Feb 20 02:09:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Xiaoxu X-Patchwork-Id: 10826025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F477139A for ; Fri, 22 Feb 2019 13:48:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B7D332771 for ; Fri, 22 Feb 2019 13:48:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F89C32777; Fri, 22 Feb 2019 13:48:25 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 D27F032771 for ; Fri, 22 Feb 2019 13:48:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD654AC2C0; Fri, 22 Feb 2019 13:48:23 +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 B567A5D9D5; Fri, 22 Feb 2019 13:48:23 +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 80540181A00B; Fri, 22 Feb 2019 13:48:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1K26Z5e024262 for ; Tue, 19 Feb 2019 21:06:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9412960146; Wed, 20 Feb 2019 02:06:35 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 981C460139; Wed, 20 Feb 2019 02:06:29 +0000 (UTC) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D6B799CFE; Wed, 20 Feb 2019 02:06:28 +0000 (UTC) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 8637B811AA6B1CFA90B7; Wed, 20 Feb 2019 10:06:24 +0800 (CST) Received: from RH5885H-V3.huawei.com (10.90.53.225) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Wed, 20 Feb 2019 10:05:31 +0800 From: ZhangXiaoxu To: , , , , , , , , , Date: Wed, 20 Feb 2019 10:09:43 +0800 Message-ID: <1550628583-100041-1-git-send-email-zhangxiaoxu5@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Feb 2019 02:06:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Feb 2019 02:06:28 +0000 (UTC) for IP:'45.249.212.191' DOMAIN:'szxga05-in.huawei.com' HELO:'huawei.com' FROM:'zhangxiaoxu5@huawei.com' RCPT:'' X-RedHat-Spam-Score: -0.702 (RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS) 45.249.212.191 szxga05-in.huawei.com 45.249.212.191 szxga05-in.huawei.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 20 Feb 2019 04:00:20 -0500 Subject: [dm-devel] [PATCH v3] block: Fix a WRITE SAME BUG_ON 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 22 Feb 2019 13:48:24 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP If the lvm is stacked by different lbs disks, when WRITE SAME on it, will bug_on: kernel BUG at drivers/scsi/sd.c:968! invalid opcode: 0000 [#1] SMP PTI CPU: 11 PID: 525 Comm: kworker/11:1H Tainted: G O 5.0.0-rc3+ #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-2.fc27 04/01/2014 Workqueue: kblockd blk_mq_run_work_fn RIP: 0010:sd_init_command+0x7aa/0xdb0 Code: 30 75 00 00 c7 85 44 01 00 00 18 00 00 00 0f 85 fa 04 00 00 48 83 c4 40 48 89 df 5b 5d 41 5c 41 5d 41 5e 41 5f e9 b6 ca fe ff <0f> 0b 41 bc 09 RSP: 0018:ffffb55f80ddbca0 EFLAGS: 00010206 RAX: 0000000000001000 RBX: ffff9ed23fb927a0 RCX: 000000000000f000 RDX: ffff9ed23f0a8400 RSI: ffff9ed27bc79800 RDI: 0000000000000000 RBP: ffff9ed23fb92680 R08: ffff9ed27c8c0000 R09: ffff9ed23fb927d8 R10: 0000000000000000 R11: fefefefefefefeff R12: ffff9ed27bc79800 R13: ffff9ed2787a0000 R14: ffff9ed27bdf3400 R15: ffff9ed23fb927a0 FS: 0000000000000000(0000) GS:ffff9ed27c8c0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f6b14cf9341 CR3: 0000000069058000 CR4: 00000000000006e0 Call Trace: ? vp_notify+0x12/0x20 scsi_queue_rq+0x525/0xa30 blk_mq_dispatch_rq_list+0x8d/0x580 ? syscall_return_via_sysret+0x10/0x7f ? elv_rb_del+0x1f/0x30 ? deadline_remove_request+0x55/0xc0 blk_mq_do_dispatch_sched+0x76/0x110 blk_mq_sched_dispatch_requests+0xf9/0x170 __blk_mq_run_hw_queue+0x51/0xd0 process_one_work+0x195/0x380 worker_thread+0x30/0x390 ? process_one_work+0x380/0x380 kthread+0x113/0x130 ? kthread_park+0x90/0x90 ret_from_fork+0x35/0x40 Modules linked in: alloc(O+) ---[ end trace dc92ddeb2e6d1fe5 ]--- The logical_block_size of the LVM is the max value of the sub disks, it maybe different with one of the sub disk. when WRITE SAME on the disk, it will BUG_ON when setup WRITE SAME cmd. Close WRITE_SAME feature on the LVM if it was stacked by different logical_block_size disk. Signed-off-by: ZhangXiaoxu --- block/blk-settings.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 3e7038e..672cd27 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -497,8 +497,6 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors); t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors); t->max_dev_sectors = min_not_zero(t->max_dev_sectors, b->max_dev_sectors); - t->max_write_same_sectors = min(t->max_write_same_sectors, - b->max_write_same_sectors); t->max_write_zeroes_sectors = min(t->max_write_zeroes_sectors, b->max_write_zeroes_sectors); t->bounce_pfn = min_not_zero(t->bounce_pfn, b->bounce_pfn); @@ -537,6 +535,18 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, } } + /* If the lbs is different, disable WRITE SAME. + The default value of max_write_same_sectors is UINT_MAX, and + default value of logical_block_size is 512, do not apply this + rule when first iteration. + */ + if (t->logical_block_size != b->logical_block_size && + t->max_write_same_sectors != UINT_MAX) + t->max_write_same_sectors = 0; + else + t->max_write_same_sectors = min(t->max_write_same_sectors, + b->max_write_same_sectors); + t->logical_block_size = max(t->logical_block_size, b->logical_block_size);