From patchwork Tue Jan 11 18:59:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12710383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0521BC4332F for ; Tue, 11 Jan 2022 19:00:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350366AbiAKTAZ (ORCPT ); Tue, 11 Jan 2022 14:00:25 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:19258 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350328AbiAKTAU (ORCPT ); Tue, 11 Jan 2022 14:00:20 -0500 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 20BI21Nh014936; Tue, 11 Jan 2022 18:59:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=UXtfIKwkptTjTLkC/HHXgr6CT19lCc/Qyppb1ppyxFI=; b=qr6R+8Yw1150MDTDHA3hUMAGHUXjFRXzRDTNJ6GAhOINYG8A21eb95TfCOt9giBJS3Br jCQS8cVi8LfDHEoUuK5asTHzPIBL6O3PLD8+H/ctb18lv+U3gM3XB8A/xwKjEEdNhRLz coQL4D0Wy9Oqq9F9U6SgK1o1Jho/IJz/PAQmJQcmNbnBNi6meqokG8RaFPFH05SstCf3 SY72rAU4N8swmQxhlROdbo9FKqfxXpZHN/dh+Ex6EqnVx8TtMRV1RZ85vnG05gCy0lKK zhAMoH+x1Ok+IIHmY3HZ+6vDOxSvw3qsGgjR99AKxyDu6qaPmWBq4eHH1EQaJBRIG9S7 WA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3dgmk9c20s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 18:59:53 +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 20BIpcm9110933; Tue, 11 Jan 2022 18:59:52 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by userp3020.oracle.com with ESMTP id 3df42n7d4u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 18:59:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GK9ICO0ldsiv7veOkz1FJEsu8tXPA6yzr1Ee907poLyic+HcuuESShZLu1Vbi2o93DEt9Kum/0YkNOh2xSs8HUFpZY7ewu82H0IvVkcxmH55pKlDWYXO1W2NlfLK42qkOp2+GftYBj8ayEWfyMERWiE2bMfSmjrSdlvUtsA25ioEHEdG2i00iAy7KufCbzN4rQh72gXSpWtnVJTX0eoHJcIcOugWT52QZI/hcMcUDwdUvijcrkrbg5/dDRTUkypPt5OmgUhhOEOci3dVRvdIijZsV/el6LKzlnOQd77KQJiGIvkyxm6eeBud5Gx9VIQBudcMG8zSBKiny/x8Rual4g== 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=UXtfIKwkptTjTLkC/HHXgr6CT19lCc/Qyppb1ppyxFI=; b=NCGdYnRoNsO6Yh2jbhJUno8LX1UHfK8z3gNAqIWArDmdYgNvel5jQu9a5CCPYwKf/uQeWvh5p5K7tQVK5EjBP/60JPAOv5e6Pd3WfFEHCvOZ5iX5NXhsRn9mCWFQfUPbVUTZh24bT4xfqHpWV05DeN54MXll+v6AhX4HzxJ8ojgwMwruqg3WfI/w3vAnk/HC8ZLe7oMeSTthW9VW/WGFxdRcix43bwexeW3De2FC7FxEJnBvM0Pzv3gU0uNMNcSU7sw/CA+ihGXRgLDAHlAuJ2nu67ZnMBpW39dT7vhZt6Z8fw84GOr6s/+/VRS/lZQrvcdin/D0WBim+sRp3oXguw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; 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=UXtfIKwkptTjTLkC/HHXgr6CT19lCc/Qyppb1ppyxFI=; b=dLigXDEOTkFIriO9sVk+7aeVV8S/v7/j2ycIlMgfxvj1QyN4v5c2Mpv88BdgbFx0g2szgdWQuCYUR9FqfWoQ/JYnmmmr2OZo9X/FWivCE/eXc5HDW9eTFKJNrdlCSyM9Y/9hL7DK/K/wfkB/WhjNXPsyOorkvOYuIAyXwoH1o+A= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by SJ0PR10MB5647.namprd10.prod.outlook.com (2603:10b6:a03:3d7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Tue, 11 Jan 2022 18:59:49 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071%8]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 18:59:49 +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 v3 1/7] mce: fix set_mce_nospec to always unmap the whole page Date: Tue, 11 Jan 2022 11:59:24 -0700 Message-Id: <20220111185930.2601421-2-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220111185930.2601421-1-jane.chu@oracle.com> References: <20220111185930.2601421-1-jane.chu@oracle.com> X-ClientProxiedBy: BY3PR04CA0005.namprd04.prod.outlook.com (2603:10b6:a03:217::10) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 31df977c-208c-4ed9-63eb-08d9d5348aec X-MS-TrafficTypeDiagnostic: SJ0PR10MB5647: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: axuuJKQEwI+ofLgGZ954h3VMMtSYhSze1cB5XWJQ/XDGTTICviSnm2VsdVuBczwP41s+2dWawAQ8QTpnDuVcjxeN7rVAlNwDfULpotZN8Ea1pMMG6A0XrZrCLiH0q+6sTvRtaF/MCfYf0VhiBSDQJEJDJX9zM9l/uP5KK4zqGfaHgeNb2c8h4mYaQt0YrWOsRdAlNWOeI3pWkzYL6+5n/cdt+CI2Q7GodbGxOgP/9YkDcF57LMYwZEg95iI/f+2VeePdZHkzdjpTCnyLxmLA5Gyjy82ODr9wbLNuN9jniJNLDVSAgf2bj6ucHT3OyEQ/BrVkx0sbVwTt9A0hppHtTuNKOOa3aYwjcTRkur6Lf/dY+zNdWAX+hTacmKyvdJRIamvYlIIehWwJNnoXfdBqVvC9yAlvdv1qMcC9NCnYkjubmQthAOR+51Qzt6jwATUJYUQ9UeUa1hjbo+1NUvxp66H0lrjXm9RPd2ac+kt1k4t5OR8V6G+kRbe/ylJxxZEukGY0qZCmnNIhFC2cu5c/HfrU+CwSjfaGRkpvH3x9eRuBoq8srI3iRNPec+KRzFuI5R2Rt9QkuVx3YcLPqqdjP2p+1JBOQ4sR+jdnCAUxtj2ujuf6/9Y/i728jeVhP8qamXaHScDYTV5nKxgLIIzKmOwJiR0gS2wvN597P3wwO0qDUghzwOgLMWs99TtxiceJithnoFovQ7thCWwbBD9hQ6E13CrEZIwKPYY5DxZhDHSHH9Oy2zwSsuXBMoThjzVOJVbWxqGKQB0RzTBAoukfBA== 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)(5660300002)(66476007)(508600001)(6512007)(44832011)(66556008)(66946007)(86362001)(83380400001)(1076003)(38100700002)(6486002)(36756003)(316002)(8936002)(6666004)(2616005)(966005)(921005)(7416002)(6506007)(2906002)(186003)(52116002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KZ0iJsPdZqfnbQdW3Joj5xaMrOvwWwOWG+uoULkanMpwTVEiGb1mefMNkE0ndBuDXcMAsW5oxRkyXMp8XU8O/p4kD9tYResoWpHutt0aghNpLNZaZS2SjtOmP2BPMB7Mj5EeGjrEA7dK+KJwOAvh5MsygDtAA1/yVbZd7gkhm78044Vvkum+TlInbZQRbU7ljm4+5soQY2kGs7atEFF6/3UTnodQWncj80CV6xA77a0Flvci6vrwdEYL4smBiDpjpRTohWx9sAcFgNzVj5Ex3TyLvHAzeGaQV5OETEXT7i0SwRFteQ6NiGApmATFfQVF82pidUoijwkvgGabtf4YzthuSDzaR1vwFdspZEqjMbWTHo+7RXMWSzDBTPM5Bu2ktBuXYtToEo89EX5n/THZJ1xREOREThieI0Cn0evUCChe7MWcZOuLjfNFJ0OZu3Hpl09Et1IYJQ169LoKv2BxqFsQR/KYMv8iHPJVAzb7aNwKxk1sWRH5BRJGTq50otgxOlYHljK+9gHQbQAt+YdgdPeGN28StoZ30fwuOsFapZEfPeE0EeRibhgjlcM+SLoQjXLmYDOzfMVydEAgYezSezCN8zkM8bLw99fsF2I0ak0eu2cG9ZsvmWzTuCVM20tjsP8fFkWrxYXYoPBQ4P6vihrdQvG9s8aVIJUltbWOle8gePX1Vu/CNPaNMmYWhVMz5IC3rQ7eFYyJ9M8vLvVvx4cNMzaFbE6s4f0MlRch9/QMP/jaaiMENvHmTG2+01uMx9u0y+fAxPKsZmh+KwJLk/jhX05aLKRbHm4ob2uRAcMletHEX+sJlYLMz0hrv8Y3dugI9MW4vpNo4kyOVf9UqfQvoty70n3SJ2H+2R5TDWeEEPglgAbqWH3Wevy4pQdLPRWp1bjINqmUU9kmpLmy7veEdIOatOkQD2pd/y0X62OdPStvVtMOKfgesO9epdvHZyHMiVCABujI1lIxpxN1rUps+345AfNz/b9yy0N16k/bjkq+Io/YqAL2mDRT2MnXvuAlQybgTzXaxFxfUvfmaMQkwucT602RhiY7en7btvAD17E3WtPiF6YoBPrser0oweG03GVioiNindowzGaJnn6FEyNUg009vPI/qPa/eCd3avckeJq0Jd1/GH5MJ8m2I2XZFONXbaX9pZ+h03UF0hggPmisUeLvmwAgXhmzWoyowYBTK2bZKZqH4Ew/KUdR/MUCemoVv/4ZPc0VRwnBBR+gWnOffk0hZwxG0mbnmQ6SoDoiwa5QD4B9IDoR9qJcN3ZT8x4Zn9h7ZZJ9Qpf1dV1UPUHZVMX4PSN8nt+ME28o8mzKLq1I4UCtdqBw/49LnCpyhvVIAy8HMiafg8S4oSB/73l6CBZKLAjhVmcWcNeFGYfKucTyQwyjg06Jl4K6zQrJxcIlfUE4GmDxucqSv5PmIfCVcFat1RoqUN6Y5lXWwoUTz9PMfXJWTHrOD6Whfx6oRrdmLl8LRU6epUxnBS95LHhcCEWQ7Vi7DIo7W8EpUu50lj6oyjPxCx6cH79f2Pnx+Jci5O5YyLK30v0OWj8L8kVd3cVBOnuMC2UXd3VbV3GciifkVBGmHYu45+Oex227bqAnCKhnlQyIFG4aEpckBULlGH4uDwIfIlF0URtFBhm08VzD0dD03wFlUQzq X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31df977c-208c-4ed9-63eb-08d9d5348aec X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 18:59:49.7958 (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: MYaNuf7EGHmcxYQw47B4gXJqSS7IiB9lBdVPCEcDcAeW4wtk8C/f3xddrHeAl2GtyEMRGMGVhwy/DgtE/M5HPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5647 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10224 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110101 X-Proofpoint-GUID: KM9JFGo0v3FiEvTJgBv9OpJXFuqxLf1k X-Proofpoint-ORIG-GUID: KM9JFGo0v3FiEvTJgBv9OpJXFuqxLf1k Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 872617542bbc..63539dfc6ae1 100644 --- a/arch/x86/include/asm/set_memory.h +++ b/arch/x86/include/asm/set_memory.h @@ -49,6 +49,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); @@ -88,13 +89,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; @@ -113,10 +109,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; @@ -126,7 +119,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 6ed365337a3b..814c016b75ab 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -601,7 +601,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; } @@ -1255,7 +1255,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; } @@ -1279,7 +1279,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 Tue Jan 11 18:59:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12710380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EC20C433EF for ; Tue, 11 Jan 2022 19:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350321AbiAKTAS (ORCPT ); Tue, 11 Jan 2022 14:00:18 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:3482 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350308AbiAKTAR (ORCPT ); Tue, 11 Jan 2022 14:00:17 -0500 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 20BI2LpB027852; Tue, 11 Jan 2022 18:59:55 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=AXxFQXYyRw+qe3jyXLdF/I63gargUEjxH/mEdBHX4zY=; b=qOsAHLvBKJtGKdm8LkkuC/0IrHZTJ+Red957KSY4x55sUP3CUhq910h3rrYvhQAuPAdG +NNctHXmHFvof3iJz0iC+VzT0ifixVrxzgFpN3Gt5VXe0nvMrlZvyvUkGtflylTCZ7V2 CvtQJp6LrteiR2sAkCY18SLf5FjxlGnEq+m9qxnZMRU7cMLUtXMfTrU54qERanfjQd7X Iwo1yErJlvPtf9botr0PsuLNHTBY2GLPGTdfsZimLgttACByrlfh9l1HiQO+SFH+AS56 /UOOG/FdG1LML1faLtHSVxQAcDrhwGg4Hlj7GJS+ARpglebx367aL9TEmWjKVZQvl6Bs lA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3dgn74bwqg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 18:59:55 +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 20BIpx74169195; Tue, 11 Jan 2022 18:59:54 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by aserp3020.oracle.com with ESMTP id 3df2e568wa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 18:59:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gsT0HtUzBf+Ef+wFfEZt4EINK3iMJWbkKqx+RB8d5kkTaGtcDH1bo+8EuPiBttB19Cgp0u52EoMvtGXS1YWiRqLP8M+PQfD9PcjLlUSxQlbE/2wlsWe0S039ZIxEYD85sdVFLAHYjiB0rirPHcjK266at55L4lpWZ/QC+cb84JNscEnNBil99wBb6UKlpk9OH0nXLxTIU3sZSTRw1fhbubl1aaDgqOIc3EPh9o3HAJ8whb3TEG/chyL2SgUINy1reGPTVqaSA7I8dwSH3YGrD6nri+5kCtMds8oBPQ3+JODmxnbEPIzs6m7fHOCRFa2XpJeDuE3BXsl9TWRvHxX7jg== 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=AXxFQXYyRw+qe3jyXLdF/I63gargUEjxH/mEdBHX4zY=; b=AGlbgqL5JG3duZhrQp07pgt7DYFpm3/gxrzKBhXdCN54mYAamNEEohYp7ypx77e2HMdz30rszig6x9GKjg351WZE8EDXDK6wqzXlIOwqFS1xIAxeWyYxa9Ji3zi2BS/Is+hVfT0xULRlYltZLEJQarK18eyNuiXd9KwmNVZ3IWlCpLR9BncjmmCsMIewE09KIHcEXSJmWbpfFtEb01Of2KKckjzcdxFctgHLiAaFlcOGkumpXntIDEuJG9aeWdnx0e6clw59gBEBjAT/FzoasTLNmr3jZABQoaViaF5aiqzl74lOHyKI92yNTkKfscQJK5FNC+kfCspBMR6GMR/o5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; 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=AXxFQXYyRw+qe3jyXLdF/I63gargUEjxH/mEdBHX4zY=; b=SP8SnJzjr7Lxl2/QQ67pLIKlPpmsBq7SsaOKPPS47dwoy0I7h2/ifWJSenPGq2LT3oHDLFiSJOQEduLpcQA8uMV87sAXLp0+l3FKSbyPrueJjxKI7EBdkAlWzujDa40WGjjU/BHBFKfMj9dpRmZ6W0ZQrUQ2rwDClCWcSBJG3RM= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by SJ0PR10MB5647.namprd10.prod.outlook.com (2603:10b6:a03:3d7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Tue, 11 Jan 2022 18:59:52 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071%8]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 18:59:52 +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 v3 2/7] dax: introduce dax device flag DAXDEV_RECOVERY Date: Tue, 11 Jan 2022 11:59:25 -0700 Message-Id: <20220111185930.2601421-3-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220111185930.2601421-1-jane.chu@oracle.com> References: <20220111185930.2601421-1-jane.chu@oracle.com> X-ClientProxiedBy: BY3PR04CA0005.namprd04.prod.outlook.com (2603:10b6:a03:217::10) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6872c48b-9dbf-47d2-7bd5-08d9d5348c7b X-MS-TrafficTypeDiagnostic: SJ0PR10MB5647:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ZKU0B8f9uS6AiZuco4uz1f8hgjjT4i2RridnoUkBjpdSe+5uCBEiWdlJ+oX8tC24vc0FGINAvP8BrE0LLT73DulNBE11MLwYS5qrGqeKBn9PvqF1SzYiHHtlbDcLkpibTJarbNyICFxDIMM4qTUfTe6OvIdKBkXh4K0DQeDHo47KleYYIUrvnphiISR8zkLbe1UMd8wqwki9sT2xohWZptrMFgJcF8ckfsR+FDe+FiyeY9Nd9fxXisvAku7yaLSYhlccWbZ03iSHNFsAZ3ixUk3ubALgZ4edWaN57hF4NJan5o8HwVS3r8rUX6vvA6KIVj3BbO+SMvUrOn+dxMwKtkUJvKvFp8AqOlAWSjVfeUE9zQ0RDI08at3Eogw5qkBbErSIIVZ+sy3s4bvhoiw1pymgG5KzPSwmuSTcLeROxhQQcmNmnjkn+A5DE4BBn1VuojadPkpMmnV6HRmTyYzK3QEPa2xOd1qw+WwTx5D96ArREf/DxdJre2ayU/xCv3Q2yvzg8ufaHqaRzCjUjeell6BaIt5RAaIvBl73pjax8kKS4RBLcEOpdQ+AgrvqEXJOZgA3/kzQ5AVPljsPQNEj6GrctqPd2u2eDrRS1xDzfR39L8wdvDSWQHKG+A9slrW6Kk9HgpBi3UumJJbnu9RiRlOIk2zjMziWclBavTSPHoNuI0Rb40LYdJsxMpZTb2T 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)(5660300002)(66476007)(508600001)(6512007)(44832011)(66556008)(66946007)(86362001)(83380400001)(1076003)(38100700002)(6486002)(36756003)(316002)(8936002)(6666004)(2616005)(921005)(7416002)(6506007)(2906002)(186003)(52116002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /kp/8H/lUfpBP1ZnIj/Rbr03DCJscVM+qZskoHu57XUs4WJihPi8yqJURDbFHNIj7NA2PjPCNQIQ3IaI4dVHFemxQqd9TwpdJarp+Vdw4Rb34CdcDJPxOclS0nbTQbF1wMJbrIsK6MKUYvM0TAgT5r2dMDdcnmHEDawxg1lS9yjowwBs6Jjbor59NTG5EaRx6j63+alt29BStQfks6lsy3nJAoKc9/I8BFQNxB2+8FcegwVMn2xxwAVoZJ/47TWWKKiFt7+kyZvPTVGXCNy9ZgJKhXdewN4ZeP0BbO0EqTqg6f2/Cdz4TiiTNdhgdAXCSaOdZYGZVPHPWLBevj0R2AGIvwukjaTruLFA0KdJ4CND5HByudQ4lhJ1fBvP0gh+eIjfw/s1JyV42pom2uAaQkDP2V3bAAt/+Ptyg1kYsKZ0XPxKqmr161fnUXlo4zB7/vR6igB0uAOU63Z2nkgX5BfgtIZS1xyTNJqfV6QUpPljAB4n+PdFL0N5IKpjbgZscoSQvl2hwsn5RIUO/fvlOt/JFB4qA/fxL9VxJ+A+Wneu9RQ80kRXaikTph6/uZQ/WRy+TJLkhHy1MDtrqVTITO4nTuw2pGe7Oqq1QM6ExJbwXem2CbJSMZ5pIHn3OiJmYMnRgDO2b7dAtEFW1wjfJkBy8SctpyUhnmcjzpZ07M3qO72Ayd0KPRxcfEFSqrHGFPTMX5DW2On5wqmLBxB67wOA/RLMczVwSTvK9gGXMF3df2B6smwJYvP1hVBWdMDCyAZ3oquKrPJLB+NqA7V1MvZPxzbmAjmzKxFg7lIMohfdP80GZMDBpdtkQ/6he2G4lmCxulsfkDrmXPG0DNIDCMlub0ZpZEkmxstM6yaToFOhRdSRTAqHDOiA94h1BOhL2xoHuYzOZmZm2S9pyva/+QH+bz1TuJX/RuPexR48/6KEMUG7KJgYMS8IH4NVU9W0+EbRUkbIuUtYBfWNkSv9EQ5SVr41PNZu2PIcbQlTjRoNNEpb9l+RiOb1NT3NQdQAW4MZcaoI7+Gnlsi5rE5cm8f0DH/8bDaronN7SpmurTVEI88A4KpCdY9+p8SPthhgmaqXAHiDHyr+KvrzTuPtA0lItHHuwsuXyvtI18+l9kxQG4mL00pPemsRmjmCSyZlkD4wT7uUmB2MQgbgo+4gfwcixGS4k7jeNAO1RnloDERI5LmO9y3tifUM9BI9qYtORiQsXbpqn1+4rnNQZzqPPrJkmntEOoNLKwNooDnTjLk1qrao2ytOHNVFs8IgCyguZnL4eamtf63qCw1mFxE9UftT+H1V7QZS/3v/PeNNP8sKDuwX/PF7PDwrs3qpaTxhOGTTFvJZHc1drAGVjTWuyIpd2n4Jv9JAJ/DRipZm1bf3KVAzTPWc3FkMcs/KE/FpmmQS2g4vwzml2YmjHDacOZ9uMhwHSxFDtJ24cZKjTTHLoiJDrQBZz7Vn53Hkk5QHE3o3w68tkCKFuwBg1iGnil/oLL5VFJ98ohFwPtjbsOxzWH/+EVgFGbCHbvUBX+Oe3OiDYqkXAeooRDVtFnqYl02iH84/DBGPmNlut+vdLha/m16xMiBb6aUtyVgAniNL8dFkkzieGVAT8JY0gOAxDGMnMgfyb3bEQLS4075FSqLmjRLm6judbSh/z026OA5V X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6872c48b-9dbf-47d2-7bd5-08d9d5348c7b X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 18:59:52.3774 (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: 5rhZUh51ZnpVgSPxuHYmohiYJ70tH3ICC3R74RkZp06YrYMtnMzXEPmH6JGih0Sfk72mFnEMrAeAGSIm9wpjoA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5647 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10224 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110101 X-Proofpoint-ORIG-GUID: wv7hQH7Ahn5yg0LCetQHDGm7ICNxwlrh X-Proofpoint-GUID: wv7hQH7Ahn5yg0LCetQHDGm7ICNxwlrh Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 | 34 ++++++++++++++++++++++++++++++++++ drivers/nvdimm/pmem.c | 1 + include/linux/dax.h | 3 +++ 3 files changed, 38 insertions(+) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index e7152a6c4cc4..bfb2f5d0921e 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -105,6 +105,8 @@ enum dax_device_flags { DAXDEV_WRITE_CACHE, /* flag to check if device supports synchronous flush */ DAXDEV_SYNC, + /* flag to indicate device capable of poison recovery */ + DAXDEV_RECOVERY, }; /** @@ -227,6 +229,38 @@ bool dax_alive(struct dax_device *dax_dev) } EXPORT_SYMBOL_GPL(dax_alive); +/* set by driver */ +/* for md: set if any participant target has the capability */ +void set_dax_recovery(struct dax_device *dax_dev) +{ + set_bit(DAXDEV_RECOVERY, &dax_dev->flags); +} +EXPORT_SYMBOL_GPL(set_dax_recovery); + +/* query by dax, and md drivers, and .... */ +/* can be true for md raid, but untrue for a target within */ +bool dax_recovery_capable(struct dax_device *dax_dev) +{ + return test_bit(DAXDEV_RECOVERY, &dax_dev->flags); +} +EXPORT_SYMBOL_GPL(dax_recovery_capable); + +/* requested by fs */ +/* can be true for md raid, and ought to be true for the target + * because kaddr ought to fall into the target which complained + * about BB and only pmem do that. however in theory, this could + * be true for md but untrue for a target strip + */ +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); + /* * Note, rcu is not protecting the liveness of dax_dev, rcu is ensuring * that any fault handlers or operations that might have seen diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 4190c8c46ca8..10d7781c6424 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -506,6 +506,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 87ae4c9b1d65..768bb9ae31c1 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -49,6 +49,9 @@ void kill_dax(struct dax_device *dax_dev); 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_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); static inline bool dax_synchronous(struct dax_device *dax_dev) { return __dax_synchronous(dax_dev); From patchwork Tue Jan 11 18:59:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12710382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48740C43219 for ; Tue, 11 Jan 2022 19:00:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350327AbiAKTA1 (ORCPT ); Tue, 11 Jan 2022 14:00:27 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:19564 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350329AbiAKTAV (ORCPT ); Tue, 11 Jan 2022 14:00:21 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20BI1guE032058; Tue, 11 Jan 2022 19:00:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=HACBNB6Dlbd22EoArX9+ZdfgySBwzu2+nWVxtO7kBp8=; b=EKr4XzmmKjLRdu4dip9Aij4ElPABFiCGNgjdfuc2gGjgRmnUp6FB822FlUTbmUdBT0ZN FAr2xhi+UbcFiFy6QSCRwJvgD5Ao9H6Ee85VlvvetQUH6VpuIYVsJfNirK6zmbJP4A7A 5/l6H9QEWsmsY89S9cIWl8RaThj50cSosdP2WWHhmHurY/GACV1kPOhv9HSmy19oDqi9 kyAqa/fTXF2hO/fcLpXEVl5MPRrx/wAtS8x9T3aW+k5Wtx2Ws3ivd9pXqxmvS/xqTW6u vb6pTSAbwacnGUoBi+nd+9zkVy6FZRr9HXjh6oU8fLpcl6NrPUlm6FPZj28e46CN8Tsp wA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3dgkhx43bk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:01 +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 20BIpcbv110950; Tue, 11 Jan 2022 19:00:00 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by userp3020.oracle.com with ESMTP id 3df42n7d9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fmN3t3G4XD8a5QMRS9JBHJ8mj1COlRdo5OofCnkaUORmVGE8Ke21Mkrt+Tx0cP1UAE5GUAH2b9jpZsWDF5uY7HOoymLsEX4lMjZSG5GnxZ3NLJCJGE/yEnpGjDfnyIdXPEPEbTIojwe3OIMmoXUIwo3qnuNaWdzJMEEuQ4jTCGDmfus53rtmGbzsANRIhEpfrd1xwiG8KeA/WPY8n8ebesfOmlEujOdammSt+kCtIU8vSa+wuMQgv7h+vgm4F7ndrz58mvLk7ubS9Sza7KbKNc6owmeurrX+SvcO2X4DCttvVMC09oeq61dF8LtllXO08Q+8r4uD2MQ+Ld8R6ki5Pw== 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=G55PzDOnkQr75B0h5lRnQqGmvjRxpcAcMyN6wiHi1RaK4HKuxcPUvTgmLOh92S4/YJNaJmnGqUuFzAiC2yccKRvzBtOCC/vnv75mzYw54kHTrTO/Ne+jBFM1p7RAmOCtFLe5670pAJMUxvbIYKc9edHKutb7ky59OhEY9rZtgoK99off2PPUsJFtvvKWPcqHctXV0D2Xwd3ZRalULN1FNejZbenXvgi2hy09MfsDJyBAlhkO/mvi0YJaJJnzPwM+sJzzeUVcw5XaCkm4G/b8FlJ58xKcZpHfApL/rmuC9KM2mvzG0dCaVb83Z5cQkaZ4YWdqo+zLV5CNdlDsgu2Tvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; 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=HlIjPi1LMMbwLSi/tBS8Qjy/2NQSAIHRODN5ZlrRhT/8EFyQFhx3+j4YFDqMV5XzXb/HzatfkOZdIrQuDAAl5kVIL5iZ0pPltSEK4DonxEGYTChrV2HIA7QibQeLZLKvGgTvjDURp6PDrBc5On/dqE5F13V/8z0+KwQLaYUXnOA= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by SJ0PR10MB5647.namprd10.prod.outlook.com (2603:10b6:a03:3d7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Tue, 11 Jan 2022 18:59:57 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071%8]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 18:59:55 +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 v3 3/7] dm: make dm aware of target's DAXDEV_RECOVERY capability Date: Tue, 11 Jan 2022 11:59:26 -0700 Message-Id: <20220111185930.2601421-4-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220111185930.2601421-1-jane.chu@oracle.com> References: <20220111185930.2601421-1-jane.chu@oracle.com> X-ClientProxiedBy: BY3PR04CA0005.namprd04.prod.outlook.com (2603:10b6:a03:217::10) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76ec3292-9b57-435b-fb2d-08d9d5348e02 X-MS-TrafficTypeDiagnostic: SJ0PR10MB5647: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: nehgXv/AgvweR3kemRCqUP3R5JRhncYKtXgcW+cScD3gOwFBeGM6nJb37lT9mRGVUwILLoje3lApomZk+8UAlVgm91MteX2JYTozLnbw5y9+cyKl5l8WuZP7l+bizJSVgtTwrT0hZrem1IOWFqguwdevYtuVxmv6CVuP4ioRFBxyKQyd6ADMQKrxJEN81Wi/wD0wLbVbTqcmOJ8jNjLyOWkTYHrvAOZlZLx0p+7DifmrNp6+kxbipOgYbuo/WI5O1ntVMATNdpfUkCzfAVizfwTfm7tnMSf3BssShOiAp7fxfUAhZaEUu655zLzi/woQtNI/qegnL3L5hGN0F6Lcs7gdQ1edBwe+KlebKhPQyh07c16H6lC50/ZIM6tEX1ZC7wAFQ29BMn5X1nQlauy6Dz2buRFTLJm/oo5VL2doGttYzdbp8o1iSRN0gxeDjMkP0MPrWrXpLxrgSRmGLQMIdNYGNTvWdCllCmVYcY9N/aAHCbDpObZms0aWG59Mm6frn6TE9zi4z/WoZ729KETP1WBY++Xf3sUApXe70LQuMJO4tjS2LGsTS57P64tn/V6yUYsn2D2XNwHJNGvmUPWAeQnZ935BgMWA2aEQdJ8PjiKeX7HG/jcbdIXzC02bDO8NZDI9IoBjd5/usI99oTmRJio6HRPsnPdph+kxjKeb0OYCmRfwEvwYhZ6L9qAzRuxu 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)(5660300002)(66476007)(508600001)(6512007)(44832011)(66556008)(66946007)(86362001)(83380400001)(1076003)(38100700002)(6486002)(36756003)(316002)(8936002)(6666004)(2616005)(921005)(7416002)(6506007)(2906002)(186003)(52116002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JkP1HNOe7bx56TDfbEjiFQsDbDZ0hNnKORzize5DLgOD3xM6fSsLzq6zbCgmF/UwJQGKgjtruKFscoKP19MWB3HfyVDbLwGt+OiOvbDszqy0rpiUQhSa7/1Mc0JozcmVxwJOAkLZzOAZSOE9V+Mz2oOn1FiERTE6eybfpyxtvoGYJG3UNnaya9ekBMh88tkP7M44ed68cyIHMa7gMuHQ6ZHJo2jFwH1CKFsXSYNrOvKvKugWf8dfDAt2fpqBqeeF1s6Ux6mLX/wzE9G9oCZLKbTRP50xhSMYckngUefqXNCwRwyoFYsbMAptbDH16aditqNM8sRcNTvGXRp7qJjnO7ltBi9E81TLpvhxN4U7fWtLFqm5O33gnz1mUqiZQOnWqmYCTE1vt0ky+UtHYD1pesv8wK/Xd6Gz58IPDZNfCeypZ9ea7qRw/vpzx/rh/xz5ZLj87z6/HpSms4xS6btD1bEHb3IkNgLnDgohgombLdVzKTBOxjG0DumIW94Kjh5/tItAuF7AHGi+rHNKxaC+LwThtEqPS6vbkJrtw8Wyiwqz+Bhb2oN2lpMketLBuPe2L2ZZuqZcstuxBMLVd9ujkY01ADcDFl7EJMEiwS+lax8sZYSgq6MY9loujwQ+YBak+ZlvZ3nGekBEHWrEz1vug8JBbjypYA3L/QW1XdatnJ9YPIZzJK2sF7vx6XRB7PpFuspLbP7vlh2fUyVRyqqJCUro04seEHLYgn4ckGX1aiBBgOtUzXn48vL9rcStWg3gWHzeE5aP0rbuQdfvkaOzLUe6eBcl/NqcBryjJrizLHDwaGKJSCYrXqL26w0jjJJR+0n7P4UjgRe+oAis5v8X2r0zsnBRvq8sw1HbFHPRUchfKVPXG+P0+labHtSQwmnV5UCGNOgg8u9+BC6/KRciHzVospUlWmolq2OcfpVJpcLjTr9BH7zZxh325KjxGuQmqZXR/69rwTzfYlKHgqy/wP+Kt+3zAPgE3oUqEgqTW4Ac5dxkSER7SyRd9I7La0/uxeI3JExGzwk8O4y9EWvvKYZ/yKSU9Xp1c6HuFurEcd7lUCXuZOUCDh1KOkbFzREyJKdLouC+oFoDCdghzo9jDJG2zRDxqakXi9aaqq9kQhZRekkGCK2ZRoQYJQ6WhjzQwyxjHGZt5fmNcNi9oZqp7l9BL/z4pobipCAhtaGMtKv86HKCiVdcvqttLCqUBBAohyp1kLoqvHMA+UTjz/f4rRkTAJMT66bSE35T74RwaTD7w3prdJ9Iw66mMyTXyoq4SRV0GGhUnT9TPJqSwOVaBnqyAPVQeGk/kw7Or5rQlsjf5rR4sa0Q3UklGClU/YfovioFSpAUZbTTlQMcFxqyF82D1mySVZVuFlqlUUNWDxjLWTL40S+DojaoIB/wAMxrBcXZ9HsiOwylxby24Noyfl4OMKLWNYPFXILWWshe7S23yH41FSNO1Trdq8ofsZhpR8uBTDt0TTbwCR09k0ym++5MgU0iI4/AJ7spdSoLC/Kvg3Qm/qfvnvXaoberKbmihAdcDhFvaJiBYLCuDoe6lV9kOE3QHCBz8GxMZqG9WmPGykW6LrF9jLc0Bf8Dg9D/dphfidqPKJnxl6/Ge08uiapSXx0HXWJXEsU9Q6KALtFD81BvQSDTPF9tbMxiOzHx X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76ec3292-9b57-435b-fb2d-08d9d5348e02 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 18:59:55.0009 (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: Jf8n3MwflJ9cSgUycG/8ogNbn5WjJrnfF6heofqr4Pggt2DgfWESg2bH8oaqBT7HIp93/ZhExKjQgpFvICGuSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5647 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10224 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110101 X-Proofpoint-GUID: UurHFB4B-z4XiL92ZyMri78J8F3bMuYb X-Proofpoint-ORIG-GUID: UurHFB4B-z4XiL92ZyMri78J8F3bMuYb Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 Tue Jan 11 18:59:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12710381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAF95C433F5 for ; Tue, 11 Jan 2022 19:00:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350360AbiAKTAX (ORCPT ); Tue, 11 Jan 2022 14:00:23 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:19128 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350327AbiAKTAV (ORCPT ); Tue, 11 Jan 2022 14:00:21 -0500 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 20BI20pl023216; Tue, 11 Jan 2022 19:00:03 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=2msqype7/aQ7LOHA5CYvYF8unFqt4ZpqGiAl6zmWNq4=; b=Ifue/qXGqAAw+MvCMA13MPcBt1kTIgbs2cMvExgH7VRvpuSBTNja7FvyR3Yci3K07xc3 dY4hVynu/umEbFwW9T7V7opnv9wfKFs1PrWy4HNzpbrUVZbANq6BpMSEDClCIZ08gDJZ hsSeHPjaTFuxKQO9bcVMe7kAYYXev+15h8YP+mKd52hYUHSi067gKsGf/9oKOX5JOsU2 ki99THG1ZPcUYhkXz2PLWC8Wvd5HMBu15c6jKffBhjlSxPXaNjWf1cnOHx25uDJ2XBkG b7u/DZX4OCqPrdwKQgJnj4yYGX3oLvTbp/SZJFhdJIXBYFbZwm1ZdNmG/gsmha7PQRge ug== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3dgjtgcb2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:02 +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 20BIpcbw110950; Tue, 11 Jan 2022 19:00:01 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by userp3020.oracle.com with ESMTP id 3df42n7d9x-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kbj0hMZlsDJrrZHn0Tu9pd0+Lgr9PLvVtQxJguOBPtAES7N/DbPQUla6MmiIaoygHZKbzy+N9l9qFe5nGPef9XBp7HhKhY7J3QpGo4TDzgDHQBTNNY7fhiBIdVcjx46+mt/8KTt4tJq9rb+XhROpSDlHJvuVOYDl+3bxpjOoykkrVAnfOYkIRY/fYbAowQeMxE23CHLYwbw0p6NdlQz3xoyNZoz/LQFLDYxN1rMYGGhJFmnCD1LPfIyLf1NrmvXbSOBcDvwZNOj493R5H9as4GZm18KfN226OxXQqa37ocm5cp4RnOidww/HQahMy4hU5Di1km1njzccbqX0rIlt4Q== 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=2msqype7/aQ7LOHA5CYvYF8unFqt4ZpqGiAl6zmWNq4=; b=cy9AoZGQVMVMQenzTgUl9eXX0X0DsxOMncNwBHzhg1OJnhgK5aR8XT17T5C6mO5/qovtNlLxhb/x3UQyot1wJ/y4oZUM6b+nYV9dH1/A1AX0R/mtx+A3HGs/quLz+Fkk6mHNPt3O6H6rlrKYf/WsXngHsFHJsj+1stNM8qH/0hhcJj9Vh5CNbJ2KbWlqJLI4uEmoEdZhZ4ILsaUZj6A9mjELiqaQwUfzTVT26pLVMyRieDDGWCV+N7hrRMX26W5ZhVVaXnRGdsX0n3/idj2T1+T8y/sjVqWZ0yzclz0EVCx+h8K1s5F/BHt0NM77c6bAiq+ut6KbYT7jxa0bqKmNpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; 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=2msqype7/aQ7LOHA5CYvYF8unFqt4ZpqGiAl6zmWNq4=; b=yjBTvk3sCqK61DFBHevPovabMU8cAcufVh4ZBhk7S6KuJjf2yp246FAD2cgSzQeFRaxHrvQ02h3XFZRPzbZOQ+4HA9RC96qRp7GFtt0Sdv8bPhYni+CshKzkzVlXnwMgO7ndpef1b4gbSm/8dMxT1jhiw1qSieCXB0spAt8JXxw= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by SJ0PR10MB5647.namprd10.prod.outlook.com (2603:10b6:a03:3d7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Tue, 11 Jan 2022 18:59:58 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071%8]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 18:59:58 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v3 4/7] dax: add dax_recovery_write to dax_op and dm target type Date: Tue, 11 Jan 2022 11:59:27 -0700 Message-Id: <20220111185930.2601421-5-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220111185930.2601421-1-jane.chu@oracle.com> References: <20220111185930.2601421-1-jane.chu@oracle.com> X-ClientProxiedBy: BY3PR04CA0005.namprd04.prod.outlook.com (2603:10b6:a03:217::10) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a721fa54-670d-41f1-23bd-08d9d5348f9f X-MS-TrafficTypeDiagnostic: SJ0PR10MB5647:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hVPQiQg43pHekpT2PeqzyQlCOET7eg8HfzabQCQycETyOCcj+42CA3L3H1XG0swlsDC+ZBDCqu5PAD3lniP8AZHC02sDQhuDNEu66D2x4e2BWFiZH6b0Xx5rCYrQyXD1PDpqNH44moIoObe0O9Y8QOmEQLWVJXI3gmcwOuSr4PWAjXEIAXILKuFYtl+5PbLpV4t8mRPoXkjmQPGfcBB7pArI9KYZqjNI+Iq6J5/sybmpBlvbMW0J4E9Yvg8J1An+NIUefZf3AusaEAfQgIhM3WUL1cx7xOZezHgyB5b5+uZFHie8DMhRyhlBgpk2rPzvP3gAVkjTgvMSymDLmBhJI5R6ZQidvEWlAuoRF94xdDB9RGsHxqodgv3lmS6zRjKUHUTHzMQBIvYodTnvw/5HWHZWqbPOphMuv0kUm6FwvLaX4MsynADd5djKXyH3nOlwVWwLkSaYUZqpYvSuIjv4xxFE5YCZPfVOb8iaUTBY61qSkHYbFhw7n7Fw8XA4edkaxqOqSdrZOJ5ujNZt0uddZiwxgVUIMFop9PqfMZEOc8UMeO50lO5aSB5InUgovTgpEhbS2m675My+jLop4cJ8+59DQS+50f5V67B0gK1OtfXrzJRT/0EqwDcxseuqztn0H5bxVmgnohyDe5GF3Yf9SNnQtdHQi6ORFgS65XV9e+Hdb8VW5ifowAQTFSTOaS7l 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)(5660300002)(66476007)(508600001)(6512007)(44832011)(66556008)(66946007)(86362001)(83380400001)(1076003)(38100700002)(6486002)(36756003)(316002)(8936002)(6666004)(2616005)(921005)(7416002)(6506007)(2906002)(186003)(52116002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G7bPbTokppciK+3K3mEvbVG7lx9IzoeUkWPvHn+DwBSPzEBST2ggFVBmmEutPJ2Lw2sPrjQ5gAqspStPWKWl/vt6gnrVPNAWOOF0MXCvmwN7C2vDeYv4n6wiIQ30L3E2MKJ0sAB2u0M2aOXjdjD8YolMdlx9HSmluDmFpDVnWCwRRiKn7KzqxMPjVTNqzALYO0uMYWBUM7XPcOgmrW8Nyt1vH7OwdwePli71KGyNEyPnO7dXLZLl05XoxNh6vhXpnKTzHhTVgeas0UV+MkYMVNY6nqGdPpzlgv++tW4sjLX6JS1q0PM2u8xKKDWyxTHdbYvupAz9kSWbz1Rt+sOMTCXkjHvczDDaAXRFMu4XDBYrz29PgIX0Ilh3ujakyCOnkWSppu9YvSGHvAVBIxXn6f83RnLeHxkMIyjQfRwv1GmgbvYC+QqDhq0fTjsqRkfWY+qxQpjqlrWUXcUxni9F2mVK+8OEh5KoKZk3jl4f5YdQKXcJlTNIeJIDLp5EHflNz9V3GAHjwC/poy6P1DPhrfR1qSWsKuyibhcvvwX95Ej3ZPhrh79blxSnsnl76nwVSiadYQUEikJLRrkCItuauJv4TU4Px+8DAd7Ln3WnSQ1VGiQHURcobyjeQVWdTDCrR/2HoIcULiWcjK2lwP5xAAK11qwZyIGp3nxVPhKhvWXZERH/ARQYdpwL6Vl98hXHyDFRgWzzv+eGPXyv8eWmdILVaMnNFtTRBEx8Yut1lCcLmKNGg4l6fq3O3WBvH5Z8myoy3Q6Dtu1i62+jqWdn2l8m0lCDKydNUjzUczt/7IQ6Zk+J30+GZ9V0iQVqQH46Fk3NR+1hWHq4R6XjZmsIyYkVvZal5pFFkFXNN/r2xzvj58reXVERvKXhw9zks3F+87WJ8L3AxfJY6PfhcyBGK6I1T01s/9tf1hoHZIEEn3dYLTgcFyvoyQ0qD+9GkTh6xchsgvkLBQ7rNsmKaw3azBYz5gpaARXziVZlW3RrJW0WdUk+G0OO33ZPN0wzp+K5nSZxMJnGFsYsW/Jct7ygSoemd571UEen3+pQbWiVrz9rGFqAvk/sKnx8QurwayS2684gnSzth6Skp7K63yHW7Y1u5xiL49VkKeEuWEwEu3dtR7ITVOzap/NRnEcBX+X+O8JqhTqtbE7vULlogXsAVD2+7e4r/ZbBu4Un13Oe6pcy+w9KGStKsIHxEU+wYouVnokGixsPFecZo1NA+H5Uqo+ku1g9FVioeFcFACo1Y1qNNgA9VZg0b6ss9be4SbeB8fdLJowchY4gLNfq4MlNcR6FcQi89ayP9srRZ4NbBm77axLI1joYrLcfN28XOXPAXUiasY+fwTpZ8itA7GZfut92D49pPg695KyDEv+7D+WFLj6R/22hToEhx4iZ62rg0vt/FbyBVq1NGw84GnkgDX5XXzseV+VDKIj1yVUvNFSKm3jd5m7S1r7NNbT9QboUEc98QXljLIZntBL4PY0+hSx5cTtFXAx7+OMdQmNLmbg1JoKEo6yYnK3knh6WVAC7OzlmkWDnFvp0BqofNCknjL+7Q9B+pTN6nJ5CYXGorIfO7QiYq5TvjBl1QpTv8uoPyxlVaSNWGYADM/TpTlPmj7vuV+4C9tzFkH+otgiauzU3hQ0fn2biuGiszIV9awnQ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a721fa54-670d-41f1-23bd-08d9d5348f9f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 18:59:57.6194 (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: wTFHIM2kPVl5p8S3YvX6eZfR1SytdOP/HyJyZmwfx/oxTTIvCiEky5vPlsTkT3Hb+mlx+pJf5oGWWztMj6KeBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5647 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10224 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110101 X-Proofpoint-GUID: GeMyAZSBlAIXSIlWyQoVBnMHjHnndsAN X-Proofpoint-ORIG-GUID: GeMyAZSBlAIXSIlWyQoVBnMHjHnndsAN Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 | 19 +++++++++++++++++++ drivers/md/dm-linear.c | 13 +++++++++++++ drivers/md/dm-log-writes.c | 14 ++++++++++++++ drivers/md/dm-stripe.c | 13 +++++++++++++ drivers/md/dm.c | 27 +++++++++++++++++++++++++++ drivers/nvdimm/pmem.c | 7 +++++++ include/linux/dax.h | 6 ++++++ include/linux/device-mapper.h | 3 +++ 8 files changed, 102 insertions(+) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index bfb2f5d0921e..84560173f1f0 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -162,6 +162,16 @@ size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, } EXPORT_SYMBOL_GPL(dax_copy_to_iter); +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); + int dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, size_t nr_pages) { @@ -261,6 +271,15 @@ int dax_prep_recovery(struct dax_device *dax_dev, void **kaddr) } EXPORT_SYMBOL_GPL(dax_prep_recovery); +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); + /* * Note, rcu is not protecting the liveness of dax_dev, rcu is ensuring * that any fault handlers or operations that might have seen diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 90de42f6743a..b8b558ef9fdd 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -204,11 +204,23 @@ 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_copy_from_iter NULL #define linear_dax_copy_to_iter NULL #define linear_dax_zero_page_range NULL +#define linear_dax_recovery_write NULL #endif static struct target_type linear_target = { @@ -228,6 +240,7 @@ static struct target_type linear_target = { .dax_copy_from_iter = linear_dax_copy_from_iter, .dax_copy_to_iter = linear_dax_copy_to_iter, .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 cdb22e7a1d0d..6d6402d5ac80 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c @@ -1003,11 +1003,24 @@ 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_copy_from_iter NULL #define log_writes_dax_copy_to_iter NULL #define log_writes_dax_zero_page_range NULL +#define log_writes_dax_recovery_write NULL #endif static struct target_type log_writes_target = { @@ -1027,6 +1040,7 @@ static struct target_type log_writes_target = { .dax_copy_from_iter = log_writes_dax_copy_from_iter, .dax_copy_to_iter = log_writes_dax_copy_to_iter, .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 50dba3f39274..b3035f32121f 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -348,11 +348,23 @@ 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_copy_from_iter NULL #define stripe_dax_copy_to_iter NULL #define stripe_dax_zero_page_range NULL +#define stripe_dax_recovery_write NULL #endif /* @@ -491,6 +503,7 @@ static struct target_type stripe_target = { .dax_copy_from_iter = stripe_dax_copy_from_iter, .dax_copy_to_iter = stripe_dax_copy_to_iter, .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 4e997c02bb0a..d4ea3afb918e 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1102,6 +1102,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 @@ -3027,6 +3053,7 @@ static const struct dax_operations dm_dax_ops = { .copy_from_iter = dm_dax_copy_from_iter, .copy_to_iter = dm_dax_copy_to_iter, .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 10d7781c6424..a68e7d3ed27e 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -319,11 +319,18 @@ static size_t pmem_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, return _copy_mc_to_iter(addr, bytes, i); } +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, .copy_from_iter = pmem_copy_from_iter, .copy_to_iter = pmem_copy_to_iter, .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 768bb9ae31c1..7747b8076f6e 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -39,6 +39,9 @@ struct dax_operations { struct iov_iter *); /* 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) @@ -52,6 +55,7 @@ bool __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); static inline bool dax_synchronous(struct dax_device *dax_dev) { return __dax_synchronous(dax_dev); @@ -203,6 +207,8 @@ size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i); int dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, size_t nr_pages); +size_t dax_recovery_write(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, + size_t bytes, struct iov_iter *i); void dax_flush(struct dax_device *dax_dev, void *addr, size_t size); ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index a7df155ea49b..896c4a18b50d 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -151,6 +151,8 @@ typedef size_t (*dm_dax_copy_iter_fn)(struct dm_target *ti, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i); typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff, size_t nr_pages); +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); @@ -203,6 +205,7 @@ struct target_type { dm_dax_copy_iter_fn dax_copy_from_iter; dm_dax_copy_iter_fn dax_copy_to_iter; 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 Tue Jan 11 18:59:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12710384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5630FC433EF for ; Tue, 11 Jan 2022 19:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350394AbiAKTA3 (ORCPT ); Tue, 11 Jan 2022 14:00:29 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:20612 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350333AbiAKTAV (ORCPT ); Tue, 11 Jan 2022 14:00:21 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20BI1gGG032060; Tue, 11 Jan 2022 19:00:05 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=S8NkDMVSMx1sB9bdmFAm+2BgYlp+yB+2UgjGvDnRibI=; b=NrAghcwhlyqaWlWEJi/aLZPwOZMCdByb3FVxHlcunHpuH4ksTkzy2dSwf7ihfBTKRrYd BAfuP03g/RUcMyyF1EUBV8hIa61ZhXy3GzM+tECCjFUr4kMSOEhuN75OoqrcM3/uaJOf WHUHfr6BKhtg8XKOoAZoMPO/Nrrfql/eA40PBD0uisZBmC5MO77R0RAiWc+1szR32MdM kntcbBdJsJlIjXFBCpN4c5r6npm3KdoxKSTzYYbw7zUepBk9Kk2E/HtK4ISag4+t8ITA Bxo16JOAxkFpvoWo8Blk+8URkAVnSkdxVLeWEF/ifuwEgWhfANTfmPJr6awIyVEqSy0S JQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3dgkhx43bt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:04 +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 20BIpdaw111017; Tue, 11 Jan 2022 19:00:04 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by userp3020.oracle.com with ESMTP id 3df42n7ddb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NfPVN2zZWhy4PiL3pDj3PbSmrFEz0gBrhhJNiK2d07s8+NfHYyBO+ADw3WJOG+rDoPpk201OVVUU2U3d2b1lWn1eZ+VCh6aatKmsA4MAduQ6qUprNdN35IMp2K4onKB6K2pRmTwCPsuL5ItP54ynfRdiYvr4knFmT5E0Upa+mHq+PYhM+zf+7+pQCW/59g1Eg6vkiqdeVpbNMtmw0B/W58Hot5mccQEwz9jzQ1QjgMpUYbIMNy/AAn+9IeF3CDsFbFld9vG9NidiINWm9mB2+hXe290l8eAa7ywRl0nAmoENvvg+o1bSXC1Vd2n3F5fqQKDYXAye9/A76eyjKjISkw== 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=S8NkDMVSMx1sB9bdmFAm+2BgYlp+yB+2UgjGvDnRibI=; b=GagNp8060EKNUvtKW1UY2B13Du3APFG8xvGTsIumYSx0OeNgNRLoN0W0HPEB+0iz2KQT7CZAy6qII9epfkf5MPTFaAy+vj27u2G+R311assaLjUP2NgiKWVZ178yq5klq3oV/1JnHmkTXLv3vVDzBnBUOTzW1uRvizRL64AEMsiNPRCR7mFJyFooddyZmp9/mPTvKbC+mjCMuX2sGLHXTIPFOiXBHH1QbovGtzyC6x0XBFF8nxI8yY4eszcqXzXDHsAwOUM7rD0KFXMb2IfsGr7ATlOx75VpTVLFOE7KgGjWGNbE87lNWDbXsPM0CR8+7Ii65sxtz4qpPkGBdGzONw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; 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=S8NkDMVSMx1sB9bdmFAm+2BgYlp+yB+2UgjGvDnRibI=; b=jb/jjnMR9k97fEy4ltjJR7xoCV5R42zdzSR+j3OAVnCNtGE5lW5Wxywgge2uuL1QxcxtLiifktN8FwsZ8ksMk49HfikGMpu0dovAiGNlWm2kEJfADFmbe4SthkGFg8byezHueJUu1j9/6RVsrFObCX1uskX8A/q5FLd9gZex5xQ= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by SJ0PR10MB4814.namprd10.prod.outlook.com (2603:10b6:a03:2d5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.11; Tue, 11 Jan 2022 19:00:00 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071%8]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 19:00:00 +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 v3 5/7] pmem: add pmem_recovery_write() dax op Date: Tue, 11 Jan 2022 11:59:28 -0700 Message-Id: <20220111185930.2601421-6-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220111185930.2601421-1-jane.chu@oracle.com> References: <20220111185930.2601421-1-jane.chu@oracle.com> X-ClientProxiedBy: BY3PR04CA0005.namprd04.prod.outlook.com (2603:10b6:a03:217::10) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 79305477-d77e-47d0-0d3f-08d9d5349173 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4814: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: ywZVXIhLG+ew/cAmlA0c6eazzcPbYOd1aW082TbGKZ9750ncUnMTS1b/pY0LKAQHryY2eJerwvd6XDlV8sfYdlQ+/U09ch3QdI/jCOr4uyrWlk2Zrsg3xt3xvGhBeQNjQ8ThOjk9FTZ7ZrR7wLQapX2lLhNQUhA3VD6cjJzVX0TgxssP/KsebSbSoqj7pQrXvZ+mOlePGxPmHp8TfvuhvdeK4t/OnJGK7cgDQy69hw5Ruod6cfQR1dU8rB6fZZLmOVMzpiU/+E9XvgeHx/pJbGmYFDFXRHRCsg8qt4Yiev9PZ2SaXX5qSLGSg2oN2gE1zb1QFWwpfxwtPuR2zh2r1aXbu1+PRKAeNS/vf5F0+Kbiuv8lzhcXxj6gl/4+OUfmbc42ayieGKN4LTJ3V3l7k/ClG5ivBAyLhg97xNYpT3AExfAuNXSp49nUO3UGGk8eBvPt/vxxIlXUKvytAAwh5unD+LQlJHqlkqYzO3e5StpGUchELKqJrOIV+yiWh6okBif1xFzW4LPhHRSwO7ClcRfdlxMZWBeZc7AcW2iYLAF2741BXKfPAt+xsyrVAiYU31eMlmjb64kSChJZMg4Jvz+q99ero1zJghPAaq1mKx2xpr59Hp9CQmQmJzw+OfOGVUGP9EDhaY/lO0GPaBAAK0UrK3OU4F4pYJyGyP9cRPqXM3LhkUrPvaEX3d7sa/dF 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)(8936002)(921005)(38100700002)(44832011)(186003)(6506007)(7416002)(66476007)(66556008)(66946007)(316002)(6666004)(2616005)(8676002)(86362001)(2906002)(6512007)(6486002)(1076003)(5660300002)(508600001)(83380400001)(36756003)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4od3/QrSOKH94v5CtRL1ZiUHvNlJEnTNr+vftThGARF5VX+ZbjOpBPKJdfv4Daw2rgghi3RtqnKugLpoqZgXd6qxPxjWUhGHrB8NUq9IaYUY9oiPO4b+Akd98DVnJ2azCYcqe8UXXe73j77imXAjwaq20nC8Eox1yUS8YKGS2UpWUDUGNETAUS9DYygxpyFJccrov6OQUl6TZk9uO+l0f/KBc9rzCfuYqlCe7Ol9aTpjptCn5sUolVqoFM0ZZ8gykUaeX4SI7WE6Rvklsel3hlQMsqhVfT1BuRKGcjvwUjPB0Y2nhGnJ1O2Qk18qhPps4NSq3yrttjSXyaS+VP4+RSFP7FX0MxPwE/DMCVdflSr6890Cl/H6yuRkqL/FnaDfdus37oz9HeLU4aI8T2e3qXURvUyO51hCRPGhT3LOB4hoQgo0xsmqUzMNEhfoNva992nbe6BRc86Z0B+M5EspGUWfmLXqlPJhh6yFzmVWq0QMiDY3wTIYA3LJPv5tuPvarXDhdrhRuBwdplYC1vd/2UNb5MttnGhM8NRC3T2UiZXYpnMClRNwBEA1Y04CvD0JFyCfhZrK3cvMysu2QCKU5E7BYuT1fs54XuG0qiB+9qMTOqhCS1FcLK1DVWl0gm1w7KVR9Kjzpk0pk/Z1DmhI/uxjEsqv+XeO4ISROFMjdxxQ+t7SqS6XjciG9MrdnifIkG7sa9QK+Z9C2SRV2Exiy3VbZixMLn4f+mfX2ejnO5MOMm0AtN9Wx/K0ZHZm8g7673FLkQMIMVbxWQsjxJuH7T3jI2aFdkm/6JDzpyWewZFkD6Fov8yJkXjjibG4nIZ6mUy7LFUvtlBIzpb3tVzymcIY2QgKbBK8bKJourB+fWle0VhxRzL7iJGsU4htKGG94E0EKfoqNdVg8o+5NeU1HsRUF7QWjwTbB3DSgANRvxcXxCANBQXHHBOzzQybs8bEOZ1jVOcKo1jXwpsCCQKAwGSvI08AxJsd8CBydSr8sjktFtaCz27SP/+ayWcxGGc72AmJXd7ptE6efBL9VGSqmyV0fvn4QP0Zc8R5XSdEi8VOwl4LzAxBm19zM+Mbeghrs8sFm2TlIKdwwHUoH8uPyHuNrfTBaiGG6SJDOTkMc95LC72UzQ7z/KIE6ppnJXh+0NZ8J1nb3mRK2hNX/NW49pRbwZfZMRDSq9TPP0x+OUCLzqM9Z22nIF3FBSt/zIgRDKrDWhh4sPQfPdVHchQUk27lTaMMe3i4jKJSJ77NY9OMeMWe9PTn2RZT/q128LapkifwB6O008Uwl8o0pgG2SbPd9liiXJPSnSWUkW3mqkot2/PKI8XqiUnYR5+XuHHBKSgIVKmXya6Rf+UO/yiRRDzlHT/W06/aW5tHTkcMhGbnd7U/O+mn6hd9EwsSiBOD+sts77uvwJQsi1VgrgmwUaEPyPvxThhMOl7vncvXIIx5yCRYSaT0pHWu7EXgqhBOBqQtzoYmaAP+Lq7T/Y98fwtPEL5+9njt5znKmTcqvaOma2fT1jVmHYQNASG+K3WsaMU1RsytbVPHLTenhiFVZxdMrNxvNFJnObJQ2/ZQpBjviEcZy2HanBaB9TmIH2ijs4PaDHfwevhlYdh8FH0tMMpcxd5fYMQlPD5bPl8ghaJXcPnleGhsVXVvNt3CGndF X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79305477-d77e-47d0-0d3f-08d9d5349173 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 19:00:00.7118 (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: 6mwojBZ5EzuxzE1N+jMO1krTecJoaYDOnXWjqmN2ixDweMnf1gGq0I5M6zsyaroIEZKCVXDDOIzQLPxMam1wPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4814 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10224 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110101 X-Proofpoint-GUID: WCkMvk99iqFEf7Lx5pXzx76cYIwQm5xn X-Proofpoint-ORIG-GUID: WCkMvk99iqFEf7Lx5pXzx76cYIwQm5xn Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 | 84 +++++++++++++++++++++++++++++++++++++++---- drivers/nvdimm/pmem.h | 1 + 2 files changed, 79 insertions(+), 6 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index a68e7d3ed27e..dd2db4905c85 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) @@ -319,10 +330,70 @@ static size_t pmem_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, return _copy_mc_to_iter(addr, bytes, i); } +/* + * 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 = { @@ -514,6 +585,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 Tue Jan 11 18:59:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12710387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E150EC433F5 for ; Tue, 11 Jan 2022 19:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350485AbiAKTAp (ORCPT ); Tue, 11 Jan 2022 14:00:45 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:22694 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350363AbiAKTAY (ORCPT ); Tue, 11 Jan 2022 14:00:24 -0500 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 20BI29Gn021730; Tue, 11 Jan 2022 19:00:16 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=1rfp+soIZ7vej1qqNdpuKGA18JLBYpfc5va5jA1zcDc=; b=fLajsfihsSE4gxWT3Qq0BdXAny+rOBrHrYZ6Zut3Fye8nCUWUdmTRpQxEe/wp5OAcjh8 6wR6m7Z3U9VVf4QyTWfxnDxzyZHzCY9GkwDwPmN6fhX4T+P2CH9jrvM7M34Y7XntZ6ft BmXiYWQilrZmN+IitJQqT0N2PplHiptkVkkikGM3uAkN6Jz2uArDY3A5emrxmvOv6WAQ wNeHUoMEWqWys2LD03DyK295OBOStyxlfRaiiJiO7z0l9ZT/b+NBcr5u28yC+tbG99Eb IjOS3qdM2ytuSuNYnZA1yDTTPxi1o6pZY/anEAvKXAkX1muvnwDC3VzzJkRpUW8ZL6QZ uw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3dgp7nkw16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:15 +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 20BJ0AW5034629; Tue, 11 Jan 2022 19:00:14 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by userp3030.oracle.com with ESMTP id 3deyqxmg1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4v75P6xUhVmhRbApTQBowErakpQISU2Zzfyjsc4IfrcVfxI9DbHMCNo76OB+Z6crVXa+zMv0VoBKMmsBLDmWiX394IQEu+Qqrmo1z76maiy+sfX9IyW7fxuY8mn8DkFqdEzQ0TR2CwK3FvVkw+VX2UD5Nj920ZLwhWxM3RKggTPUoprN+urDrO8vS7ewEAdrK6POqPfDS8iW11NecN4lNBB2U9ZQw6XuwebPvanlzP0HgsRjLLe5UWc1xFkfIpU5IrOwIIEIxB1GV2Nvd7fPUh4LMXfuHb/iX2S8Lm5jX7mn0oucYHny7dMgN1jhxhvwPJQBVvoRSPpnTZLVnZsNQ== 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=1rfp+soIZ7vej1qqNdpuKGA18JLBYpfc5va5jA1zcDc=; b=bcy02MlWZrt4e0YfhWSPA/Zb8CO/ZWIz0N3PGA9jw0PcGAOwqnC752JaFugvSzEtjTYCupIZcWj8IM/0MLSMIpZICKlkcP0snFpsRcVS4jYxFisxuRqVzfju5G+xMW/2JhL31P8rbHWaHSfuF7nTQZnXNpiPmHBpNHg2gVd8ydwH6kjRMwPiuIzlfdgA9VxhYIJ34AlBVLaJlctZhO8ihIPTuItfZEKTm5qtaoxNVRm+SR0ToMICVtOYf8qvg66dmdmAXnUxQmLU1gjE9rLveal0btFTI8lTgRuimwNVDGw6xQd3g4A1K6BOIk/eA8bVDV1WezfZrA+iiidKwf+oBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; 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=1rfp+soIZ7vej1qqNdpuKGA18JLBYpfc5va5jA1zcDc=; b=xJ0kDcHRvPhGbEtjm+OUfH4oXAIgyOkrcAQ0JvB7rDlfGCEhVKDBPp7MNpXtk71bNA99x9sj9TXdUD7nFV5CILjysDpPTez8kNnXdXV937HN/tb5xQZHNv77FB/Hnf9R1OAG99khbDggnoDrIWFQfC9zZIg6ksTYSJGLyQs4NLw= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by SJ0PR10MB4495.namprd10.prod.outlook.com (2603:10b6:a03:2d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Tue, 11 Jan 2022 19:00:03 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071%8]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 19:00:03 +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 v3 6/7] dax: add recovery_write to dax_iomap_iter in failure path Date: Tue, 11 Jan 2022 11:59:29 -0700 Message-Id: <20220111185930.2601421-7-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220111185930.2601421-1-jane.chu@oracle.com> References: <20220111185930.2601421-1-jane.chu@oracle.com> X-ClientProxiedBy: BY3PR04CA0005.namprd04.prod.outlook.com (2603:10b6:a03:217::10) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33fc787e-538d-4917-6bfb-08d9d53492f8 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4495: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: 9S/VVEVSLAdW5qpwLzsQohMB8LGbKdujBaZlVrk7Kh4Qy9qOJw4RzDluyIY6AMuFPQrKbG4hZPssl9ZSTWfwIkRUcW5ltjNwAur3Ko6pk3IFWvjQoYrUYu7QEroCY+TbWasF0uIfwJBOn9rTK+p3ZZ7d6E9gUJHK18D38VnuxXZ0ZXxqsnDad3JPedk3FtX+3hisEcINA3uBS+BG59ZhT7ZyODul25qfIC4sNpwZrxnRgh9jva0MmNGGnzfwF/0JgPS9rTzTZADOdO078IVfw1n/zhjPlYCC2KbWu7Y+PCzrEPZG7gn8XL8n1slKPUGFi5/3mFZnn2/TtdjYn/2VXze7yEwm1yMBxqM1ipybiEoqyDQVbvCIkxHLD0SuthKRH7Td0ljEFgJM5dZ++AhWqCJmFIdjdDkWYFUFbWsvmM6hJnA6TuQ+UQwfo9835zAFX1czrUOPqt4E/Zv70bjWPcLOizwdRAFQqt/ZqaREjIq/ZwDdB7BtRE3X87kxAJcCpYgYaHGmaHtITfGQAnkVaYkX3hIUMvkHfLe88oKd9fF9Se9yrU4+N2vPb3rHkg8CGtxS4+v9zkJIN6VHr5y7coZCHdFG5v/RH1bd9N1nu13s8nMtvPMuCRhowH71nLST/a9kX/03RF579wwf1Q3WG3ASRimql6DwAZEZocVf+3Eo70M6wbENmHgkn+fHjwAU 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)(1076003)(6666004)(5660300002)(83380400001)(6486002)(36756003)(38100700002)(2906002)(66556008)(921005)(66476007)(66946007)(7416002)(52116002)(186003)(8676002)(508600001)(8936002)(6506007)(6512007)(316002)(44832011)(2616005)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p1OKUxPASkGdc8om1psOMzY2Aj+O55Is35JHfAHpV5AGeFgrBs+1wWAl7KBuExJ3qN1CqquwEYVylFuDURPTZFIyuKGJlqOdLp9uJxLCTGVyCs+R/1Xv/YKjyEpYlLHcU3CsjkGw7fIyJa/PsL5sRZMAM1W3ibgPEwgtcJQMvkfXTP6Ah9BytMqmpCTXhBgWPfwIyj68XExZ8XTfJacipo23B44ZgdTZvMhQ+6mCDwzG/WyQPLPTmNJuebzssDJJjoxwpL09shRutenE3USNxYP6OP8WdTpWJ/3ZCo+zQiUrFMRZIv5STtyW25WiO44E9YQfrI6PbjioSTaOqr3VmNlCawFFGMahc3Hk2XI5dS7OpnEvJ5EO9bBWmEU2m6WYGqxTmBvdxQqQ+jkXa0AhPc2FjmIflaVKxV0WIpH+h7UNE34Qim2u2iVlWsUNkZs5CmaXZhFhaGc+rWrUOpVDqeRWXDRFUBNCWMClfODend6WLgllh7rRgpS8q1Dwsbck6S21wmilU5TaaSpfQipHUb6Ros1z0nYX+6JeH78v/3LDabAKRJqUlmye9HEHngDTllpGmXlkxIcakSSxjtysnq2PWqwtm3vISLIxlSVAFVsI3OHlYQUqeEev22eulmh1klo2c+T7fR5NRAC1fpQEAnju8xhIfHJWJ1iZO4POmZfWI+fElpyLqtYaLwcyk3+gj5mAG+Ojw/2YNM3QChydIq68wAxS65Mk8bLbB3LaKxOpkQwAa4O+gP6IrFqloXtaVF5dhBP9jjZsxXnI2Gi0ryW2P5hkNcqX93ZYeinE1nuXlEM4kUu645I9vKFhN1SryeNcyezTdsFnSYkIoPuxLgVwVOPG62jTmiXpc09cFQOCC23MQ+/GWk+Z09ViEVzigzwWKoy4/jWcTXo1hV/AAXf5hfxcolo9najT5BzUDKo+6m2rLymrrSTmglwknEz2qSMQP2x2jzCIRImmUiajiFHBTNgfVmTIIR0kDPk1IYAmRrM1UewIoxFHRXmpGMz8V0kwnNFdpZSf7vLm+LkgNtyrxDclwsOzB8rfJv3idzH8gGzrzlhNaRQmnTuJ0E953KSCPKhmzyU84hXx161+1bdFLD+4kdmkVJUM9DQ3W9pDlK3Y4+P3YZElCKi7It+7sRYU+Cmw5P+i1OeJ9F5ciHDJLKcOUF2GwfeTUywhE/lrTHpEuJ2wMEyQsYV47LTXGCdODlygy0kRgDJdTLDaaFCyAKpl/QcuEl5F4O5J7yYak/FzbFgN55m2OjMES84htsYw6c6N3/bMt2NrbAClOYX210kVbIWLJkIXTW1WH6g+ozpyWYJY+zP4hTwS21eCQS8O11Q11Zdv2OL5EZKdT/gNIhqlbntf5+/42b+vRgl20gQ1cLLGxzCtN9mVRwWq5LGGf0qvidCCzaGrMkNKkdGUIP1X31G00NoxG9/tfy7a0hQyranoxGyMw58xQH40RZLFGrDA7kgpzJMsuFuiTM5C7ReGIJdfzD/HSdxHJxhuOQOncSG8ycU16fRT32fK9ofhHZZcmlbH8v/HBZXPyvoBVoQT9U5X6weJOWLLZGT9sd9SqOSYQmWaqVQ5VFBbd/pyCpgYwTdUDY999rJRbIcZpG603tA8DJrENqY5ztSAfJkEoB+GkEzVaPQmA7kz X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33fc787e-538d-4917-6bfb-08d9d53492f8 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 19:00:03.2934 (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: rmOinlmYMoCAHchzsAzyY2vqpMqbxLlasauFwMror1n99rxilA1JGTTjOgEFy4GjN2K7qZvOAWwn2AS9J7BBIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4495 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10224 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110102 X-Proofpoint-GUID: rlgtq_5w5jJ7F6d3QEklQLH5R1rUc3_f X-Proofpoint-ORIG-GUID: rlgtq_5w5jJ7F6d3QEklQLH5R1rUc3_f Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index e0eecd8e3a8f..c16362d3993c 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; @@ -1264,14 +1278,21 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, * The userspace address for the memory copy has already been * validated via access_ok() in either vfs_read() or * vfs_write(), depending on which operation we are doing. + * xfer = dax_copy_from_iter(dax_dev, pgoff, kaddr, + * map_len, iter); */ 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 Tue Jan 11 18:59:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12710386 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7348C433EF for ; Tue, 11 Jan 2022 19:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350453AbiAKTAl (ORCPT ); Tue, 11 Jan 2022 14:00:41 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:33614 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350391AbiAKTA3 (ORCPT ); Tue, 11 Jan 2022 14:00:29 -0500 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 20BI29A4021898; Tue, 11 Jan 2022 19:00:18 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=ihfib3/XvJXH6M4ZeOUkVYVjoroTp4Pp2GUuR+aIArQ=; b=mxI07t8kFh0hu35faN9O7x0LsEr65D6VtUt9uDs4kF8Fa/fnBRJQJMP1bImDRhzn9Mmk iAFA+5jAmQh/Oq67BIMC5lRntYGy4fjYfmc53Hhu6HZZEcfEcxlmZIqw3Uy4j4dAOLSL FNlZ/GfXkjigpuomwMLUAaPO4Og4sFztve+bQtFmGUYZTF5jYMJOzewcHhI96B3bOFYH jRUoFHNXncKqyrNx7hscN+7s5Z9CsH+mjtMQ21ucOeLPS/tDz5vWOgH8QvjayOGhFNfr Q+v+mqLdPLknxDLPgfCR2oQTwQBZdzHWZm12QdW+li57+WDBALBrmP83Q6jIFdr0pOLF iw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3dgjdbvbp7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:16 +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 20BJ0AW8034629; Tue, 11 Jan 2022 19:00:15 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by userp3030.oracle.com with ESMTP id 3deyqxmg1b-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jan 2022 19:00:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kehzmpxHE7c9bQZyOmAT+g1ydMtiJfJprGSAL+jISfqcCSbJ7JA+2W+Xl3eugoWuQ5WTKvHRO22cp+4XTGtbmALUdETSvEqIhvOn0R5jEXmcbHMxyUMVc/TjsErVwFbSNYI3oZg84wr+cGYrcp4f1tVJP16LdX9GdRnUyd1u67h9c++/j2DH9wqx7/W09mZrKM26Hp1si7lJGZGmJwfGXzEezW8Ths90TaHgRR3qEST7OC6RnwiubsGoorpn3uC7wHbULlYzGi4p2CX5bkJa2UwiNoF84k/yc/JwnsTxVqwOtZb3lxq/s24Q+8wiKPTR2kdY6FVtIkWmuvI9fgR7ew== 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=ihfib3/XvJXH6M4ZeOUkVYVjoroTp4Pp2GUuR+aIArQ=; b=nr82+vs5w/e927rR8DPJCjxa0xk+kIbcuTVr6rodQJavG0fIAwIwQIOT9iRiQLZjMDN0PzD7ICLFdU7g4duLbFcUD20vXyi9/2clhxRP7UkhVS8Mmzu/YihAu+x99TLWEin5/lyBDATnW2WBpid96nP2AuEuM+4D9ABClemENactEwNTVO1mHQQ1oXWjCUu5eLQybHeavyr0r7Sn9qIuOUABf9mKjneztjAFeEEYp3TXgq/nCXHzWc1e9yXFj2utwocep6z8XYeAjD/Chzk6gpdkKiFmbXGUalBedjAEXbz7T3tGHkSL24dLjyRBQKt0ia4wx93yfLDx95DLzf4peA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; 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=ihfib3/XvJXH6M4ZeOUkVYVjoroTp4Pp2GUuR+aIArQ=; b=DWYjJV5WtO+m7M4RBry8pkPbFN16u1HZms8hpQcssutpIVVVpjB91i+SW1yYCJHLZqcAWcVJZQ7M9ZamIYlA8Z8OF8Orz1KffXbCnsy7aqqR06/GB+XLmRCqIh9jHexd7oCsN5JUNS4zMMoGcEbMCvCsn3ZC5ZmdeUMFZwFw4Qw= Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by SJ0PR10MB4495.namprd10.prod.outlook.com (2603:10b6:a03:2d6::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Tue, 11 Jan 2022 19:00:06 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::6814:f6c:b361:7071%8]) with mapi id 15.20.4867.012; Tue, 11 Jan 2022 19:00:06 +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 v3 7/7] pmem: fix pmem_do_write() avoid writing to 'np' page Date: Tue, 11 Jan 2022 11:59:30 -0700 Message-Id: <20220111185930.2601421-8-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220111185930.2601421-1-jane.chu@oracle.com> References: <20220111185930.2601421-1-jane.chu@oracle.com> X-ClientProxiedBy: BY3PR04CA0005.namprd04.prod.outlook.com (2603:10b6:a03:217::10) To SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78961368-bcfc-4161-d875-08d9d5349491 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4495: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: bO3exSQ2EZPaBRWzZILT4c+eLHGPyxAwv9CERdyznfNcamZd4Ln5Khyu1ngxRoxf26u+q24QQ6sgom9hjYkIBCdgtejBH2Gvq5s95ybhdgAV1HMdUqUvONNTFrrIaQedQe30IWzSnYC0MfOKk0bHyWqVuXVjK37/v1kUyaQBZ9ece0IHkw3CvZm20k/2FsbXkKBzcbDkVI5mcbZBY3Mg3n4nU4Wcc9UFRUtN3zSv9s27hqBJvER4+yjXav8svYOXRUKSrROnqyWZB6X8hrAVd9dujH8Z/zhUTuLKKoSRxsDY9cZmkJgF3BIuFJ23m5JgVvilsezJsDbSuq87R2C1lWSlVhMwDoA3N9UdZgH2Opl/0hxTiMdWsA8ZiWFkwgBsPBhnEsUxTmsXPXEd6RDi09rFxcpKg2YfYdvJohDLnph7aIEIEPCQm/6DQNAQuEC+aLZLA2WDMUqMnsKCUn98kna7gO5pQZUJVOd+x6I4jtWq0mTHEP/OZLocxIxlQG4hUIPwsEB6u7hgEoYHZwDXAHkPx9w7QXjuY7IT9MsDdioEa3aMcfFV0pJ+jn7s7WJPjlO/Ck3GfmMrDPCL4F3x/NjJDF6jfHLX798hV4SLcBLd/Qqd8pqfb2jZ9eRK0ovycljDQwdmMC5FCfSnqcsqX61eA8plgb/vacZZAhZwZ0TR1ysHYVYA0CzH/D3es9/u 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)(1076003)(6666004)(5660300002)(4744005)(83380400001)(6486002)(36756003)(38100700002)(2906002)(66556008)(921005)(66476007)(66946007)(7416002)(52116002)(186003)(8676002)(508600001)(8936002)(6506007)(6512007)(316002)(44832011)(2616005)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cn4W4Wffqelx+Nok6anZbGQxSgu+3g6z5f347IClPt+K/p1J8kldXyo8x1051QqsEy+UZnsKQ12x6wtgIdQPxBJRZcfcb4EqmzeK5zgj7ngnzIy3O8/7wvrcJuoH/U/Emq1P/z9EfbQc8SRnHpVMlXIIzkH/kWL3I4PLwSINSJgYCuJcgEqLvhBNWSPXZ49p5nRy6XvIJNHNurDSFblYmD/+Mlmwjx8nWZ5Y54p5bYQ8rNwArLwWKMC2M17BJIrmAswYChZUTFM4nh5pGxTDufyplqGWD53LsfB0coDXUfYejHy+eVypExVYwAOuCGwE8F3poGiMyEe8b7ThJhqTFwWUdzcdTELO05En9t/ub1tt9B9nVK5thogB9ZPkhXmWAdTXDkW6eD+MqJ6R5MrpvZUo4b+BTXbcPJnzVNK0LylSAVHqWAxgVKA1BUo/VOqRIUQ3gYo/Do+A0ZsF1L2AVDsXyaYn6IKWsAaIL27awsjEpl/Koa7c/clB+kMGsWDvfrtUdpHNVuPBLia8TDhZ6iXID/0hhmIFOwSiw1ujWwgkJs+ZSEC4hlN1i+6/3O4/SD/cRZULs0ukLz2JzcHvOd/cMwrY5SGFt3iaSXcICzJx7dLvICFzrAwjaWViusg5TE4xBzyhtFjE6DwSgTS4qoJwdqDxW92EuJGcZiBDjgRpD8tRLPGa1cSYkneO4vfDwUEUaIhE2OVvLJCOc8DvyBfqCxYzZD9u+JLPPdLcNQZl3K0JQQniiDXqhxW1AnF0Egn6v4p3/WEIZ4epU+BCBHtzeFu9IkC5YBVACvmmSISJP8Mj2fkPqro9wmeEPvdo8LLls92Kbyln/CsiZQse+Hlk8XGd08RI+o2Z+NM34SeTjqtTKT73V13vpgi0FkMw++ewfOBlxqbjxLKREZZBoBfDiVGaiY+1aeZewdl2adAyb8o1hbJsZtzIvcmCDyMBHNSBx0v3YEMIRYUVN5E3YOmt0wsDvjbufYJGwezwj3IUzbCrgEJ1k+rS9ttla+1xJWsiHIYBA8kUN+817zvNY6RlY7gpE4iJg/g5cc1pZYJdPSBHdIGztsUyD9gRxH7D+Xw3QtifTUT1hH9qCKuUIlne89KbTTF9838wuWAqeHAqCtuj7NwwPzQZP+qv/haQmg2Imh7t2sTyxQR+d3BafBLfVOS5yrFyBLXiXrkMhazSsANlcx1MjnVqb5xEj4tXoGn/8pAjHV619+0sPdVpYU+U8uf5O2o+dgTi5JTP4WDBBM8vFkvDecl1LF2Z4eP00Hbnu0CrqxLaUc+rulBBtzD8QPVC1CS088n3xuVhi25594KqoaH3lFEMFGPvkNTU1EWyJTQqL4p+dRoedf9aflhHqlbyLqKd0aowcBcqYNBu/0ojGhERk8vXOHy7sfxujyJpmjC4edhsRwiySOwBRyWjiARl31LfQPZ/SQXvWHtLJn6uVx+A6uiEq2hIgVx2bKyWKsKYgAXBUqk99KMz0j/kWQ/eHTD0K35/hKpqg3Ifbh2cKI1dRhUniIkLpsxeP+PgaqwAa5bdZ0HeVEQ+qorGj1oYD7/LgXZUQ9lsLDYyg4mr2BOOx6ueItBhGzGVJrBlYyIEeEHF4G4F3jbp3H4wTpJr7DQDigMtm3kheKi2hf75DBWJN+kRU2kbLZIV X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78961368-bcfc-4161-d875-08d9d5349491 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2022 19:00:06.0333 (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: /ZFzvJ8WeYL9it8S4yw+o0N14TEIKesiBPcFPBfDWmMnWPa3v4jLoLwiBFEWNeS6WcpCwpgXmFLJHcmsYvmQMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4495 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10224 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201110102 X-Proofpoint-GUID: raBzGuXltzm9pvEsjZuwETW8Z3S3bzIb X-Proofpoint-ORIG-GUID: raBzGuXltzm9pvEsjZuwETW8Z3S3bzIb Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 dd2db4905c85..6e395014da5e 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;