From patchwork Fri Jan 28 21:31:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12729109 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 EFED7168 for ; Fri, 28 Jan 2022 21:32:33 +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 20SK3uGl030747; Fri, 28 Jan 2022 21:32:21 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=iGl1mYVeaeq/aqbhyl5y6gx2j5/YEpTzIYC5sgNFsJbWEI1oftAcjVc5PrBPEeIpIgE3 gTyviA1TTsrggHQDlLcQAMsL4qjb0f4OnK4raMlF2226tqctcoOBOtAq7WGexF9o2+6c 5HrxyB/CorQSNkRSrb9wHfypMV2keChhZnWwINBiX3Yrgm8vi7+BWgahLrEEZfwQZRtP /Fn72OkDWOf0BlaKT2JC8cs3+oZ+5jVkhrCfYpXi9/7Ls3iHlyF9kIvPY/yBS0VUcru1 3RbhKDG4+dBc+u7QFLtbcyl8GHBnSHdEIspLQEqQkMEQxUruGYSoUVosAC/35H3QNPjL uA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3duvquvmpj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:21 +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 20SLPpxW033639; Fri, 28 Jan 2022 21:32:20 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by userp3020.oracle.com with ESMTP id 3dv6e5qdkp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CxBN+B6YXR14h4wVBQpUdDU54vqdou8Tp1oBnfdFSDqSMYKHAXSUG7nCFydb8y2QKa4X51Xejd8c+OBBTCn6jD2Rsy+/eguoKZ3wJ8LAy18Kbv4Ph638unhvL47cRGBsIoFR+7BDosguq+QfcutG3/K8AHZ7Ince5Ub11UeuNCM6BEYMH6sED1HhBu9TaTDYVR0bLuJvNvkOR4//OENJnqVvZmry+XDGdnaSCGvJGv2maigTPWrUNfcKmSIZSKS1wql0xmq23SuF0LKhXqcysYama3CcUFO8n2PzNFtdlXGvxTi93uwzW69a5JCmhHWiCijEKW4M11deJUlMMmxgAA== 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=Cz+3CQEGWxXSadLR44ME+xy7qcjKDXqBbtA60JsXfC7r1PMFPVFN1qprgUCpngq8F25Hy/4z4tTFdjtHoJp85M0aOWBx3I+wOTpMmW5sSDlwrfuJ4YNwFaUCGG52VeRm+JdXz02Rpi880G9Y+Tl5aEAlKIEOv8MhxI0D1TgGqrqH3w/B0+GL07FTxHOc83/R49iJnxsbEScPNV5lHFIoU6nD0rC5XkFdN/gEAgFOcqfLJlibOeYEL3vHdqrJa7+6rXUYtuvSq/HYp/93KIetcDqDsVYswHx1T4Kp/nxHNsJXt8JRZc6+TWSNUv3FZh8GoPGdXILYpY0OzFxAlS3O5Q== 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=eA3DmuvnCUBDbDUZb0h0BPiR8kJJKizCOgasrUz2crN+2P702tK3XQkvaFnWV6J11uMRq2ITUr0NFaWJonjGydJbsC3VtOWmmWfVMIkbm6TvehtdK5atApxUIgPwkDpHyBLxY+btSg6FugWzuogy6SEdk3uiSxiL1dWpaiKPmHU= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by PH0PR10MB5753.namprd10.prod.outlook.com (2603:10b6:510:146::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Fri, 28 Jan 2022 21:32:18 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%5]) with mapi id 15.20.4930.018; Fri, 28 Jan 2022 21:32:18 +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 v5 1/7] mce: fix set_mce_nospec to always unmap the whole page Date: Fri, 28 Jan 2022 14:31:44 -0700 Message-Id: <20220128213150.1333552-2-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220128213150.1333552-1-jane.chu@oracle.com> References: <20220128213150.1333552-1-jane.chu@oracle.com> X-ClientProxiedBy: SN7PR04CA0071.namprd04.prod.outlook.com (2603:10b6:806:121::16) 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: 0572d86c-9145-4902-3db3-08d9e2a5a8f7 X-MS-TrafficTypeDiagnostic: PH0PR10MB5753: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: nJU9Souj4t6evylVhzF2rmAgSkuphGJW/kgCaO4tW9gQAgp2REUTmI9DyGJ6OgWpyxtv+Z0t33iuEMHLP6jt7e1khuuYbztumPp+TQBD6dvfbyTTuLTwep6tSk1Q+BU362gjt9qkdl8qocXidacd74rGE/Wn7jnqiugBhGAgo54mFM+BdfaM6I1TDHv+GV5Pid/E9OGfJYagsq4p8Q+ZuTckND/uV7aHDu0c+og5Y+SuFNskkbBbTS7QIAueKxC7d7iUrhI/10Sewd3qxUHCut4bChGL43+nLCcVsEreHX8b3VVuBVWlaaQ2vdPhqcPfTThC546Fp5BDttM//w+PPcsqlV6lyzX2fW4FznPTV+RYWtOcpXUq95wZBOqn13sD7fc2DzGcK4y4H7lxvuCP/UxX9stOAv6qWImQohpGk+NzAGfZA1xs7YVKNgRpalY5B5uD1CzrGPBGQWfayMJS+wQi6b7bzuRmYKp6KBh0oHRkhxDSVolDuwAQ24gHMgNpdcLs2eSE1yi1IwQlcxiLVVJ7UbzeXZg45CozZcwXtK/Ns26AqweC1zmch/BlhP9O4YuNuB5IjMLyASTwCuFYSymQHX2ztSFLBKeArnhIwVnH37dTk6kR3MVhK72NuJXH48xOCifU/Sod/CHmNCrkBO8sbBzpiigwxRg4oU1x4jLvuni6DsQFRYk2x/Y+KGoAYHM/Zt2f191oEz/dtYGjK3afWHpnbKPOl5F9im4es2ZKs8WfJCJ9bE8NqsuCIKJbCgHkekMSS2PQv73f39VbLQ== 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)(83380400001)(8676002)(36756003)(38100700002)(508600001)(86362001)(966005)(6486002)(2906002)(6666004)(2616005)(8936002)(6506007)(316002)(52116002)(66556008)(6512007)(5660300002)(66476007)(66946007)(44832011)(1076003)(7416002)(186003)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DqtLifwj4dIUOiJl+FCS/b9k1Ym/js74fHVbIknJCd2+gbIJkPsxFl336jvhncWTvYHkys7yXg2jOTfXstnNMAV5VITUsXohOJljmBTFRyZrRToQ/5Liu4cc727FvEnDw+B+ht5HpKk4pyW8kekJWJQivmjKQ3NOOWGs8fpaHZC6I1swDw+qHNymPw3NzzV189O7LLq0sDngBP8muRa1gC2Ret9JKclKiBKA6NTdgQ9A3aDyEVmEIdfam1C5VRG0P3rQUblekVITZyHTCvzF6nHMhVdmCvzcau1nvGw+SXlj/QgPuxoR3z09zJ2v8Ht+7jKyuiVqzNFz8/0VSMZXIkLKRh3TXY+MT52N9mD0lT409vQeyNO0Kk/eHUgmIdbeOP9LZ7bAU2kYrWsW3hnICQOFI7A7IiviQPaVxrvUOPOjLsBZmi6K2Ohy5N7Sh9rDG5OoCyuf0uNV3bSagqUGifUO5cr6v6ipYIKZPkQzVvX5CJSjP/iRbgdl4P91aJOgX9wQFXErVOGA19e8bSTPSJysLP7DZxtYv287/KxUhzzEcYoLY0iEwPp7gWjnQcWKzNjkjG8Q5c9xPMgGrkUMaNWAvOfrde8spM/JesbV7I6GHQCVks+8dOZ5cso7ChyCrQ9oYOfqA+jJtYm9/fQ2U7pbmFTKv5SIh8rXNnThIB+1nj0bpjNPRJPCt25KqkSez8TtqsLFOUlVFNIZPJbYoJlNKXk1+7QhlQueKq3fRS19YYICiSa6ZQegJdk+73j/49/UBdRc5LYsMZ/H9VwODYkjKiZHDNEKWeVnBaR5YZTFIK6MZR3Jj4KLRAHyJe+KzFsI+oT9uGmyix29EsxOL+Vp5PDmlD7tX6MU3M6XNkMaPIaeEDl2X4cKckL/ZRV/indlK5dR+HLSKGQjX0i08EHI8oujadHw8/x4InJdLkTazPzVbij4fM9vNGy/wyCtTXsODFUHT0cxyANVF1mpLsC+fiQ5YaZlQb0a+g/UsDbXbu39mdQ6GZlwmnWx0dA+7dSl5SL1TjxHL3cixoqWAs/PalScVsuaK0I/bTyVhZjqIQEXSQfzVlY77rXdowLdYfI+rnbTG8kSjlWXlBoGzksDZ4+Z7ds+dHpmw8zlYqymKQw8qCh1uWW57tqZFBQnMRzbf0wZ2RC2lJfKJ8J3RZMgtJcnUv27mOTFn6JioH+mGQcxdM0qYXDYIkac9XbsImcwcr5royp5jcNeVDg7f8DsKkzb4FyFvoK/JykeAulNPJFo/YYj2lTFifrfZXu2hc9Xe7ZtdtoaJMSaJo7xANc3LPWg3evAmXyIEtQWmbMIXnc1KQkrbCPZv88MEKp+Yjd3xfAOiXqST4GqPhIuZFKZwRcSnp0DMUHEozC4dGmGh9uCt7k8HLkE4j8xqtwiqSLFDSo3mSSwLkHOCLB8ZbDmFJzpUMvhp5xo662Bti5vb/ykvmXBzsPHAXBUCaR6g94p+MeiIfwGJhzN3M4HHMCzAfmVbtdTaq9+j5JTT/nHAqDlSRZo7UwIYj/lbU2zFI0Oss54L5tPRcj9aBi1VvGf4HVW0p1o52Yx4ViJHZiUuPiA6bVJVY23CTnu2JlaRGGh54JSMM85qMSKgzdy/5fuXj425Gq4Qv4CljcYxejOZFkq0xSViyu+rOBB00G2 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0572d86c-9145-4902-3db3-08d9e2a5a8f7 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 21:32:18.2986 (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: 2T8IuRnDHICBhvmaiAGm+4QXcWCT9CmEZWRojN8xwq63qEppI7r4eH4797ls8CYfY7ov+OnK/o6dhD0UQJFPWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5753 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10241 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 bulkscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2201280122 X-Proofpoint-GUID: l2_mKZQfgxw-YKmRbpeQAnOPgVc4aTMP X-Proofpoint-ORIG-GUID: l2_mKZQfgxw-YKmRbpeQAnOPgVc4aTMP 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 Fri Jan 28 21:31:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12729108 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 EFF092CA4 for ; Fri, 28 Jan 2022 21:32:33 +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 20SK3uGo030747; Fri, 28 Jan 2022 21:32:24 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=94eeDSC3VgjoivlRpSE6Lr30mayKboHYlE9d1aMAX04=; b=s/PKbpJ1ZAHfYegF8u4id86NxaLXW4jkWcyxkv13I3iWMtzlga4J8JS/wxAK3NgQshTg wH8jLq4xXxLWwd5qVBwPVvioon7enEaFl58ngK0UOBRaW+VQP2QvLp8EeiYhx/POVCI0 Ci9CkoJFSMPjjK/B13vZ0R+UIsCoHvWSt8TWIHSZjaIZ1UIzxMsswqEJjX67SAuxVHpy 4IYGIA92cCtwUt9IJbco0B0xnFO0PceK3timimVF3nuLsPVgHPXmVltfBbgJQ1SHHyB3 GQRgkpP58PaXclRpsAoCf3A0t1PWo0g7wkdg6WTcQcgkeRxncfujHr63US4K4bs1iVHk 5w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3duvquvmpq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:24 +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 20SLQvRu134915; Fri, 28 Jan 2022 21:32:23 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2043.outbound.protection.outlook.com [104.47.51.43]) by aserp3020.oracle.com with ESMTP id 3dtaxd6usq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PFifs2DOl2tuQufb+QVUyR5Lpp4D1NBsAyPv7Z5UBu61oaGAYpweHKtcbzhmctCFwqjN0aV7cUj4TTKOYgEBi+YhdlpgygLGLZP/hdmzEO9+YgYP+lFV5d74Z6GUHiCppTOya9TOvrMDJ/y/Lj3D6M+yKhR/DNJaBp9oQwIdO/DySSTKFTDMWb6l6qSKF87KTqISLuEeUJo4sNx3HjNOUkFqATJbP5KmloDiVTzB3WLexaI6wTHLvZJggNX2yGGHeYK1o6UI4fHmkuAw1rVWDB0bVynQas/LTHHMKhBw+qGcf/e5x+HowRYzz4btSKO6xa3tG2BgsYfIaU3esDFccA== 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=94eeDSC3VgjoivlRpSE6Lr30mayKboHYlE9d1aMAX04=; b=iwa5JAMlFYPOQMdBLcMrJNjpPVnsqc8fN684T6t0/Mln/RyTGb0qawXIrjInOYjHKLHw17enaqYpT0EBchWR5ARMOHsVwUEq2is4Dj8qemeZ5yEvZyNXimAEHI9h9vjD6lmP+C8caBC5u+4pc7qtR2UHjU6HXGAufAWnRZ8YqJtx6dZF7oD5Yc2ygnm4do3SWL9uV4OOnkqtCNKcqzDBvfujzq1czQYe0qBsXdz6hgVii22vuYI7deUqfv0IEAd4PNk5l4LPCQWcTqDyHBMY2WPNEnRxhvZp2xxDrBr8QM50muuWtHuwc40LCxP5vludE06pFHA7PhKDA0pSnAJYoQ== 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=94eeDSC3VgjoivlRpSE6Lr30mayKboHYlE9d1aMAX04=; b=Ne1HRNLRq5hiIzTVm7x9AsOGYGBP2Nx78fzW8gw+L904462e6StxXccfeOPtPhs1yGDdpIxr5Fsdhy8iJ/wQhxerFEzGVsursFXbzy0rzyLBriZ5yNCDQp8iCnzqp9RN+lgp1i9AHDABAUWxK4EYqIfX5T6w1mcQX7vgq0AG5cg= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by PH0PR10MB5753.namprd10.prod.outlook.com (2603:10b6:510:146::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Fri, 28 Jan 2022 21:32:21 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%5]) with mapi id 15.20.4930.018; Fri, 28 Jan 2022 21:32:21 +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 v5 2/7] dax: introduce dax device flag DAXDEV_RECOVERY Date: Fri, 28 Jan 2022 14:31:45 -0700 Message-Id: <20220128213150.1333552-3-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220128213150.1333552-1-jane.chu@oracle.com> References: <20220128213150.1333552-1-jane.chu@oracle.com> X-ClientProxiedBy: SN7PR04CA0071.namprd04.prod.outlook.com (2603:10b6:806:121::16) 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: 22f7e4cf-14ab-4157-6ac1-08d9e2a5aaf5 X-MS-TrafficTypeDiagnostic: PH0PR10MB5753: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: RR7oyGEV27hMJt0YyXLAUgtBDJyfbkxvSPqPdHldzecEnbhSHc5VuHay+ZvAUwc29uv4SIClTPy0Zjtjb5Kcbo2ZB6xl5WeJs5hMki6oy4H0XxMd3nERNdTcNHX2XlqFZ9gl1hzDRx+BFFSwwylcrVwBXLGnqc+shqv1vS8xtTrg3+XbKucGS6MI/iVvnhcr428+4Y6AZ8vJxJ7epexi7nQ3quqJRfhA5ZwcrYfJjB9PkVlLTSwF119qsFSezkyVnWuRQ4oNFdmuF9bGt3CrmnWMz68WHFmCowIbwXXQkOiXlDev8icfSv82FzCkTTpSYNYPfop4/REbC3OXnhncqJ6EFAjNMFPil6P4E8POtSZMm5DYkr2QwdbLfLw9MakYEnhjvxB6908QjYhQvzTXynaDqUudHhx+kMXzhnCo9GizrJsYkAkcfNGkK8gj0VphLrYrdCCpiKKbvhV1UD+pijKK1hlFj313Bw/LCVKvpqPqaDA7sKYU/f6NrBaxFcRfXruvOktfD/EL6BWpqZnVGlynwKruLlz6exUrFWCyYE/cIeg67umetajY6tCRoGpIvXHdcF2AD+Z9/amCrp0JX6Y0YNfInwUbfc5uE6qnMf+pQhadnSWOnyuZVSRHB03xenfVkFVfeem64Xu5nsySDea+RMdDKIR95HvSpgJkqT8jalpK2eoNhn11tadr7CJ0j7hqPcaC+uN7S7YzgabTXg== 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)(83380400001)(8676002)(36756003)(38100700002)(508600001)(86362001)(6486002)(2906002)(6666004)(2616005)(8936002)(6506007)(316002)(52116002)(66556008)(6512007)(5660300002)(66476007)(66946007)(44832011)(1076003)(7416002)(186003)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xt4zstu4i9pT9y6pK+xHXz+BYffnpbrCgl4JTfTnco+2/a/L4s0LEegcpqLLne69FGmkgXfJsyaWrPvh0ARTYnoT7FkpdvMfZF/njEz4j2S43olEiA8srG3iAjDoGxoh21f+3DAaWky15pJeXVebzbIhPGKUBDE5ix1ZnMqSQJtcRH8q6pvCmjhtdxPczG6s2mPSGNtCN6uSwPEQFb5W8j7nFgSpF8pYDENKcL+bWVe99g5o/+qgBpdz8HZL1/DbVHeEoW/WH3Yg21p0utKLJzueExfqJi0fq1kkYl2JJKn7/XkF7YFuePiXHbIA/ldVdd7bJFOyhEdAYPB8cnaqYi3+gUmfPXNIgBjdFxDvBEQlPhAGOiMYhJdwsOJOSryvjdWMmZuvVzADCrVDwfPhIsXfV/k+RAod5zZiRsVBBTbOSvcUhTd/B2Nz6FNa/cPf8nhcnlD7KwWiKbnzC6RuUnPXLK67l7nO1S4lwx244ExilUyVvbbWdr0pHiVPFwULHxeIuUq+U8s+3P8tdQar5mULrXrRaTyuSxIaHlnX0N/35bP1JybLZh8m494OLC/WQ62EdMRlKBkX0g4hzWtEu2RwaUW2J4ZxlByrsCwPDkFXFrEGoud9e+Ln8WkRzHXVQVkx7nCtGrHRUqA2ALKN7sxibxpWr0v18SW/unFq7NN0Q87qmiOCJGVhAaA6wMmoLk9fE00diomWm+WoSSfjUT3FNO/Q757k8camjZymhDk+NRkxCc65LxqUMC43XEzMKSJlDFQlKFN0e6HBDHS/uUmQHRSTsqpXNcU7GDDUHeZDLSK8G0vwLlv87k3FTFbJVZbl/rCOBHPRu2zmjYX251DtvzEqnnPTqC3hyCs/pW7UDj5kK07QC9eMuoA79rk33HI/pBa2mC8ElaGtNrBZQ6f/tN9NvIjiv+QDRCMc5EzW42Df99c/fW5Dw0dm4wqswQK0F6Vq9JVXmctImoyFP9eebf7KT/1M2lEdFUewbeAdF9UgRCRmfVdnqeRG1KOZf3B8uM0L5dMHTaP/JPolyGR1pke7acmY4q8LQ8oxACjJ9HRCBHm3UCnOk7vqFfPhDwl7oFtqR6Vqqbur5+BDfriWjbVNQ9DvdmvMpUGq48DQaZXbvDTvjUhYSCbNZXrSbyydQiQF8HnsOVgdm4dOvF9gTLfZmbAcHVmbWzlix9ymt6M+aGDD9l7swqZW2K9vn85S4TrkYqVEdHZGaEfm8pPKBQpGWnIbNA5BTwrFdflwxRZJRuI/N5Y6MKerwrPnzoBoiireYhSZxfdFMC/lyWZc7k2IjQ+W8Bf0xuXTeemy9zgTqnBYWlTEGZhlyFr7qIvhKlAxgYyuRVioPYAMVylZSUjwI0wrkUvdLOchlr+XGyH79ZMEqNEiILi8zJdCORSkYHrF6/Wi8gsThgQgMD448fq+HBxgsfExxQKPHxbAh+jMNCpP7kbKlkwM+8q7uEEkQz0ivkwmgqGgUGbOTRU0OfZU+0ClNgZxoSdlnmBSwOP7Hj3NEPcihJp8xaGiXZk64npaVL25qdezt2TpxQ/yYC7RGzRGnh/xRm+Mf0+wxeaYlLTkVESgiCJZzkAjCS9FERsT7k/BzJRndlj7h2FSeFgFsRlH3D5LPgbZo8NsUJr8M9M8wOLfCOagGIh6 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22f7e4cf-14ab-4157-6ac1-08d9e2a5aaf5 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 21:32:21.7419 (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: /3Wya0MQiXiqSpXYO33gqRin68k4eRgfaAbmIGiqRdYssNkGiaoXBy4LnFdWfV1k2YYGdKCj3iIZUAfrIBOWuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB5753 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10241 signatures=673430 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-2201280122 X-Proofpoint-GUID: AIYoBLlnMQQ6ALiFz0_YnVaaqldUUNNY X-Proofpoint-ORIG-GUID: AIYoBLlnMQQ6ALiFz0_YnVaaqldUUNNY 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 | 14 ++++++++++++++ 3 files changed, 39 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..2fc776653c6e 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -40,6 +40,9 @@ 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); +int dax_prep_recovery(struct dax_device *dax_dev, void **kaddr); /* * Check if given mapping is supported by the file / underlying device. */ @@ -87,6 +90,17 @@ 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; +} +static inline int dax_prep_recovery(struct dax_device *dax_dev, void **kaddr) +{ + return -EINVAL; +} #endif void set_dax_nocache(struct dax_device *dax_dev); From patchwork Fri Jan 28 21:31:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12729111 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 B3AE23FCF for ; Fri, 28 Jan 2022 21:32:38 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20SK45bl004956; Fri, 28 Jan 2022 21:32:28 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=1Hd1fWipswtrwXaw3XLo4MraXyNtX8qhoUAiG0SVkuZWeIcnIdtzMIGTogkCO7YDGpMj q7hYZpT9cqs+kKR0IC/N6E59ALlNTWHnz2YsD9PCwcafii/C+Ez3HZvThCOoLTn/HFnV kbdp+LNFXulv36K59YMFCc4xZFRV92X3ECevEPCSMa/HlbAmLwDFTZwVurKs9OKaDiOR ufBmUTXNbk8VrB6HqHqb9zDLlXmha4xKe4as2/oCsJYA8djwerLSi78THfZKhiGAEzh4 oBluHeLDtBT5X+WC7Tv9fRfCH0HeeSnJPKDK6ghgLHDtb/7e5XquQWOtdh/re6A0+Iar dA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3duvnkcm8w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:27 +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 20SLQvTQ134945; Fri, 28 Jan 2022 21:32:26 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by aserp3020.oracle.com with ESMTP id 3dtaxd6uub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MIOwEygL62p5CcFdyoTn7CpYdcOOo0Al0+WFkX2lRIL51+OoheGOXZV0YjFGY2/1HV7sGLKlk+lRY7y7wOZlgBSqKPF6ckzB0c6A2Q5M6fC4HV9qTWjuQinQF4IVFgt/ZHv/7vFBRszhET3wew8DeefokmR11824JrqivKdixRR69dHVGevrWEVAG5M/qMHfI3YiTlk7XgCd1NX3Kc+g4E1QyHjad5guAzBYoO0Zl+bKndJCMMh8Tg3NeW2Mzj5ZwAUrUxGVdr/tRwRFPQhCnEZbRBO7IVW4ELIMjpir5x8j9j+G6UhMqGnGfZChlnGAo8TerVhgn0Ri7WORS46IwA== 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=nyAYFXSa71A1Yjyj8dCR9Je8Tj0Yfw6t2jfE71nJSI2pCkYjCVIZlyLiATJea4cL2spL25ZyfkEqb7rK9SRFH44nkU0ykLurRe2Qe283CNblgcC2UYN/L88O3Nmb1GKjFf7G0kny5cohHFpyRljUJikOLUx55T6Z7BGV3SfKZ2AyCvdyplSIP1lWAYf3K6DR6hWSezwWUnjqwSU7osDyavr0NYM7SrVvNQGC21rYz6w39nMC69m58KHGvHtCFWydvIKfemY3BfxXo4H1l/bSQ9GQmIy0YvIE0zZ2pUeSUjThEiwSbgbobfPVHjoAVr7lb1X3ZO+IyPuL+NwnI2ugfg== 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=G+4RMn2BaKe5biHqBpaYRjNIi+V5HXnm/qkdu18BrKwYI8r8+jQzL2maDqyb/9DUEmnHtKcMv6RtnyXe4uMaHc0/UMZs6ySQ3YDAnDv0Nb1YjSvOeJ9FeFnpjonzLG6ddM0/IO0K2drcI6eeqasWUw4ByOaEio1gusrdIId4pAQ= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by DS7PR10MB5022.namprd10.prod.outlook.com (2603:10b6:5:3a3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Fri, 28 Jan 2022 21:32:24 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%5]) with mapi id 15.20.4930.018; Fri, 28 Jan 2022 21:32:24 +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 v5 3/7] dm: make dm aware of target's DAXDEV_RECOVERY capability Date: Fri, 28 Jan 2022 14:31:46 -0700 Message-Id: <20220128213150.1333552-4-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220128213150.1333552-1-jane.chu@oracle.com> References: <20220128213150.1333552-1-jane.chu@oracle.com> X-ClientProxiedBy: SN7PR04CA0071.namprd04.prod.outlook.com (2603:10b6:806:121::16) 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: ed6b6b23-c610-42c2-1f7a-08d9e2a5acb2 X-MS-TrafficTypeDiagnostic: DS7PR10MB5022: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: Tj8suhPnBqAYVKSy33RP+GSPu7ECYiDQZV0shJnFtatgp/FXz9ygjlrdSNPEPKbmxzRbdDaqFFdJCfh4Jpih4m6IX2MsnK2gCjpLBtn2Y71hKGi0AXptoyn9tvVemYJLs+Lj//UcEIuK9uQ4YEEsWYZQm7qXjJSv1wAdovZtuAJH8z5ZGoWoXitj6J6S6358bo6tSEo8gWoleH182i7MrFZpQkIOiznPRCA8Z4oul0fO0LMUC14bwMUXDafVkRWQmo03zZNGsn+nSTRPIM9v2W1VoiXagV7H2qoDUOYnWKlBuLdqlxo6nJN2C6lDLuykwhFxKwX4B5SWaq1BztCzC04it9bD+aeqpsCNjru+twPPVTc2WlTypKy6cg9Hee5vBRndD/ZMijTNPMUtlhVsHC1O6N6QQ29YFoQA3v4ZZ/RqtlPvC4mLTHXIY36kZG5q/KlmGtAUfymNod24gYBnKWxMy6t6ARPpdrRFGc45azbtY0Z9OSv3luRA7jbT5U0x7VnC8fvmIZQP+W+a8SqqLLd4lnazmnloNJ19S1o1bLlxmASCt19hDGkaqYNbyfR50N1J2kbd0PR4yJiHSt4LXcDB8a20ZJWo64aB5lbAgCH/sos73NDDdOlFoNdFV88XlPFBqwfXWP9AUj3Pz8sNcqDq3E17oHxUMV+NkdWbTsZU3PDiSaqA7t7dwqsKICZnzIzYmntEjUgtO9kul9difg== 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:(13230001)(366004)(6506007)(6512007)(6666004)(83380400001)(2906002)(8936002)(52116002)(66946007)(508600001)(66556008)(66476007)(36756003)(86362001)(6486002)(316002)(186003)(1076003)(2616005)(7416002)(38100700002)(921005)(5660300002)(44832011)(8676002)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2K2lo+1m2lRPwfXpsTgPTRQ/28kcmoBMDGIngaJSWHLtnF8pk7BUlYNkTfy/fhXpBle0g1AxEZKoG0tTL+iB9zDcTkKVWokbphcfy2QWcRPqg2DVSslI/1rhOnA9XPv1iGQk3bkzclT05K/puFCwcP+Q++oOTP7UXy7haHWU7RPRMVmqjPGwUKIIIo2S1Q/n7JoXdB4StI+XxzvHNaKG60uD83lzfzr6sRD4wPnSrDWTP9YVmV+FmueDG95KvbZtFoJPd7OXTq8C397eYqs511Zccz0N6IL4avreTg0CjpmiSTv4MHCDhlP+Q0z7fMrQNfKv0ekWgSmrqCCvpYav53T2KaNpSjEdCu+NRxYPxzsJlPyIh8F4BxCLSbnhYXPKBky0eZG3Ik84nyKXcrR1ejwXKhooztpfM82dihZ6w+rkggGmdSEaUqfUOEJjv4yYodNiV4mPr3EzdfFmLCCVVkFeEe3jLdLgchpJeqSW/WjycAuoSiXnEx1KEI7oIhgw8hWL8du5/tXJ+WAgnolhqHbLAaoBW8SpSjboEmIat2fBaWPxTBDO/IgB2brOXHsasyn6pHG2K+EQ1MvK0nFvfVLGPpX0kTxDL4I8s/xVKFIYIIEw6aDBC7ppacb3+OwOk8SUnTwCe9rKKogCeZSsnf/5Jzfe5sN+ftXkPOGXLZYSXDvXlawS5kseM27JLTD1MV3Cko/0XbXBRLCQv2ixkxNX2Kxb8tBkh8OM8wKOmOGrXl1rtC9dxK32cAgJWNg/e5iKeZ5bj/5htLhorhJ2f8aluTiLzD4HH/1x4H3z+Z9iSIOIKmEoel6fS1Tkoqrgo1Qq/lVNwPLxGpniJE/BeyoilwG9zERv3bpJAp3tQOU0OFHD7auzQeBqIGD3xNsLWnkv7q4VUypF8XWePj4RGfL0aFByYWz8x1GYDJvdpsqx7wswYjC/ctuv767t2gqMw6XAQfZhniMwOFkGUXsCAGHJpwne0xP3ticEglM8UARm20D2BpnCbQ7UNmaCXLaOP4I0oS7xBIXeMMJCX4NKki9gy8WkQpfVzFVBDMuuIvQon5JdZcdaB/VB28kqzaIcmuEClz4NVQwr5vUBIBW/4++2PmdESwXtj6IdfznjOm94MqDEBENJhKi3FmnfPbzlSGpaZPave96vAk7U46tKcu//ZjuJUCcA7nes2Om3DY4HglfjbNey0s5DZrl3YBZ+i42PpsrUmnoGFSfThCeFenoXFoL90/znTHWbiUhhR1RI72+tmQfCGvSMLLlDaoZHwtf7sMx03VLOwoVy8KN9Gltvz/mXn5oMJIFmYYWwbbon7R0ytWWZ5MOZIOETOch23CwYQ22PCqRU9GYW9pA5saoEV7Gahb2Y+MTyAaqcJ7yaoE1XEFoGw807I8r4NXzq0h2OAnyD/7OcxQ7A+r0f/hzenpgGmIZZGs0KWl1ARt+dcDcMXi+h/pmEEmdy+HurW8uv6EvZqpCMuFv/SMQEKQCMO29IV8CwQfy/Jxyo4OD40VY022gqStwb4bp7TmuFJ4yAweInO57d2pBuU6FWs8O8Dnc6FLpWvHnz3D1EwfpWPprRnxZnXYVrehb/DZ57QCkLQuqz0tSoEgQ1o3HXcHdSAlNZeY44gVxH5JsChNMMLNxwcrImW0MvU9VPS4eO X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed6b6b23-c610-42c2-1f7a-08d9e2a5acb2 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 21:32:24.5565 (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: P5O3kfvv7wtlQs5bF5UjEQDWtimSsRnfYCsIfBL6TsNbPVduz4p7K6NbEWsRobUwkHOsbDvY1VzJg4wcg61+dQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5022 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10241 signatures=673430 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-2201280122 X-Proofpoint-GUID: rE7T-fmfRUmJhOYH4mkoafNkr3zMWlYD X-Proofpoint-ORIG-GUID: rE7T-fmfRUmJhOYH4mkoafNkr3zMWlYD 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 Fri Jan 28 21:31:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12729114 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 3A9D23FE3 for ; Fri, 28 Jan 2022 21:32:42 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20SK400L004896; Fri, 28 Jan 2022 21:32:31 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=ZJT6fQ4VAi0pfbDSZoiY3HULZbw7hCfF5pcYH5wYyhY=; b=0KnI2O0SECai7DbkgNSk/8cABl0oHHGPDF97rgbsrRjUzt0ik4DEiV8l5/RjsAMTynAt LfKffDB7oTeTj0G001BE194pqMG7bSmPRWJG5qAn6A2YD7cLAhIBmqC5g+f98Cy44hym kSOCs4qgST6RshP0V+H3y9YRthkbnTb7dBbsPK9YLfnpjNr4Udfs+2Nfw3LE1uTQPZB3 CwurVzZRUEX7QDgJctcjZYUHAQNH+pRruHNHHF/VqxIMIMktiMfGjOl/LguP1yAUBBxQ ZLuOyahS8p0PH33Ubrl5MZOGpy8cUmPE2pksIHea1cAoONfuDMuhKbXFPB/vwshZ8Qth tw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3duvnkcm8x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:30 +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 20SLQv3h134958; Fri, 28 Jan 2022 21:32:29 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by aserp3020.oracle.com with ESMTP id 3dtaxd6uvk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NYZv8yyyD1xQkBaVKKiK1FrMW942uUO+lXr8Y3wyLrXAK+cW2y3gE9U0rVzeVteCxg+x059s4iZH7C+cFbpLUs0PehedmVKgklrqPktD9saGnimD/7oTms2E4LfF6qznZRNJ6BPIsVdPFZWIVzfqxivvjcisyasY9AnKEF7da3f9kVPRzhbxNKNFotYBV4ZVgmUbXIVBF5wscO5Kwe4c0MCXzuxrGZ+YBbX+KvcX5egKm7HMd2HcqVZlp38+sZB6expmhWghfDpnjh53fQv01A4XO8F+/iVCGaHOa21d5INm81mJK6YDJhH/Su9O0Puuzh5ZgSuS0CElNYec+glYLQ== 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=ZJT6fQ4VAi0pfbDSZoiY3HULZbw7hCfF5pcYH5wYyhY=; b=SCTX9sGslHoMs9nTkeqlm2vPS5UFliaCD6eog7VeC7c1Wss3PsOpp/rLtfN5SAPAmzbKj7cIH8gl0DY7zjiSuHqyUASPUZDNHfMpW/COUuwEH7oafoJDdltiR8UbHMJsYoD9BXMJaFJ55Ni8j2p/T/g+5CINSnQeqBhpLjKHq7DSc7W7tXyfZBa4yBU60jgKmnTtYyHpc9YHyQYHyxn0OJX2q9oc447xFlbE3u5CmeBDiKpElNHUMnkUDA/yUeRdUkf0eYaXSU0lgWF2FJU+QrxkG84vM2RVpgc8lPOPNjhi8TZuozVmiFcRldCRD570KicbjcxzQt5aHg7k3jKVPQ== 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=ZJT6fQ4VAi0pfbDSZoiY3HULZbw7hCfF5pcYH5wYyhY=; b=C6516n2lvBCvTjW1oTAr/rA5slhSEbgyjM8iV72cFDAEVs64H7LJf23iH/f4nEKGBUuEOH/ayxNJ2O7HJ841TOx3nh/cgEC7TI1wlltTWqEHMZC/qFnSS3Ebl5L92QpSFJsIN9Dk4q+UhltOrScmNfb+akXCgAvWz788WogCbKg= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by DS7PR10MB5022.namprd10.prod.outlook.com (2603:10b6:5:3a3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Fri, 28 Jan 2022 21:32:27 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%5]) with mapi id 15.20.4930.018; Fri, 28 Jan 2022 21:32:27 +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 v5 4/7] dax: add dax_recovery_write to dax_op and dm target type Date: Fri, 28 Jan 2022 14:31:47 -0700 Message-Id: <20220128213150.1333552-5-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220128213150.1333552-1-jane.chu@oracle.com> References: <20220128213150.1333552-1-jane.chu@oracle.com> X-ClientProxiedBy: SN7PR04CA0071.namprd04.prod.outlook.com (2603:10b6:806:121::16) 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: fe1fce86-950a-4fe1-a2d4-08d9e2a5ae61 X-MS-TrafficTypeDiagnostic: DS7PR10MB5022: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: PK96djq+rcDihCPOkNuvhspW1mF4JAdOedUFUI9WZMQ/waLSI1CSAaR6nl7XyXqdpu2lXg2romUouNXa5f/ynXXHOye6FJ2RIHwbtJbjru4ySnKMx67onyDIicPaZDsheNvjxk3Rg/6+7y0s+9sCdvJFQXBplcaqKV1sVOHiEYq8BoeyT7SYxhJDiFiyW+sXvniDRSMUNieIAzeR8NX3ddF//zAagRYeo44WvraU3bR/oGcjcmTSmE5zW52E28wuuQ8drEjnKT+FvoW75Qt0ua3kCs882lBKiw1E+dt5VJaORPQq8jWSXe70JwURvVNtOKDUkFHIyDaZprA5xFeGRlv97JOjFmHqeUlx91yl5FJkjmK7FfKrJbThatBa24xfqIeCWe0hphRVQnerd/QcwZwl3VubyO2+A2mP4gFyPrUJ5t4aScZ31+AwjIG2OHP0+4WIJ5ct/r3dycvbTItGIsNUVDS3AkNssaogAUiLfrxV58Gs3iG1VX5HTDRNjl+Kp7auiGGKfHtG9VL652db6MsB0NVQuI4fJMBURVRelwd6O6rMIIp2zLuVI4lwADpkc23MGyS+oaNouzQzIvEppHl2olxeXB7OJZheOOyKpeUa0yJulTuHRuRHcbptehNmfRWyzZk5ACMhFHBoMhQKbAI8NiIQZHZrntpEal+m+JPS1eQfU0XtGvojkG0aJeW/X6nff+3mtYzuPwI2/LcDfQ== 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:(13230001)(366004)(6506007)(6512007)(6666004)(83380400001)(2906002)(8936002)(52116002)(66946007)(508600001)(66556008)(66476007)(36756003)(86362001)(6486002)(316002)(186003)(1076003)(2616005)(7416002)(38100700002)(921005)(5660300002)(44832011)(8676002)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0UZKwt7FFeJCwqgFGvwu8CH+xKKa8MCGu7c4nTKYxq3pWGv1QVBMh4yfMMUkb7z/LPrr2htBOQpTrIlNlSIE8DncALSYRVfLvCI595pffmpUtOjrNnWVdKIWZnj12Z8qvBOy9ps65Yop6mEZQWIKl+F3olWU7V4bSIHH87Av4kqfLiIxtn6APUmarIw4UVwGmApMMrIYnm98EVYApJP2hORDnEL62jMAw4T7OZIUwGwzQ5qkNd0ExL/SptR2s0ttgSDG0ossMiYh2z9wM5dYwP1+0vIplIMG+liWP8pfWSPknQ7oxCevcBrLANZ66M3u7UouhI1j3uzJIfjK9LvDI/P22GySDPu7tZHc3X0BlUdSz1AQprE1IeHtcl2uRVHRhfrCHjiMun7dO3qKOQf6XVHWoMXkICRTPHwXzqK7Tmsp0/xz2M0oQOI3yEbuI6GouOABan+y2yaNZayZQo3tBjMroEqKuWQaBCJO7bvnAAlumOdqbObINzjGq6N9WTvtOmtdf3oCmGRAbm4ylaYPJfyJuse+jD1m2jK99BmbEHP3sekM02DCvUymFRP22euCUHQDJxs6kJmOkJwQAJuXqkgKz5y++2WDHv5wjD35ylqafMKsZ7vPBPlw4VqHIkXlvCIZQcE/oCp2oO9M678+udXXlMv7i16zOutTMAHZAusbtwX3JxArd6L+6LehwRnnvmfuvjyTqgebGtUqKZId8mly9XF01MK/yFnV6AhT0gfOOFy7JoYyv50SaYSSch/U3W3c9h/A2xZ1XnJqQy0ehQGM49p6kk8c95CYXgSwzphlXECOTqd2uLpzFgIIS1m4HoDVUrmtXJnRHr804aePQW1ohyXtdlniNc+0ZURM2PsiQ15CoSqcdIdSM0rEeWIMpCjTWhNZM6uVs9aP909ybBvZy30zZeSeVbxKiwh2C28eKSE/ekncyECmcjlOt/paMTqzcrhV8HKksb2ADK7htPQBvJJfo+VkchZHjIsEfk4cEBrnO3or46nNWr5rqKWFgSkD706J+w3a53Dmq4O+PQdgKMPVJKdGdKrC9ZWCLNXBWhUrGTv/eyRgPH9ZJYaTTkUjoZHXu4uLcVELv4gCKENwNxlhpKqhr4hXyVSz3FftYdHhBvTlAuYJEt+UNBHd1jDpYk5VOSUOb0P57DbYlVOIW1g5euCFoDsBiEY7mvfR4SfhoFU5E4lopQy/iO4WiJfqDaYx3mzmpNu/6h3QO+myToIBuHhxwpTliqppqFZMat5kjUT/lNNS2Uri35ySJ1MjhRGNBwKCrMf1xrHZ9r6+KNizGPPhdfTyAzQIz7GA8K5tqkvUOjZPtvE9QOQUFxa3FLT0/abhG22fipJy3lGielSdo8PNDI2u8BI/rQN5bG0vSJ0xyrYuE6yqYyNzKTGPLmmw1J2oQZ7rJEiexX8n1khIUhi4EQvr6yb0vMCzC+PLrkdfbmBQL5XFNeCN7RivoJANcQi7NWw27Vcfxj500gO7fPJdm0cVKARFWxOUrHXKphmVwDq5Ye3X+p02OvaiajXTbSW7srFU8SGePy8gEF6hcOPsjGgk8vA4ciQO8xBqH0AjOWxCfmvfNG7BLQeUyvgY2fbRYQRJGvA37EYhwdkfzgUrGGeptdaqVzSymEztoLZTMBqZE/r+RBVm X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe1fce86-950a-4fe1-a2d4-08d9e2a5ae61 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 21:32:27.3844 (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: AI8qKuhZ9p07PVbnioYHhfvgwzzQx4xTRDIwt7RbHhi/UNc7FDpNpM3RiWVwDGmYCc66XN6l3ocF968FuQ8QsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5022 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10241 signatures=673430 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-2201280122 X-Proofpoint-GUID: VmCf48OGqgyb8L_4Ll2DzdWghemN1nFE X-Proofpoint-ORIG-GUID: VmCf48OGqgyb8L_4Ll2DzdWghemN1nFE 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 | 16 ++++++++++++++++ include/linux/device-mapper.h | 9 +++++++++ 8 files changed, 113 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 2fc776653c6e..1b3d6ebf3e49 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) @@ -43,6 +46,9 @@ 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); 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); /* * Check if given mapping is supported by the file / underlying device. */ @@ -101,6 +107,16 @@ 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 inline 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 void set_dax_nocache(struct dax_device *dax_dev); 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 Fri Jan 28 21:31:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12729112 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 539A83FD3 for ; Fri, 28 Jan 2022 21:32:39 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20SK3sbF028584; Fri, 28 Jan 2022 21:32:34 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=IlVxUoS+0RAUVqvl7jlXLvZ/rvrg0bhU4wFZAg6kFiHo8W/lpqivr1F5FJSCDCwDLN5L qxnSa5q8nWK0Lde8cujMnryfSrF+e6viPz1r4jr6IrIG0J9Ud21yW73cjHhlPgVxgewS Sh9Pxsy6UF64fX1XZPhoL1rrEjCXXYd03/2l+LvZzAWrkW6CxYKuRp0fgbtoDWoKONPU vdx03Dj1U6ZipTprMwo0hW1UimVSYtyntltdYez3Vyk2X6UdeUiFWuHaPiGX4rbajmDG S6KshOt2miCvw51Ah51bJWJ2oosCESuQcEXtbkBCKbcc8e5F7ASzubT+PUXjC3hWQmfZ og== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3duwrxmhm3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:34 +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 20SLR9Kl184419; Fri, 28 Jan 2022 21:32:32 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by userp3030.oracle.com with ESMTP id 3dr726n00c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bQv1rXi8Tm7dAdRJ5l+VqZwK9/T0c2kY4J5JLJYjzktuh5ewPTO90w8QYL+4vRAjvTlfFtvbqOo6lfr9inMj+O6t28Fas5v+puGWSWlqkK41vTD6GibOPdbPIfYMbb8ZsM/1xhXS41kTZwj+aiEayg25iqWUMkm+ePpQ48IpylSnb/xEtVEvkniXd/ViH3NFtYC8xlWubRwfU8RalX+vUE7f1nBDwjZNziuWuJsnE2Lpy0rfN8yZnaqcWkQtfncEZNfTfVj/OJxg48Lzz3USsSxcDG5RpaQFvDAQ01cnrN9wjQwKq/jms9EnW4oCLubhXJ+RrNPY5zoIRrVoDLdahA== 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=MKOwiYbAzHAWgw8wzyzQQi4kx+sZYjYV+1PIycEn5rNOzz9P13nSpMMrwPivPBHyx5YAZYHH+3SaerPk9uRDKIGWf7LOWp6TV+3enej/B9/Z1gbY67RRUpuvml/zm9QfnHr8L3/P0MhCr/pLgqY47weVj2aG8ekRrM8tl3YfxdMVytdveJ6zV7gNOiy9xMzK7+A32PO4Ly8yixB1LH76JreZYD7sFEwBKz6wnhiZPqlWqxnrjNOwJMv1QF2JuuRfp2BAKvWgmyT/QjsAlMO6ZzRkMEliSatS86JJQJA6HVVVH31+RusBtFe/GjEC+mWgz6JuXmpbxLUmPK4RO+wEmg== 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=a62GfRfTKqr6BtQsjIslMH7N7YSnCiPIalIEDonKP2FQRepVRLrD+g12hVnlQqfpVXeKVIpmDBSsLw7vXlwRatG4UrmEK6qyOAZOm2dL2PDbDQXdO7PFwu29AVLSmg51xxHBC1bUXpB8G84rWK4A9VKH5oDVCVwqfLAsitqJUrI= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by DS7PR10MB5022.namprd10.prod.outlook.com (2603:10b6:5:3a3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Fri, 28 Jan 2022 21:32:30 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%5]) with mapi id 15.20.4930.018; Fri, 28 Jan 2022 21:32:30 +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 v5 5/7] pmem: add pmem_recovery_write() dax op Date: Fri, 28 Jan 2022 14:31:48 -0700 Message-Id: <20220128213150.1333552-6-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220128213150.1333552-1-jane.chu@oracle.com> References: <20220128213150.1333552-1-jane.chu@oracle.com> X-ClientProxiedBy: SN7PR04CA0071.namprd04.prod.outlook.com (2603:10b6:806:121::16) 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: 021d91db-8d9f-430a-aebc-08d9e2a5aff2 X-MS-TrafficTypeDiagnostic: DS7PR10MB5022: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: VrRKMZdDtVdCRC0Ltz1JX46KKxWIIDoBj+4b9fCyC6npLlvRJ3w6vBQh1HNZI1GJkUEuNdpHxmS1IcQGyYRP5AgXxXmhBvWOdsQPy1QpU2SIbznCjwou6xpQkYrJrQ/exDCCykgJ/jCqtRHYurEQthighAmOH0YJ7qI/DVmTmPWQcsU5TNMFHE1Cojla90ft0BjPAaFqbFE68/aAeMjEKXsacTHMKUJdvnayRZ8dl5lxWzY6W0pG8wbk2MA1NjuhhGgM2GlfGyAE3z/P49DjxdbT6nd+zgojxIKWyHjRHGFxDvqQOIZrNYi1LdXsGatXH/COr5hosNm6eXsNsrWqrFyxZwSNLkzPrpl/QsACOrdTpTPPrnkpsYAzeq4+QuBS7z0C0gxoAdQ3IYrnCDveqw4MJyxgDxvzXnizQXX7/7ZJawYd6hgdTS9TlQdX+37IBSZcOag7dd4X72VAKfUP1HfU994ty4GUTX8LsVUBro1ocY5BnUEDrj127HgBpjSI31y+4I76h8MImDqISNxJilmvihGxYOZmbLAZhRPz3Ts7RumqaRqnffQNutooxm5Me9VO9geoLZwArVsniCWYDaw0EEKXR5Blqce6O1nF32QouwCvwz+2UnaPTGs4XO8CKiQPkxCEX0uwhgbzM1q/37fr2xa/q9TxHyZelBNdUhdZaxkL+tDWXFQRkEBfgTeOCPRgM9GvZppTg4nkyfABWg== 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:(13230001)(366004)(6506007)(6512007)(6666004)(83380400001)(2906002)(8936002)(52116002)(66946007)(508600001)(66556008)(66476007)(36756003)(86362001)(6486002)(316002)(186003)(1076003)(2616005)(7416002)(38100700002)(921005)(5660300002)(44832011)(8676002)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dn9JKSuYRCoR534ZVZE2ZNC2DxHSuqE/qCKJCUhCg4DB5W0x6sB35XIaCdGu6AVEcu3+VjagJ9eWq63M1PiM5z0oeg25znfKg/8F/Xkkq56Ngs/kN4oFnDt5LBjOpgti+oCNmCKORe8lJmi9okM4N5acsnxRvllNF8V2m9xrKFXxok/tEATjuYaKWmVYHDK4nG0XcPLT+/Ly5IZDwqt38lju+zGIsUBedaYWzH+FEO3kMbEztkH7RB5bCaid6ketieaO7tnwVcDTDPspdr0Et6LjenfHWP2N7MfWP5+XE7CMvO7xTYsY72va6z/jtpERwNMub/Ion3lDSDn4C67eGpNt70BpqVaV3DN+v/3CcX35l8S04Jyde2tocqmcw+cqwHlti8fhoeR1IurRaHqGi/TyqK/IFWCXoLyBFm9As7wsuWik6/0CIwbjo8U66W5M8tX24Aj7bS+riiYfwIJL0iMnukPx7Ssnru8fL6OiA9MRgnnvWop3OT9BuRuaEKxz7pbRVC9BdYo9xlqNvGWIG8YVcAB2wnWPewa/cWROqSBmdrCTMsf00ihHqBeebLibjKYBRGEO3DEudx4tmVyVoK4EY3CeAz+oh5HMwaQpIo3g+gqNj7knPMAwp/sd24hgLdsEsRqrJItdC5oKIQ8omBHsLslNGW+Bx5+teouFuQ70PnkDrrRjW3TqkSWjA7f+1oKjBAqUbQ6UZXOVycs8nFkhXDg0YSL4ihux/LU8fhggiu9P+mG8KgjulAW4dlZ8I2pHUypbfvMjK7VYhYOxAkss7Dbw45iRr7ADfbA/zpgvkOUV0HbYUxXBpvrH1EyMTCjhUYi4ReCy8LNiEDOpSHGvr/3Ig8FmzKJsMgHTefR1yCcCRQ0O+W1akZAgwtsdHJEjZ4yE2uKZe2EwdckSl8ZAEYrGKgQA0xjXfG6DDCWhOM3BvwW6DqynGhsajRJVhUFCsikuwoTBKTx+7zm20ANWVAq3lhEMBcuVbCzP55vQGtkVoEA5DFh83vU9oPmaK67WBDBKGGCYbl/usPu836YRmohDpSTaH6WzeTr0nm2EhOc16NURJT6OIVXyNFyTPcnmErFkY+/qwDohlaRbGkmFwCMpnt0L7UA3SN/IonJg7CfLSDb2lfWFqwYS9g9cWEV3Auadk9gnGKYg0CQosaUaqVymtdSxM7n0+Q8zSNHsIgqWfuQ+boLP+/Ie1Gb+nxulc0uJaUwYMXVOt5yZVFTX2jEfJMse3Hkq66oNGcrcMgf3E0SnMa4SawNQ/CXD5wjNuYiw5sR/CeuYWbe95264kN9n4GOqebMVNodE0GcL2xzwMcvPabmlS5qYZioXcBmG6Hqa1SEJYaMjIyd7wUZI4uZvbf4FRpxLccvM8IItGoXwkcxGDa2S8ewhLMJcxmpYse+vxNNvBSTZqvP6xCncJM3t8bbEsl5nxDYJyaMCVAGvDX1E3hXmeoi4Xyg5YuBeYUfS1j3+cU94azEyj06FqT+jmvMVBloHXAWadgweqn3bkQT2PDiExfRDPD7Py6Hkz65OYF49sA370O4+xdTKX5pgb+aTs4ZkJGiL5gpeuoZHFSNP71wfhmUNoZ3vsAUcnqiZ5WD0Ezpz1OlqzJCj6MR45NzXAQniWzgQHcwrAIh3TXhRyg1pSp1m26OA X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 021d91db-8d9f-430a-aebc-08d9e2a5aff2 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 21:32:30.0284 (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: S6tAy222+JoMXuaPOJyz2BmpA5ReQ8T5iRBtuZrg+SOYD2Py/6g+Db5078wxY3xWl43Q+rsJla3cXjm1qFCCeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5022 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10241 signatures=673430 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-2201280122 X-Proofpoint-GUID: pfHzixXDIkZRc-QPo8hc2oFoRLFGwbHJ X-Proofpoint-ORIG-GUID: pfHzixXDIkZRc-QPo8hc2oFoRLFGwbHJ 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 Fri Jan 28 21:31:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12729113 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 919A13FD3 for ; Fri, 28 Jan 2022 21:32:41 +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 20SK3xK2005724; Fri, 28 Jan 2022 21:32:36 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=JQjLNKe/MeuXEMmdmI7XbzuMB3oDnownzsySReyUa/n1suxlVy2NrspwxSFj9ClYTxsF 77R9fhBH/3l1Zt2g+DsfRVmCU6su6b4/z6GZPSVD+s+l5CTkJOGQ1AMC+GkLWt1dxCxD ERQX4+GT9rUT8Cfpf5JVRQCsaVnBaDoArkifdcmH2YkgKudeRwuFCN+ecZhH+UQvVNdZ UJuVTG4x3e6nPzFJYW7UADKNuj3ooBYhHRTotQBWp0w6mcrTxnA9OWXSdKz861bH6e4g Rn8Lq2UfCyVPjxhPshc1l2nE9nNeJAJbIaSar+d2Wymusgp5TJ4/iuh6uIGEbqyalgMb Kg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3duwub4cvs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:35 +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 20SLRAqG184491; Fri, 28 Jan 2022 21:32:34 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2176.outbound.protection.outlook.com [104.47.55.176]) by userp3030.oracle.com with ESMTP id 3dr726n024-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zz/rEBVYNeVeVqdkFJSRmaCxneBdAG9ZtgqeHbcwRvBLgnRc098ezZ1Xoj+SRN7utfijAZcpELocPxDTtMmWm2W1FFdaxuB+ZFaQYi/cGGytl4aL5vOq3/k0AO3M+0kyTpIf/NAW2weHNNGTOi1nWMstpS7PGw3Fg3H8VGrtx35DNnRRoeYk82GjpwQjlKVyN3cVKllnGIhLtUbXvx51rmyjQKPlmbPufaZuQo2xVQkrgcyXi5xkvb26MILKo+iOqaC855selMpayTYjvQwrJVR2w5e3FlkJu0pXNvEyWzWkbwA3a7aK6V67MiLjmThgje8ngN5OeMW9RhehcVby0g== 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=CKO4oPXyS9VtwiyXlVxGYYOMc1tM+yN49z8fHIONuEtdBJ3GEpG616/vRXTBbVr8LhcORdzPTYa4pWpSlrYaSdyLhaRKmiCOqkezWmhtr32iR5tknkYSb2JRlh48xAQNY0Td7ISdFkTCJwkxnHrTro2HklS06vj+NrOV76/+8OLQy13n+2lvdlonOO6DIdV3sykHJCbw5Ea8MVzO/jzwtCk6QpzrVjrltKsMs/GNbNlrPtZRfumyuARzq+prIrLSNTEtAH9pz0qJYM12oAkZUVoC2KfM4voOlV1og70NaEtEVt14JWYjk3B6EKmoWlNeONTSA45Al4HV61YX8ipyOA== 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=y5EgdOQ95iATwe8DuvnU55oxBfjiHMqEgUzZxp63fVdYFaNgOPCyRN0RvI4Uuzd9zRXwA90iW5hyrd5Nm9/9ecXd1+XC/x/mdrG9tJxuAzpHDXoQzJ2fAz8mUrx3MaxHWfMbnQbtggdQyXNEjRgu919eN5vCw2S1iyc9WOC6OUg= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by DS7PR10MB5022.namprd10.prod.outlook.com (2603:10b6:5:3a3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Fri, 28 Jan 2022 21:32:32 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%5]) with mapi id 15.20.4930.018; Fri, 28 Jan 2022 21:32:32 +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 v5 6/7] dax: add recovery_write to dax_iomap_iter in failure path Date: Fri, 28 Jan 2022 14:31:49 -0700 Message-Id: <20220128213150.1333552-7-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220128213150.1333552-1-jane.chu@oracle.com> References: <20220128213150.1333552-1-jane.chu@oracle.com> X-ClientProxiedBy: SN7PR04CA0071.namprd04.prod.outlook.com (2603:10b6:806:121::16) 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: 735031a9-4eef-4c8b-24bc-08d9e2a5b18a X-MS-TrafficTypeDiagnostic: DS7PR10MB5022: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: xHUiZFZSvrvzTECb8svQVbU335TU5NhA0EOPEucoiEUcKtROlsxHYW/G2+yiTPPFx8TRK199V599pc3+vRCKiy0L07z15IbsqhalW7M/o5wHAz9jHQEtiBFk7sBSCc/Z/cMzZ+G2bEMwPxuPQFXVf/R5PUTrcij6el0aNoFYknzV+QWNJToaCh1Mst23UzL+KL16mtwHQ7OfSR9Dek+1pmPWl9kJBdY9qh7ecATbjLXb71DFa+2k/vUjbTaZsBpZXXuNhrHzwxT5U/RsqoNPrrQqjnO4g1hFEIVZKZvkR/fBjOEdt+ZIBfnMzDvnOzdpavpRpNKnzV/pkpHUq12LlQQCr6MMf8MLrD/qaOmTRXdqwckqBZxBbQiSv7a8oMtG5m8D7hTdPT2pRwELCvQxchBDbEuQ+QXZo3CBJWR6w4/A5YpqLX7Ksan6YGm0rwWS6pfpzYqUESbkTKvduo6nzSTS8Aga8pyBDW4+7W9pkj0BCXZuhqbKmjdr2/fVOGol234tbjR1vCkc5RBm+KLq+8KxoNZ21m6U96CuR5zU/589SlH2XMZ8oDbBbrVTWSJMGix/4IMDyOs6/1w34uRJTCiLnqtpN6YdMmjJLslYgPyU/uSU6+clu5LXy3NWCkfht+8YVt8JvLlTnt0EmOxG9c1v2X5HOuy8kjgFP2clxbUC597mkXIRNn43s97nsE13ZMrKKy8IN00xlKkFI+RaGQ== 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:(13230001)(366004)(6506007)(6512007)(6666004)(83380400001)(2906002)(8936002)(52116002)(66946007)(508600001)(66556008)(66476007)(36756003)(86362001)(6486002)(316002)(186003)(1076003)(2616005)(7416002)(38100700002)(921005)(5660300002)(44832011)(8676002)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 34kDvhgJuealC8TDJchq52Qc62r2OYvSaEEZx78Vt3eeHZnIDdKuL8s/n8Stz244tECZeO5oHkB2cxXnSKNo2sbaEYg2XjbRc6XKQVFJ17kI25VZeaj/kyj43LDz7llU4ZA80BbLrd+8hH0lv1zukarsVZ4W1mRW0oXBVXXTWpK000v61Uc3SMIPIJPg+v3a4BZOI/r3dcFwD4mMdxI13g49RR2HkhK8LE9YN2SlW9es3W2WbxyaGN9bVtNPuZyfLPTNkaCn3WFLRBTmHd45X8Rf1MCn5wKNGHYD5qly3ZLtlufmdh8mvs8SPxn3Ge4nlCB+pdl1olxECXBwMnt4csNTpWzxLiJoAKJIfLoUSe/Xit0WYLarcoE7HzVLE3lcCuJ8XXSrnh26MrgEA+oFflkHwtoHCFCIXUrSihATeozJISa3jQpfXKx71pnOZ+O8fzgDDKwRT6cOqZW0hV5RqLFmI55oIzp7CN8VAm9pMRB1NWyOudI5c6j8go/SPV7ke9wZuLZpmliMj8db+2P64O/eQuqN1tRFvlmw1/k0oq24KSb429q9VgqlBiEvdYpOo4vdLfpJBHu1aP0TzmJoBHW2BykfKTgNPMxX6lA2nQkUXb57RE00VL11o4AThYf7DQB2VClyCD0ZodXKxTd0bICghxMOuyptt0/8r1oa0AXllhpt1GDUAhCQoPDDWGJvP1NDlqJoMU74toVsMpN+AORCDQBNkMC9EEnQE07YtTmfY7F37OCTuTpN5lsOyh+yNxwP54tOfqckGYYeLKoueg5a4ARxdS7WPHOHZBz4dKA1qhOIZBLJV8DDgycV5MTZLl7h/1gX9ocB0cpPDYcBU6gSFT7YbaO3pao31pFkkZjd9D3FDVYoPVqonJ5IT2hx690A1gu1/B4gujDpLjw5w81nIhmXzwHpQDDFYZyMw4g7x7WO5KJ7XQqoJsUxPlWCY/q/2fpWzCHMKqGu+pycMJSx853C0pPem/JhzwXo11+gQbxsAp5Tt0O7uVMFq8mvOmuApvWEXqsmWfWHdPDpHOmxKhkjebrQHUEScLXzuWf1vE6OeWZubIF2AdSA4TSqIedD1F/NnPcQtfMRniWW8fudulld5lJoL/rGHlIhngHY59CebrA49Z6Fhxl7CVn7bov8yCBEXdMSS1gt/u/yXkMcFiyjBKWKSunxmwITiJ1Xnq85yDyD6syLujR6vy2FUBIvLeIBO6cRxcXNJRb7uBbXlJbvkmtejdBPg8k3tGTGUDBzhPZ94tXAXITo+dl7/UJrttHXPEVcHFH9hb6q9L9Qy5sUgxwQm/Ub2lZI7DY3nE2o12UKUP2yNVQxDw4cGTDEr6ArRS9tcqOiuRSNxUBTapWW5VBtdsov7pbv1cN49bv8Ztv2G0RqIjViCAuqUkzumUzuYvdwrVgx/jvgkT3FFTpXjQ5tqraFAtz98gQMBCNZs5qIOrwWV7NAmQcerIbHMuSpDVxDmrz4NZ1v0J/Q0jQy24d2AxNVkeAU0vIwqUT4x48zovSEhoHLPVuQikqcpzPvn/iGJeUmtTlmOtQORWJ6V6g2AoR+w20DEElLiQn2AWc3w8twMtm7aDYmfZC5UHKt5JHwvP2cSsQnRS+//AoxBoZUi1H0geZQ6z1h2QkckUUq/3L7yfSaO4eN X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 735031a9-4eef-4c8b-24bc-08d9e2a5b18a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 21:32:32.6831 (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: bL/L5hP8gAtm7qHotDUVO9CFj7Uoo0M/M+xsv7x6H6B8/Lhm9LBu/LeQXYCxHo0ojeO6Rpbs72c0iYOMf19KDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5022 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10241 signatures=673430 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-2201280122 X-Proofpoint-GUID: UZwckryaTJEVRlm0H2FJP-UvsoJZYcC2 X-Proofpoint-ORIG-GUID: UZwckryaTJEVRlm0H2FJP-UvsoJZYcC2 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 Fri Jan 28 21:31:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12729115 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 3740A3FD3 for ; Fri, 28 Jan 2022 21:32:43 +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 20SK47cf025842; Fri, 28 Jan 2022 21:32:39 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=X/Kyz8ddmvxkwJziF7x8ArpIVmLa/53s0n4KJa/zT+Ldz7crmmvTaQ9Vt/Pq7vjbNQ5q VCZl30xX0HD0tPVqBWWSurR6FddA3JrBxuxcoaklQrHPetMPbhVCCeHl5MqbC2LkTZt7 XI3LfIuLCiAoIqBzqNLPYLl1YB4TL2cp9PllsKw+dqFNhJINMJn+jiDk08ZESPqd3uWI ryh+IVCIYVepJdLc3DYzgN4u/p4zxtKBcAuLAWTOdYuj8HzV4XdMAg+pKLLJc9w2Qgyl 3iLTMSjo3cOH39fAceY1A8pYrZLff3qBvFytYFOvVfRq4BNNdbeHJTEjqUEQdHFIqiRY mg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3duxnp4224-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:39 +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 20SLQvDm134966; Fri, 28 Jan 2022 21:32:38 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by aserp3020.oracle.com with ESMTP id 3dtaxd6uyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jan 2022 21:32:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lN0A0U52s8U2fCGpQ5/XltJ0KP0oDGA6w1CwXqcm4NBX5iEDPTYp51XAgWCpLYcHLaqKd+ZCeAFup/LUB/xLZB48W54TBh9TKZjxy/6qhEKYA3NQruX48KFrhQuxrW7r1SRi20tEOFf+GpdjiHuysIHrQyhg7vmkE1vUlPKcv4RX5Va0wwvM7dkWam6PHTRoF89JOh6JXe8uSqbqq2/FOgPyFVaxZJ0uvsQLISk6mrb6+PF1ukDbK+xCgnHuV4RYcLpTV8W3dtxl1MvimeAQbKXwONRbEYc+UCDQa5hhBW/zpdeoYD+MMJasT/kc4VuGTCWWOPZtIxBvWIzJxgXyRw== 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=GJdJapgV92T+/Ta6sj77lAzFwEQ9U37JIzRE0LG1AWwxvoGjy2AN/pX32/gpW6y4Iw5CS7djVqjfnp03X2ULtlTJr9QmOvTlKlQbSHqu+F5vIQf2bPFChJ5RnIEGDS6J8VDp1Ho4i2aNDWb3bxY/m6KnPy/Mp06/AapTCZ5tl2KEnA4vSh0AOqkIllbxFHTduUbjishp0xlE1klvIKcSYa2eFFdkbUZL6ijt+fu//scOMrTQxcUyp9PNZ/E5l9CbUeqobhVSBD2ddMd7e6VaAWcdVrZntUkFuR4S+aiaaOo1KiXRKy/w9VmpjbgJ3CKtyK+XqY1lfO39chLcOPdB5A== 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=hZ/AGsHfWLRGlnnvYmTzxBKWfWrnQ5OhGhKWbyZyxZUAY3rSeXrHN3FZHXb0z4Hz2NGkae/HDoF2SLSb6oGgmCulmFrumbybTTNwUtHEUkS8gJYI7K+XwASdfrZOJ/P1fkGBQEFrs/tGFLiGSnd1cvj3lbvm8FgWsuI/15uMp+s= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BLAPR10MB4866.namprd10.prod.outlook.com (2603:10b6:208:325::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Fri, 28 Jan 2022 21:32:35 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::d034:a8db:9e32:acde%5]) with mapi id 15.20.4930.018; Fri, 28 Jan 2022 21:32:35 +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 v5 7/7] pmem: fix pmem_do_write() avoid writing to 'np' page Date: Fri, 28 Jan 2022 14:31:50 -0700 Message-Id: <20220128213150.1333552-8-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220128213150.1333552-1-jane.chu@oracle.com> References: <20220128213150.1333552-1-jane.chu@oracle.com> X-ClientProxiedBy: SN7PR04CA0071.namprd04.prod.outlook.com (2603:10b6:806:121::16) 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: dad539e7-1599-4904-a4e1-08d9e2a5b332 X-MS-TrafficTypeDiagnostic: BLAPR10MB4866: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: ZltUfmli/SEkiU2MSJzaOXcUQ4q90o81k+T3l7wneDKvnTveUU9cSG+A4WLDMAc6EJzZmcnzN/oXonRIssVReJBr5A3mqsB79NCHm0GAXIrclw5y5noZrBWZPvHCG5bKeOXQmpbv5l6PJmX+C0GQ30m9jAxy0XBSNj0NMlsz0Nq3Vd//f3z4dYxyAE29k4szd+OhrWKACd5RksAyzAtcfvVWB6SIywXNEgcH6LhnLBi1P8gtBE+FOORqDADqMf1pE0bRSZz0tGCa2Rg4Pf82f8KJDAAskF/731HRJkZIx7XbPOvUjtp8YuoKWb4sYqMeApiFQcxvzVmktW0qZsYgiWPPiNZK7A5WgXH5oi5kf0N336PXou5WuFXcqSupxUxOtH5bjln2U04I9kpGdclblNUIltc9k1jzzt0E7BggIFEpQIr9JqgLt4OdVPrPjY3xlVU7rfGpPwr5F3DcIbd1Xiqt1wgvh58D/Wg1gA+PHiy+EWuibO5WikrmQtEEYjPP9rOd2s5IQoZo6I4AG0MjqXwMzscHS0W8Jza6MXxfeDBTI0V/Xr5ZWOmiD+kE8IiA8KJi/bCV9OUTQQbBA5/94S+LIUlHZH/IwOcJlJeS2lhFt5S08i92Gr3lbG1QvzQUgrsgVtLHoBUayPqHBbmG0s9NhA8dGbXkKHuSX+nDGZOPwN0gqTXSIfLRjsSs4YWI9eL0udqgYQX9gtiSgCk1hA== 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:(13230001)(366004)(921005)(2906002)(2616005)(52116002)(4744005)(6506007)(38100700002)(44832011)(36756003)(6486002)(6512007)(6666004)(83380400001)(186003)(316002)(7416002)(508600001)(86362001)(66476007)(5660300002)(66946007)(8936002)(66556008)(1076003)(8676002)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LKSxtD2WWDXpkHIMbPhl3U83dMRp42GBfrsUp/BY9mwg2ZIAbfD7lIZ5r7iYXwG5zBuYLwyvu+Aht4E8RWvpDzoNq+cDED06c0X86xPsLzWG006zk0EtZw7mrCa0xWaDV/P/6oRmKbyqoRM39c2e/Q8WvQv82XZCpjJvaT+/FeZWtwsNWwRfRgN0gyjGR6b139izkNaFcA8SGfCdC/qGb2BQ2LCBImLn3P6+F05UwDoycxBCt7qoDYZVXq+9vgq3L6/JIVx8Km0lG623/IM06lKprk2WbbCEGdraLU2Y2ZPWz08m+wfmmGsbW4QdmLrxtJ4IroAi9eLmioNtg04ToHc3I3yjeszCGDKGqMF0ePKegV2/jVRglb6TOLVNLxXN8Zpows6eeHqKX0H1qfyD7wlGvpWAka50MFUQwrz7m3pRK/uF5mUYQJUYMGcJ9udL6UVMMVkkccgA+Ced0YyZhOhb1h/tKUbjUi8hEuqrIV3hhLYDLZ1eP9jniSHD8gbPQ7wYRoR71khsDuftxgz5TA5TMBgU/jnsQQQQSC52/QjOPWZPH8nnAcb95wpXF04N68ffTqT9IN1LRofRhvk067XxZoyP9e7FgB6n8i9oyfloYLLeZfNXF3SR1KjriB/lVaTWn7rxE7Y+z4zNfEHJR0ixFOcyJg1k5DHVID0+ZY6QaPhGxBAyZMRFW4GzM1qeUN2NnW2b7ICuo4D+phBAZlui/4ZhIYNnHJCqOSlQRf7nfwaSvVLAINk9yaZ0vQKSJaVwQ5yEGyuvLSKRK10ijdDt3eRwP6gBkUz7t0SC6v25VcKEAEh9tmtR23lW7H1A9Myhf53Sfpl7rPRkg8rJ5RAyRytmpUzS5cuDNcjIauSJ2/IBy3jyxZXdMhdoD1yLN/vdeYXdKABR7yVgPxCNS/uIY2xs4TEc0P914y4vznna3cimb1dM2KeqmWzvseyKh/IKbsEmItEYt1mooBAPLULzJWBEnOg5vJEW/cnX+EdRZ9btmRvGJCjHtppCU/ulTCHSSzuWXnqo32vT/cjGgDeF8isa4mH/ApuWMiGs/Wzz2KktGTYpXTCY4Xhd0wjFPztp3tK1YwWaE+N1F81x0CQrS4Eyd1tzh+tLWP4QR9+mKLMXEnUcJOu+WiP6j+zKDUTcutZtQ5rhQfa4ZKj0QmsrxGDQ2NSTY6aPckQxM+vxSSPJAGys6z5n1NSq46wld1kfTEu+3fheIG3BrlmJyMglIRfAq7K9Kb1G/NfvjYxNGsh5dOUogcQW+fpwJ6Fj9YryR4c1Rv3flZVOx4LL5QSRgTervZyaQR4nfa6PHzeVizMEkmBsM/i6OmywHOkY8l+66UpFv6JXe1kG8HlRJKXIvwbiHvfOGkynYZOsl8rGPob2rfQl6tq1qjQB+9kXFnLo1UhuJCHcpYMw/3ZMkTZdIn6hpHLSy6nv2BEeVr90DNdj0nC9oP5Xclpr9p+vMDEUd7peenePi5OWqZkESLBCjioi0u546IOalh6QYZzTHQUJY4Q2hfFsa1qekSPvL5ZBbpz1zEe0+yyIjHF77UBkDdlw5zoVIMa164zx/yOAKEbRdQlie5hHW8elTsWXHOiut15373n2pE9ZbZXYzgmRBCekWrzW3efq8CzZs/Fc2MR6+Zvb2kyut5VqmWJk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dad539e7-1599-4904-a4e1-08d9e2a5b332 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 21:32:35.4963 (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: PIL8+19nqU/qKas+8j0GNk/OOHvh4m7rGoWdIOol7pAa/bfJHEefGhp5nxT/4rWZwzedFZPe7e8Qnh1H0bo06A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB4866 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10241 signatures=673430 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-2201280122 X-Proofpoint-GUID: sMkB169Skh_pr8g4gZFJpHr2jWlnLt40 X-Proofpoint-ORIG-GUID: sMkB169Skh_pr8g4gZFJpHr2jWlnLt40 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;