From patchwork Wed Jan 26 21:11:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12725815 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CF903FCE for ; Wed, 26 Jan 2022 21:11:55 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20QKYe4F012687; Wed, 26 Jan 2022 21:11:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=BpLrUXu27m8TBMebgxcTEGYDfcF1R7IFdRjAS5rNhVM=; b=udmPnka/QQG/OcJDk4A3T4H6X7nkBK2OF9t7oKhyW6XE7y9eUQyDDGfOvVOvD/aG2/KT nrlC+LqK194s2XVWCeJtPw6fsy9I8QDEE3/bPzi9H4WROHbzVQ73TpCNcrzfSshSYWCk bT2EiMb9ByznIPioC1vEBM0fEwUiz/PNbx8CWk1G+gYIoqCi/arHstCmHYuWi+Xt40sR MAj/sE716gtrSK71Z7TaVGEQoCE8db/bVW1ATQmc6+vKsY+YCypXKOZO+7jDhFk1GWNr YY/Nu9sWvMRtmogHYCe0xO6OnIS5b7u56D1YUJ8MCBLcUn9qmo8+2eHnkDq2tP8R+33k VQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3dsvmjfux1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:40 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 20QL6q3U050207; Wed, 26 Jan 2022 21:11:39 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2176.outbound.protection.outlook.com [104.47.58.176]) by aserp3020.oracle.com with ESMTP id 3dtax94ua3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EviptLP0u6KwKWEDGHt7nEw8GG3r3T2HNP99/keIeuIpzqJ3P5LDtzUR4VtWcNiYt15L2fHMj7t766onlNCrOq5yzkr90XJfQuTPY57NijYaamy42SORkoH2/InjDoeyJgObk3tz8B7QHbpHIjaDryFFXhKxKLLgiN8a6fKQo+wga9Kl6f3uiPsqMu7A9tbR9vKZdV1R2DxQTpO9tRPP4OrKAyHLVCzprXp7AiD4/Oz35Mv/CCK/8Cvn8x+HpkRXaR0eFF/YkK6DTDR0deH2NYJzNNJzesBgZcA64Sv1jWslDOH7mdoMS5w28uz60u9EPYsUo+2tFj2WutQyMDjrbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BpLrUXu27m8TBMebgxcTEGYDfcF1R7IFdRjAS5rNhVM=; b=UKlPVXh8Ynwa4TaPzYta54MIp8/x6luhhJolZunAy0/Y8R5e4/vWWdw2Wr3T+LmT9i7hw7RdOL5uQbTw+Q/1bz/R9X9P7+myNQnhYZX9icSLUUtD8X5ang+oAJV6KM5HSZqljNr6ZABn4ZLASXhdulk/kRIdru8t8b+Vr8utkExywnUJlKlSfsM5fqqLQguwehYPG3YGBVKrmsIJ6eDHROFhx6Mdn38PmlyY39nr4MYuA4h0pNlbYlEOEuyOxHiiG/HXujPXDbfDyJhW0eTBiIm8hP6W20I3s6BTVVya+9mO4f6aX1J0DgN/75HplVKjNTW6hBKsASYPulxl1C8EuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BpLrUXu27m8TBMebgxcTEGYDfcF1R7IFdRjAS5rNhVM=; b=uwwd6buDH5nfrSN1O4G7SYi0QM9lsHaXz2aHtOOOPqtpkhv4vZga/toqFaeZeuuz8hj3vWa0QdOmHv89WQ1VYjk2U2WxX0jEh/ohlRWlB3dRpq3ztpQFkaz3cRqf7D3E8vwUCnI2CBfPXUkEgMNdjN5Fh9ElrXYbL+55KrnIUVs= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by DM8PR10MB5494.namprd10.prod.outlook.com (2603:10b6:8:21::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Wed, 26 Jan 2022 21:11:37 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%4]) with mapi id 15.20.4909.019; Wed, 26 Jan 2022 21:11:37 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v4 1/7] mce: fix set_mce_nospec to always unmap the whole page Date: Wed, 26 Jan 2022 14:11:10 -0700 Message-Id: <20220126211116.860012-2-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220126211116.860012-1-jane.chu@oracle.com> References: <20220126211116.860012-1-jane.chu@oracle.com> X-ClientProxiedBy: SA9PR13CA0112.namprd13.prod.outlook.com (2603:10b6:806:24::27) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6a1b297f-5f82-4266-2226-08d9e1107046 X-MS-TrafficTypeDiagnostic: DM8PR10MB5494:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IzksrH9KDtlLo0u6ruAqdZgjV9IoZZWY4eBvC1XoXebrGB05SyrKXYHcsmIoHHeN7k1OueR5IT3DckXkeAkX/2aiABojYzhRqutl+9tbGLdCp2wfnkfhQKdtlIPXxz26AxkAYssdXvLH/HOzMcPOa2FqHgxZVXdW+0DjYEeQIg19T6ieoip2W01JfBd3pLWRnNSjnI4ss0PSZ49ZHMWuojActvjwdE7Ne1XTVeonsHDxkRQ50ritP6mQGNV23dk3auUP0CPcsyaz/9ZRoC0B981H3aKP2VMx60K8uoKp+qyxjbqOBkHM2IZpH3E1BMPPY7hq8VJmJTwj85LgEVT+jFnCnA6uboob/bNPcWYDTyzn8OL3qO3VYWgRRXsP+0RXpiyAxQW9f4HHBdBt7fgi2spZfnBtxC5CrcKa71ngnBeLdSYEohDwAiNnhcyaLMzCURAj4boo+blBr09A2XoC6uCT4h650rPAAknV6LoaNc2yLIMF06YBveFtOBtWHjguji9EtdI6duJs0m9AtvfHzgUC6CAQMjisa+7jdU28dXje4AtFJH5pym37ii2XfTbcfjX+srVcYvkkPproHnoQ0Wf16dL5muKpuJ1xRZ0YghepX0YJQcn2nTQiURPdPUD4HI/O+c8gSaoJlV241tUxaGoQjMN/YfiJBBAN38fVIWBtz7APApOMXKxdfQ1NRgp8i8XHZYKX4AVP/EnKHZaZS6M/gop7mQ2GeZTePGHwG4O244jrQAY30GoZGyy4wTI68f7nyWJvXCNSfdDdydtZgA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB4429.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(66946007)(52116002)(86362001)(186003)(8676002)(6666004)(966005)(7416002)(6486002)(1076003)(8936002)(921005)(508600001)(6512007)(66476007)(2906002)(6506007)(83380400001)(2616005)(5660300002)(66556008)(36756003)(44832011)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M7Nj8XYTV0JiHpX8o+EwoFhwvN643HGRmQjUK5IsP1PBiDptEHvZoBB7fYzru3nDrbmMDZhp6k6XcCIe1lFu5FsctiOFRiEH4vVlAa7TOtzaZuI6NqRxdWnpibUN1dfXaTQkl3oEjn4aKN4s/U6I3DHPDnOW/oVjePsoI4zvTL3EdYWj+N9Lcc5XBonIXi+JDkrr1iQml0Bvj8GEC6tkfwFpl0L50dGVqxzZJE1YW5qABBwEV+M1FAchXfD9YxQ+Tza3pzez5BZ17rZ8MGotdakXv0fU8frPyh05NbvTfRj7kIc12DVahWnjl+pCk+oay8JygDnsuHTklNIIDKEdpeyUptQo1byCjbDdRDWVdSyyJsi9Go33OH+o4b/c6dx6pxbb0tU9WBYQ/FoTdBHykIoyGfDpv0N4saR7xcldCxrS3qQ2dpfQm6QIqxYU9Qpuuw4cYoXdd72VmB66Tuc5C+g61SJcIgc95u5vOsGvRUuTLjnf5KwCUFcc2+kZDhz1u5YyY+/i6bVhqgBe2ihbmtS2D9Sa/cFRz83L7gxljtIM2WmOsRMAivnMEYDuZEKYC+IxHr7XRFrnHPNKSJiBNvNtKMlXuFziDtMFQuFVQEBcJ/igy7gP5YcvZEByVoydH5ftaB/Kx0H/dkvY5TZHIo1XeMSqfvDVk0hUUc2gl7KdY+iN5KlBJeaggouHtP4NkNsV0/gb6IRVqzp2NABDoeIyXyrumJr9Xidti81HSsbITqmqq3YFk+6V7dBiHb0d0jxzaToCPc67hjAgxjAu97rO7iXGFJB1lw9uAyfbCnmCEZtKql2VzSOGHuOuMRORcPQ1CnDm9k/IExNBLmrABPhDX3v2OOmUFfg4OUSvPPCnk2q4TdG0hoV5rvp065REIDyAN5MF0yRn5yh+9noXdwfsyQJs13Y5KC7eegRhOpx8cPcsJZ64WUfIVATAS4zwfjG5Di0UkElc37gDT8osg6uVJtp7JEegj0SVO+XSLHlb9dJ6nPmnCdEpgyd4KYit7ZoDuUMtNAZOJcOhbuXqqdMJWvssOB063Gm/X1WSCQym2AfunZFa/fUJfZCianGQkiPXHLaATUVqn9QRFaWelOLN3kA+SsYi+fyVtnB9P2aHo6o7/3rSilXFd4Ve3aUhLOjexsa8EMXZJoMBOMsZkS4kcUdJhpJkyZGV3kahRmHb/LGG5GQsPqIC/Z05OAnhiirSeDxTWSyymzkEHF8huAwJiIpw8FuQWMFKR+6N0wgWtnxpkeghSGps4ZA1ptsn7y+JRKSM+K5u303YtUtWf9Ox5n17D3HPRERtko34fZOnzgJ+hpBkIh8BeYeuqiEKLXxpYnErsOVVQ9z08B4LdQJ5+bbjGtqiDqRMK87Yabwdrw1sPDAQ91IAi6jUjnvAnJNIDjKOlPLu8xKTcrhjdEjuV0HA+S0r+bEbSOUiD6Qke+wLdNiTVgcY/Au7r1Zcii1SGyE6ZTHF+aUj+cjwgwsvh1otok7stxmsPLj2qlk3p/Rvfk0n0u9HK807KfAEtFvlVSMayI6ZUWqmBlQrL8j5GZIHAA8eWO6GfG2SG9vT/SKbG9KapndP3nQbAGrAIeiU4Tu3et1P7ei0WRpfHSYen5b66DvWzciFFxL33xUCkJjAkia/AE+La/cToDDa X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a1b297f-5f82-4266-2226-08d9e1107046 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 21:11:37.0412 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: koRV2kTD23tsiF6K7AqA5uil7jWvy7H4A409tEK/Rz4N3ib0Q+W9aOgkG/ZFcaaIe/jeRpnUX9GobMiODQg6Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR10MB5494 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10239 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201260122 X-Proofpoint-GUID: I0YQgTTHhtyXx3R4tohfzZj96xKSmYgV X-Proofpoint-ORIG-GUID: I0YQgTTHhtyXx3R4tohfzZj96xKSmYgV Mark poisoned page as not present, and to reverse the 'np' effect, restate the _PAGE_PRESENT bit. Please refer to discussions here for reason behind the decision. https://lore.kernel.org/all/CAPcyv4hrXPb1tASBZUg-GgdVs0OOFKXMXLiHmktg_kFi7YBMyQ@mail.gmail.com/ Fixes: 284ce4011ba6 ("x86/memory_failure: Introduce {set, clear}_mce_nospec()") Signed-off-by: Jane Chu --- arch/x86/include/asm/set_memory.h | 17 +++++------------ arch/x86/kernel/cpu/mce/core.c | 6 +++--- arch/x86/mm/pat/set_memory.c | 8 +++++++- include/linux/set_memory.h | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h index ff0f2d90338a..aef6677da291 100644 --- a/arch/x86/include/asm/set_memory.h +++ b/arch/x86/include/asm/set_memory.h @@ -50,6 +50,7 @@ int set_memory_decrypted(unsigned long addr, int numpages); int set_memory_np_noalias(unsigned long addr, int numpages); int set_memory_nonglobal(unsigned long addr, int numpages); int set_memory_global(unsigned long addr, int numpages); +int _set_memory_present(unsigned long addr, int numpages); int set_pages_array_uc(struct page **pages, int addrinarray); int set_pages_array_wc(struct page **pages, int addrinarray); @@ -89,13 +90,8 @@ void notify_range_enc_status_changed(unsigned long vaddr, int npages, bool enc); extern int kernel_set_to_readonly; #ifdef CONFIG_X86_64 -/* - * Prevent speculative access to the page by either unmapping - * it (if we do not require access to any part of the page) or - * marking it uncacheable (if we want to try to retrieve data - * from non-poisoned lines in the page). - */ -static inline int set_mce_nospec(unsigned long pfn, bool unmap) +/* Prevent speculative access to a page by marking it not-present */ +static inline int set_mce_nospec(unsigned long pfn) { unsigned long decoy_addr; int rc; @@ -117,10 +113,7 @@ static inline int set_mce_nospec(unsigned long pfn, bool unmap) */ decoy_addr = (pfn << PAGE_SHIFT) + (PAGE_OFFSET ^ BIT(63)); - if (unmap) - rc = set_memory_np(decoy_addr, 1); - else - rc = set_memory_uc(decoy_addr, 1); + rc = set_memory_np(decoy_addr, 1); if (rc) pr_warn("Could not invalidate pfn=0x%lx from 1:1 map\n", pfn); return rc; @@ -130,7 +123,7 @@ static inline int set_mce_nospec(unsigned long pfn, bool unmap) /* Restore full speculative operation to the pfn. */ static inline int clear_mce_nospec(unsigned long pfn) { - return set_memory_wb((unsigned long) pfn_to_kaddr(pfn), 1); + return _set_memory_present((unsigned long) pfn_to_kaddr(pfn), 1); } #define clear_mce_nospec clear_mce_nospec #else diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 5818b837fd4d..8d12739f283d 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -613,7 +613,7 @@ static int uc_decode_notifier(struct notifier_block *nb, unsigned long val, pfn = mce->addr >> PAGE_SHIFT; if (!memory_failure(pfn, 0)) { - set_mce_nospec(pfn, whole_page(mce)); + set_mce_nospec(pfn); mce->kflags |= MCE_HANDLED_UC; } @@ -1297,7 +1297,7 @@ static void kill_me_maybe(struct callback_head *cb) ret = memory_failure(p->mce_addr >> PAGE_SHIFT, flags); if (!ret) { - set_mce_nospec(p->mce_addr >> PAGE_SHIFT, p->mce_whole_page); + set_mce_nospec(p->mce_addr >> PAGE_SHIFT); sync_core(); return; } @@ -1321,7 +1321,7 @@ static void kill_me_never(struct callback_head *cb) p->mce_count = 0; pr_err("Kernel accessed poison in user space at %llx\n", p->mce_addr); if (!memory_failure(p->mce_addr >> PAGE_SHIFT, 0)) - set_mce_nospec(p->mce_addr >> PAGE_SHIFT, p->mce_whole_page); + set_mce_nospec(p->mce_addr >> PAGE_SHIFT); } static void queue_task_work(struct mce *m, char *msg, void (*func)(struct callback_head *)) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index b4072115c8ef..68d84c8bd977 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -1816,7 +1816,7 @@ static inline int cpa_clear_pages_array(struct page **pages, int numpages, } /* - * _set_memory_prot is an internal helper for callers that have been passed + * __set_memory_prot is an internal helper for callers that have been passed * a pgprot_t value from upper layers and a reservation has already been taken. * If you want to set the pgprot to a specific page protocol, use the * set_memory_xx() functions. @@ -1983,6 +1983,12 @@ int set_memory_global(unsigned long addr, int numpages) __pgprot(_PAGE_GLOBAL), 0); } +int _set_memory_present(unsigned long addr, int numpages) +{ + return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_PRESENT), 0); +} +EXPORT_SYMBOL_GPL(_set_memory_present); + /* * __set_memory_enc_pgtable() is used for the hypervisors that get * informed about "encryption" status via page tables. diff --git a/include/linux/set_memory.h b/include/linux/set_memory.h index f36be5166c19..9ad898d40e7e 100644 --- a/include/linux/set_memory.h +++ b/include/linux/set_memory.h @@ -43,7 +43,7 @@ static inline bool can_set_direct_map(void) #endif /* CONFIG_ARCH_HAS_SET_DIRECT_MAP */ #ifndef set_mce_nospec -static inline int set_mce_nospec(unsigned long pfn, bool unmap) +static inline int set_mce_nospec(unsigned long pfn) { return 0; } From patchwork Wed Jan 26 21:11:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12725816 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 116E03FE3 for ; Wed, 26 Jan 2022 21:11:55 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20QKYcSI012678; Wed, 26 Jan 2022 21:11:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=hLaM827GTTNxGwAx2dc3R/WTT0IBXGaIkPOthxJHxQ0=; b=uFJfdxkuJ80V1fq6F/sIv+nm/z2+kLehkVG5VpRfIxE//9NOZ5cfJWOE9EYMfBSaYZgF fsxjVvIBLwHW+VwekFyoxlUzn8+uUb0Y9LiFprQJ7e2RYzzaMxoEiExmMv2RBzgBEaoI 4iLUCxG3hCMnS9eD0UFQ1TBx/5mFAl5Nd1FXol1DDeWrftu153RKTj2RGFL3Ibs1IU8m xW+SzhPzffPdOdemZ6PbrkTkUdrrl/h+NPj886bBk2T67qz9+0Of7IJp8DPVLWCP9TSE lOyI/ElW7aieJWyyHANn1piv1QXZUfOLycJW27GEbaxLoI81UXAUwzmyfQT25XaLB52S Lw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3dsvmjfux5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:44 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 20QL6Ue5020718; Wed, 26 Jan 2022 21:11:43 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by userp3020.oracle.com with ESMTP id 3drbcrx82m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nQCNC3UwM2opuKpkn81dC6dAlE6DufCu7r3nX92pO5Sdc6huyZCfqlcWKs/Y0/0BbM10zzq0xNbomhEQ7KOxhacx+/fUjQQaKa/XhVgK2TvhrSxx/36/8fMZq0PbWNtxRQW2Ou9LI8YAvxvB7BU5K6pOHk0OS7uU+PJprf/bk0CMZuUeWZqcHm2jIolJ+qU7ZXNjY+d9ZkN1UAYWXDVS9fLc2wqhV/3PMFJ55jPxFbNdP4piXxe5v4TB3n5f38vn2BdTY+x8GUVVYYN7PA9op7KuZao8Hd1bHt/6hSU9iDTKh+vC8/rMGX23LEyWGPAa58ddtws/YL+rTv/mwc/E0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hLaM827GTTNxGwAx2dc3R/WTT0IBXGaIkPOthxJHxQ0=; b=mKdr0IFobkhEOQILObuXrbKpeuleNqKJkW85tSa7lvEHz6esMNx7ez+LiWkPFshr1gSMAI2BEpGkoafRnGh94ek8boGpjphBsh8y8diZHtEy2HYCFnud1iMQkxB7Ib5K9tKu2GQlwc2CFRByROlY/CeOlNrgBkxpS6bS1GQIbh6CM+TMfP6IZvdf+215yqZYzuhx6m7CQdSPOke5aHrZAF568EFpHZgtlMb8xwLQfunboX9Nv/Daz+Z9nw5GxS7raU9YdVPLE81HKPuUU8vqx0QXB3phULZKtYZP4ChQ0hggshF4gWaPBzzcxljbh44wX2Bdf31M9xEUN9SMh8SJOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hLaM827GTTNxGwAx2dc3R/WTT0IBXGaIkPOthxJHxQ0=; b=c3ksnw/bSq0arR0KEb+nsnKXRnVI2WGMS7JWBQs+Kdnfnj1XFf5UHN+EjSc1XPWVjVSYlLmz4rldtamqu4AtNKe2RuEKf/d5ykBZJcFBbrYMglYGjzbGw/3fatfwOlgwnx/4D0VoIYcCQaNWzAelxVHdcbVyhcSfl2yXU2zhzt4= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by DM8PR10MB5494.namprd10.prod.outlook.com (2603:10b6:8:21::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Wed, 26 Jan 2022 21:11:40 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%4]) with mapi id 15.20.4909.019; Wed, 26 Jan 2022 21:11:40 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v4 2/7] dax: introduce dax device flag DAXDEV_RECOVERY Date: Wed, 26 Jan 2022 14:11:11 -0700 Message-Id: <20220126211116.860012-3-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220126211116.860012-1-jane.chu@oracle.com> References: <20220126211116.860012-1-jane.chu@oracle.com> X-ClientProxiedBy: SA9PR13CA0112.namprd13.prod.outlook.com (2603:10b6:806:24::27) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b17c1e7-c810-4cff-a655-08d9e110726a X-MS-TrafficTypeDiagnostic: DM8PR10MB5494:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8iRqKCRsR6KTldW4/RLjdZCOyL+ri1yx9ZuCGTPgBzbGRNZZHl8HzmpOWc8E8tadCN4P9ilT9tcAjIP2MdsQSnld3nzrYPJzh4jCa1dK7jVr6aAsnZA2dLrnoFAJqtMQP4urbu0imil91wze+S68A6QWpmChQYFwYZunvk/mQi4waFnLz1hwkm5iqVtbXmQ0qckpfXPwJpnRX1c8bvB2+Df+RdY/BtqMpV7Ju2k2oFoW3wsAAv3kLbxroqBiWVzCuVHyaD0G56Cxg8yqJHPi1fpIruMNALJsse0xSseHCVzA4SMhdDcN0IDEXGyV7mGtA8aYeYFPmKZe0BT5HzevbLDBjijMUlVxflLO448t1QtPe2zbRfcv7DVutApHjhI04M9h3xtiSSToCXuKLzIaXkcrE0r727bBuJULhid8Fx56h5+Rf1G0L3mABIB1MI8GYqZ7D0J+H3AfExP2YDvZeaEtkKFycL0ldO5TzVAupamG5D06n/NhKhAe7wiPvNJR77qm6TFMQ6LcIohoexBzwRLHKBsogVaYJENKEdEY+sBB/Ex65SHW2u6b7t9xovxPYTPKANvFVMmSMxl131JyL4q7P5hVNrN7rCEmwFCY7cO4euvrQQWWnatVB14dIyM2nLBE18tdYZiFM0ak5jCiP0XCklZtciLZC2Ih5rluFiq3ENCHOU/sWHy63hc5jGsk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB4429.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(66946007)(52116002)(86362001)(186003)(8676002)(6666004)(7416002)(6486002)(1076003)(8936002)(921005)(508600001)(6512007)(66476007)(2906002)(6506007)(83380400001)(2616005)(5660300002)(66556008)(36756003)(44832011)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hLH8/cBwAlhBTcGUFXV7YiS5k2/Ieqh8JU1oK7uxkbiOAs0dwzfDz/SGk48mJkStB+9RPR75Dozl3CXUYtvxCev/1Pq7foDQG+i3VXgGWxTmV3nExUjbCV/rJIBWs8NnolppWZmvJTqQiDk8Gw3MGIZMn7oJlATB3xQ4ak63rsnCNVZcBCJpH8n2kq0KpIhYONkakwFG7PqGEAQ5phAqyREEvts+g4sVPzNQe2gOdKq6DoL+d/BvSJVXdKjr8+wY4zZOHdyJHFJAZe9HMrXi7TPRyC3g15vEP2LhHxElOrNO+hBahsaNF4JHuUPiNUYCN5vIkMp1SAZ15nX29EYHMDfYnj00aMfH7cWIw49Cyh2jCEXeN8/Y/JDv/2aHrUXvmrc/ses5I9hpPaIM/Q3uwJ508OYE7o/2OUeLplQfQQveGnXpXOlAsn/OW2dt3JHhd0P9lFAmKosyVWXfPi3LJ03z6/9qPf787H1eAI2wIQPJOPLglL8WfOgTz+CKM6NoNWKobvsSiSHV1CKsCogDyma/TcQvxTl80WLuF2RiCRvDp8p/b2Tvl0tQaHvAAS0S4r3/ETvdtGJpC4L7oOf/6Zd4Uhq/21Do44k8Hl+M0mChIN3f3B3vumY85O0nvDNYsCxEzkwNJNzCIh0wFZ/m4EQ9BTHHI14zC/62xi9ejeQGMeFocnuDTdKm07nC4WGN5td7aQNELSnBCE+4JGpxPi0uLj+bOPWmdObu+SyUEvgmecfiYXMhIuUL8ppRshPLbdwvVtE6g+LfiYCcE7T/h3pjKG0NdpCCbzcjlvN7ocMbFg4Tvf/8Bxps09lTbMIMyx/0p+PFgRhoD8sXcYt+Byu6ojTTN0jEsUYEGpO8bDYpmGAyZ2Pb73C/C1WYaMvhHtKf7M7qV4A6/m1ZiT/5bgafBMuGDUO7twVsRTr7A7iaeHEoC0PjeukwfXDI6qGPgO/LsJAj28DXSHjQdVzeCdu1G7avlW6ArQPB8ltu1VUOP4kPDYgLiXe1OozhqkzkAI+qhH/3GNr436zXxIK93KsOb8LfkAnlHGlpklV/ktD9rzLGRBF6n5l6hM5gzqG1sLuziRfgy6FdfFE8zKN6spXfR0VapZTKJa8WOKPqSQZUBPiT2s0l9p9RF3oNdHbzKS309xjrrwWJT2c6pNS5sI0fBzz5DBXFWWYCY+Xobu5oUDvHqaZBD3He6HfU7e2ZPLlAt7+Sm4UIkls2snIhVze/VB0KnKmQgKeZKHDD6D4U3skw1ydDI5wAnwSvce5a74ofnffWQblO72LupimGfgY2gD3Y1xnVh6Guubf/ZNx14FSqa4njVoSDAsaMnd2yMqVadJlsUwA+KlC5a4kucICptEW/0oHEhu5RV8f3OtP0PE2Uxo/RDs6qvm3+q/0v0w9b7OzLmCtxWkTdT+cPiLGikek+lWqWbH9pS9WOyGof2EafxO7aglSlfDqFCMDJZOo8SXLI1RZR0YI4cFaFAlrlU4d6PcZgRli5/XTASbq2/dHOiMhjJhbSJiIyVEk60Yf5b+EJEViyDduf80RhngkPRX7iBTT/mIS7ekwiiUdRJV8rwKNbPsmAm2Ene7S++l4/Pm2gRilzOKwxkZJBMu8tLeD4taNwi5zUZ28lcNBIT49PHaHqmSZDsi4lg4Ac X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b17c1e7-c810-4cff-a655-08d9e110726a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 21:11:40.6203 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qvlNmQ64RxRCUzCPiwBPfStL44xNXhX3pQts/X/vm5G3pIXjkWky7xDs1gYYdpxlOEGCYAG/ZWc1OMmIEodjEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR10MB5494 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10239 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201260122 X-Proofpoint-GUID: W1FyW1TOqGE73TG2ekhmDeOX9a5ByR_K X-Proofpoint-ORIG-GUID: W1FyW1TOqGE73TG2ekhmDeOX9a5ByR_K Introduce dax device flag DAXDEV_RECOVERY to indicate a device that is capable of recoverying from media poison. For MD raid DAX devices, the capability is allowed for partial device as oppose to the entire device. And the final poison detection and repair rely on the provisioning base drivers. Signed-off-by: Jane Chu --- drivers/dax/super.c | 24 ++++++++++++++++++++++++ drivers/nvdimm/pmem.c | 1 + include/linux/dax.h | 15 +++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index e3029389d809..f4f607d9698b 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -109,6 +109,8 @@ enum dax_device_flags { DAXDEV_NOCACHE, /* handle CPU fetch exceptions during reads */ DAXDEV_NOMC, + /* flag to indicate device capable of poison recovery */ + DAXDEV_RECOVERY, }; /** @@ -311,6 +313,28 @@ static void dax_destroy_inode(struct inode *inode) "kill_dax() must be called before final iput()\n"); } +void set_dax_recovery(struct dax_device *dax_dev) +{ + set_bit(DAXDEV_RECOVERY, &dax_dev->flags); +} +EXPORT_SYMBOL_GPL(set_dax_recovery); + +bool dax_recovery_capable(struct dax_device *dax_dev) +{ + return test_bit(DAXDEV_RECOVERY, &dax_dev->flags); +} +EXPORT_SYMBOL_GPL(dax_recovery_capable); + +int dax_prep_recovery(struct dax_device *dax_dev, void **kaddr) +{ + if (dax_recovery_capable(dax_dev)) { + set_bit(DAXDEV_RECOVERY, (unsigned long *)kaddr); + return 0; + } + return -EINVAL; +} +EXPORT_SYMBOL_GPL(dax_prep_recovery); + static const struct super_operations dax_sops = { .statfs = simple_statfs, .alloc_inode = dax_alloc_inode, diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 58d95242a836..e8823813a8df 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -487,6 +487,7 @@ static int pmem_attach_disk(struct device *dev, if (rc) goto out_cleanup_dax; dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); + set_dax_recovery(dax_dev); pmem->dax_dev = dax_dev; rc = device_add_disk(dev, disk, pmem_attribute_groups); diff --git a/include/linux/dax.h b/include/linux/dax.h index 9fc5f99a0ae2..5449a0a81c83 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -40,6 +40,8 @@ void dax_write_cache(struct dax_device *dax_dev, bool wc); bool dax_write_cache_enabled(struct dax_device *dax_dev); bool dax_synchronous(struct dax_device *dax_dev); void set_dax_synchronous(struct dax_device *dax_dev); +void set_dax_recovery(struct dax_device *dax_dev); +bool dax_recovery_capable(struct dax_device *dax_dev); /* * Check if given mapping is supported by the file / underlying device. */ @@ -87,6 +89,13 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma, { return !(vma->vm_flags & VM_SYNC); } +static inline void set_dax_recovery(struct dax_device *dax_dev); +{ +} +static inline bool dax_recovery_capable(struct dax_device *dax_dev) +{ + return false; +} #endif void set_dax_nocache(struct dax_device *dax_dev); @@ -128,6 +137,7 @@ struct page *dax_layout_busy_page(struct address_space *mapping); struct page *dax_layout_busy_page_range(struct address_space *mapping, loff_t start, loff_t end); dax_entry_t dax_lock_page(struct page *page); void dax_unlock_page(struct page *page, dax_entry_t cookie); +int dax_prep_recovery(struct dax_device *dax_dev, void **kaddr); #else static inline struct page *dax_layout_busy_page(struct address_space *mapping) { @@ -155,6 +165,11 @@ static inline dax_entry_t dax_lock_page(struct page *page) static inline void dax_unlock_page(struct page *page, dax_entry_t cookie) { } + +static inline int dax_prep_recovery(struct dax_device *dax_dev, void **kaddr) +{ + return -EINVAL; +} #endif int dax_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero, From patchwork Wed Jan 26 21:11:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12725814 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D2373FE1 for ; Wed, 26 Jan 2022 21:11:55 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20QKYohX016830; Wed, 26 Jan 2022 21:11:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=HACBNB6Dlbd22EoArX9+ZdfgySBwzu2+nWVxtO7kBp8=; b=MAH5MqsYDic8uLdLHCY1b3OBfmO4bMzuJ7zoMbegubb0hGeEuCnNp19BUIHoFAhv98sZ 2h6lGE6Z+p7DCZe6AFs56Hf0X4vsNKEW/2H0M6ZPdpEELg1EBeSAVw43WToQPvtsnW+Z 0NdfR/T/9G1ZT78GtRAnjThV3p6pldWzo3ffXny/yusziKDYiA51EJNhYj+0k19k1Dp2 uMoe5fLYQwqRaT8fp920fFej+jRX7uWLjZ/Egj57JAxrQpBnV99P6GiM89LK9EhmKvJp QOuk8gsVlUlZeThrYKlp6xvBZLSS2SrDQy7g3u6V9Bs0WkDRO+rJRirv75X4xDZxwiH1 /g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3dsy9s77su-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:47 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 20QL6Ue9020718; Wed, 26 Jan 2022 21:11:46 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by userp3020.oracle.com with ESMTP id 3drbcrx866-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jIOn0s96CyEcacouOftluGugM7r+Y3rVt9GkVAOhIIgnDWPR0Y/rQr5LjdUhRFIOaVy0NlpXw1UHgzf7GppsoLRC6/MwQ1T6WQIff/l4WLp1nIkd3k0rxUp8xBlWkssyVKH5zbiS5jHSULXFxruAd5H7U6yqebFw9adOHhotjcF4brzBfw6E+agV91z/ZWYgKOn+irugthEIC/p11pfRUQ6I6Nrk5ydjgt4ENx56nVvCmq6J0aZ3gYCv4O9cNGj49lrlidnTw2thTZQvWsHcEANw8dmVQRSKuKd2TCs9Tb17d7KCqOGLM/bP5qK0rr0BufmQxYrN0Isq5oflukrrwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HACBNB6Dlbd22EoArX9+ZdfgySBwzu2+nWVxtO7kBp8=; b=SpdwPcQ88WKvsiW6IWHnWbJHZIAjO3UQ9EGYIAmKndtM0fZE1OaLhCLC/GLS1nxOSIpurlmOcV1uIqMVeMflcBzlfhGja9eua7glBjWZWw1GOVo30nhldNcHQ8o5IZGqo/e1YHFsWyrbYMn9x7urPURY1mBQqlIPToRdvYMGl/9skayFZbRu3qeVIi2wppGA1grLhiox6wZoCeAmFo+UBq+u9i0hN0m8gJFwM59l63OTqjkdW8AVHYG3WLqU8ftV7IF/h8mTf3I0CQU5+jtQEhxODEM2nd1qGcJjqaP9rz5IBi1q4LaxbDNz++0JHCIduZft013zv2bc9BnDKZbJzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HACBNB6Dlbd22EoArX9+ZdfgySBwzu2+nWVxtO7kBp8=; b=HkfRDgNU6LDw5cykL6TNUxOKbjwRhNW0iyQvmQnfuDsmvvYfkkyJbKj1LwWWHo73CMLlDDdkaHhz/597zEX1jhBJvZbPswFv+owmiEsbZN9EO1hvyx1Vxc9mYfaApoeDzgoa7vtD19u93rEQuv9pQPBUfTtB48ymZqPu1TYi7Os= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by DM8PR10MB5494.namprd10.prod.outlook.com (2603:10b6:8:21::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Wed, 26 Jan 2022 21:11:43 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%4]) with mapi id 15.20.4909.019; Wed, 26 Jan 2022 21:11:43 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v4 3/7] dm: make dm aware of target's DAXDEV_RECOVERY capability Date: Wed, 26 Jan 2022 14:11:12 -0700 Message-Id: <20220126211116.860012-4-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220126211116.860012-1-jane.chu@oracle.com> References: <20220126211116.860012-1-jane.chu@oracle.com> X-ClientProxiedBy: SA9PR13CA0112.namprd13.prod.outlook.com (2603:10b6:806:24::27) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b9654b01-5e64-4be3-8a6d-08d9e110743b X-MS-TrafficTypeDiagnostic: DM8PR10MB5494:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /7u2fgOv1cQvtFOAc6HvFJ0dR4eZ1ubczcLWLyvILeLj30bsdR3tfiDKP48hygVXcfQYO/UpoZgG8qUDMTIOszFmSbocWaIWFwl6gGmm7EzdcCIMKiTq5tn9mMiZwlD/Wi2vBRJkR2OYW6/w0G+dc5J2oJ7qoIBUcuNKYzvnz7AvCiSpQTjdBkz6uts5kCbbwtzNM9mpn/nCmY4Bzh3J64vatJT6T8AJoPNJ7LBpCSJSjVpqUZpGrbN2SLAuaCusn/yPhs17Pf7ribB2bymNzayHASU7fErHqQp/tmQxtl5BMfxWVTgDqbBFGdicFuGW8xfs7ubFQK6l2xEMqLwhdBunUrq+IFO/JfYr/TgollWT9j2x7JUJ6AMrHu6uBl9LRZx/Wbr/xO7hf7XCY5+34DZASmOy30OyCskOFACIgipiKty2k6wlblqLmu6D9+ChxH8TCPfCjCimoqDMC3XaK4tEQ2qLS8on2xLD/oHuzgqtvfMKYmuHfhYR4M9dMIsKUdjckdKPvlP9ZiMoxnR5uIuBX0p8rFWxJVfvnxzdgWuuCxfNVbTL7nffKimF0m/MpICHnTXjtChRHCVe/pwBw24QEMSCdysuxwGF2h15N4b4n5OEMpgV/9Sz9hnzFL2KnhJNf8EyTvP468YCn/Jn+XpNmcafJZXb7YxR5k2xtFml0158/AU8/vYR/mOOVfDa X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB4429.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(66946007)(52116002)(86362001)(186003)(8676002)(6666004)(7416002)(6486002)(1076003)(8936002)(921005)(508600001)(6512007)(66476007)(2906002)(6506007)(83380400001)(2616005)(5660300002)(66556008)(36756003)(44832011)(316002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kiMUGc1gJAUG7UuqQvNVUZCiT/0DH4w8QiRT71EW93ofFogfYhugOu/ppMXA1uypfQF2pH0WrNsm4GaRzlJA6wAQdWnPX6Du7t2UiuZWydYehkLaMgWy6ZvmfY7fWdGvLx8kGit6jcQ3yn77Kp7Y961774byFWxta+Khb5xpFkSiDGFiGIky3n5QiuqEkJGc/p+1znKfWjCgbJCOVW6AkCeb0RI4ra5PFg9rOHX4KqLMpBbusI0Uz/1pakYm6rVZn9nzEPm6Qxo1lojLYc091JaI2ZhQRsMLyaC5O4JwbfUZUURRpIW672ENMQObqhWZnDuSXegVxq3xZigaKnMcguOUsc0vaOq43DwQa9aQMO513J13sKGu6PI7/eGb/GFpU48U5lr2FpFsZyHWSMVe2R+BydWZ4hDGaKc1C2JeGYbvIZEjraWLq+b7Ff/NLhQcHsy4kBhJHxUtyHXrits68gSmmg6ez6BxBKUkEi7m0tVe3FYtUr/6tfc7EF2vEIM+07u1CNueAZEksi60aB5I5XVgJuJv4iaM9HrjXig5lb6tQgmgyJyL3onNmXGe1ejuGBaiwal/0k+a6qIc1xyt+T/rkes1IwkUcuTpOsbOfzIv9N3u2WensOxbIfQ7Jmq/wpaOUHmNsKRaQqJMxBcX1nKnFAKkTCuWaMnNuiJAK4rpS7fg7Hr+2+pjzigH/8TCctKvT8SCkJnDPDHon9fK6A2STuhEaZaRdTvYQFkJOOgsnExdPAVrHSSFl+Hstnfn+Ly3bsI54+KGJEigIQIr+PumhHGCE/8uwCynJj0NCgGZdgw4086jeWnXa93HOQoN9cpK3dL35vdh6nNI/0twWywJ37Xy5gA5hrLunbTrGeJ172YZM2qTxqTi7oE6lxLss9C+kpG902U6UhMrXEuoPVv2zeLL9t9Haa6nV7A+Vxrl3zvIwOjrYvC775jmkGjqKwwD0O4c7aFgSwlLk5WN9oDsNYIIIOvLh54glGckhy6SC5RZLubRvYYzHiWxvOgSYcnbF3UswuhvrkHZqxnuV+VLLVXNv7koJrqpJlb0DNipo2d1aZShtrhInv/sk4OlcQYTsVWSC8PRQfo1ya2SEzc1gbGJke0EHpJzFt2B/QLqSJI2dP1TZdc9u8wbRj42Jq9cQOBxh2gukJ1ypgeblKvMl3JJkxiZt0Hj+gFBzx+1BOOC+7q6jlGSDdUXpclROlh9KeIlmYYGU1g1zdbytsYj5IKwpAXwWfSB8Eigs9Xktw+gie8ERJTg6sgGlnCecKPUF94H0V39JdJzJ3/vyjmo2llz1q7fQalf3PXFdfRqjH7LqiPDg5eGCgRisQMzG6ZVmUjnELTbw5ClXOnlIqMVdZPsRwT8L9z1iiv4HfzBRxCjRA3mpUMbBzTCYdkYb3wbh+2ggre8/pBHQiItYLXe1uZnT7QFSwBhCSgLN6YSYUnEpG+bVYaY6edY2tmMFZK8mhFjRZw2WH6JQR70jCjiiSrGu9e/g27JC0lWTFmNwJVs+PReoP1BOUkBxD2Y/MUwkinjeAoGIXV6FE8JnRzKrnaD+GFmw6ldTtbgA1UaH3mF44grqU6iquY+IWmcju1fxors6PdWzP9oDBnr0wre7espXb399Q0irtqIgRtbjejnzUCEgYl5kYG8av4b X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9654b01-5e64-4be3-8a6d-08d9e110743b X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 21:11:43.6983 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5hvojK836zXGyQAPtezFli5M3b2hIH3YppIAEVg6THJVtvlZGWNT5+8F6sHIPmLp27SezcF5z9Xu1Icwe8D1Hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR10MB5494 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10239 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 malwarescore=0 spamscore=0 phishscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201260122 X-Proofpoint-GUID: Lzl3h92bUsjBcfqz76wYdVNlh0HHa5Ii X-Proofpoint-ORIG-GUID: Lzl3h92bUsjBcfqz76wYdVNlh0HHa5Ii If one of the MD raid participating target dax device supports DAXDEV_RECOVERY, then it'll be declared on the whole that the MD device is capable of DAXDEV_RECOVERY. And only when the recovery process reaches to the target driver, it becomes deterministic whether a certain dax address range maybe recovered, or not. Signed-off-by: Jane Chu --- drivers/md/dm-table.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index e43096cfe9e2..8af8a81b6172 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -844,6 +844,36 @@ static bool dm_table_supports_dax(struct dm_table *t, return true; } +/* Check whether device is capable of dax poison recovery */ +static int device_poison_recovery_capable(struct dm_target *ti, + struct dm_dev *dev, sector_t start, sector_t len, void *data) +{ + if (!dev->dax_dev) + return false; + return dax_recovery_capable(dev->dax_dev); +} + +static bool dm_table_supports_poison_recovery(struct dm_table *t, + iterate_devices_callout_fn func) +{ + struct dm_target *ti; + unsigned int i; + + /* Check if any DAX target supports poison recovery */ + for (i = 0; i < dm_table_get_num_targets(t); i++) { + ti = dm_table_get_target(t, i); + + if (!ti->type->direct_access) + return false; + + if (ti->type->iterate_devices && + ti->type->iterate_devices(ti, func, NULL)) + return true; + } + + return false; +} + static int device_is_rq_stackable(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { @@ -2014,6 +2044,9 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, blk_queue_flag_set(QUEUE_FLAG_DAX, q); if (dm_table_supports_dax(t, device_not_dax_synchronous_capable)) set_dax_synchronous(t->md->dax_dev); + if (dm_table_supports_poison_recovery(t, + device_poison_recovery_capable)) + set_dax_recovery(t->md->dax_dev); } else blk_queue_flag_clear(QUEUE_FLAG_DAX, q); From patchwork Wed Jan 26 21:11:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12725818 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCEEE3FE4 for ; Wed, 26 Jan 2022 21:11:56 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20QKZLjN022453; Wed, 26 Jan 2022 21:11:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=jojUtbcLCG50ylx9yqExazUQrPPzxIhDmCE2ac6VeZQ=; b=JAzgOvznb0xYd8J5wcGfozN3WmcLRBPTQA7LtvMrVTGx5w5uLeNKOOwnULJ1F4v22q5/ Nf6n9Q1mETEYN+XcVWBQTXZ5nTUTN8VnTf+4Ed1VZNY5Mq9yjTwCmo8PFnhD3wORFuUh chQfgCkxFl8nRP4tFI88EScADqQPZHVt0AtrTrjayScLRuQHwWKSXoNeXmAw9qGXFKEA qJguiAaKKa4h6p9hcGz8Azbm868Guk4Tjo3Iwz8vyYVviV31aLymrkzVqIRSyJtMZjdJ IwTdx3LiM3/wu0GG8bkaFoTxxlp6uHtvmiFK9+DknbSZ5Bf6hjwM9N23eHlqda3PQAhI IA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3dsxvfq3up-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:51 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 20QL72LM016259; Wed, 26 Jan 2022 21:11:50 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by userp3030.oracle.com with ESMTP id 3dr7220axh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RxF+KZo7rFsZk/L2+NgJVKF64bFIhxSpTjA1xsb/Iyn6PcBhxUQhMV3/4Wkhgpay2vXhjTiUoW1nLhEVlG5s1MR48u8tdgOn1J5I/iBV2YeLIWX6P7q/H2kDZOzxOgDzW76PDDuJpxF5cx9kOE8jJDGtVPFd29W2mC1GR3GoD26XmXUidOmWK8/8unFabop71ZXOj7naMvn9nAxOI9cPAT5SS5nTIZ1n0I5xx3fkZeY58Te9nLVTXJCsZ2E43OjAr6ArFLhqx5ln1pdCDW/bWycwNcfyrW5fofLdS+sNj5OaKK6CUcznm3BpxkGM34gHd69TlXVJySJ08Uzo5+SZdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jojUtbcLCG50ylx9yqExazUQrPPzxIhDmCE2ac6VeZQ=; b=BlQYCTIZmNxmVSv35hxbjAtd4P7Yp7AjJZFcOoQ7LTRVzkCTG9tanugprMNoQZ+u4X4jAJtwMVTzmx2mF8tCFV6VsRVn8Br+2W4rMc5R12t5iXW71DrkNR3xeQ8sAus/qhZdQXIxFEv4W2xQL3DmUsfx3sBn7e2PYxO7yS7ePHzg8yqtTDsJitIx/zfhe9DUpiMRDYbq9jurXWuRyxHMc0aktYH5KrUmkUoQG7c6fiExMaGC3ZJrIZoX40Z/0YWdG0TlWDS+bAuK8jo6J2YjpSgnI2LKk4NeMHtyLEa05LVHCiD1cKDodL5cg/oKHCqJnjb+72FtNq8Qp5y0RdAQZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jojUtbcLCG50ylx9yqExazUQrPPzxIhDmCE2ac6VeZQ=; b=wQkHa8BVou91jk4FmBYcXayYCuUzGPjodG4fQnEEPR+sdZOVGGZ5PMVWYcE19NHAnVj389zeDJvVNG9ZVynME7i4O4Ki9ExQnaoRSQnhTKyi+nK5PtCMJt/AfRC0clyMbf7iD8M/R+wxR5JXjKV0DF+Zg5pQ7TtNjY/RLJFkQB8= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BL0PR10MB3044.namprd10.prod.outlook.com (2603:10b6:208:33::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Wed, 26 Jan 2022 21:11:46 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%4]) with mapi id 15.20.4909.019; Wed, 26 Jan 2022 21:11:46 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v4 4/7] dax: add dax_recovery_write to dax_op and dm target type Date: Wed, 26 Jan 2022 14:11:13 -0700 Message-Id: <20220126211116.860012-5-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220126211116.860012-1-jane.chu@oracle.com> References: <20220126211116.860012-1-jane.chu@oracle.com> X-ClientProxiedBy: SA9PR13CA0112.namprd13.prod.outlook.com (2603:10b6:806:24::27) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b14d8967-6e38-4e7a-1ea4-08d9e110760f X-MS-TrafficTypeDiagnostic: BL0PR10MB3044:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:632; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cP2zX8XRKVq9YpqYL1SpYh6wrMMm8jD4XBEDqsTGs7r6ZtVh1t4CFGOV9/v5SeMy1dEPWPik+6x14/c2ufq6Yy3veXSED1LggavqxZA4fz7LnMV1E2RtCDibHkaDLvkKHmZCbBN7Hdr6HuTGxpNvuB42+xhGuB9rbdvq3WFZ4jZZdagvBGpjSmWIlW34w5hbZUga7A5BnD7b/MJn6JXzOLjAJCBzTYZ+ukFLsGel6XFAonBnoLYudE/jJkszmbz43C9WRldg/bvG2Es3vf3lpH8el5B6WXwndtgvfw4XaRY2kwkbUd8OdKjqQc4QpSgUkKRggp2nri/NE3qjjky6/eHQg3+H5CikAx+2OR7k7kILZFEeUYkA4RR+tcHKFaE461E8Ak272LWj4j1BieUc2EYqSIw+iRjA0fKQ7DOQbN4P4+0vAIPvjN+Vp8da7WzmqVMSPPTFd+xmX6jrJp6szaZzrEK3RBt/845KN40p/TvxdrdgHCfXdQjPwL/znDX3IHLuxdMUiABggE5MamdA3vaOP6c7gWhqyF8vkWBYa/U5Ln3oY7YPFhSw8kym/oZixTipZvvaJWhg3/VlCwJhIEPDgfx06+Sd2mnbx1Zbrcz/RuQhjEq1bbZ9YLg3DPO6xGgb/ZSo/Nn2ExdWGg6q+b9C/O+YHo9XOVGMKkpKGxVCRuEoyV9trRwmop11xf90 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB4429.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(38100700002)(8676002)(36756003)(86362001)(1076003)(52116002)(83380400001)(921005)(7416002)(8936002)(2906002)(6666004)(186003)(508600001)(6486002)(5660300002)(44832011)(6506007)(2616005)(6512007)(66476007)(66946007)(66556008)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lxX3tarjO0u5quYHpCGSbfaPlQ6gbNKZIn4K4UT021Hxr6p9+FGSHw15ywAnukzzMwDOUp4K7kFWyE1ZsO/GHwYo/5gNJtjQadDTNr2D5QYwrdn9/5yXf67XV3ef4yAAMpnGIoWFKNIZ62kuwWtwJqtUkLOie7BeDlz+J/z8WN1nP30e0iw9T5PL+YKdfFRoosP5REXL1kwiq4PvjBOUqYCLHYXp6QiBljwMUE5hr50GGfEBygnalTAY+D+EUR3uNGpi0VgXAJ+l0edhDHV9zRzbB6co4zVPUd8fRYMFR4CE1gu8xR/gxFBG/uOvAOjy+i6t372a1U0jEoXYZrLMIV8iC3rPhSSlvJMyEtOl5xDZUU7XmU3fReoHx9DQHduJ+rXQF3TCp0ars9rvUzWDBwtsNjNdwy7d98E/m0YJQNF4LDDfE+6Ws14NTFDc9QDq3CKKFCFmjiuu65fR8k1c0nQfFhoTSwU5XqNWX4fW0rWJedaKP7stPV/+ok9PWVS64scF1n8epnmevbez+KguY77x0fSPZwPH9+Sqiv6PCber54/rzOolPNgJhVEI3gRry6CHAYO9GNkdncM9BNJe95s7DksnvoylYnwQHtcMoiKDRiiIj5cKYjTvvGgZuvd2V/O4c1oAP3+WK8JJmUyhQd+HksZGR4jmfCG7JYfHrunEICPB8J9NSYSOKPlpJnYzAAitNinhEj92VdpFTO+pHdvmsqFTzJSDRg6Jqugo663FuFN+fosaAx0ca5r7wA6wBQ/ZYdYFQTjp2SYG99nveFHr2nbo/3kSyGYK/9oRaBZNQRIK8aKggZnQl5L9UdbBOMKJQunO+UOo419Y13bSlR/ROvja0brjALkm1fnAfPwIK0H2Hh1cQ9fYWqaUjRDbLDw9tcbzTXW0TpP3Q452ZImxCff3JvFDmIPZrMLXQKQgoG4yDa3Ny+PnHgdeKJVDOUtg5wUYoWTQ1yGTKCj7U67UZ+SRhRL+h0yVRHknJt18Bg1FtAjLirpnyvahMdadswFeqJwk2MhoCuM4J0uleXfSIs6o3LdhAJGLgGOnQs/daez+KJ+u7GD73WbQ9JNuQQC9p7RrZegrG7SfnDXMntCiQp4g+HA9ukSCVgq9miaDn6n3QL/YvFTfIF4i2B4I7yZK+zZj2RijIpoOA0cpKwKolpREBZHHnX2A9+5WUqskpci4bk8mFRF3n8L7Feq7W66M6rFr5fxqLkQB/H5hYlN6ILbTDUS4IJHdVehHEvNXeH8jUcwk0nRpBt7x7uFjZ97/3MV6k+Jir4tHwR02BzOGU+88USPY9UHnoYkhBorXHTO0dXHL2BAvYD/aT1D02z80Oyl06wA09evcxDxR6nbXvGg3SkOdqP0J/hpLg+m1yRjIsMHeqtLG+cKcsxDCo9QmkT27WI9MfjISGhyiWfUkBJC9x4AfqrMhJd9ZH2/rsPmnpdI0JKklO/cAjJWOIx7tBN/niyuIicV9bM9Ly7bRDVrYIIs9YJbbgmo9/MH6L4CSgpZA9HfaN3F8ty3dwsIv7y1zzbSHXZHSOeiMI886JxRkx8bWrJxySA7Jp4Vm+NYPgsAAMVl3pEiwtC87NOaGFdBQzE3pBx1ujgASBu1IpDn4XXUktvSZqpUAhdA7n/6XnolkLzYX8o1C2AvS X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b14d8967-6e38-4e7a-1ea4-08d9e110760f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 21:11:46.8720 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dCzMIPlVDG0OeM/bmCpzvj+qpqBFvAA+W6rMdmgAiWCaYH5pQXXFMR5B35x39VPEWYXUzOzGi3YccnWpTEYYsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR10MB3044 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10239 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 adultscore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201260122 X-Proofpoint-GUID: UtpwDzrsMyn7sjlKGB4UXPz_KtZLNZUB X-Proofpoint-ORIG-GUID: UtpwDzrsMyn7sjlKGB4UXPz_KtZLNZUB dax_recovery_write() dax op is only required for DAX device that export DAXDEV_RECOVERY indicating its capability to recover from poisons. DM may be nested, if part of the base dax devices forming a DM device support dax recovery, the DM device is marked with such capability. Signed-off-by: Jane Chu --- drivers/dax/super.c | 17 +++++++++++++++++ drivers/md/dm-linear.c | 12 ++++++++++++ drivers/md/dm-log-writes.c | 12 ++++++++++++ drivers/md/dm-stripe.c | 13 +++++++++++++ drivers/md/dm.c | 27 +++++++++++++++++++++++++++ drivers/nvdimm/pmem.c | 7 +++++++ include/linux/dax.h | 18 ++++++++++++++++++ include/linux/device-mapper.h | 9 +++++++++ 8 files changed, 115 insertions(+) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index f4f607d9698b..a136fa6b3e36 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -195,6 +195,23 @@ int dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, } EXPORT_SYMBOL_GPL(dax_zero_page_range); +size_t dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + if (!dax_recovery_capable(dax_dev) || !dax_dev->ops->recovery_write) + return (size_t)-EOPNOTSUPP; + return dax_dev->ops->recovery_write(dax_dev, pgoff, addr, bytes, i); +} +EXPORT_SYMBOL_GPL(dax_recovery_write); + +bool dax_recovery_started(struct dax_device *dax_dev, void **kaddr) +{ + if (!kaddr || !dax_recovery_capable(dax_dev)) + return false; + return test_bit(DAXDEV_RECOVERY, (unsigned long *)kaddr); +} +EXPORT_SYMBOL_GPL(dax_recovery_started); + #ifdef CONFIG_ARCH_HAS_PMEM_API void arch_wb_cache_pmem(void *addr, size_t size); void dax_flush(struct dax_device *dax_dev, void *addr, size_t size) diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 1b97a11d7151..831c565bf024 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -188,9 +188,20 @@ static int linear_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, return dax_zero_page_range(dax_dev, pgoff, nr_pages); } +static size_t linear_dax_recovery_write(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct dax_device *dax_dev = linear_dax_pgoff(ti, &pgoff); + + if (!dax_recovery_capable(dax_dev)) + return (size_t) -EOPNOTSUPP; + return dax_recovery_write(dax_dev, pgoff, addr, bytes, i); +}; + #else #define linear_dax_direct_access NULL #define linear_dax_zero_page_range NULL +#define linear_dax_recovery_write NULL #endif static struct target_type linear_target = { @@ -208,6 +219,7 @@ static struct target_type linear_target = { .iterate_devices = linear_iterate_devices, .direct_access = linear_dax_direct_access, .dax_zero_page_range = linear_dax_zero_page_range, + .dax_recovery_write = linear_dax_recovery_write, }; int __init dm_linear_init(void) diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c index 139b09b06eda..22c2d64ef963 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c @@ -927,9 +927,20 @@ static int log_writes_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, return dax_zero_page_range(dax_dev, pgoff, nr_pages << PAGE_SHIFT); } +static size_t log_writes_dax_recovery_write(struct dm_target *ti, + pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i) +{ + struct dax_device *dax_dev = log_writes_dax_pgoff(ti, &pgoff); + + if (!dax_recovery_capable(dax_dev)) + return (size_t) -EOPNOTSUPP; + return dax_recovery_write(dax_dev, pgoff, addr, bytes, i); +} + #else #define log_writes_dax_direct_access NULL #define log_writes_dax_zero_page_range NULL +#define log_writes_dax_recovery_write NULL #endif static struct target_type log_writes_target = { @@ -947,6 +958,7 @@ static struct target_type log_writes_target = { .io_hints = log_writes_io_hints, .direct_access = log_writes_dax_direct_access, .dax_zero_page_range = log_writes_dax_zero_page_range, + .dax_recovery_write = log_writes_dax_recovery_write, }; static int __init dm_log_writes_init(void) diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index e566115ec0bb..78c52c8865ef 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -332,9 +332,21 @@ static int stripe_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, return dax_zero_page_range(dax_dev, pgoff, nr_pages); } +static size_t stripe_dax_recovery_write(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct dax_device *dax_dev = stripe_dax_pgoff(ti, &pgoff); + + if (!dax_recovery_capable(dax_dev)) + return (size_t) -EOPNOTSUPP; + + return dax_recovery_write(dax_dev, pgoff, addr, bytes, i); +} + #else #define stripe_dax_direct_access NULL #define stripe_dax_zero_page_range NULL +#define stripe_dax_recovery_write NULL #endif /* @@ -471,6 +483,7 @@ static struct target_type stripe_target = { .io_hints = stripe_io_hints, .direct_access = stripe_dax_direct_access, .dax_zero_page_range = stripe_dax_zero_page_range, + .dax_recovery_write = stripe_dax_recovery_write, }; int __init dm_stripe_init(void) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index c0ae8087c602..bdc142258ace 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1054,6 +1054,32 @@ static int dm_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, return ret; } +static size_t dm_dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + struct mapped_device *md = dax_get_private(dax_dev); + sector_t sector = pgoff * PAGE_SECTORS; + struct dm_target *ti; + long ret = 0; + int srcu_idx; + + ti = dm_dax_get_live_target(md, sector, &srcu_idx); + + if (!ti) + goto out; + + if (!ti->type->dax_recovery_write) { + ret = (size_t)-EOPNOTSUPP; + goto out; + } + + ret = ti->type->dax_recovery_write(ti, pgoff, addr, bytes, i); +out: + dm_put_live_table(md, srcu_idx); + + return ret; +} + /* * A target may call dm_accept_partial_bio only from the map routine. It is * allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_* zone management @@ -2980,6 +3006,7 @@ static const struct block_device_operations dm_rq_blk_dops = { static const struct dax_operations dm_dax_ops = { .direct_access = dm_dax_direct_access, .zero_page_range = dm_dax_zero_page_range, + .recovery_write = dm_dax_recovery_write, }; /* diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index e8823813a8df..638e64681db9 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -301,9 +301,16 @@ static long pmem_dax_direct_access(struct dax_device *dax_dev, return __pmem_direct_access(pmem, pgoff, nr_pages, kaddr, pfn); } +static size_t pmem_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + return 0; +} + static const struct dax_operations pmem_dax_ops = { .direct_access = pmem_dax_direct_access, .zero_page_range = pmem_dax_zero_page_range, + .recovery_write = pmem_recovery_write, }; static ssize_t write_cache_show(struct device *dev, diff --git a/include/linux/dax.h b/include/linux/dax.h index 5449a0a81c83..0b4ce58b2659 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -30,6 +30,9 @@ struct dax_operations { sector_t, sector_t); /* zero_page_range: required operation. Zero page range */ int (*zero_page_range)(struct dax_device *, pgoff_t, size_t); + /* recovery_write: optional operation. */ + size_t (*recovery_write)(struct dax_device *, pgoff_t, void *, size_t, + struct iov_iter *); }; #if IS_ENABLED(CONFIG_DAX) @@ -138,6 +141,9 @@ struct page *dax_layout_busy_page_range(struct address_space *mapping, loff_t st dax_entry_t dax_lock_page(struct page *page); void dax_unlock_page(struct page *page, dax_entry_t cookie); int dax_prep_recovery(struct dax_device *dax_dev, void **kaddr); +bool dax_recovery_started(struct dax_device *dax_dev, void **kaddr); +size_t dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, + size_t bytes, struct iov_iter *i); #else static inline struct page *dax_layout_busy_page(struct address_space *mapping) { @@ -170,6 +176,18 @@ static inline int dax_prep_recovery(struct dax_device *dax_dev, void **kaddr) { return -EINVAL; } + +static inline bool dax_recovery_started(struct dax_device *dax_dev, + void **kaddr) +{ + return false; +} + +static size_t dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i) +{ + return 0; +} #endif int dax_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero, diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index b26fecf6c8e8..4f134ba63d3c 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -150,6 +150,14 @@ typedef long (*dm_dax_direct_access_fn) (struct dm_target *ti, pgoff_t pgoff, typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff, size_t nr_pages); +/* + * Returns: + * != 0 : number of bytes transferred, or size_t casted negative error code + * 0 : failure + */ +typedef size_t (*dm_dax_recovery_write_fn)(struct dm_target *ti, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); + void dm_error(const char *message); struct dm_dev { @@ -199,6 +207,7 @@ struct target_type { dm_io_hints_fn io_hints; dm_dax_direct_access_fn direct_access; dm_dax_zero_page_range_fn dax_zero_page_range; + dm_dax_recovery_write_fn dax_recovery_write; /* For internal device-mapper use. */ struct list_head list; From patchwork Wed Jan 26 21:11:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12725817 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FC2F3FD3 for ; Wed, 26 Jan 2022 21:11:59 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20QKYe4J012687; Wed, 26 Jan 2022 21:11:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=Tenm3Cr/HWLEXvF1vxqr+qnt0+OskmnhIiwTMO1NGDM=; b=gEvm9mALVbF8QkYhOs3cYTXn+XySCAg5MlIfJnSrj5ZYKExJwbuIcVkCoKX+yVDOp7f6 nKuFFlyyefMAh7twi9GYK2k3vzFJZYKRHw1S3o8fM2zDzVcSfnYdyiDGIuf+i7IpIkNi JFfxZGtr21Je3GRtWyk8wFDroMG08weajiXHfIVjUFMDr2bYISVj89r+R0E3XYu/KFix yt5E9blcRbnN5xF170nxPTtPCLOJfOx3lHcawPwTHuc3l9Bfi/VLu8dSuIaQkdto3ufT 0yS1V9GvjG20vEys+x8wVx+PiNarmdUSU59J4s4awADXQ4MyK0LKdRjLc+XuuIAQKdbq 2Q== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3dsvmjfuxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:53 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 20QL5L5Z082550; Wed, 26 Jan 2022 21:11:52 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3030.oracle.com with ESMTP id 3dr7yjfe30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F+Pi1XTEQ8gCw7wDxlFZuONrlTtA7tN3sK/oPR0M/taHlf+zg0jcyB8prvsD4myfqMfehFN8pAKYaGaLhJBYvcpzuB8z2eP4NoXgYsUmcl1MvhDuR3xFRXVq737CK8lczydkNGJ2eD8A+QlQpvFaqzlUy/DqLc3xKTA8Otw7BpX9AN2E2/BUtVDBfBtTKmpBFwgr++dxtfmChWH8OblEaaCjZ07Z/xOvHHq57XyfmLldNHrUhGxIkhk4deGZTtBfqodj98nz8jiUjzhGtAT/IfObOCU5CfN7NmepMsnQPtyqB71MCNEE8k85SLG4uv/swfeClDyhep3DgL1clqfZDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tenm3Cr/HWLEXvF1vxqr+qnt0+OskmnhIiwTMO1NGDM=; b=Vi1c6wFUmoSbsMuNnjbpLSXPGSe69EWDvFzWOkG6d/bLA2WkGnvBcJF3HKbqspBzweAuMC3cnf59AtjJurH8OfXXNERmWtMSaoteYw/2AV+JQxHG1HofGsPRajmvAEb+PobBuH/rsJbFoZdhKfHboUEBzxdyISKt/rClHuVHp8MnSikX0iZcYmOt3AMdOBtjGoRtnH2w72Xd7vxX/2Blkdgo3CYRe+mfXdfOy3eOJgTkFFsDypzjWsieFWBRxKKZt6VRxCQ29+AULrxIpkDAPzxA2N/14vJKWMHJ65X/+5ulu3wImZX7irfM8Fd3HRV1TXa413FymIktB1oiWIWESQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tenm3Cr/HWLEXvF1vxqr+qnt0+OskmnhIiwTMO1NGDM=; b=DMtWMdzh2uJO8YaAnn92nDZxVAgIZml+4q5RmRYNYVma0P4LlOOmiHIK7cVM5diKPHRP9CKhcMw3LUr3ZKYn61Ql5AWn2LhENFB7peSdiY/FxarcfS/kEKBgHyQ/eCkgYpvty2dc3t0fe+I76UW8yb42wUhVP9VhEZY42cn13Ic= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BL0PR10MB3044.namprd10.prod.outlook.com (2603:10b6:208:33::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Wed, 26 Jan 2022 21:11:50 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%4]) with mapi id 15.20.4909.019; Wed, 26 Jan 2022 21:11:50 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v4 5/7] pmem: add pmem_recovery_write() dax op Date: Wed, 26 Jan 2022 14:11:14 -0700 Message-Id: <20220126211116.860012-6-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220126211116.860012-1-jane.chu@oracle.com> References: <20220126211116.860012-1-jane.chu@oracle.com> X-ClientProxiedBy: SA9PR13CA0112.namprd13.prod.outlook.com (2603:10b6:806:24::27) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ba1e0f2-5776-456c-b2af-08d9e1107808 X-MS-TrafficTypeDiagnostic: BL0PR10MB3044:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1201; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mSX7M1y+qRiY6oc46GYihr1oGe1+ZKPi+N1kWMgujDqTcFMo1/HORmgfgk+fYmoL5am6VwiAbw9cEdD4kI7Lmr5GcxfCZs83PJIW0HRP0TR7EL5omFgynK6L2alwPb79wVEiZqsiRU4s9s1J38YMgQxSvwhpKwQZ6T/ZsOBa2U2tpenjDb1QzdFMJmliq0Yk8Glhq0T9VZYlA1Ave8xptG7HUKxEQbkNVDjHB4mT5/+/MI/nwQbQaso3J5iFeIGgPFRy8dRS8Y2HxCYc+8opU+7ZyCCYD7oiU/N1b6kWyUELBbTFtEyHS3rRAl8Rzft7k9lw8Jvj2Kz6kUbUcuSTIfh/e0V6wYP3c6gS97XwnW8xfXUfTW9q1D3CefSp1x4PapPqiyDaz4sPpMmUNTsp2IDOai0C+R68uuvg4GIXXIdZvOwJju1uaswG121+hsNFoGCcmOXEz9TUAgnEWxnwedfbMwNk1/59duCGSuRS7aJgMpxPIXJF3Hf4E8ApyESQPdJowW7xCgNzCoiLPNK+iBv9I6TPZYHnZ7MBBoo29C0237VQYM88R8LSQs3pGoGyhMDuao6Xfh45l8bdFBB+S8X5j1E01+OWdm8TWB7Zu6u9ORJYHfpUibYt0u5wBDyXJprOVdLHSa+bmaXYUIxTOhUfqPaE74InmrMdF7IXCbzY2FABgtRxlnfdpR5+/nmt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB4429.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(38100700002)(8676002)(36756003)(86362001)(1076003)(52116002)(83380400001)(921005)(7416002)(8936002)(2906002)(6666004)(186003)(508600001)(6486002)(5660300002)(44832011)(6506007)(2616005)(6512007)(66476007)(66946007)(66556008)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ukApHDTAjjySXZBDSd6OX5x/teCnSO3nuA6aDNSOCaqXItQL+ENV8G2+dyecwuQo/eFZjVne/kX9L685BX0KxXt5IbXxUJHFB3zePx/XnXWBnUnBEkikeqkmMAlsCMSLzx8vFjJ7bBdG8MlXMHA8J44lyHP/Af2IhPDI9AwZnFIpK2QOsbLP1yb4qzcbxpHVeZNAt3QIMAhcRIbaq2lFNjrAxAQ+4Br4iCGaH0mxdLX4Ucf7dzuiWqccH/W1L4oYmVrepX5Q61CjyEMTP88qZ1okVqZNTjWjYCKCiJMkjErGsfIfo7RoPdL1xVi5BqKDpGrqpZeoge6/Q3PYHQEpzKIXxhuR69zICKErO2RhMsWgx4dJL96Q/UuWTTuz7SbP+2VD+11LeF3iYcfvv+MEo9oN1EQNg06t0IZrhbFSCz0gG49uVAb2MJk7J7lQnMiKxQ4SJMJggu/NwrcyvMYKmfeyNA1eg1mg2xfyoAU+jfTjP/WkAYBn5o2bc9DcruPYER0Ezml6WPyONAuw4t8omF3jw6f2HRbEObEhcdjWNlOPo6g72rZHWarN2NSkveOchY/EdvotaclNO/EPvHmalbZqChZRR1QI9ACcI05ifcA0zIJieVm6Z+33Lv6agq2buOMX0fxBb5qrbMpCo8L6/MMubul/+bBwQImivghOf9suWwL/oF4d0QJOVwCf8zoTFh/QCjLOFLnBNRf26Me+uoEwYUZ9XQv3axvdWALpp2ncbaWc8RUMQIGLSie5uPxzaqWwdlOXq8BRsoOTXd3kLfIo4iPBQcm8TNPcSeaOXWksOLKvqfNe4B9TUMzmkgkeZG1fL5JZK9MzFZbpXL6iMwP9V1N9fMjnPmm8go+rDps2qfodv6NwlBWKSjSyJ9whULjJRjE5zOXaQJKnPlsWy3Wx/ymvDAL6RgedGKL+fqCgoiJo0eg4bK/NajHxpk7mDMKwfHxMZ0LqLh64V068rEKO2Ev3C13sBwEeb7tr5EOAuh37K5fmFzXbEgVqHqwsQ6TsLJk/NK2pDreJyILY+46Hi4i2FQyxpcrbI76gcakypejeTyy9Scw2XdQ+lclEjpnZorNJIUx9CRArwyJMUVNMnKGfDBW03JnG1Wldq4QFAMSA399uzPlwZxop6+eyFxJro/0jqX1KtTw+qAqx2qlD5JwE08Ulmi1yPnAhKo/1/2AdHHZiaUIBSzASwsM+qDH63M40MLk29bku/5oxyjzQJ68fsFdsKXidJoQqS3IYACMGYH+AMsmWdGoQdVQtWDXSwo1yPIk5GAg22wyF+WzSkgvc/hWSuI9PvBgvq8j/M5XOUHmu1HmtYu2LPtvjT4PYWQaVn6Ffv+Pg4gnVkiz1PolE1EBLN7SXXRVyANUBHBju9UFEIHo6C1ipXRbnejTWab4sFB3/JuP2idVtLbd4PvQK/GH1f/vCIL+Yisv3CaE9zHLyR0aZ/vHdZg0Wze5bp1rkEVrUSAa76JU/RFB2q9lEim4l4clOZ8XQzpl2vu9zLpHtUFiakgkM0x+9341RPUVxuwMm2QxGvsS5iFGLrAPTwaaIEjdmI7Vos5YUp04tsJO1Yz5/jNwOW8jECyXIYVH4oSAjlR7XEF1SVn1Y8VeKrJqI9taPGGHZICwbSLKHuUiDg8PQcUC8tT7m X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ba1e0f2-5776-456c-b2af-08d9e1107808 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 21:11:50.0928 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AJ4uhETFemSmVaDlO9mJVlDV87LMn4JqzDGrPjloiDcc3HOuM6cT7/8ydmlnAJZcCflGL06vfQcyEoRAci7Ceg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR10MB3044 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10239 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201260122 X-Proofpoint-GUID: wKbf7r2juN7yBGE0IyQQdaPFOyuzfyJw X-Proofpoint-ORIG-GUID: wKbf7r2juN7yBGE0IyQQdaPFOyuzfyJw pmem_recovery_write() consists of clearing poison via DSM, clearing page HWPoison bit, re-state _PAGE_PRESENT bit, cacheflush, write, and finally clearing bad-block record. A competing pread thread is held off during recovery write by the presence of bad-block record. A competing recovery_write thread is serialized by a lock. Signed-off-by: Jane Chu --- drivers/nvdimm/pmem.c | 82 +++++++++++++++++++++++++++++++++++++++---- drivers/nvdimm/pmem.h | 1 + 2 files changed, 77 insertions(+), 6 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 638e64681db9..f2d6b34d48de 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -69,6 +69,14 @@ static void hwpoison_clear(struct pmem_device *pmem, } } +static void pmem_clear_badblocks(struct pmem_device *pmem, sector_t sector, + long cleared_blks) +{ + badblocks_clear(&pmem->bb, sector, cleared_blks); + if (pmem->bb_state) + sysfs_notify_dirent(pmem->bb_state); +} + static blk_status_t pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset, unsigned int len) { @@ -88,9 +96,7 @@ static blk_status_t pmem_clear_poison(struct pmem_device *pmem, dev_dbg(dev, "%#llx clear %ld sector%s\n", (unsigned long long) sector, cleared, cleared > 1 ? "s" : ""); - badblocks_clear(&pmem->bb, sector, cleared); - if (pmem->bb_state) - sysfs_notify_dirent(pmem->bb_state); + pmem_clear_badblocks(pmem, sector, cleared); } arch_invalidate_pmem(pmem->virt_addr + offset, len); @@ -257,10 +263,15 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) { + bool bad_pmem; + bool do_recovery = false; resource_size_t offset = PFN_PHYS(pgoff) + pmem->data_offset; - if (unlikely(is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, - PFN_PHYS(nr_pages)))) + bad_pmem = is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, + PFN_PHYS(nr_pages)); + if (bad_pmem && kaddr) + do_recovery = dax_recovery_started(pmem->dax_dev, kaddr); + if (bad_pmem && !do_recovery) return -EIO; if (kaddr) @@ -301,10 +312,68 @@ static long pmem_dax_direct_access(struct dax_device *dax_dev, return __pmem_direct_access(pmem, pgoff, nr_pages, kaddr, pfn); } +/* + * The recovery write thread started out as a normal pwrite thread and + * when the filesystem was told about potential media error in the + * range, filesystem turns the normal pwrite to a dax_recovery_write. + * + * The recovery write consists of clearing poison via DSM, clearing page + * HWPoison bit, reenable page-wide read-write permission, flush the + * caches and finally write. A competing pread thread needs to be held + * off during the recovery process since data read back might not be valid. + * And that's achieved by placing the badblock records clearing after + * the completion of the recovery write. + * + * Any competing recovery write thread needs to be serialized, and this is + * done via pmem device level lock .recovery_lock. + */ static size_t pmem_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i) { - return 0; + size_t rc, len, off; + phys_addr_t pmem_off; + struct pmem_device *pmem = dax_get_private(dax_dev); + struct device *dev = pmem->bb.dev; + sector_t sector; + long cleared, cleared_blk; + + mutex_lock(&pmem->recovery_lock); + + /* If no poison found in the range, go ahead with write */ + off = (unsigned long)addr & ~PAGE_MASK; + len = PFN_PHYS(PFN_UP(off + bytes)); + if (!is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, len)) { + rc = _copy_from_iter_flushcache(addr, bytes, i); + goto write_done; + } + + /* Not page-aligned range cannot be recovered */ + if (off || !(PAGE_ALIGNED(bytes))) { + dev_warn(dev, "Found poison, but addr(%p) or bytes(%#lx) not page aligned\n", + addr, bytes); + rc = (size_t) -EIO; + goto write_done; + } + + pmem_off = PFN_PHYS(pgoff) + pmem->data_offset; + sector = (pmem_off - pmem->data_offset) / 512; + cleared = nvdimm_clear_poison(dev, pmem->phys_addr + pmem_off, len); + cleared_blk = cleared / 512; + if (cleared_blk > 0) { + hwpoison_clear(pmem, pmem->phys_addr + pmem_off, cleared); + } else { + dev_warn(dev, "pmem_recovery_write: cleared_blk: %ld\n", + cleared_blk); + rc = (size_t) -EIO; + goto write_done; + } + arch_invalidate_pmem(pmem->virt_addr + pmem_off, bytes); + rc = _copy_from_iter_flushcache(addr, bytes, i); + pmem_clear_badblocks(pmem, sector, cleared_blk); + +write_done: + mutex_unlock(&pmem->recovery_lock); + return rc; } static const struct dax_operations pmem_dax_ops = { @@ -495,6 +564,7 @@ static int pmem_attach_disk(struct device *dev, goto out_cleanup_dax; dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); set_dax_recovery(dax_dev); + mutex_init(&pmem->recovery_lock); pmem->dax_dev = dax_dev; rc = device_add_disk(dev, disk, pmem_attribute_groups); diff --git a/drivers/nvdimm/pmem.h b/drivers/nvdimm/pmem.h index 59cfe13ea8a8..971bff7552d6 100644 --- a/drivers/nvdimm/pmem.h +++ b/drivers/nvdimm/pmem.h @@ -24,6 +24,7 @@ struct pmem_device { struct dax_device *dax_dev; struct gendisk *disk; struct dev_pagemap pgmap; + struct mutex recovery_lock; }; long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, From patchwork Wed Jan 26 21:11:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12725819 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F35323FE4 for ; Wed, 26 Jan 2022 21:12:05 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20QKZF5X011980; Wed, 26 Jan 2022 21:11:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=YNdmcW56aleJoC16aj/By1K5R67/T3TMnT3Wjs2Vhpc=; b=fg0VkXb6/1HZCdK9s57f++Tmzl0uW7b61jMP+H3qzQLFLHa6N/5HIJ9UlCaEySTAtjOQ BRwz2iBqmZeErZ3l6kUfO7U/aHpfcdv+6au9S+YwBIPgf8jtQMZsmDNmlDgaof+QVTR6 DmhPNfHDEbQqbrQeVYzVYuwQ+k9KkR0LRlYec7Wx2UwUkkAuOagznsRqVtqnHfqG3oNM OJbBCFDDn5rs/O2fPibnRV2SiqHFM0IRoSkzt6XaY+K81/tD3hPr+/GufOvjDf61i+8M 8QKAAkgn41t/Op0ZePUT5K4BC5kIz/n2NNS/JJ5d16vbWTN/afC9euKExeVtVT7jfgQX ng== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3dsxaaf95x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:56 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 20QL72lQ016295; Wed, 26 Jan 2022 21:11:55 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by userp3030.oracle.com with ESMTP id 3dr7220b16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:11:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RayrrZ99J+Q/P1zcp9Lm5mVlhdhjobAgBDOmoelJcHiOqKrqf7MQ2Rog/Y2jJLSMb2NrHmILWgCu4QK6kOKYKcP82bqZRcoGs4o+4iX7ubNP8oZcTjeYHpnonc531fu2J+jXnGZFA6hQO7t0FezXHbY51zydLrNYm4clfwlG8PLDDo73hKOKCObNqL959pUJ74bBJY6A91PyKW/w93m/TpjS/0WNwpnH+Ock8q99jz5cBDqtAd7MOVeqJOo7SXo3s6sDY1iYpu3u5Zqxo0d5RRWohK+Dr87m0Ye1LhXV1AHDZIVJ2MXO6yP3cRnPzoYnI4hpwtlAcoo45knagm/Etw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YNdmcW56aleJoC16aj/By1K5R67/T3TMnT3Wjs2Vhpc=; b=HS6YSh/zar5m5CDNcewnxG0713FYsYqUjCxA33o3HBjPPz+socoOfC5fB/f60UyjDyfP4aDxuTI2USEp1MMwmroRuoLlbLQtgc3Haef7uZfpq8SyNXkbDNHnLwfa9lHSRduawN5GxBaU5UR6Hk3TC1QmI/oDtzyJjkK/bg1hJMNzRrSazlvkk42nXq7KKlqRhI/VgMTZuRzcbcBZN8L521iwmy3daWc1frRBUYyB6hKSspzT7PqeUN2snh66yoIjQUTohiMJWgZGuC3j4QpEVAa7OdmjCVotnAXqqygJSe3ahcRAXoqK07ZDkdleScs2fwZFnaJHu44j5crES9Sa7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YNdmcW56aleJoC16aj/By1K5R67/T3TMnT3Wjs2Vhpc=; b=LOS1BoxlvlgwsFA0TP8YOVk7nQkJ8J7yLKpgG1AvHrCqMYRmA5+MmPhTynX+FlnUbuAP5pN0hn9ExI8YpH4ntZfLYFcjBQeu+IWocBrvTZCXem0GnA3M8dS4OfEXJ95kMB6qRGX4qNoPTn2MBQQeiFWB6Zr/C1Q9uuFwwz/Eqxc= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BL0PR10MB3044.namprd10.prod.outlook.com (2603:10b6:208:33::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Wed, 26 Jan 2022 21:11:53 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%4]) with mapi id 15.20.4909.019; Wed, 26 Jan 2022 21:11:53 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v4 6/7] dax: add recovery_write to dax_iomap_iter in failure path Date: Wed, 26 Jan 2022 14:11:15 -0700 Message-Id: <20220126211116.860012-7-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220126211116.860012-1-jane.chu@oracle.com> References: <20220126211116.860012-1-jane.chu@oracle.com> X-ClientProxiedBy: SA9PR13CA0112.namprd13.prod.outlook.com (2603:10b6:806:24::27) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27cbd4cb-d671-4e36-ee51-08d9e11079f3 X-MS-TrafficTypeDiagnostic: BL0PR10MB3044:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Uj15tosVqqVeO22TocfR2zps4usq1fVP7u4PTj3c1Ta165KtZypEoGJhLT99xhMnSJAX3m7mcA5WKbaWdJOqZ3/h2lFDUJLGTOPeY+B2OIf6vAIXTBpVUlH82y4Ajx5ndILTJCiMWmbP52PwNTgSredRnELDBWrkZrLhXoszdX7jg87cnFv2Ia1t/fjvEvwDrqSKHPF3jjgXHe6B7Gj/GwJLAPsJqqwdLPJMLxzBue7o/LMxHJryLzYwEDrcS3HBANWZLyEfZM+epQldeNsnSnX6NlxMVcZm3cgVq+7cvzUXsojrDdqQ48cM7DJrJyVQ1PShh595YaRflnaMF3nlGcOVts18Q4cHBOtIPxP9pa6lUiD8wndOi675FZpU53vWV9iIVadi52Fr3SNscPo+1p2rzHiT88v5kTFGnhtudf+WEiJF9PdLhWKJ7qSC2eSg2eiB1m7DY5M2cyNO0jpX8C7dhZzixYgLEFfcm/dcZehKYyC7xz123NlMsdv1BlEMoHqAsVEksBQ74+kz+MbKT8ueSCD6CZPljGlD/igklHl6Tgfz2fp+h5hS1DEsioOA8pLQg0vy2vwFQrDQMygfHod5EvhBaL8h9iTCo/9n0DaR4JCqiYS4EBkGpM6pe1vJGnW4CjM+oI0ymdE8FJ2qciOxWaL3v0NyEAwvOyh3SJfsykHn5sx1LMZ6ZQ8hBpRW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB4429.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(38100700002)(8676002)(36756003)(86362001)(1076003)(52116002)(83380400001)(921005)(7416002)(8936002)(2906002)(6666004)(186003)(508600001)(6486002)(5660300002)(44832011)(6506007)(2616005)(6512007)(66476007)(66946007)(66556008)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: prqTXOVcPFpTNupPz0KxL9HvwqelE2Jep3xLv4OP/sFImGWQIQY1aPW+bKucKOlmvbykAuTcN2b9ClfHm9MTzDcNegjOnrk372w/ch7WlKWDn7Wq+NKV65CVrErMTuy+I57kN+kZzyBoEDa9TGJLI9/jLe9z9trq/ROn3rU8rap30BhuScIPlqHPkDpS+qGx46rxnIvIshVpB4jv0pATEbQteCfkKSbo44oLWemv/+dIbEOVcA4nd7iBcp3cmS37LnXMhe32hwVA4cTOIbH19hCvCm6i9NPami/Ctb49ZixZbsZ9eVuAuz8iJ5YNJ/KRGsUuFK+VhgdZ+T7rYp1z0QTxnqn60rIhOZT1eC86dwY+thux/ibxxFFBFqAuJzLvnBX0jcCYouHrdPRQfzsVy6kLli2C9US5jfHkIqv2S2PRh/GvlL6GL5NOcw4tP+VrcXovx0UUIT1KZRYh/+9fSN8trTz1bV85ixXou7KVNd2n7cgb/c4O08ww+CwLMSd3Wt0w5YlGAwH814nURESFFH945m7ei9fOB9Qp89T8KfUpNNpGf4AvQgTNJhOOKqOkdhgy2C2lU/0RRTahCy4qO2/BTJ6vWEhyfaiBmMdHfkxaK6R71YQAATmy0FnAnWwyB91QPDyNoCzkXicd9YIRJ5tzgZjAiMT26L22/cg5yGpWPLCzIE5+FLGWqXKi6Oq2enyj1OGbdGqlcPCDv/yGnbjR8cWpP24kJOxeHuAmWPyVIuFJ4SyG7E56S9K1JFkYgvwf70H2eSE73zjycqAkVXCjyFySnunc/JfXmPUL8s0gEPT7wmMt9fHoWR7a7OlIVSWXPrDMYsvdDsPmNUs3r4aSfUKrEgBd4Rq6Vi2wlwAdbOHE5TFdGplrAFHBTIRpMo5nNAZz2BLcnrhDpKx4joVVTfj3Yov6XE0bkOyZVDkQed5YNxZmxKFDQ5Gl8WWxY1JFUO8MmhEKxkYHZyA2jfwARCn1I3bEBd6SEoFLRD68b6ekEyAE1YaZADuNSMKu2Y2aBVnyEr75UQLj6WaxRnRYMj0lD0m9FcP1uokC0vEqyjIVUiJKDtT6x60mP5YovLgQYdGK6jczBepJ5mQYaatzZCeQPBIouzdwAjeuB5SOG9bOOXci3buHWcv0j7JtRpQfnuNJhbZmOda44zTDxuVyQGqZ5NLz0YGWz/PnxW1E8zF85J5XiWNGhoBsLwX4evNO+0lWpJ1qFPLNnAqgSj6Umn1Kpzm1ZEHi42BhQx0jYnf/RsR8yWGibk74BrAntyVgI1lynDlSIyVuwfyavtjNrGOyTrcU3AchU0r15/4/ct/914WstdXLTQ7/AvZ7h1h9Uqq7upT010X1KI8F6XcTTUbGrPO5+JAas1Svfs/dKHAwEOnvYUMKPdUdsR2wjH17Ns2DfQX0zJjyv9oj5RqFw/8VqFDqTt51p6AFO2uh1iWHFMSUNQTS+sOV8emnzP/o3TMKEw6BR0dGB/jP8WBgKEuo9xLQskg3/V0ykkJ1EvEexDnsJ/EoXBWJhWolG6OOpuCbImh4ZN65iCIzC++iYFvoF86WjIIMIh8wwXBxY4lNAfw39IYYHMtWZWFimLcXPv6Z535SRD8+iN/zxgP+XoqFxcFrZbt6URsl69schx4gJQl+3fgc6ad26lDc X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27cbd4cb-d671-4e36-ee51-08d9e11079f3 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 21:11:53.2641 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jX107dEI9safjv/ts2u6fifTTPbEt46Xy3ogcDE0UOsZENVm0lDkSGLdnZ6a6yAe6NZXNvswEJNMYcXiY9I7Pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR10MB3044 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10239 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 adultscore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201260122 X-Proofpoint-GUID: q24lQjtz-8q50fhX-v_YwNRxVDqnnL-I X-Proofpoint-ORIG-GUID: q24lQjtz-8q50fhX-v_YwNRxVDqnnL-I dax_iomap_iter() fails if the destination range contains poison. Add recovery_write to the failure code path. Signed-off-by: Jane Chu --- fs/dax.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index cd03485867a7..236675bd5946 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1199,6 +1199,8 @@ int dax_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, } EXPORT_SYMBOL_GPL(dax_truncate_page); +typedef size_t (*iter_func_t)(struct dax_device *dax_dev, pgoff_t pgoff, + void *addr, size_t bytes, struct iov_iter *i); static loff_t dax_iomap_iter(const struct iomap_iter *iomi, struct iov_iter *iter) { @@ -1210,6 +1212,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, ssize_t ret = 0; size_t xfer; int id; + iter_func_t write_func = dax_copy_from_iter; if (iov_iter_rw(iter) == READ) { end = min(end, i_size_read(iomi->inode)); @@ -1249,6 +1252,17 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), &kaddr, NULL); + if ((map_len == -EIO) && (iov_iter_rw(iter) == WRITE)) { + if (dax_prep_recovery(dax_dev, &kaddr) < 0) { + ret = map_len; + break; + } + map_len = dax_direct_access(dax_dev, pgoff, + PHYS_PFN(size), &kaddr, NULL); + if (map_len > 0) + write_func = dax_recovery_write; + } + if (map_len < 0) { ret = map_len; break; @@ -1261,12 +1275,17 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, map_len = end - pos; if (iov_iter_rw(iter) == WRITE) - xfer = dax_copy_from_iter(dax_dev, pgoff, kaddr, - map_len, iter); + xfer = write_func(dax_dev, pgoff, kaddr, map_len, iter); else xfer = dax_copy_to_iter(dax_dev, pgoff, kaddr, map_len, iter); + if (xfer == (ssize_t) -EIO) { + pr_warn("dax_ioma_iter: write_func returns -EIO\n"); + ret = -EIO; + break; + } + pos += xfer; length -= xfer; done += xfer; From patchwork Wed Jan 26 21:11:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12725820 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E3EB3FE4 for ; Wed, 26 Jan 2022 21:12:08 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20QKZ2bT013145; Wed, 26 Jan 2022 21:12:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=Ks1lDdZOoeu+ebY6MNA+Kn7IVzJQAEX4+SArnEKkR/M=; b=1IGzok+6iDZRETzaYLGB/q6KL0hp7DZRhB7+QULb9ieSXsKiyhm3KM0JFaXXj2osVXIL 55aC+MBwO0ecE82f/BzUd9tKII6fGK3GR4FuA6+yCJ6L33JN5pyL0cmrf6sUdMknxcU+ 5uuT19iBRYZ+a33JNh+BQIBuzvHYui0YVTnZ8nACxs4BIASltoloZzEOlW6FbfoKS5/8 AxxREpfSxaqQKsuOGUklnSnFpVqflsxBJxC9qkUlIYoDh7HaUUzBDG81lzJZBmt0E77h 8TFpCJM4gt7Gl0lmwDDvQQCS85vo4amUSo01HwZnW3DAHEJHHkmUnOMFYDG6QfThNeL1 ow== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3dsvmjfuyf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:12:01 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 20QL5Mxw082682; Wed, 26 Jan 2022 21:12:00 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2100.outbound.protection.outlook.com [104.47.55.100]) by aserp3030.oracle.com with ESMTP id 3dr7yjfe7r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jan 2022 21:12:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RIkWxT3UZ6UlILBSM31DnVWbWO4JI+lEfHClG4aWqr7rTAFjepAjX8sadd907K++TFhdL8geA3Y3YRy5hHh/VUZdhnfSt3OGGq2tA0RiAvxXFCi82lTWFPguMAqp+nMrX8lUN2QtAJTkO2vqOV6UPT3r7nWf5gFGLfPVvAIvUBkxoKLXurh/BNuysqa5EaW9JJ3Hy4rwG7zp/ghF3HgUu20PizAIYAk7oroF5PMZDqyGeOAiZrYaFSTbqFG1wM2FuoJomkBbaGr1fP6KT4nmMFwkAhXNcTaC41ajjR9+QvUCgHMiVW+V0UKp732p8e1AMnbqz+BtY/kLTQh2If2THg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ks1lDdZOoeu+ebY6MNA+Kn7IVzJQAEX4+SArnEKkR/M=; b=F72KBFEXnAoBsLiM6ZJhqzcg7Fxjj6m9nHpEnrvUsY7xUWV277bGTJKj2A4kI/gKj/7zs3IDcRp8wsFG+KmO1ignZEpNcKve/on8Ocq/aZZugJ6W4ayOPp/M35BFtic4mGh/XYRM2UNAVcgHOoQzfglD48SwZZJhmK6UFkw4sZrEumxeGtfAB2Cintz+zfz5S5riVqlje+laKmsqragRZlr2zzCAaGLFAu0lXNPANPI6+3oOS9mmWcSu/AW6G5x8S4w4NRf5ymtOg6hHiBjnGnLDTTeyFcBgxMctvm18sl9CFIgLpWInsh45xlZpT7GhTTglgHSuUkJwfJ0MQzpocA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ks1lDdZOoeu+ebY6MNA+Kn7IVzJQAEX4+SArnEKkR/M=; b=gMHo8GB4gsjtbO7C7/2kqND49BbYlXkwdRAJ0lcWkIwf2hrhfFKXkskYKduORQbJjd2RigEPmQhu3+QCXXemEKIsstHTvorFTke/xFWAM9vxIJ6RWFRPHA7MXqyf+iti2EBP7ir5SuKzB2aWr3eH0uWc5oySmfjDnL4zXeQRi2I= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BYAPR10MB3368.namprd10.prod.outlook.com (2603:10b6:a03:150::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.12; Wed, 26 Jan 2022 21:11:58 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%4]) with mapi id 15.20.4909.019; Wed, 26 Jan 2022 21:11:58 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v4 7/7] pmem: fix pmem_do_write() avoid writing to 'np' page Date: Wed, 26 Jan 2022 14:11:16 -0700 Message-Id: <20220126211116.860012-8-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220126211116.860012-1-jane.chu@oracle.com> References: <20220126211116.860012-1-jane.chu@oracle.com> X-ClientProxiedBy: SA9PR13CA0112.namprd13.prod.outlook.com (2603:10b6:806:24::27) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0614ab3e-3043-4797-844a-08d9e1107cee X-MS-TrafficTypeDiagnostic: BYAPR10MB3368:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SKXbLBbM4GvlADn5ig1hchTxvfvvhDKEwQExu6dX21v9Al6ti/0N2EcRO9lcjI2uDZ8bD9MHbELZbylTAcC47XVX8bC2ce0V01OKFy/QwfazSEfwC+Gug9x1RRJUzaE3zRn7NjbZZkyZpJpOgvi/A9cZhs+9UCvu8z6o1D6ZN97uM5kz6mhS86cuwpyVdltwat73Eqr3ovO19tvfVcG9yS1iBDlS3fuf+xgwjLuTeXGzKCbp7LtnZdv0rBSSe9Dl9RIRDVlBM0BMiIETnhVyAFAwHi27nl21R/0Uxfhu4VjYWIDkHL2HLhiWStPwbdMXJNlVaohNMfkEsEf6tQ21MMTfIlI443N3pMfG2Uk6lHU7/hhxCJ/xvKnvxzwXomNMC1I89d2cURqrF1ysTaNy3hCpZpUTM/nIsTY2hm6QZjIyH3VduReJ2cK3yJXrGPYIs2yZh5+8vZLMcKtPNTtQiFLaX/DN0dfl4S2/s2H+bnSLD3jvzzLxauzUN88lIljJaFnTrCfPQB8PTncAT86WSurz4jirpf5yBBO7TQcjGVAJpx4+EBqn+2OLQNug3IHRnuQXKri8JYffbEgzCuTwxINYL0Ho4QbORW/sUsZDTNIqcgoHK8VVM81HSZkbpUec0X6k2FWXpMKmhssp5xzCgsU/hZ/blO0MN4fJfahVUhJUHQVGhFzoxud3t0+QPxaK X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB4429.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(36756003)(316002)(7416002)(52116002)(6506007)(38100700002)(2616005)(8676002)(5660300002)(6666004)(86362001)(44832011)(8936002)(66556008)(2906002)(186003)(4744005)(6486002)(921005)(1076003)(508600001)(83380400001)(6512007)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EacyS6jr+wnJ1/UTCSK2YIg9Y0Dm0/yjVXKKRXP0YXOc6vdqzs4ut3ENUm+zf5hXlxO6u6ktJo7J9dZu0XBWvhPW65uL+9slRozPUVe/5juQ0GxyMR2duKeiaeA/4UYjchQEgb5L9Ww1WTRV8W+LpJXUyMH5NswDmVsYb83BHpsIpTbQZ50CNkIBUF8GZ0DmXsOW0EFKYRqwv4lXdjqfS8GZmm1MTHGQ61/eJa9R7wdJESOpzMty8NVG2Nkop35gioDy6Emv1hiqxvbMySGvv6aw0MnF7nZzLQ+uYPi70ktIni7a4MFHvoN12dGvPlYF+O7epvmPBGzq2xf609Cz3nRf9YUNoyNuFT5TVli5DVAC9iq69V7qhag2Y9oTJ2yTAKG2pnWP7Sk4hhy7Z3xCVB4wrreTkfrlq3V3C9Uj9EmEXoBzajgqAQguTrH9pyZqut91Gg9kLqBRKQkTYnP4fwnS3Jd77z/Zc5RFyQWMYT75mVlQCIm5MsAfxJXQd/lfNawlkG/+1NV/DyVzD1mRiyqxU5grqmdFhOyxLqvlwCwUsNwFJnhseE0E1W3FvG2wD9YR5X3Lw68mC00e0fY5QSx5Z3Q3q4pWijCzXbYJuzRVIy7XGweOPCq4CfBK/M52tI4noz0+7rz9dN99+IJkO1FZiHcUyqvEd+sRtrOOKSb/zP4Y6EQb01jm0iv7y+TqkgaDj1o7N59BKinjoPq8kVr82DqJcIw5UMf1iFmcqOdtzLt7Jm95P2keRMNGlvqT/loX5n8ZSUjpgvUtHQ0eUGs/1Wic0Z7RPqiFzVFXMI5EDQJWmm+bJHG0aqFBQnCu3F40fYm/OOG/5LCXMfWab7I6vecCfdORfZvoD5boPZ1pM3g7EausZ+suzr2UUXKZQ1WpslgZalbJqidRGK9AJ3OZN6+LkM1thRZguarTccEc9OdmHHlsRYbbrqTaM8A9xfavtHL1XaTH258nhG8omltYh46JCtSUNxHRKg3Q92ENWRr6UyRUvQXETQw6Z6UznM1BlNmwwuskL889V7bgrp8Aa4oeCZolRUBr0MQjxN8ongsbDIL9h/mYoWBCiem9tjKScKPfC1gGF1sLymhe9Sk6AMx3/DKAWrSUJdLA8dZOKvo3okzni7bQbJwMFScnoN1HYUK61P9jvt5iFjv5t/Y1U40JxKcb7wnJtfF2v3nlr4B0eLbQst2iqueMDlVNBAXpvDD8d3i9OnFy0CYme+f+LPZNuxtaeSHCwt0n5nGSb0SWQRBpLwLsYV3VnOuspb0XiFmMvYxAFbpgPiDuiTaS4BR97CCrXxiIU+ltDlXGnbwDKnv+2KBnXx/AGmKSHVffD7kmnaILRQ8oWj/0GXJmVfDJLMCkuVW0zdA53cKZr8IuDBDWmUxowulVS9Z8q6Ck6/ASCPoxWVC50PR43tG/T+hxvaYoONMdceKw0navVtdlrgROLyWXF4rblDnMQpFPV6qVdXyH7a8yRn9L8nAOcRKsfL4oNFnmXbGXgR6YTv/OhvgL2kWn6Q1pWxI0XQ4riHNCWczpOKZNymomqI2Fmq2m0VjJkuj9p09aUqtai4mYKhuIOM2opFU7F35J3YecDqHV3eg+wpgni2hU9TJ+NbVGjixFJnSPuQ6lZGN70azMri6CK7Fs4Juecc6k X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0614ab3e-3043-4797-844a-08d9e1107cee X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2022 21:11:58.3243 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ekIDsCVRvlxi7bqyxca7niqec3kmwOXWCvjCaJjVukVAwtJVKQ/EqOecitHABb3AlTOoHU/nhk5IP10CmrVgIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3368 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10239 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201260122 X-Proofpoint-GUID: EV1vOI7aqriyYxpcPMbwyuxDRqxWeZVL X-Proofpoint-ORIG-GUID: EV1vOI7aqriyYxpcPMbwyuxDRqxWeZVL Since poisoned page is marked as not-present, the first of the two back-to-back write_pmem() calls can only be made when there is no poison in the range, otherwise kernel Oops. Signed-off-by: Jane Chu --- drivers/nvdimm/pmem.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index f2d6b34d48de..283890084d58 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -187,10 +187,15 @@ static blk_status_t pmem_do_write(struct pmem_device *pmem, * after clear poison. */ flush_dcache_page(page); - write_pmem(pmem_addr, page, page_off, len); - if (unlikely(bad_pmem)) { - rc = pmem_clear_poison(pmem, pmem_off, len); + if (!bad_pmem) { write_pmem(pmem_addr, page, page_off, len); + } else { + rc = pmem_clear_poison(pmem, pmem_off, len); + if (rc == BLK_STS_OK) + write_pmem(pmem_addr, page, page_off, len); + else + pr_warn("%s: failed to clear poison\n", + __func__); } return rc;