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: 12710375 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E07F52CA5 for ; Tue, 11 Jan 2022 19:00:21 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 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) Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 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+rWrUOpVDqeRWXD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X6weJOWLLZGT9sd9SqOSYQmWaqVQ5VFBbd/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 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;