From patchwork Thu Oct 21 00:10:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12573553 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 216A72C80 for ; Thu, 21 Oct 2021 00:12:17 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19KM5SgP000812; Thu, 21 Oct 2021 00:11:45 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=1BbWCXWzj9c4p/AtzW6dlJYAODCGWsVna4JLDz5OPJ0=; b=FrXhSLWcW3i7r7P08f4694AWr+uORK5tBAr0sUdn3I1dPX1Wo4taniTUpMFw2h9pmQpf hhMCGUQjrmVLEH/BjmULiovTQNgRYrK1sRpvQMOZ8/dfIcH8YUDhZlwZtqLaW3ouQwVS jQ+ppNY7XSQl5LrEdqChk7lrzWZx+WQMI0TKz2HqH7njgFmrtD+5Xd4oMunjtSsUIkSQ nEpkq7szvEkEEUaHlGPNoJmBFnSuMQD4NPqenAkpK7mBGY5VVKgs3kJx2wCWsDcs/G0w SVhl63CfhupXI1MLdAIsqL871gL27M76Y1wm0HUR1hIfyWvatN0VNeuHrexS/mv1z+1z Hg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3btkw4ua8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:11:45 +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 19L0BacI133105; Thu, 21 Oct 2021 00:11:43 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by userp3020.oracle.com with ESMTP id 3br8gv1krg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:11:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NLTSSnc8gGWQfyZ5gln495V4Nj1scBvrLjOedM+NTvVpkHuHeAcHoIiG2qShaZGDJ54bYQLxLrVZOjpTplCG8p/EES+UxhQIw/EM9OX4+bKdsugru94sYr2UtFdGIwPAGgA+y4pmbyqg5+FXt+Ad0jKimIc7l7Htv4A5iC/gXaPOJn7Uo+y0yjff0sAnUhrhBV5ZhEkljasNrHV8KEzFGrZFWqV+aT5dy4bum7c1SWd/Tn7CxVaoSTOT82Hfh/Fq9QxSkpt6vd/ZHsOXuyXiUqZ6bk6VZqlVXZs4JLz20IH2ti8jrXyGIGALmADdxVe1HiNVyVcFgQFTe27VUrJWhA== 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=1BbWCXWzj9c4p/AtzW6dlJYAODCGWsVna4JLDz5OPJ0=; b=ayY+IrQQlzdnBQHxY1wB7NMptlDj04Nc8ZN5S46vX9ZhbNhBmaurG1sCo+0iZjP0/Gc0hgLIme/huIb4kRfMBWJeVh6MsIlmucgiO+DiqnLo1OOJYnm4Hs8fyMwhaCSiUT684mcUpc7pfjvvRagjVGdEhGtdOh9cZJ8xEWzArn53yniQ5IxTGFyXveOsMI2xMbBpLj68Lznlg9NRmXmMkanZFk7/XHi9awqCakRTvlB8tZuvYdswS0nsAERUB8Y/naLv6oAUlaq1Heup4u4MPrRHyKK638MZ1bI8Q0skCH7o2frgLRTkZ2qbfIu8JvdQVhOpqfM3AaCe6bQph0llCA== 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=1BbWCXWzj9c4p/AtzW6dlJYAODCGWsVna4JLDz5OPJ0=; b=NqYyeftX8BxVE7NgbOg+MnqW/LNJ0nJnaQXNc8A6MzqnKSp7g9I4jvoBThtnn6jx/VmEE7I5K/yBFgRgs/9ibGZBq+vlHlV/wQjgyjaZWRdsrxabkmf8tWZO1/R72QtCJ+kh8ZoY8TfAO5/ZYxoYFrlb489PP9AFbgwcxPU0Ncg= Authentication-Results: fromorbit.com; dkim=none (message not signed) header.d=none;fromorbit.com; dmarc=none action=none header.from=oracle.com; Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BYAPR10MB2759.namprd10.prod.outlook.com (2603:10b6:a02:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Thu, 21 Oct 2021 00:11:40 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c%5]) with mapi id 15.20.4608.018; Thu, 21 Oct 2021 00:11:40 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH 1/6] dax: introduce RWF_RECOVERY_DATA flag to preadv2() and pwritev2() Date: Wed, 20 Oct 2021 18:10:54 -0600 Message-Id: <20211021001059.438843-2-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20211021001059.438843-1-jane.chu@oracle.com> References: <20211021001059.438843-1-jane.chu@oracle.com> X-ClientProxiedBy: SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) 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 Received: from brm-x62-16.us.oracle.com (2606:b400:8004:44::1d) by SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 00:11:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef4796e8-e358-4a54-5b9f-08d994275b28 X-MS-TrafficTypeDiagnostic: BYAPR10MB2759: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2AI6XekBnjXoFm//pkIzwPSmpsDAqi18CLAMorG2nVz7LYIxHc7qanPDM5Jfr75kYPrUfXiFWNNaec/8jL49tZamPEXhqx/5co8+KtE975Qy3czsUx2REw8eC5IuHoI4d0Vc7lqgsjA1gJxvbewCB8hQqZmqcwIkMVjC362W9ORu76Ci3VpNwLV0vdiv8uNKAspE0qzaO7rd+7ShNq+HB6pTRT/+OOJzuS/EhXUjHKYyw67TFRmFw7eoPBCkFYLq10GMd9Mj4WOf3jyjMQ8AFrucgGhimc144JJTxG3/HC7FstSoXKi1H++j7OKCTuzPIVJ1xWQbrchwDZO6LJyZrydYns8hmevht52g+wvwm0RohhR9Tm876jXSR31kZe36VXlSzspjEUag1eXzXWstcBm7yckjeFMjL2c9DC2+AjQxnVi9d216CfdwfbHJ8JL1W83jU4Rs3gawAhtMzN75ZM5KJcdkxrLTyalVSUr8yAxL+XUwppMkfNNlsw16CzsXzYaj/RgYMUcy6D+ENFA/OLRz30KQC9vswh6VgGuVtAR8f1YZTnQPwLimjJrvftoRkyKN/paiKI/IRGjSm6gqVoDLpY5T38yasaV6NfIpN50yyf+DpBl0ls74o3KAM7vDh2lag3CoJNVirxJM3gd6Oy/EVaTy+xcNGDQ6yZjSW/fUSUOoqnqY80CARj2ov+Vw 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)(316002)(5660300002)(1076003)(66946007)(66476007)(7416002)(6666004)(38100700002)(83380400001)(36756003)(66556008)(921005)(508600001)(6486002)(8676002)(86362001)(186003)(7696005)(52116002)(8936002)(44832011)(2616005)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9ZFBALpXqz0ghYUUqn6hN5NFhWVBIcAscVYelrsRmo4Ylq4lg5B0W3e3J5LsQ29MTh0i/4WsXp/gmQtEWjbcFpIvAjZS6OjGGYNHOmuINrmgMzQm5O1HARcLnriyqv68YfkXAh3wZwIQ3ek8CQhXY2zGsUPVC4tUuubn0WE45PgeRu6HmK0+MMsx/6rueKJubN28eYkHXOlXDfh87sqbrPhsMN7+KUWYxd3TQP4LA9ZWAqsRIktToFuzuBLJS/klzAZr+yzUXWQwUsqXQ4lgJDfPik4dcs2pjL/ARDDPSaPfseWPg8sZCIC7MvF61PIWQLi35f5XzCMEWd9ZudmMQRf8YOH16zbkQSDhSquJDaXIS553SDLqfvBplY1EKva43x087DKJiKPoxwJGnpqRaOaBAXGSPIoOQHL+yBBYJMgZnLGOz55C0oA8EvhSZGHoTh5rt9XpQGW3HeZLViJQ31X7y8B7w51gZBBnix9njr/MxEWEeQqCvQbd5du/LaFX0bUnTf4N6qlpUUJIweAkzXUed7ROL9OAlciDRDbWtuM01uYYaFLyJkUM/vPAOmjN3V5obKCvM91Uwc/psfTRJJV5Eyplh4PgNWjccNMTKjqT+BAuWZOf0alGExaYhYx9ljQvzW6hkafsug695kD95Hunbr2hxuZ0AsgQeXZ61cswkbQsFHKnXBMGvyTkOAAVp0AKWFj2SaMXzYZWbRmMiRTxKfzzlBXNZUlGDIp8GbBoEvEh269Z9U5ATk07nENs4sMedr3WYqeZbvOx2ixHDdfZAqZLAeoRztFagrgXyn7jQw1xvFjKeshJAskQTtdXO0+amjYGWzcqp3dEKld8DXRWn51fTvlXbVUVkkJ+TZhyziiEuMfZ3kUBtS/9S9dDzoOZvZtwhIgsvc85t3HtCeEYQWO0b6lwR7SiX6W0TbQkzsamhAthmcTDPsX5/eTy3ATb/v7c4l11vDVsG/1gkIs8tgJh3U6BhM+kZKzLWCQoSl2/DBga8wz4XR2tIuqf2l/vlOKwATQabKEbB5IgCXnawR7SWaCJvAXwPrgGA1ODUUSu+KW2CIBHEOgFFEQ2DLLEoKmQ+DrUGaWRFw/tjt7BqyOBt6uuD4NVOAe9BHKqCDkbjs/GluEisv6vESsrnIOvsdAuBRW3iqZTZ0oNWJWZNva2pwuQfQLRQXvHJoB4Yawdm5toGo4txqUebXyLOyEyOl3ydRRC6WE7e1P0rB/RASfaYTdZML/uQNwLv1fkDie1tD6gFmgriowA7aTFvhiplsoSHJAMlOpKMEMcBv0ZUALHpv5QL1RF/2W4YYXnXdQsuIoZZ/qY8bix19QPXC2SiVKJQx3J41a5JpLpVg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef4796e8-e358-4a54-5b9f-08d994275b28 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2021 00:11:40.5574 (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: jane.chu@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2759 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10143 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110210000 X-Proofpoint-GUID: Fi4W2rYrk5bNBurtKJbC6_nV14Ouq-fp X-Proofpoint-ORIG-GUID: Fi4W2rYrk5bNBurtKJbC6_nV14Ouq-fp Introduce RWF_RECOVERY_DATA flag to preadv2() and pwritev2() for the purpose of recovering data loss due to dax media error. Hence the functionality ties to the underlying media and driver with capability to clear media error(s) on the fly. When this flag is provided with preadv2(), preadv2() will attempt to read as much data as possible until the poisoned page is encountered. When the flag is provided with pwritev2(), pwritev2() will attempt to clear media error within the user specified range and then write the user provided data to the range. Both the range and length parameters must be page aligned in order get the recovery process to work. Signed-off-by: Jane Chu --- fs/dax.c | 3 +++ include/linux/fs.h | 1 + include/linux/iomap.h | 1 + include/uapi/linux/fs.h | 5 ++++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/dax.c b/fs/dax.c index 4e3e5a283a91..01118de00011 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1288,6 +1288,9 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, if (iocb->ki_flags & IOCB_NOWAIT) iomi.flags |= IOMAP_NOWAIT; + if (iocb->ki_flags & IOCB_RECOVERY) + iomi.flags |= IOMAP_RECOVERY; + while ((ret = iomap_iter(&iomi, ops)) > 0) iomi.processed = dax_iomap_iter(&iomi, iter); diff --git a/include/linux/fs.h b/include/linux/fs.h index e7a633353fd2..ae138649cbe3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -311,6 +311,7 @@ enum rw_hint { #define IOCB_SYNC (__force int) RWF_SYNC #define IOCB_NOWAIT (__force int) RWF_NOWAIT #define IOCB_APPEND (__force int) RWF_APPEND +#define IOCB_RECOVERY (__force int) RWF_RECOVERY_DATA /* non-RWF related bits - start at 16 */ #define IOCB_EVENTFD (1 << 16) diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 24f8489583ca..c13d23328140 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -141,6 +141,7 @@ struct iomap_page_ops { #define IOMAP_NOWAIT (1 << 5) /* do not block */ #define IOMAP_OVERWRITE_ONLY (1 << 6) /* only pure overwrites allowed */ #define IOMAP_UNSHARE (1 << 7) /* unshare_file_range */ +#define IOMAP_RECOVERY (1 << 8) /* data recovery */ struct iomap_ops { /* diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index bdf7b404b3e7..febec55ea4b8 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -301,8 +301,11 @@ typedef int __bitwise __kernel_rwf_t; /* per-IO O_APPEND */ #define RWF_APPEND ((__force __kernel_rwf_t)0x00000010) +/* per-IO for data recovery */ +#define RWF_RECOVERY_DATA ((__force __kernel_rwf_t)0x00000020) + /* mask of flags supported by the kernel */ #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\ - RWF_APPEND) + RWF_APPEND | RWF_RECOVERY_DATA) #endif /* _UAPI_LINUX_FS_H */ From patchwork Thu Oct 21 00:10:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12573555 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2170A2C97 for ; Thu, 21 Oct 2021 00:12:17 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19KN63tX025798; Thu, 21 Oct 2021 00:11:48 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=ifSBF1RQnUVXGKyvH12egtVGx++r6u9YJdKhok8OWeU=; b=SX8d46bT/dYb1mRTPJFQ0qVXifkiEdw+zmuP/LNkW7mS75YbdHM2PtW1Dyan248J5T2q km9u0NTpsBIAJejvUWfWb+levQwWqg5AA6uqxKXyV6hBxc78hmTD+N1zWkrfC3cyMbgN y/dnR8Pt1d1dfK4ipx9a7cc5n94asHPRUkRAJ9hG9jcyhMGXB7PC+JeG+1PYhmcJVIp4 U4LhIivnEPdSvS/bnOsBMEegHX/15Nq7MijqvVJfJjfz3AvlXycUdJ9TcLPWojRnWnI5 X+/9dtTzJmmuym8DnbY9cDvroPu6EPmCQTSrOkLo6bm5L+JiU9iCAYHo5dIebH1wYsx+ 6A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3btrfm1jng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:11:48 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19L0AsIi065365; Thu, 21 Oct 2021 00:11:47 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by aserp3030.oracle.com with ESMTP id 3bqmsh8r0g-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:11:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mgsZ25HSZmQm122fPMnqVbHw1SeFX7rPKuZ4F6wOtRqM1aP6UXFYw9XYP/kN0mltgF5YV/fiMRxSgtAjM5G9A384xzL6iTSQoNxUrhQzhttnCYWsxWKtqDdfmtQUFHOxHfZ7kuZd7jagkpz+WxPifDAb8r3+MqkD2XqxEgShLKcaVKAtnKCYxAZuSfkLmBHso2fHLQgwR7YcTYJ3kx42RJcyQWoxtjQHgMwp6qPoZFAfCzpaigAKi+C0/R+7LDNGTFJQu75tOY7zw8K5/ulnp2nr58zmsi896v+JAPz4ses7CuH9vHv2NPlUhZ1FxcOx/WD7QEVV80X/zK3ThVeQZw== 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=ifSBF1RQnUVXGKyvH12egtVGx++r6u9YJdKhok8OWeU=; b=AWnZ8LhKUrT0jrRWHEHVJub5czvIk8Pzckh0UCDpWJZKupCN/NHHNtgeQ3GFZv8Dp85/eAqZ39WaE+ANQVQWVfClX2g4g21UX4oumvKVcH8nOXnqQMGIk9FRWazpEVmE6D7GVMzSqMz1Q+a5ZZNtAbxhetsDoFM5Ye/LKW0XPtFUHF6uj93XcOpe23j9sXS9rmQi1F2TQiSOEY5ocWbcaPClTsKZkXPNHsvOsE5aFMRHV7iplg7/MoMsAf186wz8tFL8Fh+TIytWjMjG58L7fcEY1+xy5vdIEsvkpKmUDXVJkuzgKBJAjMRtrhskLZxXjDMppMsDPVnMC/eetwgi+g== 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=ifSBF1RQnUVXGKyvH12egtVGx++r6u9YJdKhok8OWeU=; b=zSdaFUz8sQ2vWfz9HiR6QYmMtarccHMcDpE2DmwCd/i/l7v5CC/NOe8h8u1rQX/lDX02LngCh+AzbJlP28k9EdH7smqTiOGwJQPHAree4lZQ9BPrx+Rsq6ruTEtlCvPmEbxnzO7tx+L3X8gWFyc9dY0KP3ktYZFRwelhGAQogKc= Authentication-Results: fromorbit.com; dkim=none (message not signed) header.d=none;fromorbit.com; dmarc=none action=none header.from=oracle.com; Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BYAPR10MB2759.namprd10.prod.outlook.com (2603:10b6:a02:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Thu, 21 Oct 2021 00:11:44 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c%5]) with mapi id 15.20.4608.018; Thu, 21 Oct 2021 00:11:44 +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 2/6] dax: prepare dax_direct_access() API with DAXDEV_F_RECOVERY flag Date: Wed, 20 Oct 2021 18:10:55 -0600 Message-Id: <20211021001059.438843-3-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20211021001059.438843-1-jane.chu@oracle.com> References: <20211021001059.438843-1-jane.chu@oracle.com> X-ClientProxiedBy: SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) 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 Received: from brm-x62-16.us.oracle.com (2606:b400:8004:44::1d) by SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 00:11:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fde00a49-f921-43cf-a301-08d994275da7 X-MS-TrafficTypeDiagnostic: BYAPR10MB2759: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZbJa3gxOHifzVqDHqT/5E0T5fxzG5Sp5/YmambrOUPicQdXoJ+PCnMWcmclnmKLBQWBc1a/A2cyXjQfdq4hpxe7kTBq5mKIF2tRl5p0d1DtIrD2HoExDU9JhmJJNOJUAWNqDLdAZkYAWiQzNGzBJe3sv4SHmMn2mlg+hg+tRfBv9U6N+JGZjbORngNdtfU8uPcg5x0qlv5UX8RApiRmU9s68mQ/Wh/tT4dMw67hb0+zPBwp6N7LFVPaZN6sG2BxPcZd8xWvLMfiKOq22G1cgz6WjXhoxvHyegg/6i1Wli9LWiF/kejhD7paKFLZ+BUhmD2V+A/otj9vd7YbhbIsgpL/zMvF+aPNMmDShzQdZ/CMTts8gGouxk4HWq/4P042Hj7r33RRiNaldJjT0qreR5/71NfqoP1pdhIfk0a1Ezm3WTNLeS1DKHvrAm1k0ghe6Sk8YOFWfR5OK0YkVx+YynVuAMbvFWgHSQ4xsf+U4XcEnbCcqdVgs2UWGrCIcmIAcczBzEsxZnJggr4EbfRK4iVCV2/ibu00js7DnfoUTYulO2LjLzmvvcP06mZ1jbU2tulYTM86g+Y2izCvhZ0KI6DPCNaH4Ekx7dvt2zZGgJWWkKp+72N8lKz+ONnN3A3qvmQ+yK3EAMD22h4HOgFhW0OedU1qMVwGvyjblAHHsSftEPeDtQZAIji6On7+BSlXm 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)(316002)(5660300002)(1076003)(66946007)(66476007)(7416002)(6666004)(38100700002)(83380400001)(36756003)(66556008)(921005)(508600001)(6486002)(8676002)(86362001)(186003)(30864003)(7696005)(52116002)(8936002)(44832011)(2616005)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JdNiGkgPN9IIWvbLtjl7RZB5b9rj1LCzPVtgGq8zEnCEl5hSKUbT3zZvGqZ/Fgh59/LlUzdjURtZwEN+2tBYvMjDAcml/WLVQW9Un52txNcEQSHUbHUm+Lxf0N6mNPrrOCMjwi3Btr+QHLgqrHRnkZBnQdpwTIGaJzRE9CtRFc84wbgNtn4rdNcpkepfjXT7SGVyw6E2utpJi+LzmW5+qOk3iBjn9HXdUjH610z7SoYxJhZy7TL2jQIOnt5Ykzqz7dHhX8LMsHU2zOeSY2sa5FalawdFCIFf2v8syHV3NJeHDoYZRDLsq5cDiUDjelDcOfAfgpYPRSmG2nm6MmYSPtyiW1zpCivOtqVrrhzflk/Yt0L7C1WVwJ7/84xopEbHWqS64IVvcLZgZ7RM9LozGIBQf/Q74DRpTcSCfNHftreEczVVumoyrZgQFGJjARu0sPWqiR5USbieu/zN0Ic8dT4f5PDUyrg+hVfJUDISxp5w4MiJQS1WAq67sUb8VgoR4qEEZ0BoSrjri0cL9N+sfd5iyvdUbEH4XDpzDgQGVeIwxPqz6atrl29Q11wGkdpZtrNWy5KIVwO7MOOIEThpEqHJIaKgcfLGSWm68TrJ6YsY9vtXhaZZk66tv4dzii5y7cHm2LthX3/qoIM+2aJAVx3mwJUa50RvGirsYb+bSmrO+0TsQ3vZbb1UdQl/8SJTOBoPxWQnwxk+WxMq9nXUblMjzsNWciJsxmPWfrSFfVqqdILVZkc6N1TgHmDtMzMWQJUiZQ4obQhd1vbmVSXCB27VftN3VXfMIPoGrbXWPnjV4gikjsEvVBQarz1+9Bh27PiWJFyZGYR4qbqyZrlrkDNcrm/U4gfWF8cVyNydsmzA4WXaOJVDz5tT3HWlls5/McG+XuXxwZiGzEKBcKBicJ28fsH5+5TP33untLatDxTkfPK1H5LWuSSc8qgCez59jFdWgGescA6x3cdZwc4u1RKT3uCe0MF8+fzYeqIK9eAYpYj3Jv64nWpTu71kTo97GYgGCWjsoQwTBMK8mhxVucVE3TV6ss2W9E1osnxdH0WYJESDasHe1KK69HGvZ3IhouvT/RjpmJv3wzi/TrR7ZYbYrUgVAl5QI158M5Xf08H3CYSc4ux7Py0BjzQHlcx97DIngvr7n+nKemMpixMXhnjsugTK6FHwVNJX6GfKcVI//oulXImohvCkg7aJQm1xuy3avZ0Li7VcOEYcORXOBvKKmEF5aI66avZWiP+rmha2cI1G48OYiGyPZNw8kWXyf1aMVSQDSXrRfVmPx7Pi3dEbEs89jEcGS2Pv89pvSC9QP28fPVW8n4oPZgQb+sboGfs2LFYNRwhY4XqDFX6nTg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fde00a49-f921-43cf-a301-08d994275da7 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2021 00:11:44.7022 (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: jane.chu@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2759 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10143 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110210000 X-Proofpoint-GUID: dlctoru7oZnGTJA3wIxJpDafsvNLMJiK X-Proofpoint-ORIG-GUID: dlctoru7oZnGTJA3wIxJpDafsvNLMJiK Prepare dax_direct_access() API with DAXDEV_F_RECOVERY flag such that the API may perform device address translation in spite of the presence of poison(s) in a given range. Signed-off-by: Jane Chu --- drivers/dax/super.c | 9 +++++---- drivers/md/dm-linear.c | 4 ++-- drivers/md/dm-log-writes.c | 5 +++-- drivers/md/dm-stripe.c | 4 ++-- drivers/md/dm-target.c | 2 +- drivers/md/dm-writecache.c | 4 ++-- drivers/md/dm.c | 4 ++-- drivers/nvdimm/pmem.c | 7 ++++--- drivers/nvdimm/pmem.h | 2 +- drivers/s390/block/dcssblk.c | 7 ++++--- fs/dax.c | 12 ++++++++---- fs/fuse/dax.c | 2 +- fs/fuse/virtio_fs.c | 4 ++-- include/linux/dax.h | 7 +++++-- include/linux/device-mapper.h | 2 +- tools/testing/nvdimm/pmem-dax.c | 2 +- 16 files changed, 44 insertions(+), 33 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index fc89e91beea7..67093f1c3341 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -156,8 +156,8 @@ bool generic_fsdax_supported(struct dax_device *dax_dev, } id = dax_read_lock(); - len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn); - len2 = dax_direct_access(dax_dev, pgoff_end, 1, &end_kaddr, &end_pfn); + len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn, 0); + len2 = dax_direct_access(dax_dev, pgoff_end, 1, &end_kaddr, &end_pfn, 0); if (len < 1 || len2 < 1) { pr_info("%pg: error: dax access failed (%ld)\n", @@ -302,12 +302,13 @@ EXPORT_SYMBOL_GPL(dax_attribute_group); * @nr_pages: number of consecutive pages caller can handle relative to @pfn * @kaddr: output parameter that returns a virtual address mapping of pfn * @pfn: output parameter that returns an absolute pfn translation of @pgoff + * @flags: indication whether on dax data recovery code path or not * * Return: negative errno if an error occurs, otherwise the number of * pages accessible at the device relative @pgoff. */ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, - void **kaddr, pfn_t *pfn) + void **kaddr, pfn_t *pfn, unsigned long flags) { long avail; @@ -321,7 +322,7 @@ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, return -EINVAL; avail = dax_dev->ops->direct_access(dax_dev, pgoff, nr_pages, - kaddr, pfn); + kaddr, pfn, flags); if (!avail) return -ERANGE; return min(avail, nr_pages); diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 679b4c0a2eea..cb7c8518f02d 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -165,7 +165,7 @@ static int linear_iterate_devices(struct dm_target *ti, #if IS_ENABLED(CONFIG_DAX_DRIVER) static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags) { long ret; struct linear_c *lc = ti->private; @@ -177,7 +177,7 @@ static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); if (ret) return ret; - return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn, flags); } static size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c index d93a4db23512..6d8b88dcce6c 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c @@ -950,7 +950,7 @@ static int log_dax(struct log_writes_c *lc, sector_t sector, size_t bytes, } static long log_writes_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags) { struct log_writes_c *lc = ti->private; sector_t sector = pgoff * PAGE_SECTORS; @@ -959,7 +959,8 @@ static long log_writes_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, ret = bdev_dax_pgoff(lc->dev->bdev, sector, nr_pages * PAGE_SIZE, &pgoff); if (ret) return ret; - return dax_direct_access(lc->dev->dax_dev, pgoff, nr_pages, kaddr, pfn); + return dax_direct_access(lc->dev->dax_dev, pgoff, nr_pages, kaddr, pfn, + flags); } static size_t log_writes_dax_copy_from_iter(struct dm_target *ti, diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index 6660b6b53d5b..0a97d0472a0b 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -302,7 +302,7 @@ static int stripe_map(struct dm_target *ti, struct bio *bio) #if IS_ENABLED(CONFIG_DAX_DRIVER) static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags) { sector_t dev_sector, sector = pgoff * PAGE_SECTORS; struct stripe_c *sc = ti->private; @@ -319,7 +319,7 @@ static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); if (ret) return ret; - return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); + return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn, flags); } static size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index 64dd0b34fcf4..431764b77528 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c @@ -142,7 +142,7 @@ static void io_err_release_clone_rq(struct request *clone, } static long io_err_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags) { return -EIO; } diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 18320444fb0a..c523cb911eca 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -286,7 +286,7 @@ static int persistent_memory_claim(struct dm_writecache *wc) id = dax_read_lock(); - da = dax_direct_access(wc->ssd_dev->dax_dev, offset, p, &wc->memory_map, &pfn); + da = dax_direct_access(wc->ssd_dev->dax_dev, offset, p, &wc->memory_map, &pfn, 0); if (da < 0) { wc->memory_map = NULL; r = da; @@ -309,7 +309,7 @@ static int persistent_memory_claim(struct dm_writecache *wc) do { long daa; daa = dax_direct_access(wc->ssd_dev->dax_dev, offset + i, p - i, - NULL, &pfn); + NULL, &pfn, 0); if (daa <= 0) { r = daa ? daa : -EINVAL; goto err3; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index a011d09cb0fa..e5a14abd45f9 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -998,7 +998,7 @@ static struct dm_target *dm_dax_get_live_target(struct mapped_device *md, } static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags) { struct mapped_device *md = dax_get_private(dax_dev); sector_t sector = pgoff * PAGE_SECTORS; @@ -1016,7 +1016,7 @@ static long dm_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, if (len < 1) goto out; nr_pages = min(len, nr_pages); - ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn); + ret = ti->type->direct_access(ti, pgoff, nr_pages, kaddr, pfn, flags); out: dm_put_live_table(md, srcu_idx); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 72de88ff0d30..b0b7fd40560e 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -256,7 +256,7 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, /* see "strong" declaration in tools/testing/nvdimm/pmem-dax.c */ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags) { resource_size_t offset = PFN_PHYS(pgoff) + pmem->data_offset; @@ -295,11 +295,12 @@ static int pmem_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, } static long pmem_dax_direct_access(struct dax_device *dax_dev, - pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) + pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn, + unsigned long flags) { struct pmem_device *pmem = dax_get_private(dax_dev); - return __pmem_direct_access(pmem, pgoff, nr_pages, kaddr, pfn); + return __pmem_direct_access(pmem, pgoff, nr_pages, kaddr, pfn, flags); } /* diff --git a/drivers/nvdimm/pmem.h b/drivers/nvdimm/pmem.h index 59cfe13ea8a8..fb769b22777a 100644 --- a/drivers/nvdimm/pmem.h +++ b/drivers/nvdimm/pmem.h @@ -27,7 +27,7 @@ struct pmem_device { }; long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn); + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags); #ifdef CONFIG_MEMORY_FAILURE static inline bool test_and_clear_pmem_poison(struct page *page) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 5be3d1c39a78..6ab2f9badc8d 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -32,7 +32,7 @@ static int dcssblk_open(struct block_device *bdev, fmode_t mode); static void dcssblk_release(struct gendisk *disk, fmode_t mode); static blk_qc_t dcssblk_submit_bio(struct bio *bio); static long dcssblk_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn); + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags); static char dcssblk_segments[DCSSBLK_PARM_LEN] = "\0"; @@ -62,7 +62,7 @@ static int dcssblk_dax_zero_page_range(struct dax_device *dax_dev, long rc; void *kaddr; - rc = dax_direct_access(dax_dev, pgoff, nr_pages, &kaddr, NULL); + rc = dax_direct_access(dax_dev, pgoff, nr_pages, &kaddr, NULL, 0); if (rc < 0) return rc; memset(kaddr, 0, nr_pages << PAGE_SHIFT); @@ -932,7 +932,8 @@ __dcssblk_direct_access(struct dcssblk_dev_info *dev_info, pgoff_t pgoff, static long dcssblk_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) + long nr_pages, void **kaddr, pfn_t *pfn, + unsigned long flags) { struct dcssblk_dev_info *dev_info = dax_get_private(dax_dev); diff --git a/fs/dax.c b/fs/dax.c index 01118de00011..f603a9ce7f20 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -722,7 +722,7 @@ static int copy_cow_page_dax(struct block_device *bdev, struct dax_device *dax_d return rc; id = dax_read_lock(); - rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, NULL); + rc = dax_direct_access(dax_dev, pgoff, 1, &kaddr, NULL, 0); if (rc < 0) { dax_read_unlock(id); return rc; @@ -1023,7 +1023,7 @@ static int dax_iomap_pfn(const struct iomap *iomap, loff_t pos, size_t size, return rc; id = dax_read_lock(); length = dax_direct_access(iomap->dax_dev, pgoff, PHYS_PFN(size), - NULL, pfnp); + NULL, pfnp, 0); if (length < 0) { rc = length; goto out; @@ -1149,7 +1149,7 @@ s64 dax_iomap_zero(loff_t pos, u64 length, struct iomap *iomap) if (page_aligned) rc = dax_zero_page_range(iomap->dax_dev, pgoff, 1); else - rc = dax_direct_access(iomap->dax_dev, pgoff, 1, &kaddr, NULL); + rc = dax_direct_access(iomap->dax_dev, pgoff, 1, &kaddr, NULL, 0); if (rc < 0) { dax_read_unlock(id); return rc; @@ -1172,6 +1172,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, struct block_device *bdev = iomap->bdev; struct dax_device *dax_dev = iomap->dax_dev; loff_t end = pos + length, done = 0; + unsigned long dax_flag = 0; ssize_t ret = 0; size_t xfer; int id; @@ -1199,6 +1200,9 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, (end - 1) >> PAGE_SHIFT); } + if (iomi->flags & IOMAP_RECOVERY) + dax_flag |= DAXDEV_F_RECOVERY; + id = dax_read_lock(); while (pos < end) { unsigned offset = pos & (PAGE_SIZE - 1); @@ -1218,7 +1222,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, break; map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), - &kaddr, NULL); + &kaddr, NULL, dax_flag); if (map_len < 0) { ret = map_len; break; diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 281d79f8b3d3..2c45b94647f1 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -1245,7 +1245,7 @@ static int fuse_dax_mem_range_init(struct fuse_conn_dax *fcd) id = dax_read_lock(); nr_pages = dax_direct_access(fcd->dev, 0, PHYS_PFN(dax_size), NULL, - NULL); + NULL, 0); dax_read_unlock(id); if (nr_pages < 0) { pr_debug("dax_direct_access() returned %ld\n", nr_pages); diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 0ad89c6629d7..d201b6e8a190 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -739,7 +739,7 @@ static void virtio_fs_cleanup_vqs(struct virtio_device *vdev, * offset. */ static long virtio_fs_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags) { struct virtio_fs *fs = dax_get_private(dax_dev); phys_addr_t offset = PFN_PHYS(pgoff); @@ -773,7 +773,7 @@ static int virtio_fs_zero_page_range(struct dax_device *dax_dev, long rc; void *kaddr; - rc = dax_direct_access(dax_dev, pgoff, nr_pages, &kaddr, NULL); + rc = dax_direct_access(dax_dev, pgoff, nr_pages, &kaddr, NULL, 0); if (rc < 0) return rc; memset(kaddr, 0, nr_pages << PAGE_SHIFT); diff --git a/include/linux/dax.h b/include/linux/dax.h index 2619d94c308d..0044a5d87e5d 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -9,6 +9,9 @@ /* Flag for synchronous flush */ #define DAXDEV_F_SYNC (1UL << 0) +/* Flag for DAX data recovery */ +#define DAXDEV_F_RECOVERY (1UL << 1) + typedef unsigned long dax_entry_t; struct iomap_ops; @@ -21,7 +24,7 @@ struct dax_operations { * number of pages available for DAX at that pfn. */ long (*direct_access)(struct dax_device *, pgoff_t, long, - void **, pfn_t *); + void **, pfn_t *, unsigned long); /* * Validate whether this device is usable as an fsdax backing * device. @@ -192,7 +195,7 @@ static inline void dax_read_unlock(int id) bool dax_alive(struct dax_device *dax_dev); void *dax_get_private(struct dax_device *dax_dev); long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, - void **kaddr, pfn_t *pfn); + void **kaddr, pfn_t *pfn, unsigned long); size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i); size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 114553b487ef..307c29789332 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -146,7 +146,7 @@ typedef int (*dm_busy_fn) (struct dm_target *ti); * >= 0 : the number of bytes accessible at the address */ typedef long (*dm_dax_direct_access_fn) (struct dm_target *ti, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn); + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags); 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, diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c index af19c85558e7..45dcfffe5575 100644 --- a/tools/testing/nvdimm/pmem-dax.c +++ b/tools/testing/nvdimm/pmem-dax.c @@ -8,7 +8,7 @@ #include long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, - long nr_pages, void **kaddr, pfn_t *pfn) + long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags) { resource_size_t offset = PFN_PHYS(pgoff) + pmem->data_offset; From patchwork Thu Oct 21 00:10:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12573557 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 535142C97 for ; Thu, 21 Oct 2021 00:12:19 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19KLtHCg000751; Thu, 21 Oct 2021 00:11:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=mMKPxxZP2e+K4hCIEILD333DY0RfxD/67zs0FCuASD0=; b=pf209cCFJTZeZk7IS5DkXhx7oz/yS2N+sSxUm9/HSRkXUkTqEbbK9mysgf39jYcfR37n ddXIZsJE4RyaDfkhF0XsVRWstjhyr/yUzWlAzz2KG7JzMmBx5CiCq5xfVdj9XyCwtfmr W73vL1xaIZ11TroecE/HPflUy2o/9TMbtcLDym+paD1VhmSimLOHWxR3WxQadsw2jFZU ji8KmL1pghE/zYQMCHJ/BM4pcmVlTnesDHO9SohKuz93WtrZ60wtpNCqF45A4AB0Dj1Z oRt4iCotL5AO5K+XfC0IpDlJJQkeFmOOdoqLnHWPPiNX6gXZInoda6a7bq5xTj2q4/rB zA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3btkw4ua95-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:11:51 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 19L0Assm065243; Thu, 21 Oct 2021 00:11:50 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by aserp3030.oracle.com with ESMTP id 3bqmsh8r22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:11:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dIs3dWsX+TZLc7Dv+f4lluY6CKNYT5C+YHN7Pt28K7oqkU+DHdvNsSSvxFMuQVJvhnEByleiL0LIFWj/eEQbV1AseD37S88jKI/mX/uKhNWQh6pbINJs/+HqIP5S0QM69V34uYAT3yWSRzSd/sH9UGPzd7XebKlYHv4H3xxsNmFXT3re8xooUgQ0Th6+ot1oylCDTnHDpuLPxIZdVHlrZfw1NBXZ4ZAKxtegEvIr3oE/ihM9qG28gIItUPO7CMnLyLFdXYlJrb+lee+V4UgoAUYnYxehKnTM6MJKQDbG2Fn/6O1buRYm2uyi5hUCMDRpWL3bsx794nWbPVmQT0W/xw== 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=mMKPxxZP2e+K4hCIEILD333DY0RfxD/67zs0FCuASD0=; b=lYSx9Yu7pR8laP8Cy7cVHP8MSsWq4Z4Yh7Yp3CIeNgYYW0YU0dgRNUtF5p+3z8h5iJQvA/o/OTlUtupsGQ2rCyFKVhTlrQBmv2L8TMV5iYm6egpHP+miVcPEhacdGYGbteZEAH1tZaWxn79rLamjBBbshzlQpha2nnzgco0sbStLDMcAe9ZZXAN6UHbPZIKrKEnfziC2VCfkMmVdkLzTn2ss2Bs0vG5c5xB6xX6hJKC6myx+cEECm5KVFDL4Ll7bBav44l7XD6bPiSmIeJmw/pgw3mwFd6c5XD5IdaSUOS5NUtTOsLuU+l5+SwhJfWW35oZ1ZtCUgUtW55M2PBK1xQ== 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=mMKPxxZP2e+K4hCIEILD333DY0RfxD/67zs0FCuASD0=; b=POhbYpAVllGP2L2BfMqVKLnQa6mwHkBpwqKKxfWUXRTWn088G7/EMEwi9MAEm+JpZ6MUwMww2toFupyerSCYQHFHgGXl96A1ZhY1qnZJa/rLOtXHnpmzNxwt/Q7+046ZSH/ikIsP1yW0iQzPp+RwXTuJMACMnzmsp/iy6uPuHZU= Authentication-Results: fromorbit.com; dkim=none (message not signed) header.d=none;fromorbit.com; dmarc=none action=none header.from=oracle.com; Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BYAPR10MB2759.namprd10.prod.outlook.com (2603:10b6:a02:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Thu, 21 Oct 2021 00:11:47 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c%5]) with mapi id 15.20.4608.018; Thu, 21 Oct 2021 00:11:47 +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 3/6] pmem: pmem_dax_direct_access() to honor the DAXDEV_F_RECOVERY flag Date: Wed, 20 Oct 2021 18:10:56 -0600 Message-Id: <20211021001059.438843-4-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20211021001059.438843-1-jane.chu@oracle.com> References: <20211021001059.438843-1-jane.chu@oracle.com> X-ClientProxiedBy: SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) 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 Received: from brm-x62-16.us.oracle.com (2606:b400:8004:44::1d) by SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 00:11:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 03e34304-e552-4085-9c9c-08d994275f70 X-MS-TrafficTypeDiagnostic: BYAPR10MB2759: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1360; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ialZt7rdQ9aIEx7M/r1Pi4gWS0ZLaaRPf+kP0X6J2SL6126a62SaXhTkN6n7FJG/ef5/Qky12S+Vv6sSrwzepM+36PAACUSxw0ZhH/9vIaTCXEjDmwwgx0e0l29DSp7impHapoT3RBR8iJPOBZjdl5na8zLkD6pkBsWPzIKhX1Of9b8qTUX5V3HpTH7tYAoyximAuEIC2KQMhSMubwvEvcrbormZ+VPrTV/uj0HuCKVp40Q5e3I4ETTCZyVXAfpgK8+gaF9kk00o3p083ahihYTeDP2VW+fr3e+3ePz9T20tnqPHKkRSYVuKIXuRy8d+h4sCiCwhAZAakh3zb+bi1J6sv7VPGgY1FthOAyKpGedtwM94n9u/nscYnabbV1lYzEWMiqoTnZKADIJkMR0OHrB6hFF21GpbjIyO2eZ+qrZbz6ovg2cT12aHwEirG5T7iuB9cJJ56kj0DQzcORK3SQaNHhT9KaUsnd4CAQOgB4OfStuLlrn0rrDySsnkgWHSO3s9ipjO+1OTDq0071imlQK2iP5qMQ6fUbxLwjQOi6TGrjn6OPZI3OobYIjnCQg/jqWiGNu8a/rf1yMNY3XtLg+l6sXI28iA6d91yGs48Y5CXPaU8BsvwlF8NglqPDhA9cv5Jh6vWmRJ6GPSFDImQrXCaq03uyI72fIbLBR9b/5TQwR+jbWMg+O4UWk4JsxB 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)(316002)(5660300002)(1076003)(66946007)(66476007)(7416002)(6666004)(38100700002)(83380400001)(36756003)(66556008)(921005)(508600001)(6486002)(8676002)(4744005)(86362001)(186003)(7696005)(52116002)(8936002)(44832011)(2616005)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3t1vODUDhznxz3ZhH0NnQG9j3KKZWfQpcPjrUWSZ1ZoBZW1gCjSXNOLwlWI98sJob0c1KCg7Aqpf1awq4UEYc0UnXHK1rP+VGL8SoI/+KYVWw8j2IFEwUmVFqE6DYnkmog6RQQffsko8frYRzgeletjVWaQc9/UJ8YwfClgKvg/BV2M9xZWWcM8EI6Q6val5RnxvwHxlr8/+o2maU2Orq5VVS6yuDX2Yu+HtjUVd0sKOGtAjHRAY8qnvmEuwusKULqM96f4ZSoXhlyGwqPzQiB6SwkVO+Ppys6b9NLx2iQ49jNca95vXQeZr/i7GgOjU6Ac1a1kv1V4rclLkOlyjBPR4a0VuhSbqEVuNKXW52f98sYLhnvX2whSU1861E92+vswTLjwngcaWSr9RfDb1yruH8J9CxmB71G+KKov9n79qMDhxT+m5FNXd8seT1QAu53VPDuK7QvGap9kxwSIsQIpsevYev1ShGZ90mgLfmlbXAj+IJ8makU0m1wjiPqHugNOFZeBwyhPYpJZyiHjviYUxOSLhILSBnNaYrRLrfDasrTaPML3PG4CThJzrG24pFBMKn5aQ0li1frIFuPKTB3T9W8/5sHkLNMvTYmRWb5clPiPans21FuXCo7CFI7bNb5NJ9KgtMlFkiVROUyjYinIfSxscIpZmAIpvMB8EVsNfkdkXaMqWlyEeQQndrX7PvaLwEMM0j8tETJmg+4VIwTMmuZjlsWgb87DZ2vXRYI9/7j3YgcqXAkaKCXB07z1rpkoxpzlZqhkP6J0ZxC6c8Pd7763mZMeJUK71m6z1Jy3UNd63aKJR89/s8AX1ECWa8SyQZ1fIL3wq/e8aN3M6wKGGvmUIvd0IsoqVJ9tMEsD1YA8duj2C6VynfT2HHj2lY02W3Prm8PYBo7CiJhPBm17tdmG0jsGcm6TalxbwbvH9M/SdWBkmP1KMxJyOs2wPyxni6jwbV5EoHbjTWMuscO1sFj5zLkEvsdnpx2g+PIBAnBAqTTJ8KUYV0EsmYnAzRzvBShdZ3YL0WWQnAbM+yPSMAlkzYgz3OqfbV4hM2d9jpzs00cGIxHNPA04Y06MC3U7Hd8PM+dxxLeJWNpeJQL605Y3LM2+z5FZq8wRYc32CXEvKVlbeFqtfwUQPzt+4ATI8baC58HwI82UUVeaqVxQUZNpgHTa6TW2g8CTlcp/dmAfEUHS8qIG6ykfB9equq2qufafOTkPIF4MIP4mFdvJqqlGvi5MhWhjBpnBwi5KJj8CwEcWR3GGzELaWcRNlhJYL75kHf3wzZxrfyA1nTvc9YfI/JK0V3qyebrKAULHtbpq1lEIwW90lVKMiY6y+x0MfX1zXRoNtP6wftH4gRA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03e34304-e552-4085-9c9c-08d994275f70 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2021 00:11:47.7129 (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: jane.chu@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2759 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10143 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110210000 X-Proofpoint-GUID: BSrYvwcrth4GIo732G3Bx8_-w7XVfbUy X-Proofpoint-ORIG-GUID: BSrYvwcrth4GIo732G3Bx8_-w7XVfbUy Let pmem_dax_direct_access() skip badblock checking if the caller intends to do data recovery by providing the DAXDEV_F_RECOVERY flag. Signed-off-by: Jane Chu --- drivers/nvdimm/pmem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index b0b7fd40560e..ed699416655b 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -260,8 +260,9 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, { 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)))) + if (unlikely(!(flags & DAXDEV_F_RECOVERY) && + is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, + PFN_PHYS(nr_pages)))) return -EIO; if (kaddr) From patchwork Thu Oct 21 00:10:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12573561 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 190242C97 for ; Thu, 21 Oct 2021 00:12:24 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19KNdHEJ008053; Thu, 21 Oct 2021 00:11: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=Eij/sg5hmzvGS+w44cdS5GtrMSK/p3O8vShBfYZ3yew=; b=S9vZSN1TC1LivRw2PkLVnnLanjFJbv8f0hSvAp6rcPTrO03X7jEdySfFiYWZ2A7I4+Ld ncSw4WPvS1qwHfHXl7dZK+AQfECwMR+lh9xHwPmcFZi922AMFBhInmp7w3akrr7qEZM1 8dbU3Xu2Z9GeHrMiHoBcDRYnfFcg8h9JcigxZ2oywRvs1XRK2Bj6fo91Ptw5WIwqS0bW LyilOw46vCq9R5kQSo7OHXud3rp/tC5nG3dMLEomm6ZceYnkzL4c7yWLVsnOCOGSfw+k DHNbwq7PQFOyXZY52/DC6MGO+//2u86/UuTHEP37or9tio+fuHpOZVFX7v4538AxWmEx vw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3btqp2hv8y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:11: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 19L0BDPA010121; Thu, 21 Oct 2021 00:11:53 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2044.outbound.protection.outlook.com [104.47.73.44]) by aserp3020.oracle.com with ESMTP id 3bqpj7vunv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:11:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R0D6SbS8iV59ixujJjSewGSeUCQIpt95kZdOiHVkjDZOuICfbWdRZrQa6Euk5KsbA/2Ufj25UyzEC7M9ljjIevVi9Ywiml2/jKfdCztdkxwe04vLl7XGXVph00SSy5E2whxq3q2MvJAFmMXpBenvbbS0FCjqnxbV+30oipjgR0xTf68FDftqQO91S3fXbgPJlFZ6TmzGDkHVwMGA3CYssoOOI3P28U8lUlJLg1Cp8rcS3G2aASMd1XfvOYFoPd9RBRYiKWszbjK0kp0wfkjup4VUffhlbrVpTVzpyyYxQyQiuSA28jrLUnoE8rVwcZtJ6sJxvant8NUGfJ0kcF504Q== 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=Eij/sg5hmzvGS+w44cdS5GtrMSK/p3O8vShBfYZ3yew=; b=d61FbmZb1kB2QUaYOaOXx+saOA+PsfFxVq/WsndGkzM11+LaTubJQ6UzP+IzV99OT/zwHebgPmzf320JPkWV9+Tz1ZDiGPBwf0DCJjTCyShX8JtAtbUDQ4eYSAc4SzDjszYvUsy/fbdYL55pZ0U/T/xzod74bAiP7mLahEWpimuN0TRo1RjQVUUS2y2jyCFBBs04OEUh/52hQsEYE7mwA81GI1YFzPG0ULYS9aaWS2OFst79rkPDyrfPKOmAUtMbpNYQFR+exxylmXCbaxG5drdWjBZnjST8S2ciLD7NkQSFOxTX8CRGvRwDTvr09sNQFXTAf/eNJUhplzoMXBBSrA== 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=Eij/sg5hmzvGS+w44cdS5GtrMSK/p3O8vShBfYZ3yew=; b=cnizekoiZxVnWJbCHHW3uXmYeau7ek6pFlys/w7AppnNkN7n6Y3f8JFCXi5EQ2JP70oh8M0leWejIDfaKA4lHClL4IZiP0kXm78GWqjwp4t3BcruIiVP5mkc/5CRAjPVAqdCsGI1pbJWCWHZiSIpcea6BxPJeb/BSUrJ3nUcGRA= Authentication-Results: fromorbit.com; dkim=none (message not signed) header.d=none;fromorbit.com; dmarc=none action=none header.from=oracle.com; Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BYAPR10MB2759.namprd10.prod.outlook.com (2603:10b6:a02:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Thu, 21 Oct 2021 00:11:51 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c%5]) with mapi id 15.20.4608.018; Thu, 21 Oct 2021 00:11:51 +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 4/6] dm,dax,pmem: prepare dax_copy_to/from_iter() APIs with DAXDEV_F_RECOVERY Date: Wed, 20 Oct 2021 18:10:57 -0600 Message-Id: <20211021001059.438843-5-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20211021001059.438843-1-jane.chu@oracle.com> References: <20211021001059.438843-1-jane.chu@oracle.com> X-ClientProxiedBy: SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) 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 Received: from brm-x62-16.us.oracle.com (2606:b400:8004:44::1d) by SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 00:11:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e57e0c6-4f9d-41af-597b-08d9942761ad X-MS-TrafficTypeDiagnostic: BYAPR10MB2759: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8M4Fl2ifT5VEoVngRkyzC51dG6chdJuXj95oJ5djbz5xRwlpEfOVZVSOyM+Q623i7At9Lookl5+0CiR9NBVHtx7R16e46Eo2Id4wHNkDv80vSEhWYdJsCFKbo2vzWMd46M+JYM81xgX0WGxjm/Lhwn1IuvwQz/Z3jfEWOinCBeJFt5+TX3X8ueKwH9703t3Sg7YlXNhRDm5vlo8F/e4BPvEiJoOm67MdF2Stk9nbTJl3VypAH0w2YgXYxbu94zXJ0dfvzNP8TSmXVcC5+JAgPb+scsaKdaenCILf8TqkpGQWHdvcQMaxxZg+he83W8nIdjBDsW9aPXCZ78LbYG4UbFFlUqANau+RXCm9NC5qU0hzYOufkVLTrPq6v8bxMaPVdZxHvIbyGHogh06stsyQaP8C1kbRtMUuzZi8+FT5zVm5rw+aR3fCmANbm+Oarl1grAZMOBGHYUX5R5s5iT8ypQORAH/a/w0Cyws2yY9zCID2mTVxCG8i2ilzPbGjRpkf9LYaX+l7PiStV8klVlhw2hROlVRIgeGYIRKxK0rtluB0y/5SSfKWDobhCXKG9o1lVeDH1jC+jVnE6jsNY5OgX3nm067zQfilptnUNLJNqZr1hZvbgcI+396ew/i496A/W90xdkkHYMgUfLJrh4ioG5nMgZchgSnVShhHafXHYltertQrFDpohWOlPkxbLZl+ 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)(316002)(5660300002)(1076003)(66946007)(66476007)(7416002)(6666004)(38100700002)(83380400001)(36756003)(66556008)(921005)(508600001)(6486002)(8676002)(86362001)(186003)(30864003)(7696005)(52116002)(8936002)(44832011)(2616005)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A9ph07vDWIma8zo6X5PhjDqw9dggPkLXy/TX6CRGlBxQnqtjmgl7ulvp0vLdBBuHWIHaYPkcuPYSjDCWTNcAns3wKNUyb9c1untZ8RvJLrbyGQy5AxofSXE7QJoVGH7mKVrq56eyTiv2069FKYyOLMULS22AhZhIl0tHpXv0ldH9l7xv0VTeqncaD8duDorlrkCLkxpAcQHi0b0qTQQ3ik0DI8g6g7WD2Xy+Jx83d3MW01qBWYlcPyWuTdE3kbEXdWmUnm2L/Z18e2iKub3eaVIil+B0YMvp+7h/QtgnzcubV7UJdwDiFhbZ7eGwEaWj2AOFpzgMb9wrXIvF6EAhtOF8swZouvTDpUfLnHYBJFfuuAzHOF+rtn6f59VeqLI5QeVlTs64X/IZ41RbXHDZ7PCAs6q4X/1BUyyR3zQ26ST1oSA/zOxtIpTixz+b0Z4UZPKCJQfFcqoS1PJXMmnj4pdtcncDFWkJVH3yN5GfFqmFl3XxYGAZ/HZY8NnVhkQwVQIo9PB/r2G/6WGb1T88p57tpXb4IlNlRKUgFCnB/tVs0+3yZL2G4j1LT1x+xLTncJd536dBhgNMMueaZfnmUYpSIU7MErXVpua+QJ2SP9N48bnWyzaN1gu976j8Dn1N5osRBTkaqMqVv6YzOk24cykTGfO1hWaXfqiiDJZ2UYJzi2hOhBC+4TIl3MJo7Yo8kHuYQbE00AjgmTJm+uM/NkBpE5qJMJbGo3fnnpAS8I3+Zr78d7f7nxPQW81lsTgWKdQDZ2tLVNmqPfeJiHcpE071fN9Sb4pZxSFgsbEKDsOaZMFxTL9L0QyMXZmYg9MTO4aui+csGdQV3rItKiKqJyARdHHDwhiOX/TwGl16mnX9pNhpvan92dvEpFDtlLRSCm/UJ4NeyEhAMa4LIdExwcRcpY4UedO1OdKTT6qkQJ0iK05y+oGqPRz3oULeEquvew23+NS22FnZUfgq+fkcnS1q7w2IPlOFKti9gG6BFFwv4WCydpzyDYV/mFK3eRj537r1zTwAksspyy+nDFxmz5GmjeJCF+ew6+0tAPVHnHG2k61XSXAbkiBDRjCPARmFyUDcsX+fcomwqX4zDvIlJ/GdSAc7G6WHSuWNaV+6BNop5C2vTyB4KaAz4pVCMo77mtHSpDmYJOC/z1hoXtCqx7E65NKv4SR3TF9Z9jgvn04FKN1JB8N1HcL62UQ8vyAC65D7oEdb/xRRissy2ZxsvVABxuMgokGWR106FOFfFNCanfmIW5D9T5Fx6xl6Y5LDfbCUOMa+g8Fj+gbB8XbgenTHKa8DcXJwhhA50PcH9gdWWPWYuj8R8yot2Bg62cYN0v+vkCCJmjpHnGhX3X56AQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e57e0c6-4f9d-41af-597b-08d9942761ad X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2021 00:11:51.4485 (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: jane.chu@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2759 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10143 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110210000 X-Proofpoint-ORIG-GUID: Jvdl1PV3WsPqNp66Z_mOywvxjJEM4RUC X-Proofpoint-GUID: Jvdl1PV3WsPqNp66Z_mOywvxjJEM4RUC Prepare dax_copy_to/from_iter() APIs with DAXDEV_F_RECOVERY flag such that when the flag is set, the underlying driver implementation of the APIs may deal with potential poison in a given address range and read partial data or write after clearing poison. Signed-off-by: Jane Chu --- drivers/dax/super.c | 10 ++++++---- drivers/md/dm-linear.c | 8 ++++---- drivers/md/dm-log-writes.c | 12 ++++++------ drivers/md/dm-stripe.c | 8 ++++---- drivers/md/dm.c | 8 ++++---- drivers/nvdimm/pmem.c | 4 ++-- drivers/s390/block/dcssblk.c | 6 ++++-- fs/dax.c | 4 ++-- fs/fuse/virtio_fs.c | 8 ++++---- include/linux/dax.h | 8 ++++---- include/linux/device-mapper.h | 2 +- 11 files changed, 41 insertions(+), 37 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 67093f1c3341..97854da1ecf7 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -330,22 +330,24 @@ long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, EXPORT_SYMBOL_GPL(dax_direct_access); size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, - size_t bytes, struct iov_iter *i) + size_t bytes, struct iov_iter *i, unsigned long flags) { if (!dax_alive(dax_dev)) return 0; - return dax_dev->ops->copy_from_iter(dax_dev, pgoff, addr, bytes, i); + return dax_dev->ops->copy_from_iter(dax_dev, pgoff, addr, bytes, i, + flags); } EXPORT_SYMBOL_GPL(dax_copy_from_iter); size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, - size_t bytes, struct iov_iter *i) + size_t bytes, struct iov_iter *i, unsigned long flags) { if (!dax_alive(dax_dev)) return 0; - return dax_dev->ops->copy_to_iter(dax_dev, pgoff, addr, bytes, i); + return dax_dev->ops->copy_to_iter(dax_dev, pgoff, addr, bytes, i, + flags); } EXPORT_SYMBOL_GPL(dax_copy_to_iter); diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index cb7c8518f02d..cc57bd639871 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -181,7 +181,7 @@ static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, } static size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) + void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { struct linear_c *lc = ti->private; struct block_device *bdev = lc->dev->bdev; @@ -191,11 +191,11 @@ static size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, dev_sector = linear_map_sector(ti, sector); if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) return 0; - return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i, flags); } static size_t linear_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) + void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { struct linear_c *lc = ti->private; struct block_device *bdev = lc->dev->bdev; @@ -205,7 +205,7 @@ static size_t linear_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, dev_sector = linear_map_sector(ti, sector); if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) return 0; - return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i); + return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i, flags); } static int linear_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c index 6d8b88dcce6c..b8e9bddc47b8 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c @@ -964,8 +964,8 @@ static long log_writes_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, } static size_t log_writes_dax_copy_from_iter(struct dm_target *ti, - pgoff_t pgoff, void *addr, size_t bytes, - struct iov_iter *i) + pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i, + unsigned long flags) { struct log_writes_c *lc = ti->private; sector_t sector = pgoff * PAGE_SECTORS; @@ -984,19 +984,19 @@ static size_t log_writes_dax_copy_from_iter(struct dm_target *ti, return 0; } dax_copy: - return dax_copy_from_iter(lc->dev->dax_dev, pgoff, addr, bytes, i); + return dax_copy_from_iter(lc->dev->dax_dev, pgoff, addr, bytes, i, flags); } static size_t log_writes_dax_copy_to_iter(struct dm_target *ti, - pgoff_t pgoff, void *addr, size_t bytes, - struct iov_iter *i) + pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i, + unsigned long flags) { struct log_writes_c *lc = ti->private; sector_t sector = pgoff * PAGE_SECTORS; if (bdev_dax_pgoff(lc->dev->bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) return 0; - return dax_copy_to_iter(lc->dev->dax_dev, pgoff, addr, bytes, i); + return dax_copy_to_iter(lc->dev->dax_dev, pgoff, addr, bytes, i, flags); } static int log_writes_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index 0a97d0472a0b..eefaa23a36fa 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -323,7 +323,7 @@ static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, } static size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) + void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { sector_t dev_sector, sector = pgoff * PAGE_SECTORS; struct stripe_c *sc = ti->private; @@ -338,11 +338,11 @@ static size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) return 0; - return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); + return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i, flags); } static size_t stripe_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) + void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { sector_t dev_sector, sector = pgoff * PAGE_SECTORS; struct stripe_c *sc = ti->private; @@ -357,7 +357,7 @@ static size_t stripe_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) return 0; - return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i); + return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i, flags); } static int stripe_dax_zero_page_range(struct dm_target *ti, pgoff_t pgoff, diff --git a/drivers/md/dm.c b/drivers/md/dm.c index e5a14abd45f9..764183ddebc1 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1045,7 +1045,7 @@ static bool dm_dax_supported(struct dax_device *dax_dev, struct block_device *bd } static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) + void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { struct mapped_device *md = dax_get_private(dax_dev); sector_t sector = pgoff * PAGE_SECTORS; @@ -1061,7 +1061,7 @@ static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, ret = copy_from_iter(addr, bytes, i); goto out; } - ret = ti->type->dax_copy_from_iter(ti, pgoff, addr, bytes, i); + ret = ti->type->dax_copy_from_iter(ti, pgoff, addr, bytes, i, flags); out: dm_put_live_table(md, srcu_idx); @@ -1069,7 +1069,7 @@ static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, } static size_t dm_dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) + void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { struct mapped_device *md = dax_get_private(dax_dev); sector_t sector = pgoff * PAGE_SECTORS; @@ -1085,7 +1085,7 @@ static size_t dm_dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, ret = copy_to_iter(addr, bytes, i); goto out; } - ret = ti->type->dax_copy_to_iter(ti, pgoff, addr, bytes, i); + ret = ti->type->dax_copy_to_iter(ti, pgoff, addr, bytes, i, flags); out: dm_put_live_table(md, srcu_idx); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index ed699416655b..e2a1c35108cd 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -311,13 +311,13 @@ static long pmem_dax_direct_access(struct dax_device *dax_dev, * dax_iomap_actor() */ static size_t pmem_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) + void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { return _copy_from_iter_flushcache(addr, bytes, i); } static size_t pmem_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i) + void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { return _copy_mc_to_iter(addr, bytes, i); } diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 6ab2f9badc8d..6eb2b9a7682b 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -45,13 +45,15 @@ static const struct block_device_operations dcssblk_devops = { }; static size_t dcssblk_dax_copy_from_iter(struct dax_device *dax_dev, - pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i) + pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i, + unsigned long flags) { return copy_from_iter(addr, bytes, i); } static size_t dcssblk_dax_copy_to_iter(struct dax_device *dax_dev, - pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i) + pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i, + unsigned long flags) { return copy_to_iter(addr, bytes, i); } diff --git a/fs/dax.c b/fs/dax.c index f603a9ce7f20..69433c6cd6c4 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1241,10 +1241,10 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, */ if (iov_iter_rw(iter) == WRITE) xfer = dax_copy_from_iter(dax_dev, pgoff, kaddr, - map_len, iter); + map_len, iter, dax_flag); else xfer = dax_copy_to_iter(dax_dev, pgoff, kaddr, - map_len, iter); + map_len, iter, dax_flag); pos += xfer; length -= xfer; diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index d201b6e8a190..b0d80459b1cb 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -754,15 +754,15 @@ static long virtio_fs_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, } static size_t virtio_fs_copy_from_iter(struct dax_device *dax_dev, - pgoff_t pgoff, void *addr, - size_t bytes, struct iov_iter *i) + pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i, + unsigned long flags) { return copy_from_iter(addr, bytes, i); } static size_t virtio_fs_copy_to_iter(struct dax_device *dax_dev, - pgoff_t pgoff, void *addr, - size_t bytes, struct iov_iter *i) + pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i, + unsigned long flags) { return copy_to_iter(addr, bytes, i); } diff --git a/include/linux/dax.h b/include/linux/dax.h index 0044a5d87e5d..97f421f831e2 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -33,10 +33,10 @@ struct dax_operations { sector_t, sector_t); /* copy_from_iter: required operation for fs-dax direct-i/o */ size_t (*copy_from_iter)(struct dax_device *, pgoff_t, void *, size_t, - struct iov_iter *); + struct iov_iter *, unsigned long); /* copy_to_iter: required operation for fs-dax direct-i/o */ size_t (*copy_to_iter)(struct dax_device *, pgoff_t, void *, size_t, - struct iov_iter *); + struct iov_iter *, unsigned long); /* zero_page_range: required operation. Zero page range */ int (*zero_page_range)(struct dax_device *, pgoff_t, size_t); }; @@ -197,9 +197,9 @@ void *dax_get_private(struct dax_device *dax_dev); long dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn, unsigned long); size_t dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, - size_t bytes, struct iov_iter *i); + size_t bytes, struct iov_iter *i, unsigned long flags); size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, - size_t bytes, struct iov_iter *i); + size_t bytes, struct iov_iter *i, unsigned long flags); int dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, size_t nr_pages); void dax_flush(struct dax_device *dax_dev, void *addr, size_t size); diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 307c29789332..81c67c3d96ed 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -148,7 +148,7 @@ typedef int (*dm_busy_fn) (struct dm_target *ti); typedef long (*dm_dax_direct_access_fn) (struct dm_target *ti, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn, unsigned long flags); typedef size_t (*dm_dax_copy_iter_fn)(struct dm_target *ti, pgoff_t pgoff, - void *addr, size_t bytes, struct iov_iter *i); + void *addr, size_t bytes, struct iov_iter *i, unsigned long flags); typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff, size_t nr_pages); From patchwork Thu Oct 21 00:10:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12573563 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E96DC2C98 for ; Thu, 21 Oct 2021 00:12:24 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19KM5Sgc000812; Thu, 21 Oct 2021 00:12:02 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=CZBG0ZI3xO0HS+NJlup+RHX+AYJe0yMKmRUGBcXXnDQ=; b=ZIS8SCuqKDBtWnTLawk1Dv/C32HFVf5Qq8g6McKTZSD4JmOg8EOgJY0R0lDZ8/SdKeAj eO0MljrBhjgQngPK/PwOAe2/woBbpmD/6rzgWryCijh2F6bVzaUrAfThkigfkFoaRz+N l7HQtT9AgFmA8qzPjQYC+AIUywmNdh/AbG5zbs01QD/Mmjz/A3CePMDQ5+0fMSIo2udI oW5lfRfMVsaj7OSUPLpqvGBP3HnoXHInJ4t+IR+auKKrxfbPQgXlfD63hJxpW+lGoU3w G7f1A/QQXbqHoapISlL0Q3JvjAxH1799fCclf02gA4+e18PGUZoNiI1ol/AsFRAOYiD2 Ww== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3btkw4uaa6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:12:02 +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 19L0BaoJ180521; Thu, 21 Oct 2021 00:12:00 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by userp3030.oracle.com with ESMTP id 3bqkv0x74x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:12:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mbkF/Vls4feA5Idfg2KERYCH3yphk1xkSq/d9PLLXOW9cQ9ymYzzfz4v37s/zu+26vWXcRL6uevErAFwj1SzNj3S5LjMFHkobB7ZSdGMBDb72EqvFqfGh5Yw63whdMyLrDKv/KCErJ+4ZQH13iby5MfzIAg22OcDzaXSMEs/s6bRNGXmm1vkA8iAKuuMgojOtw3+8mk4L1CsJLOVsIXFyCmqp2FO/9EOkF5D999UmyY2G/MZNUT2iXCIhCqx+zW3pCLyqhCeTU1MS9Luj/e9csaeJYN/9jtdhIZWNjbdcx5UC4pLywGXetRiVriB3O2eeejpeZ/Z6n7pQ9UJ5JDktg== 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=CZBG0ZI3xO0HS+NJlup+RHX+AYJe0yMKmRUGBcXXnDQ=; b=VobLBt/GzW9jRkU+dqPaGqmFptiHFqNIyx8lrXwzLjZHAedwfHrtpKRsD9nV2bHVmCzAWHjOvhOID+PwvVWeDYW7lSJRe6UaoLNfisx9r0avvgP/nFTlotPhjbbHlP71Xogr2V8QtWjozpyQDt4LWBQfDC/yMcWFq6mfMnTv5dxzTHoHJc1vMNjWJkNY92+YMiHFELNNXECJKAtjxbpVF2V9SdzdsuVs+GdUUWRQNNXYwSqRfVvuTdQoBlv9LthXuOnT/nBrAvzIei2G7Q7E0IRTR90UrFZF9UwC3Wb0jEW9lMIztUA3L0XtZTghMmSrOGNVcRMD8LmCr2pPBRqogg== 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=CZBG0ZI3xO0HS+NJlup+RHX+AYJe0yMKmRUGBcXXnDQ=; b=BE3ECGEtxa9REAKXoui9NlRQdFlRY99hBsivQ3d2nygPUjU0lJaZBtvyPnTmU5zk4mxzN+y/51TjhpBMrZqS7QDWfl1PEND2XgD5HYBou6I6+4fi9sQkOFBDD9O9f9gOs1CLYsyBQsm/XhrS5qbY3K2HNpdssBGtHBjRf44eMAk= Authentication-Results: fromorbit.com; dkim=none (message not signed) header.d=none;fromorbit.com; dmarc=none action=none header.from=oracle.com; Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BYAPR10MB2759.namprd10.prod.outlook.com (2603:10b6:a02:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Thu, 21 Oct 2021 00:11:58 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c%5]) with mapi id 15.20.4608.018; Thu, 21 Oct 2021 00:11:58 +0000 From: Jane Chu To: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH 5/6] dax,pmem: Add data recovery feature to pmem_copy_to/from_iter() Date: Wed, 20 Oct 2021 18:10:58 -0600 Message-Id: <20211021001059.438843-6-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20211021001059.438843-1-jane.chu@oracle.com> References: <20211021001059.438843-1-jane.chu@oracle.com> X-ClientProxiedBy: SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) 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 Received: from brm-x62-16.us.oracle.com (2606:b400:8004:44::1d) by SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 00:11:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10ffa4db-15d3-499f-a894-08d9942765ba X-MS-TrafficTypeDiagnostic: BYAPR10MB2759: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:655; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qmEX2epLGYlRwyw7bKWTM3QJ/xGFG7I1YYudye7DFk2+l6pvORl+GXJmNmye5hBZ7ZTKReYsQxxzQHYHbSXv2KrpLDrdBpEEWsI0BJq1gkAiUyk22sUfC7vgDzRNQfoXgaTgUJFloynJXEgWtv2nX6Ln3teGMIEebuE4kj6PzuL6gtVqckJoTdWCiCeueQg6/SX87kewfCEEWOfJiOkC+J8ehXVpPj0wmmI9N4aYzIlDZkEu88d56dkuq/Xm6ffMe3AwW8UA+x1xIgvrfvDLDfL5aF9OMMjwntWYc3xwirltZbGSwIx8SCpzVqt5gSVej1jhhj29M+DJWL8t9FVxRgZXd4SXvdFy92OvtQuZBWWz6CiHVTegsDFjMU2Gc+qpqDoVz523wvcTA0lIB/0cWt+f/LIz7ZSQ/21d5zPHO0MKSXHFVQPottVOjsoF3lt2ZxdouLnwJpMH5D8TjKGIiHGgx9jKontfoyCE+M0fVttg1yVcfjOAGb+tAc39hntT9UIloT8hId6SPHLySOAZd2CnBOIgN8zq2F3An/+D6CHG7Zw8t7t7M8zbzeuglclLPt7xANoWfKaGYW7uzKSvM0BMf8jdCAZ0m+ImCj4uRpaCOlPKJBSZir3KAUNHCOcdz2lT7Fcw5Q89nquLVKnVQyZMBF3ys0OCGX9id9UwFgX7Km/uLrgX4O1L+kSCbBq8t/zTHe9GBdyFXJX8R1ex+5LN/kfLgkXR8fQv8YVh7a4= 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)(316002)(5660300002)(1076003)(66946007)(66476007)(7416002)(38100700002)(83380400001)(36756003)(66556008)(921005)(508600001)(6486002)(8676002)(86362001)(186003)(7696005)(52116002)(8936002)(44832011)(2616005)(2906002)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1qKRFLVA+L/hlQG4sjPnJIPupHiECM2Ie9obJ/FXDRNj8XIhi8XssVFOkGDkJUhMGBTrUqYRfwt6DVYgz0/5ESqVZYXalBWdTq6/m4YyA/zztUGE+tVwAubuYS7XATCr/7tBtQO0lMbqLO61L7pC1Y/oljTVD41lPCEGxiRq0sxTXx+Z00l0iD6oD8/oTkN0Ycddar3UdkRtSSW6JnHhPlUq5GVSFDa3xEbB9Z2jhgEgAAFKwMOi2jwZJA1BgxgejSyvUPHoJ7W6lML9bZII0GMEKn/Rkt+AgHhQv0EEEtDHq/535BSf8S+g01KEApARLksHl0j4IN+jO97pfb0o6FbvjL3//ecJcHeZFFMA1jHDbTUH2M32ecl7wyTgi5Dx3g2cwe+AXgof86g9wJxFFRYe00iBuVEwSl4CsxnxboqNXjemazmCHxJ8y9NSSZW/CgpYKyClFNpV0UloPHXcvok+T2bK2DgszY/n2FqW2srM36nAneXBiFcdvaJYArwytwT1ZCc9A9gWKiXnxZlfX/XJK5RTw4kFdh5KPLWBBe+WLVo7FAttHoPrfvl9P6k7ZyGZK96TSgn5+uwy3j8WLqJpaCwYsBNeiN85XnR40Mqrinl/7HgR+9b90VjL6UZIsKsOFx0tFAdFUm1GYM7CrMLHbjsBuTB2i8EVFr88LBg+RjYeM4ZKGFXwHWg7N5mNbLGIk5M7LhVvfUcGpocioU+lJZQmrAZpmApjSZz+I3JB7XNRUV1eSilj40O9v+KbGih+c3Q83plBxtXHqSGYFzeNoJdAw1DL5v4c22W87SSLgY1li5WikENs82iQHY1j9DZaYygUrKosvpOx/qQdBLCeEJCLwJ2vi0QKo7FTqt4QQZMZgfTB9dPscPmrqMky6QYJF30Fn5wsB8I2ae62gUsI4NgHfK378V//n96ScPtnI3nt8gcW9bhkuof0B0h3Fi4/LcP+/b6abGqhM/+/VWq3/6vB2Dg/QSLMx2WLFZ2Vl2Ux+z0fNJogkApgujfTv6vVt8Fer/6i/ko5WfgoWX8fbB79IGQTOMR2ivmv0Bqi9NXQF6/aTjQgmca1bHsLFjX8Er17fY65vPIedruROJj1f6dgMNXSSVtrvAOgg+zz+DcLwj0HjXpV1JnaAfCbfJi1R1ggz6dsDdE8gPv0miZ21ySU3HNjf9hc7aGtgendMOoWDSsZsNAqvoaRYk2jwdyHxKqBoH+Z3g6IJUvZGPvk5vci8FRzEbiYigo8cVLHA6mh/93JtzQSVPQ1pFYUgRdxzK5oJOi4OliIiJ0UJt69Kraxiritk/EMtNSlkoQl/0pigSfUtqoFu1Cu5w11Oo48/bqXMC47wFxPRewtIw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10ffa4db-15d3-499f-a894-08d9942765ba X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2021 00:11:58.2297 (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: jane.chu@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2759 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10143 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110210000 X-Proofpoint-GUID: 2GNaifIXaztcZirYLUBeXCikFjLzvFMM X-Proofpoint-ORIG-GUID: 2GNaifIXaztcZirYLUBeXCikFjLzvFMM When DAXDEV_F_RECOVERY flag is set, pmem_copy_to_iter() shall read as much data as possible up till the first poisoned page is encountered, and pmem_copy_from_iter() shall try to clear poison(s) within the page aligned range prior to writing. Signed-off-by: Jane Chu --- drivers/nvdimm/pmem.c | 72 ++++++++++++++++++++++++++++++++++++++++--- fs/dax.c | 5 +++ 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index e2a1c35108cd..c456f84d2f6f 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -305,21 +305,83 @@ static long pmem_dax_direct_access(struct dax_device *dax_dev, } /* - * Use the 'no check' versions of copy_from_iter_flushcache() and - * copy_mc_to_iter() to bypass HARDENED_USERCOPY overhead. Bounds - * checking, both file offset and device offset, is handled by - * dax_iomap_actor() + * Even though the 'no check' versions of copy_from_iter_flushcache() + * and copy_mc_to_iter() are used to bypass HARDENED_USERCOPY overhead, + * 'read'/'write' aren't always safe when poison is consumed. They happen + * to be safe because the 'read'/'write' range has been guaranteed + * be free of poison(s) by a prior call to dax_direct_access() on the + * caller stack. + * However with the introduction of DAXDEV_F_RECOVERY, the 'read'/'write' + * range may contain poison(s), so the functions perform explicit check + * on poison, and 'read' end up fetching only non-poisoned page(s) up + * till the first poison is encountered while 'write' require the range + * is page aligned in order to restore the poisoned page's memory type + * back to "rw" after clearing the poison(s). + * In the event of poison related failure, (size_t) -EIO is returned and + * caller may check the return value after casting it to (ssize_t). */ static size_t pmem_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { + phys_addr_t pmem_off; + size_t len, lead_off; + struct pmem_device *pmem = dax_get_private(dax_dev); + struct device *dev = pmem->bb.dev; + + if (flags & DAXDEV_F_RECOVERY) { + lead_off = (unsigned long)addr & ~PAGE_MASK; + len = PFN_PHYS(PFN_UP(lead_off + bytes)); + if (is_bad_pmem(&pmem->bb, PFN_PHYS(pgoff) / 512, len)) { + if (lead_off || !(PAGE_ALIGNED(bytes))) { + dev_warn(dev, "Found poison, but addr(%p) and/or bytes(%#lx) not page aligned\n", + addr, bytes); + return (size_t) -EIO; + } + pmem_off = PFN_PHYS(pgoff) + pmem->data_offset; + if (pmem_clear_poison(pmem, pmem_off, bytes) != + BLK_STS_OK) + return (size_t) -EIO; + } + } + return _copy_from_iter_flushcache(addr, bytes, i); } static size_t pmem_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i, unsigned long flags) { - return _copy_mc_to_iter(addr, bytes, i); + int num_bad; + size_t len, lead_off; + unsigned long bad_pfn; + bool bad_pmem = false; + size_t adj_len = bytes; + sector_t sector, first_bad; + struct pmem_device *pmem = dax_get_private(dax_dev); + struct device *dev = pmem->bb.dev; + + if (flags & DAXDEV_F_RECOVERY) { + sector = PFN_PHYS(pgoff) / 512; + lead_off = (unsigned long)addr & ~PAGE_MASK; + len = PFN_PHYS(PFN_UP(lead_off + bytes)); + if (pmem->bb.count) + bad_pmem = !!badblocks_check(&pmem->bb, sector, + len / 512, &first_bad, &num_bad); + if (bad_pmem) { + bad_pfn = PHYS_PFN(first_bad * 512); + if (bad_pfn == pgoff) { + dev_warn(dev, "Found poison in page: pgoff(%#lx)\n", + pgoff); + return -EIO; + } + adj_len = PFN_PHYS(bad_pfn - pgoff) - lead_off; + dev_WARN_ONCE(dev, (adj_len > bytes), + "out-of-range first_bad?"); + } + if (adj_len == 0) + return (size_t) -EIO; + } + + return _copy_mc_to_iter(addr, adj_len, i); } static const struct dax_operations pmem_dax_ops = { diff --git a/fs/dax.c b/fs/dax.c index 69433c6cd6c4..b9286668dc46 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1246,6 +1246,11 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, xfer = dax_copy_to_iter(dax_dev, pgoff, kaddr, map_len, iter, dax_flag); + if ((ssize_t)xfer == -EIO) { + ret = -EIO; + break; + } + pos += xfer; length -= xfer; done += xfer; From patchwork Thu Oct 21 00:10:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jane Chu X-Patchwork-Id: 12573559 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 F1DA22C94 for ; Thu, 21 Oct 2021 00:12:23 +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 19KNjJrX019159; Thu, 21 Oct 2021 00:12: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=rDb12PtZNgwTC1TYwBkAnpIWDw9Pt6HblK1iL44AkUU=; b=ZW/9hTO1jUKL+n8QzLRCnSq5cfz+N74UkwyUxbuBTwBzGc7KNHfFMzH6YS8mmO7+YGBw aEYiJSR7vMiMBVn3x8LcsBnJgChQsYbXGR7TYUnT69RMwSetrpIxVknxKCgdXWuT5v+5 ZBUFhRS6UKgGHZpJXqg4vgedkQ0VSDa5r1AqoXPUOWS9YPpghRZqVAEZn2uYiWvYsxZ4 K4AUkRzBqpWLAdxRMEErwN79eU9g+MJZAhJ5tg68dYNv038Kz7Undl7LO/i3/UmE1w7i qRLMQLceC/V5C+S6/wKvXhuJkWV44UUYQ6sRLh+OACllYZv6a4bSLwB2sEwKLEH6SgWv LA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3btqyphuu9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:12:05 +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 19L0BD3W010014; Thu, 21 Oct 2021 00:12:04 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2049.outbound.protection.outlook.com [104.47.73.49]) by aserp3020.oracle.com with ESMTP id 3bqpj7vuvd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Oct 2021 00:12:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P1s2sBqsFk2Wei9l4OZbIuXPWhekb3J4yjfQp5oHQI8YB9F4/p5Ykd6QCmDAXpdRPx8VTCH6w8wfquK5jkI2bxBIIpuIipOl58JlmWuH4AK6KuVMDNIjR3V7nHhwZV8AEe8OXEUMKV9KOcviYnbKIhQsKkCVYW9ev7w8Aiha0yI1kfw+Ymg84YrtPtmSVhoS/2a9UOmaRwDcWsJGiPH857bdvDmhPdx07MPgBinI8qL6Zztye8nRFLAYg02h8bEP/v9nIQB6oc8J82lJCLGQhUpjliF6f0sdEi1I0m78bV0+5Es5JSsS8O8sdYi8swutU38ueku3BybDUyD5fNr1KA== 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=rDb12PtZNgwTC1TYwBkAnpIWDw9Pt6HblK1iL44AkUU=; b=O8qG3Dd6rmCesxeV2LtXFzlOghHOARGj6JslQbtSO87a6JBUxmNsvHiqIckVaeU/AZUQ+k4dGiwMT1kL3+c9cf4F5CwzGSkqnX1eh6ZxT+GWcm0EMdfAwv+IK0j+WOsPPas+D4B1iWtPExPuQysui6ZsAp/TKd+omYWNTmluV7Kobu1hMjJO/On+45ouKJeytckWMp5iuDI3oXxs/9L3yyfCmYu1n+0dUUxh/mx5pzL6ROm45ixXHwxQqOteLpKmYQ5cqMb1Czbn+hbDh3J1WYVIEw8vN1055pQ+1+Q8C+ZI1P7OaE2dwqfGW7xBKwul1vIk/krl4vekscr7VhzYiw== 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=rDb12PtZNgwTC1TYwBkAnpIWDw9Pt6HblK1iL44AkUU=; b=rKpx11dpxDYSYqNg2MaPwyp9aTgY980PhGBW67cRFi4qF5Jz6pckfCDz1uW9cOekYCYBa4Z4xrhBUgHV8Wgyt2BMCuj3r1PNNe3ZHtoeDlLSAfVgJTNZ9O18B3t3aBjgWxbH2VnCPR69rtpgGpTc900aAuNz6sr8rM9fXd0WpQo= Authentication-Results: fromorbit.com; dkim=none (message not signed) header.d=none;fromorbit.com; dmarc=none action=none header.from=oracle.com; Received: from SJ0PR10MB4429.namprd10.prod.outlook.com (2603:10b6:a03:2d1::14) by BYAPR10MB2759.namprd10.prod.outlook.com (2603:10b6:a02:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Thu, 21 Oct 2021 00:12:02 +0000 Received: from SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c]) by SJ0PR10MB4429.namprd10.prod.outlook.com ([fe80::401:1df2:3e9a:66c%5]) with mapi id 15.20.4608.018; Thu, 21 Oct 2021 00:12:02 +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 6/6] dm: Ensure dm honors DAXDEV_F_RECOVERY flag on dax only Date: Wed, 20 Oct 2021 18:10:59 -0600 Message-Id: <20211021001059.438843-7-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20211021001059.438843-1-jane.chu@oracle.com> References: <20211021001059.438843-1-jane.chu@oracle.com> X-ClientProxiedBy: SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) 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 Received: from brm-x62-16.us.oracle.com (2606:b400:8004:44::1d) by SN4PR0801CA0003.namprd08.prod.outlook.com (2603:10b6:803:29::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Thu, 21 Oct 2021 00:12:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3086f6e0-b295-4ae8-3830-08d9942767f9 X-MS-TrafficTypeDiagnostic: BYAPR10MB2759: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:813; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SwUxeInXWh+dgh6GbaS/ZG2Nv9S0cNJ6M42dZaeHBDJs558Q90G0R2h30G+aA3dCh2LfzmJWyQA/ahTIb91NfBH9wHpRUhPbLz24LQwxTDi2nc/xAnN81kzemmPwmScfKMnCd7/XDyPhNWepbqP7QhOJG/zrvKDustSxzm/HfGh4o5epcm/eNGP6fBFBnssAbDxt2nCnv4qpz/1+OKzrUhVmjQ9c0/wPCAa9WFhx2pRUtBlj+iqMPv/AF4kvb6otCDzlfbF6S9YH6BBLGvXXCSjDPvAp3qZMIvPDeMPU2rWMuEXGxzjNGrYzFgxJbJb0TjgDCSMAT28yHD/I11P91WFAub1FnuSHFRk3aKzHaNcXYE10DyJwa+YvavKRJ69ZB3NiS2/JycT1JWrbsyPkIelWMNA26e/3FVsoy83xHacU916cXMiiVuI9rZAUsd39hJk88SVbBHi5f972R8ZvpNZx+xCVg9n4pXEM6ARcSocBkGxcAHXwPzA5d5jxD/wpZu/x3vBTcacXOaCpPicCnYwiaSSI9DWOBaxNAzNM9sM3P/jYeH1YUA/eaLlA9fubW+bxuFpxRaNZahyUxaK4AC1B65GAErZBXlHRpDPpSIyDVDI/ug4nOCZc7qlLl6ZeOLx2FaMycGoOyu2JjwI7/9n5XbMup6N64gRaHe8etM3IVwf7o8zfY5cDzPMdMpPW 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)(316002)(5660300002)(1076003)(66946007)(66476007)(7416002)(38100700002)(83380400001)(36756003)(66556008)(921005)(508600001)(6486002)(8676002)(86362001)(186003)(7696005)(52116002)(8936002)(44832011)(2616005)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1JriRzLKMTs+EtHmGlcariODedtlWhYMtDDMliqQ+PnnOYwKb+N265nSqLb78TImsA4Pmr5rNPkLiMJLcMJtzDHoo9bxJeIzfLWjqjB+TJV/qy2JLPWxmUPEcO473bekRvRPx32LXD+5J2ZBvmmaBBSUMlXCdK3+mZll4QjuDJ0+jPbTxT8cJ8E5Z5RkTcdxdlFJR+I9jo8VxRyNGJDvmpH0Z3uDKgEzlRX/C07RxtaXhwqqc475/0ZCWr2829X+9FzM0tggHKJwGeVLLB21iIyZG5BW3iEtJDsSjNG5CWKONlU458r2dPNhZQgamu61TBQ48pimdGVZP3gIZ1h1lMB7FKhHMrBA2EIScmHT9YM4qC0eIcO0bWwFvE5JhK3Va2FKziCN1gh482FtlfefF4ZB6maXsgA9L6wE3F+wRWJ75CwPNSEkA2rkSXT0PrUUU8JHo4Ec90iopP10Z5yR6S/zlqu3AiWmKxslpKSQMHgqVEYdiTCTuacobcyruTAU/cRpNxZFHjYKtEr37Mdcw3HWyA2ZViDB5NN4tgFilwSBcFHCOYcRw7TgDO7XWb/rRydso0C1zs4ZzEl0xs+zN45Gxx3q7dOKU0SSoToXmzYzWxb8hvniCBfxrb4rCSMftf38CJTcQHYLr4P9rOqMmY3SrVDiW2c+JvM88GmR5hwhjBXUBEl2Lyz8SvRaSArKg1q9JasUbZvHXzueKN6jZtKmRwy+29XBZSSoxbTsYjVbjxlzkg030EPGvGyudI2SLvgr4kY/ztmG3p98F6isss1Qv3T9jlOBQJOj2ZavTBQMj5B7GkKmLKULreEB9fAKXMAuQ+NP4mV/IUkmR7RwkoMFwhCBDANQ+VzRO8pcmSJNLS1jW9eHseVV8vP1ktu7mmG5bycp7geH8gJK/zT4KpPmqq8yjBkQwJKeKfCNLy59Exc3U0T5FldExKael5dJvTE+Z00seULukXaTTKSJ6VnRTWIfiVT+hAC9UW90qjVU6aflWzlasKKCWFWY4SHs8qoQF2x0cVRX2ln5ED8cCX44z3lCkknCULe9XyxKK87lu4OjvMrIQbZx80+GsibrZcRIlcyPNwpVZgtOXfEWg5my2Ae8H7IJIlZPmy96I+0Y9TLi0wPySexNpj68zuim3kxt7xsEVW6ad51jnZPtwTgzpOZo3XJ/IAOF49aJXcswzWgAxUg/HPAipIfuTuiRVYAHYkLH29pu9panYqfrB3FeLj5l6DIBhTqf1v8PzkhhxZngUX68nlU3KeSsKt9FJvrnPzInBPqPsTWS8TqeOoNFe7H/mG7R0mN5tYSgv3/dtJeqUjuVbQbM1WoYTD4HRUc8Xbozeto1fjJ6YE1RTQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3086f6e0-b295-4ae8-3830-08d9942767f9 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4429.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2021 00:12:02.0369 (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: jane.chu@oracle.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2759 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10143 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110210000 X-Proofpoint-ORIG-GUID: jlTJ0Uy0HZJPhubLMe06VMJMPNG1rwVD X-Proofpoint-GUID: jlTJ0Uy0HZJPhubLMe06VMJMPNG1rwVD dm_dax_direct_access() supports DAXDEV_F_RECOVERY, so it may translate a poisoned range. But if dm_dax_copy_to/from_iter() don't have a dax_copy_to/from_iter() foundation underneath, performing load/store over poisoned range is dangerous and should be avoided. Signed-off-by: Jane Chu --- drivers/md/dm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 764183ddebc1..5f7fe64d3c37 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1058,6 +1058,8 @@ static size_t dm_dax_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff, if (!ti) goto out; if (!ti->type->dax_copy_from_iter) { + if (flags & DAXDEV_F_RECOVERY) + goto out; ret = copy_from_iter(addr, bytes, i); goto out; } @@ -1082,6 +1084,8 @@ static size_t dm_dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, if (!ti) goto out; if (!ti->type->dax_copy_to_iter) { + if (flags & DAXDEV_F_RECOVERY) + goto out; ret = copy_to_iter(addr, bytes, i); goto out; }