From patchwork Thu Jul 20 09:29:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinyoung Choi X-Patchwork-Id: 13320235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 643D8C04FE1 for ; Thu, 20 Jul 2023 09:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbjGTJoS (ORCPT ); Thu, 20 Jul 2023 05:44:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjGTJnz (ORCPT ); Thu, 20 Jul 2023 05:43:55 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6322B2D55 for ; Thu, 20 Jul 2023 02:40:16 -0700 (PDT) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230720092959epoutp02dbfee0b8db6df7601a1891fc80dc5e5c~ziW-9PGWc0664706647epoutp02M for ; Thu, 20 Jul 2023 09:29:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230720092959epoutp02dbfee0b8db6df7601a1891fc80dc5e5c~ziW-9PGWc0664706647epoutp02M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1689845399; bh=nGeZCbqTKt9GUpDssg640prX0TVeJcRGPnCQlXxuDF8=; h=Subject:Reply-To:From:To:CC:Date:References:From; b=U8XincyAfZcUCI+XG+PFDNayJLbUCum0RTEa2mov4A6em9Cc9isnWCZNAnP7wMbQD tilFVJ/29kSiysiwIJgEWHSLZmIJHT7LLU0+D4N1YWVsUUlPGcVanLJm//sCg1gLsG iAo2+g8VBL0HEmmHP+06It8LAbD3m4H0q5Jv8sLw= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230720092958epcas2p337adc17ec76a86125b70561a74631592~ziW-Q5fAI3131731317epcas2p3s; Thu, 20 Jul 2023 09:29:58 +0000 (GMT) Received: from epsmgec2p1.samsung.com (unknown [182.195.36.99]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4R66pt01VKz4x9Px; Thu, 20 Jul 2023 09:29:58 +0000 (GMT) X-AuditID: b6c32a43-2f3ff7000001d7ef-00-64b8fe9563f7 Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmgec2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 14.B5.55279.59EF8B46; Thu, 20 Jul 2023 18:29:57 +0900 (KST) Mime-Version: 1.0 Subject: [PATCH v2] md/bitmap: Avoid protection error writing bitmap page with block integrity Reply-To: j-young.choi@samsung.com Sender: Jinyoung Choi From: Jinyoung Choi To: "song@kernel.org" , "linux-raid@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "pmenzel@molgen.mpg.de" X-Priority: 3 X-Content-Kind-Code: NORMAL X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20230720092957epcms2p6cbd0ecdf7f5bf0db3c04eefaf0a6644d@epcms2p6> Date: Thu, 20 Jul 2023 18:29:57 +0900 X-CMS-MailID: 20230720092957epcms2p6cbd0ecdf7f5bf0db3c04eefaf0a6644d X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-CPGSPASS: Y X-CPGSPASS: Y X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGKsWRmVeSWpSXmKPExsWy7bCmhe7UfztSDP4vNrN4eUjTord/K5vF 5V1z2Cza5+9itHg5K83i+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adYoG6UDZvve3w0pv1kpFMu7tVNLgXH+YlklluKMREMt5qLiRADA68L5CQQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230720092957epcms2p6cbd0ecdf7f5bf0db3c04eefaf0a6644d References: Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org Changing the bitmap page is also possible on the page where the DMA is being performed or scheduled in the MD. When configuring raid1 (mirror) with devices that support block integrity, the same bitmap page is sent to the device twice during the resync process, causing the following problems. (When requeue is executed, integrity is not updated) [Func 1] [Func 2] 1 A(page) + a(integrity) 2 (sq doorbell) 3 A(page) -> A-1(page) 4 A-1(page-updated) + a(integrity) A-1(page) + a-1(integrity) 5 (sq doorbell) 6 (DMA) (DMA) I/O Fail and retry N I/O Success To be Faulty Device My Test Env: Two FIPS PM1743 - nvme format /dev/nvme2n1 --force -n 1 -i 1 -p 0 -m 0 -l 1 -r - nvme format /dev/nvme3n1 --force -n 1 -i 1 -p 0 -m 0 -l 1 -r - mdadm -C /dev/md0 -l 1 -n 2 /dev/nvme2n1 /dev/nvme3n1 The following is the log when a problem occurs. The problematic device is in the faulty device state. Log: [ 135.037253] md/raid1:md0: active with 2 out of 2 mirrors [ 135.038228] md0: detected capacity change from 0 to 7501212288 [ 135.038270] md: resync of RAID array md0 [ 151.252172] nvme2n1: I/O Cmd(0x1) @ LBA 16, 8 blocks, I/O Error (sct 0x2 / sc 0x82) MORE [ 151.252180] protection error, dev nvme2n1, sector 16 op 0x1:(WRITE) flags 0x10800 phys_seg 1 prio class 2 [ 151.252185] md: super_written gets error=-84 [ 151.252187] md/raid1:md0: Disk failure on nvme2n1, disabling device. md/raid1:md0: Operation continuing on 1 devices. [ 151.267450] nvme3n1: I/O Cmd(0x1) @ LBA 16, 8 blocks, I/O Error (sct 0x2 / sc 0x82) MORE [ 151.267457] protection error, dev nvme3n1, sector 16 op 0x1:(WRITE) flags 0x10800 phys_seg 1 prio class 2 [ 151.267460] md: super_written gets error=-84 [ 151.268458] md: md0: resync interrupted. [ 151.320765] md: resync of RAID array md0 [ 151.321205] md: md0: resync done. Signed-off-by: Jinyoung Choi --- drivers/md/md-bitmap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 1ff712889a3b..dfb7418ba48a 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -467,6 +467,13 @@ void md_bitmap_update_sb(struct bitmap *bitmap) return; if (!bitmap->storage.sb_page) /* no superblock */ return; + + /* + * Before modifying the bitmap page and re-issue it, wait for + * the requests previously sent to the device to be completed. + */ + md_bitmap_wait_writes(bitmap); + sb = kmap_atomic(bitmap->storage.sb_page); sb->events = cpu_to_le64(bitmap->mddev->events); if (bitmap->mddev->events < bitmap->events_cleared)