From patchwork Fri Jun 4 01:18:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298755 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69BFEC4708F for ; Fri, 4 Jun 2021 06:25:36 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 01B6E6140B for ; Fri, 4 Jun 2021 06:25:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01B6E6140B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-EdQc8BwcNJ6ax2k56J7Mxg-1; Fri, 04 Jun 2021 02:25:32 -0400 X-MC-Unique: EdQc8BwcNJ6ax2k56J7Mxg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A4B95801B12; Fri, 4 Jun 2021 06:25:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82B185C1C5; Fri, 4 Jun 2021 06:25:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5410E1801264; Fri, 4 Jun 2021 06:25:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541KDiP026798 for ; Thu, 3 Jun 2021 21:20:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A68120951A0; Fri, 4 Jun 2021 01:20:13 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85AC820951A2 for ; Fri, 4 Jun 2021 01:20:13 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CFCF1857F29 for ; Fri, 4 Jun 2021 01:20:13 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-371-ZRWsnm0vOmClGSVMCi_JwA-2; Thu, 03 Jun 2021 21:20:09 -0400 X-MC-Unique: ZRWsnm0vOmClGSVMCi_JwA-2 IronPort-HdrOrdr: A9a23:N4lpJ6sSDEGhtG3G4G6toNZs7skDktV00zEX/kB9WHVpmszxra6TdZMgpHnJYVcqKQgdcL+7WJVoLUmxyXcx2/h1AV7AZniAhILLFvAA0WKK+VSJcEeSygce79YFT0EUMrzN5DZB4voSmDPIcerI3uP3jZyAtKPPyWt3VwF2Z+VF5wd9MAySFUp7X2B9dOEEPavZ9sxavCChZHhSSsy6A0MOV+/Fq8aOu4nhZXc9dmQawTjLnTW186T7DhTd+h8fVglEybAk/XOAsyGR3NTaj82G X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209803" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:19:06 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 4A1734C369E0; Fri, 4 Jun 2021 09:19:01 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:18:51 +0800 Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:18:50 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:18:50 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:35 +0800 Message-ID: <20210604011844.1756145-2-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 4A1734C369E0.AF67F X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 01/10] pagemap: Introduce ->memory_failure() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com When memory-failure occurs, we call this function which is implemented by each kind of devices. For the fsdax case, pmem device driver implements it. Pmem device driver will find out the filesystem in which the corrupted page located in. And finally call filesystem handler to deal with this error. The filesystem will try to recover the corrupted data if possiable. Signed-off-by: Shiyang Ruan --- include/linux/memremap.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 45a79da89c5f..473fe18c516a 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -87,6 +87,14 @@ struct dev_pagemap_ops { * the page back to a CPU accessible page. */ vm_fault_t (*migrate_to_ram)(struct vm_fault *vmf); + + /* + * Handle the memory failure happens on one page. Notify the processes + * who are using this page, and try to recover the data on this page + * if necessary. + */ + int (*memory_failure)(struct dev_pagemap *pgmap, unsigned long pfn, + int flags); }; #define PGMAP_ALTMAP_VALID (1 << 0) From patchwork Fri Jun 4 01:18:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298771 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89C18C47083 for ; Fri, 4 Jun 2021 06:28:03 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FED36140B for ; Fri, 4 Jun 2021 06:28:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FED36140B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-115-Y3JFfB4_MM2DQw4Rm-fD5Q-1; Fri, 04 Jun 2021 02:27:59 -0400 X-MC-Unique: Y3JFfB4_MM2DQw4Rm-fD5Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 164FB6D4EE; Fri, 4 Jun 2021 06:27:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED01F7012E; Fri, 4 Jun 2021 06:27:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B71AF1801264; Fri, 4 Jun 2021 06:27:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541K7pP026771 for ; Thu, 3 Jun 2021 21:20:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 09EAF11E5D2; Fri, 4 Jun 2021 01:20:07 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 035BC11E5BB for ; Fri, 4 Jun 2021 01:20:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6241980348D for ; Fri, 4 Jun 2021 01:20:03 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-584-ZT1htKkbOJ6brDY16c1kvA-3; Thu, 03 Jun 2021 21:19:59 -0400 X-MC-Unique: ZT1htKkbOJ6brDY16c1kvA-3 IronPort-HdrOrdr: A9a23:g3ZKiKlaGTCpHJTyTExY54VFtYLpDfLI3DAbv31ZSRFFG/Fxl6iV8sjzsiWE7gr5OUtQ4OxoV5PhfZqxz/JICMwqTNKftWrdyQyVxeNZnOjfKlTbckWUnINgPOVbAsxD4bbLbGSS4/yU3ODBKadD/DCYytHUuc7ui2dqURpxa7xtqyNwCgOgGEVwQwVcbKBJb6a0145WoSa6Y3QLYoCeDnkBZeLKoNrGj9bIehgDbiRXkjWmvHe57qLgCRiE0lM7WzNL+70r9m/IiEjYy8yYwomG9iM= X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209786" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:18:54 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id 9860D4C36A0F; Fri, 4 Jun 2021 09:18:51 +0800 (CST) Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:18:51 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:18:51 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:36 +0800 Message-ID: <20210604011844.1756145-3-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 9860D4C36A0F.A12C5 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 02/10] dax: Introduce holder for dax_device X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com To easily track filesystem from a pmem device, we introduce a holder for dax_device structure, and also its operation. This holder is used to remember who is using this dax_device: - When it is the backend of a filesystem, the holder will be the superblock of this filesystem. - When this pmem device is one of the targets in a mapped device, the holder will be this mapped device. In this case, the mapped device has its own dax_device and it will follow the first rule. So that we can finally track to the filesystem we needed. The holder and holder_ops will be set when filesystem is being mounted, or an target device is being activated. Signed-off-by: Shiyang Ruan --- drivers/dax/super.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/dax.h | 10 ++++++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 5fa6ae9dbc8b..d118e2a7dc70 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -222,8 +222,10 @@ struct dax_device { struct cdev cdev; const char *host; void *private; + void *holder; unsigned long flags; const struct dax_operations *ops; + const struct dax_holder_operations *holder_ops; }; static ssize_t write_cache_show(struct device *dev, @@ -373,6 +375,24 @@ int dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, } EXPORT_SYMBOL_GPL(dax_zero_page_range); +int dax_corrupted_range(struct dax_device *dax_dev, struct block_device *bdev, + loff_t offset, size_t size, void *data) +{ + int rc = -ENXIO; + if (!dax_dev) + return rc; + + if (dax_dev->holder) { + rc = dax_dev->holder_ops->corrupted_range(dax_dev, bdev, offset, + size, data); + if (rc == -ENODEV) + rc = -ENXIO; + } else + rc = -EOPNOTSUPP; + return rc; +} +EXPORT_SYMBOL_GPL(dax_corrupted_range); + #ifdef CONFIG_ARCH_HAS_PMEM_API void arch_wb_cache_pmem(void *addr, size_t size); void dax_flush(struct dax_device *dax_dev, void *addr, size_t size) @@ -624,6 +644,24 @@ void put_dax(struct dax_device *dax_dev) } EXPORT_SYMBOL_GPL(put_dax); +void dax_set_holder(struct dax_device *dax_dev, void *holder, + const struct dax_holder_operations *ops) +{ + if (!dax_dev) + return; + dax_dev->holder = holder; + dax_dev->holder_ops = ops; +} +EXPORT_SYMBOL_GPL(dax_set_holder); + +void *dax_get_holder(struct dax_device *dax_dev) +{ + if (!dax_dev) + return NULL; + return dax_dev->holder; +} +EXPORT_SYMBOL_GPL(dax_get_holder); + /** * dax_get_by_host() - temporary lookup mechanism for filesystem-dax * @host: alternate name for the device registered by a dax driver diff --git a/include/linux/dax.h b/include/linux/dax.h index b52f084aa643..1ce343a960ab 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -38,10 +38,18 @@ struct dax_operations { int (*zero_page_range)(struct dax_device *, pgoff_t, size_t); }; +struct dax_holder_operations { + int (*corrupted_range)(struct dax_device *, struct block_device *, + loff_t, size_t, void *); +}; + extern struct attribute_group dax_attribute_group; #if IS_ENABLED(CONFIG_DAX) struct dax_device *dax_get_by_host(const char *host); +void dax_set_holder(struct dax_device *dax_dev, void *holder, + const struct dax_holder_operations *ops); +void *dax_get_holder(struct dax_device *dax_dev); struct dax_device *alloc_dax(void *private, const char *host, const struct dax_operations *ops, unsigned long flags); void put_dax(struct dax_device *dax_dev); @@ -226,6 +234,8 @@ size_t dax_copy_to_iter(struct dax_device *dax_dev, pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i); int dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, size_t nr_pages); +int dax_corrupted_range(struct dax_device *dax_dev, struct block_device *bdev, + loff_t offset, size_t size, void *data); void dax_flush(struct dax_device *dax_dev, void *addr, size_t size); ssize_t dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter, From patchwork Fri Jun 4 01:18:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298761 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C0E1C47083 for ; Fri, 4 Jun 2021 06:26:57 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A158A61078 for ; Fri, 4 Jun 2021 06:26:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A158A61078 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-534-GX5H71z1M62L1lDMUKgLHg-1; Fri, 04 Jun 2021 02:26:54 -0400 X-MC-Unique: GX5H71z1M62L1lDMUKgLHg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F100803625; Fri, 4 Jun 2021 06:26:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E64051007606; Fri, 4 Jun 2021 06:26:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AF8221801265; Fri, 4 Jun 2021 06:26:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541K6gr026766 for ; Thu, 3 Jun 2021 21:20:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6BC1510CB263; Fri, 4 Jun 2021 01:20:06 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 66E2D10CB266 for ; Fri, 4 Jun 2021 01:20:04 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1AF2180D0E3 for ; Fri, 4 Jun 2021 01:20:04 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-469-kW8x8JIeNJCznYqLN0CQwg-1; Thu, 03 Jun 2021 21:20:00 -0400 X-MC-Unique: kW8x8JIeNJCznYqLN0CQwg-1 IronPort-HdrOrdr: A9a23:97nSk66uC1F30wIpuQPXwCzXdLJyesId70hD6qhwISY6TiX+rbHJoB17726MtN9/YhEdcLy7VJVoBEmskKKdgrNhWotKPjOW21dARbsKheCJrgEIWReOktK1vp0AT0ERMrLN5CBB/KTHCReDYqsd6ejC4Ka1nv3f0nsoaQlrbptr5wB/Bh3zKDwMeCB2QYo+CIGH5tdK4x6peXEsZMy9AXUfG8fZodmjruOdXTc2Qw4g9BKVjS6lrJrzEx2j1B8YVD9VhZcOmFK16zDE2g== X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209788" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:18:54 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id B3A5D4C36A05; Fri, 4 Jun 2021 09:18:52 +0800 (CST) Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:18:54 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:18:52 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:37 +0800 Message-ID: <20210604011844.1756145-4-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: B3A5D4C36A05.A0A85 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 03/10] fs: Introduce ->corrupted_range() for superblock X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Memory failure occurs in fsdax mode will finally be handled in filesystem. We introduce this interface to find out files or metadata affected by the corrupted range, and try to recover the corrupted data if possiable. Signed-off-by: Shiyang Ruan --- include/linux/fs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index c3c88fdb9b2a..92af36c4225f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2176,6 +2176,8 @@ struct super_operations { struct shrink_control *); long (*free_cached_objects)(struct super_block *, struct shrink_control *); + int (*corrupted_range)(struct super_block *sb, struct block_device *bdev, + loff_t offset, size_t len, void *data); }; /* From patchwork Fri Jun 4 01:18:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298759 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41271C4708F for ; Fri, 4 Jun 2021 06:26:56 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4E7061078 for ; Fri, 4 Jun 2021 06:26:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4E7061078 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-396-JzMopbXdM6CC1h6R7RyfsQ-1; Fri, 04 Jun 2021 02:26:51 -0400 X-MC-Unique: JzMopbXdM6CC1h6R7RyfsQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5127D801817; Fri, 4 Jun 2021 06:26:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B38E5D705; Fri, 4 Jun 2021 06:26:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 33CDD1800FFC; Fri, 4 Jun 2021 06:26:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541K7Wa026777 for ; Thu, 3 Jun 2021 21:20:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8FA3320951A3; Fri, 4 Jun 2021 01:20:07 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B04A20951A0 for ; Fri, 4 Jun 2021 01:20:07 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6ED2F101A55F for ; Fri, 4 Jun 2021 01:20:07 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-371-HRoaUlBQOO2kGElyttXNfA-1; Thu, 03 Jun 2021 21:20:03 -0400 X-MC-Unique: HRoaUlBQOO2kGElyttXNfA-1 IronPort-HdrOrdr: A9a23:zEBVIKP+X+K9zsBcTv2jsMiBIKoaSvp037BL7TEUdfUxSKGlfq+V8sjzqiWftN98YhAdcLO7Scy9qBHnhP1ICOAqVN/MYOCMghrLEGgN1+vf6gylMyj/28oY7q14bpV5YeeaMXFKyer8/ym0euxN/OW6 X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209790" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:18:54 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id D97724C36A1E; Fri, 4 Jun 2021 09:18:53 +0800 (CST) Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:18:54 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:18:53 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:38 +0800 Message-ID: <20210604011844.1756145-5-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: D97724C36A1E.A43F3 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 04/10] mm, fsdax: Refactor memory-failure handler for dax mapping X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com The current memory_failure_dev_pagemap() can only handle single-mapped dax page for fsdax mode. The dax page could be mapped by multiple files and offsets if we let reflink feature & fsdax mode work together. So, we refactor current implementation to support handle memory failure on each file and offset. Signed-off-by: Shiyang Ruan --- fs/dax.c | 21 ++++++++ include/linux/dax.h | 1 + include/linux/mm.h | 9 ++++ mm/memory-failure.c | 114 ++++++++++++++++++++++++++++---------------- 4 files changed, 105 insertions(+), 40 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 62352cbcf0f4..58faca85455a 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -389,6 +389,27 @@ static struct page *dax_busy_page(void *entry) return NULL; } +/* + * dax_load_pfn - Load pfn of the DAX entry corresponding to a page + * @mapping: The file whose entry we want to load + * @index: The offset where the DAX entry located in + * + * Return: pfn of the DAX entry + */ +unsigned long dax_load_pfn(struct address_space *mapping, unsigned long index) +{ + XA_STATE(xas, &mapping->i_pages, index); + void *entry; + unsigned long pfn; + + xas_lock_irq(&xas); + entry = xas_load(&xas); + pfn = dax_to_pfn(entry); + xas_unlock_irq(&xas); + + return pfn; +} + /* * dax_lock_mapping_entry - Lock the DAX entry corresponding to a page * @page: The page whose entry we want to lock diff --git a/include/linux/dax.h b/include/linux/dax.h index 1ce343a960ab..6e758daa5004 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -158,6 +158,7 @@ int dax_writeback_mapping_range(struct address_space *mapping, struct page *dax_layout_busy_page(struct address_space *mapping); struct page *dax_layout_busy_page_range(struct address_space *mapping, loff_t start, loff_t end); +unsigned long dax_load_pfn(struct address_space *mapping, unsigned long index); dax_entry_t dax_lock_page(struct page *page); void dax_unlock_page(struct page *page, dax_entry_t cookie); #else diff --git a/include/linux/mm.h b/include/linux/mm.h index c274f75efcf9..2b7527e93c77 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1187,6 +1187,14 @@ static inline bool is_device_private_page(const struct page *page) page->pgmap->type == MEMORY_DEVICE_PRIVATE; } +static inline bool is_device_fsdax_page(const struct page *page) +{ + return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && + IS_ENABLED(CONFIG_FS_DAX) && + is_zone_device_page(page) && + page->pgmap->type == MEMORY_DEVICE_FS_DAX; +} + static inline bool is_pci_p2pdma_page(const struct page *page) { return IS_ENABLED(CONFIG_DEV_PAGEMAP_OPS) && @@ -3078,6 +3086,7 @@ enum mf_flags { MF_MUST_KILL = 1 << 2, MF_SOFT_OFFLINE = 1 << 3, }; +int mf_dax_kill_procs(struct address_space *mapping, pgoff_t index, int flags); extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); extern void memory_failure_queue_kick(int cpu); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 85ad98c00fd9..4377e727d478 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -56,6 +56,7 @@ #include #include #include +#include #include "internal.h" #include "ras/ras_event.h" @@ -120,6 +121,13 @@ static int hwpoison_filter_dev(struct page *p) if (PageSlab(p)) return -EINVAL; + if (pfn_valid(page_to_pfn(p))) { + if (is_device_fsdax_page(p)) + return 0; + else + return -EINVAL; + } + mapping = page_mapping(p); if (mapping == NULL || mapping->host == NULL) return -EINVAL; @@ -290,10 +298,9 @@ void shake_page(struct page *p, int access) } EXPORT_SYMBOL_GPL(shake_page); -static unsigned long dev_pagemap_mapping_shift(struct page *page, - struct vm_area_struct *vma) +static unsigned long dev_pagemap_mapping_shift(struct vm_area_struct *vma, + unsigned long address) { - unsigned long address = vma_address(page, vma); pgd_t *pgd; p4d_t *p4d; pud_t *pud; @@ -333,9 +340,8 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page, * Schedule a process for later kill. * Uses GFP_ATOMIC allocations to avoid potential recursions in the VM. */ -static void add_to_kill(struct task_struct *tsk, struct page *p, - struct vm_area_struct *vma, - struct list_head *to_kill) +static void add_to_kill(struct task_struct *tsk, struct page *p, pgoff_t pgoff, + struct vm_area_struct *vma, struct list_head *to_kill) { struct to_kill *tk; @@ -346,9 +352,12 @@ static void add_to_kill(struct task_struct *tsk, struct page *p, } tk->addr = page_address_in_vma(p, vma); - if (is_zone_device_page(p)) - tk->size_shift = dev_pagemap_mapping_shift(p, vma); - else + if (is_zone_device_page(p)) { + if (is_device_fsdax_page(p)) + tk->addr = vma->vm_start + + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); + tk->size_shift = dev_pagemap_mapping_shift(vma, tk->addr); + } else tk->size_shift = page_shift(compound_head(p)); /* @@ -496,7 +505,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, if (!page_mapped_in_vma(page, vma)) continue; if (vma->vm_mm == t->mm) - add_to_kill(t, page, vma, to_kill); + add_to_kill(t, page, 0, vma, to_kill); } } read_unlock(&tasklist_lock); @@ -506,24 +515,19 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, /* * Collect processes when the error hit a file mapped page. */ -static void collect_procs_file(struct page *page, struct list_head *to_kill, - int force_early) +static void collect_procs_file(struct page *page, struct address_space *mapping, + pgoff_t pgoff, struct list_head *to_kill, int force_early) { struct vm_area_struct *vma; struct task_struct *tsk; - struct address_space *mapping = page->mapping; - pgoff_t pgoff; i_mmap_lock_read(mapping); read_lock(&tasklist_lock); - pgoff = page_to_pgoff(page); for_each_process(tsk) { struct task_struct *t = task_early_kill(tsk, force_early); - if (!t) continue; - vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, - pgoff) { + vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) { /* * Send early kill signal to tasks where a vma covers * the page but the corrupted page is not necessarily @@ -532,7 +536,7 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill, * to be informed of all such data corruptions. */ if (vma->vm_mm == t->mm) - add_to_kill(t, page, vma, to_kill); + add_to_kill(t, page, pgoff, vma, to_kill); } } read_unlock(&tasklist_lock); @@ -551,7 +555,8 @@ static void collect_procs(struct page *page, struct list_head *tokill, if (PageAnon(page)) collect_procs_anon(page, tokill, force_early); else - collect_procs_file(page, tokill, force_early); + collect_procs_file(page, page_mapping(page), page_to_pgoff(page), + tokill, force_early); } static const char *action_name[] = { @@ -1218,6 +1223,51 @@ static int try_to_split_thp_page(struct page *page, const char *msg) return 0; } +static void unmap_and_kill(struct list_head *to_kill, unsigned long pfn, + struct address_space *mapping, pgoff_t index, int flags) +{ + struct to_kill *tk; + unsigned long size = 0; + loff_t start; + + list_for_each_entry(tk, to_kill, nd) + if (tk->size_shift) + size = max(size, 1UL << tk->size_shift); + if (size) { + /* + * Unmap the largest mapping to avoid breaking up + * device-dax mappings which are constant size. The + * actual size of the mapping being torn down is + * communicated in siginfo, see kill_proc() + */ + start = (index << PAGE_SHIFT) & ~(size - 1); + unmap_mapping_range(mapping, start, size, 0); + } + + kill_procs(to_kill, flags & MF_MUST_KILL, false, pfn, flags); +} + +int mf_dax_kill_procs(struct address_space *mapping, pgoff_t index, int flags) +{ + LIST_HEAD(to_kill); + /* load the pfn of the dax mapping file */ + unsigned long pfn = dax_load_pfn(mapping, index); + + /* + * Unlike System-RAM there is no possibility to swap in a + * different physical page at a given virtual address, so all + * userspace consumption of ZONE_DEVICE memory necessitates + * SIGBUS (i.e. MF_MUST_KILL) + */ + flags |= MF_ACTION_REQUIRED | MF_MUST_KILL; + collect_procs_file(pfn_to_page(pfn), mapping, index, &to_kill, + flags & MF_ACTION_REQUIRED); + + unmap_and_kill(&to_kill, pfn, mapping, index, flags); + return 0; +} +EXPORT_SYMBOL_GPL(mf_dax_kill_procs); + static int memory_failure_hugetlb(unsigned long pfn, int flags) { struct page *p = pfn_to_page(pfn); @@ -1298,12 +1348,8 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, struct dev_pagemap *pgmap) { struct page *page = pfn_to_page(pfn); - const bool unmap_success = true; - unsigned long size = 0; - struct to_kill *tk; - LIST_HEAD(tokill); + LIST_HEAD(to_kill); int rc = -EBUSY; - loff_t start; dax_entry_t cookie; if (flags & MF_COUNT_INCREASED) @@ -1355,22 +1401,10 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, * SIGBUS (i.e. MF_MUST_KILL) */ flags |= MF_ACTION_REQUIRED | MF_MUST_KILL; - collect_procs(page, &tokill, flags & MF_ACTION_REQUIRED); + collect_procs_file(page, page->mapping, page->index, &to_kill, + flags & MF_ACTION_REQUIRED); - list_for_each_entry(tk, &tokill, nd) - if (tk->size_shift) - size = max(size, 1UL << tk->size_shift); - if (size) { - /* - * Unmap the largest mapping to avoid breaking up - * device-dax mappings which are constant size. The - * actual size of the mapping being torn down is - * communicated in siginfo, see kill_proc() - */ - start = (page->index << PAGE_SHIFT) & ~(size - 1); - unmap_mapping_range(page->mapping, start, size, 0); - } - kill_procs(&tokill, flags & MF_MUST_KILL, !unmap_success, pfn, flags); + unmap_and_kill(&to_kill, pfn, page->mapping, page->index, flags); rc = 0; unlock: dax_unlock_page(page, cookie); From patchwork Fri Jun 4 01:18:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298765 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26625C4708F for ; Fri, 4 Jun 2021 06:27:01 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF7366136E for ; Fri, 4 Jun 2021 06:27:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF7366136E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-Ly6W6Rs9PaKzxB03V3w8HA-1; Fri, 04 Jun 2021 02:26:58 -0400 X-MC-Unique: Ly6W6Rs9PaKzxB03V3w8HA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2660A106BB33; Fri, 4 Jun 2021 06:26:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0949C376E; Fri, 4 Jun 2021 06:26:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CF2D944A58; Fri, 4 Jun 2021 06:26:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541KGM4026818 for ; Thu, 3 Jun 2021 21:20:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2968011E5BB; Fri, 4 Jun 2021 01:20:16 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2500111E5CB for ; Fri, 4 Jun 2021 01:20:16 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D780805F44 for ; Fri, 4 Jun 2021 01:20:16 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-371-CrnSrQysNU2CzVrkgSpltg-3; Thu, 03 Jun 2021 21:20:11 -0400 X-MC-Unique: CrnSrQysNU2CzVrkgSpltg-3 IronPort-HdrOrdr: A9a23:ciOndaGMdrd53wsKpLqEjceALOsnbusQ8zAXPiFKKSC9Hfb0qynDpp4mPHzP6Qr5OktOpTnoAsDpKk80naQFgrX5Vo3PYOCJggWVEL0= X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209802" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:19:06 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id D3F604C36A00; Fri, 4 Jun 2021 09:19:01 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:19:02 +0800 Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:18:55 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:18:54 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:39 +0800 Message-ID: <20210604011844.1756145-6-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: D3F604C36A00.A0E01 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 05/10] mm, pmem: Implement ->memory_failure() in pmem driver X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Call the ->memory_failure() which is implemented by pmem driver, in order to finally notify filesystem to handle the corrupted data. The handler which collects and kills processes are moved into mf_dax_kill_procs(), which will be called by filesystem. Keep the old handler in order to roll back if driver or filesystem does not support ->memory_failure()/->corrupted_range(). Signed-off-by: Shiyang Ruan --- block/genhd.c | 30 ++++++++++++++++++ drivers/nvdimm/pmem.c | 14 +++++++++ include/linux/genhd.h | 1 + mm/memory-failure.c | 71 +++++++++++++++++++++++++++---------------- 4 files changed, 90 insertions(+), 26 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index 9f8cb7beaad1..75834bd057df 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -718,6 +718,36 @@ struct block_device *bdget_disk(struct gendisk *disk, int partno) return bdev; } +/** + * bdget_disk_sector - get block device by given sector number + * @disk: gendisk of interest + * @sector: sector number + * + * RETURNS: the found block device where sector locates in + */ +struct block_device *bdget_disk_sector(struct gendisk *disk, sector_t sector) +{ + struct block_device *part = NULL, *p; + unsigned long idx; + + rcu_read_lock(); + xa_for_each(&disk->part_tbl, idx, p) { + if (p->bd_partno == 0) + continue; + if (p->bd_start_sect <= sector && + sector < p->bd_start_sect + bdev_nr_sectors(p)) { + part = p; + break; + } + } + rcu_read_unlock(); + if (!part) + part = disk->part0; + + return bdget_disk(disk, part->bd_partno); +} +EXPORT_SYMBOL(bdget_disk_sector); + /* * print a full list of all partitions - intended for places where the root * filesystem can't be mounted and thus to give the victim some idea of what diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index ed10a8b66068..98349e7d0a28 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -364,9 +364,23 @@ static void pmem_release_disk(void *__pmem) put_disk(pmem->disk); } +static int pmem_pagemap_memory_failure(struct dev_pagemap *pgmap, + unsigned long pfn, int flags) +{ + struct pmem_device *pdev = + container_of(pgmap, struct pmem_device, pgmap); + loff_t offset = PFN_PHYS(pfn) - pdev->phys_addr - pdev->data_offset; + struct block_device *bdev = + bdget_disk_sector(pdev->disk, offset >> SECTOR_SHIFT); + + return dax_corrupted_range(pdev->dax_dev, bdev, offset, + page_size(pfn_to_page(pfn)), &flags); +} + static const struct dev_pagemap_ops fsdax_pagemap_ops = { .kill = pmem_pagemap_kill, .cleanup = pmem_pagemap_cleanup, + .memory_failure = pmem_pagemap_memory_failure, }; static int pmem_attach_disk(struct device *dev, diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 6fc26f7bdf71..2ad70c02c343 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -219,6 +219,7 @@ static inline void add_disk_no_queue_reg(struct gendisk *disk) extern void del_gendisk(struct gendisk *gp); extern struct block_device *bdget_disk(struct gendisk *disk, int partno); +extern struct block_device *bdget_disk_sector(struct gendisk *disk, sector_t sector); void set_disk_ro(struct gendisk *disk, bool read_only); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 4377e727d478..43017d7f3918 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1247,6 +1247,36 @@ static void unmap_and_kill(struct list_head *to_kill, unsigned long pfn, kill_procs(to_kill, flags & MF_MUST_KILL, false, pfn, flags); } +static int mf_generic_kill_procs(unsigned long long pfn, int flags) +{ + struct page *page = pfn_to_page(pfn); + LIST_HEAD(to_kill); + dax_entry_t cookie; + + /* + * Prevent the inode from being freed while we are interrogating + * the address_space, typically this would be handled by + * lock_page(), but dax pages do not use the page lock. This + * also prevents changes to the mapping of this pfn until + * poison signaling is complete. + */ + cookie = dax_lock_page(page); + if (!cookie) + return -EBUSY; + /* + * Unlike System-RAM there is no possibility to swap in a + * different physical page at a given virtual address, so all + * userspace consumption of ZONE_DEVICE memory necessitates + * SIGBUS (i.e. MF_MUST_KILL) + */ + flags |= MF_ACTION_REQUIRED | MF_MUST_KILL; + collect_procs(page, &to_kill, flags & MF_ACTION_REQUIRED); + + unmap_and_kill(&to_kill, pfn, page->mapping, page->index, flags); + dax_unlock_page(page, cookie); + return 0; +} + int mf_dax_kill_procs(struct address_space *mapping, pgoff_t index, int flags) { LIST_HEAD(to_kill); @@ -1348,9 +1378,7 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, struct dev_pagemap *pgmap) { struct page *page = pfn_to_page(pfn); - LIST_HEAD(to_kill); int rc = -EBUSY; - dax_entry_t cookie; if (flags & MF_COUNT_INCREASED) /* @@ -1364,20 +1392,9 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, goto out; } - /* - * Prevent the inode from being freed while we are interrogating - * the address_space, typically this would be handled by - * lock_page(), but dax pages do not use the page lock. This - * also prevents changes to the mapping of this pfn until - * poison signaling is complete. - */ - cookie = dax_lock_page(page); - if (!cookie) - goto out; - if (hwpoison_filter(page)) { rc = 0; - goto unlock; + goto out; } if (pgmap->type == MEMORY_DEVICE_PRIVATE) { @@ -1385,7 +1402,7 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, * TODO: Handle HMM pages which may need coordination * with device-side memory. */ - goto unlock; + goto out; } /* @@ -1395,19 +1412,21 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, SetPageHWPoison(page); /* - * Unlike System-RAM there is no possibility to swap in a - * different physical page at a given virtual address, so all - * userspace consumption of ZONE_DEVICE memory necessitates - * SIGBUS (i.e. MF_MUST_KILL) + * Call driver's implementation to handle the memory failure, + * otherwise roll back to generic handler. */ - flags |= MF_ACTION_REQUIRED | MF_MUST_KILL; - collect_procs_file(page, page->mapping, page->index, &to_kill, - flags & MF_ACTION_REQUIRED); + if (pgmap->ops->memory_failure) { + rc = pgmap->ops->memory_failure(pgmap, pfn, flags); + /* + * Roll back to generic handler too if operation is not + * supported inside the driver/device/filesystem. + */ + if (rc != EOPNOTSUPP) + goto out; + } + + rc = mf_generic_kill_procs(pfn, flags); - unmap_and_kill(&to_kill, pfn, page->mapping, page->index, flags); - rc = 0; -unlock: - dax_unlock_page(page, cookie); out: /* drop pgmap ref acquired in caller */ put_dev_pagemap(pgmap); From patchwork Fri Jun 4 01:18:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298773 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39D2CC47098 for ; Fri, 4 Jun 2021 06:28:05 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FCDD61405 for ; Fri, 4 Jun 2021 06:28:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FCDD61405 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-153-oCmORRvnPVa4mWmoJTzuHw-1; Fri, 04 Jun 2021 02:28:00 -0400 X-MC-Unique: oCmORRvnPVa4mWmoJTzuHw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E5750107ACF4; Fri, 4 Jun 2021 06:27:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6DDB5D9F2; Fri, 4 Jun 2021 06:27:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 95FC9180C69B; Fri, 4 Jun 2021 06:27:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541KE7Z026803 for ; Thu, 3 Jun 2021 21:20:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DABC21144D1; Fri, 4 Jun 2021 01:20:14 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0936321144C6 for ; Fri, 4 Jun 2021 01:20:14 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E5515101A531 for ; Fri, 4 Jun 2021 01:20:13 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-89-7KVYDoBuM6y3H4RtKFoqTw-1; Thu, 03 Jun 2021 21:20:12 -0400 X-MC-Unique: 7KVYDoBuM6y3H4RtKFoqTw-1 IronPort-HdrOrdr: A9a23:JRAGG6qYgVw+29Uknxze6CEaV5pOeYIsimQD101hICG9E/b5qynAppkmPHPP4gr5O0tApTnjAsa9qBrnnPYf3WB4B8bAYOCMggeVxe9Zg7ff/w== X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209807" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:19:06 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id 77CCF4C369E0; Fri, 4 Jun 2021 09:19:06 +0800 (CST) Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:18:55 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:18:55 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:40 +0800 Message-ID: <20210604011844.1756145-7-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 77CCF4C369E0.A2269 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 06/10] fs/dax: Implement dax_holder_operations X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This is the case where the holder represents a filesystem. The offset translation from disk to block device is needed before we calling ->corrupted_range(). When a specific filesystem is being mounted, we use dax_set_holder() to associate it with the dax_device. Signed-off-by: Shiyang Ruan --- fs/dax.c | 16 ++++++++++++++++ include/linux/dax.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/fs/dax.c b/fs/dax.c index 58faca85455a..1a7473f46df2 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1762,3 +1762,19 @@ vm_fault_t dax_finish_sync_fault(struct vm_fault *vmf, return dax_insert_pfn_mkwrite(vmf, pfn, order); } EXPORT_SYMBOL_GPL(dax_finish_sync_fault); + +static int fs_dax_corrupted_range(struct dax_device *dax_dev, + struct block_device *bdev, loff_t offset, size_t size, + void *data) +{ + struct super_block *sb = dax_get_holder(dax_dev); + loff_t bdev_off = offset - (get_start_sect(bdev) << SECTOR_SHIFT); + + if (!sb->s_op->corrupted_range) + return -EOPNOTSUPP; + return sb->s_op->corrupted_range(sb, bdev, bdev_off, size, data); +} + +const struct dax_holder_operations fs_dax_holder_ops = { + .corrupted_range = fs_dax_corrupted_range, +}; \ No newline at end of file diff --git a/include/linux/dax.h b/include/linux/dax.h index 6e758daa5004..b35b3b8959a5 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -254,6 +254,8 @@ static inline bool dax_mapping(struct address_space *mapping) return mapping->host && IS_DAX(mapping->host); } +extern const struct dax_holder_operations fs_dax_holder_ops; + #ifdef CONFIG_DEV_DAX_HMEM_DEVICES void hmem_register_device(int target_nid, struct resource *r); #else From patchwork Fri Jun 4 01:18:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298775 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64904C4708F for ; Fri, 4 Jun 2021 06:28:06 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F19DD6136E for ; Fri, 4 Jun 2021 06:28:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F19DD6136E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-L9ahUlD4Ny6jBBKs0aA1CA-1; Fri, 04 Jun 2021 02:28:03 -0400 X-MC-Unique: L9ahUlD4Ny6jBBKs0aA1CA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 08EA96D4F0; Fri, 4 Jun 2021 06:27:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC1EC10074FC; Fri, 4 Jun 2021 06:27:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AEC94180140D; Fri, 4 Jun 2021 06:27:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541KMhj026832 for ; Thu, 3 Jun 2021 21:20:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id CF24C20951A2; Fri, 4 Jun 2021 01:20:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CAF6F20951A0 for ; Fri, 4 Jun 2021 01:20:20 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 233BD800C00 for ; Fri, 4 Jun 2021 01:20:20 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-538-ldCO46VUOfKF0YDardIM1A-1; Thu, 03 Jun 2021 21:20:18 -0400 X-MC-Unique: ldCO46VUOfKF0YDardIM1A-1 IronPort-HdrOrdr: A9a23:SN1Snq5yCRqqVPqEvgPXwCzXdLJyesId70hD6qhwISY6TiX+rbHJoB17726MtN9/YhEdcLy7VJVoBEmskKKdgrNhWotKPjOW21dARbsKheCJrgEIWReOktK1vp0AT0ERMrLN5CBB/KTHCReDYqsd6ejC4Ka1nv3f0nsoaQlrbptr5wB/Bh3zKDwMeCB2QYo+CIGH5tdK4x6peXEsZMy9AXUfG8fZodmjruOdXTc2Qw4g9BKVjS6lrJrzEx2j1B8YVD9VhZcOmFK16zDE2g== X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209814" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:19:13 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id DCB934C369E0; Fri, 4 Jun 2021 09:19:12 +0800 (CST) Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:19:09 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:19:07 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:41 +0800 Message-ID: <20210604011844.1756145-8-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: DCB934C369E0.A20ED X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 07/10] dm: Introduce ->rmap() to find bdev offset X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Pmem device could be a target of mapped device. In order to find out the global location on a mapped device, we introduce this to translate offset from target device to mapped device. Currently, we implement it on linear target, which is easy to do the translation. Other targets will be supported in the future. However, some targets may not support it because of the non-linear mapping. Signed-off-by: Shiyang Ruan --- drivers/md/dm-linear.c | 20 ++++++++++++++++++++ include/linux/device-mapper.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 92db0f5e7f28..f9f9bc765ba7 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -5,6 +5,7 @@ */ #include "dm.h" +#include "dm-core.h" #include #include #include @@ -119,6 +120,24 @@ static void linear_status(struct dm_target *ti, status_type_t type, } } +static int linear_rmap(struct dm_target *ti, sector_t offset, + rmap_callout_fn fn, void *data) +{ + struct linear_c *lc = (struct linear_c *) ti->private; + struct mapped_device *md = ti->table->md; + struct block_device *bdev; + sector_t disk_sect = offset - dm_target_offset(ti, lc->start); + int rc = -ENODEV; + + bdev = bdget_disk_sector(md->disk, offset); + if (!bdev) + return rc; + + rc = fn(ti, bdev, disk_sect, data); + bdput(bdev); + return rc; +} + static int linear_prepare_ioctl(struct dm_target *ti, struct block_device **bdev) { struct linear_c *lc = (struct linear_c *) ti->private; @@ -236,6 +255,7 @@ static struct target_type linear_target = { .ctr = linear_ctr, .dtr = linear_dtr, .map = linear_map, + .rmap = linear_rmap, .status = linear_status, .prepare_ioctl = linear_prepare_ioctl, .iterate_devices = linear_iterate_devices, diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index ff700fb6ce1d..89a893565407 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -58,6 +58,10 @@ typedef void (*dm_dtr_fn) (struct dm_target *ti); * = 2: The target wants to push back the io */ typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio); +typedef int (*rmap_callout_fn) (struct dm_target *ti, struct block_device *bdev, + sector_t sect, void *data); +typedef int (*dm_rmap_fn) (struct dm_target *ti, sector_t offset, + rmap_callout_fn fn, void *data); typedef int (*dm_clone_and_map_request_fn) (struct dm_target *ti, struct request *rq, union map_info *map_context, @@ -184,6 +188,7 @@ struct target_type { dm_ctr_fn ctr; dm_dtr_fn dtr; dm_map_fn map; + dm_rmap_fn rmap; dm_clone_and_map_request_fn clone_and_map_rq; dm_release_clone_request_fn release_clone_rq; dm_endio_fn end_io; From patchwork Fri Jun 4 01:18:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298777 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC507C47097 for ; Fri, 4 Jun 2021 06:28:06 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 900F66140B for ; Fri, 4 Jun 2021 06:28:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 900F66140B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-452-Vxk7_-rlOlmRbmNTKr4h4g-1; Fri, 04 Jun 2021 02:28:04 -0400 X-MC-Unique: Vxk7_-rlOlmRbmNTKr4h4g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16EB21883527; Fri, 4 Jun 2021 06:28:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDE4A60CC9; Fri, 4 Jun 2021 06:27:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C1F4A44A59; Fri, 4 Jun 2021 06:27:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541Kn8c026862 for ; Thu, 3 Jun 2021 21:20:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 402BF21144D1; Fri, 4 Jun 2021 01:20:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 368DE2114DD6 for ; Fri, 4 Jun 2021 01:20:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 08DE6919823 for ; Fri, 4 Jun 2021 01:20:47 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-339-ceCrmAVxPGqqC4xYPHPzww-1; Thu, 03 Jun 2021 21:20:43 -0400 X-MC-Unique: ceCrmAVxPGqqC4xYPHPzww-1 IronPort-HdrOrdr: A9a23:oySG86mbvXdBRFbyJo4BYTZBOT/pDfJJ3DAbv31ZSRFFG/Fw9vrPoB1173LJYVoqMk3I+urgBEDjexzhHPdOiOF7AV7LZniEhILCFu1fBOXZrQHdJw== X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209833" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:19:37 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 0F1214C36A00; Fri, 4 Jun 2021 09:19:35 +0800 (CST) Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:19:35 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:19:13 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:42 +0800 Message-ID: <20210604011844.1756145-9-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 0F1214C36A00.A4EB9 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 08/10] md: Implement dax_holder_operations X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This is the case where the holder represents a mapped device, or a list of mapped devices more exactly(because it is possible to create more than one mapped device on one pmem device). Find out which mapped device the offset belongs to, and translate the offset from target device to mapped device. When it is done, call dax_corrupted_range() for the holder of this mapped device. Signed-off-by: Shiyang Ruan --- drivers/md/dm.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index ca2aedd8ee7d..606ad74ccf87 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -749,7 +749,11 @@ static void dm_put_live_table_fast(struct mapped_device *md) __releases(RCU) } static char *_dm_claim_ptr = "I belong to device-mapper"; - +static const struct dax_holder_operations dm_dax_holder_ops; +struct dm_holder { + struct list_head list; + struct mapped_device *md; +}; /* * Open a table device so we can use it as a map destination. */ @@ -757,6 +761,8 @@ static int open_table_device(struct table_device *td, dev_t dev, struct mapped_device *md) { struct block_device *bdev; + struct list_head *holders; + struct dm_holder *holder; int r; @@ -774,6 +780,17 @@ static int open_table_device(struct table_device *td, dev_t dev, td->dm_dev.bdev = bdev; td->dm_dev.dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); + + holders = dax_get_holder(td->dm_dev.dax_dev); + if (!holders) { + holders = kmalloc(sizeof(*holders), GFP_KERNEL); + INIT_LIST_HEAD(holders); + dax_set_holder(td->dm_dev.dax_dev, holders, &dm_dax_holder_ops); + } + holder = kmalloc(sizeof(*holder), GFP_KERNEL); + holder->md = md; + list_add_tail(&holder->list, holders); + return 0; } @@ -782,9 +799,24 @@ static int open_table_device(struct table_device *td, dev_t dev, */ static void close_table_device(struct table_device *td, struct mapped_device *md) { + struct list_head *holders; + struct dm_holder *holder, *n; + if (!td->dm_dev.bdev) return; + holders = dax_get_holder(td->dm_dev.dax_dev); + if (holders) { + list_for_each_entry_safe(holder, n, holders, list) { + if (holder->md == md) { + list_del(&holder->list); + kfree(holder); + } + } + if (list_empty(holders)) + kfree(holders); + } + bd_unlink_disk_holder(td->dm_dev.bdev, dm_disk(md)); blkdev_put(td->dm_dev.bdev, td->dm_dev.mode | FMODE_EXCL); put_dax(td->dm_dev.dax_dev); @@ -1235,6 +1267,87 @@ static int dm_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, return ret; } +struct corrupted_hit_info { + struct block_device *bdev; + sector_t offset; +}; + +static int dm_blk_corrupted_hit(struct dm_target *ti, struct dm_dev *dev, + sector_t start, sector_t count, void *data) +{ + struct corrupted_hit_info *bc = data; + + return bc->bdev == (void *)dev->bdev && + (start <= bc->offset && bc->offset < start + count); +} + +struct corrupted_do_info { + size_t length; + void *data; +}; + +static int dm_blk_corrupted_do(struct dm_target *ti, struct block_device *bdev, + sector_t sector, void *data) +{ + struct mapped_device *md = ti->table->md; + struct corrupted_do_info *bc = data; + struct block_device *md_bdev = bdget_disk_sector(md->disk, sector); + + return dax_corrupted_range(md->dax_dev, md_bdev, to_bytes(sector), + bc->length, bc->data); +} + +static int dm_dax_corrputed_range_one(struct mapped_device *md, + struct block_device *bdev, loff_t offset, + size_t length, void *data) +{ + struct dm_table *map; + struct dm_target *ti; + sector_t sect = to_sector(offset); + struct corrupted_hit_info hi = {bdev, sect}; + struct corrupted_do_info di = {length, data}; + int srcu_idx, i, rc = -ENODEV; + + map = dm_get_live_table(md, &srcu_idx); + if (!map) + return rc; + + /* + * find the target device, and then translate the offset of this target + * to the whole mapped device. + */ + for (i = 0; i < dm_table_get_num_targets(map); i++) { + ti = dm_table_get_target(map, i); + if (!(ti->type->iterate_devices && ti->type->rmap)) + continue; + if (!ti->type->iterate_devices(ti, dm_blk_corrupted_hit, &hi)) + continue; + + rc = ti->type->rmap(ti, sect, dm_blk_corrupted_do, &di); + break; + } + + dm_put_live_table(md, srcu_idx); + return rc; +} + +static int dm_dax_corrputed_range(struct dax_device *dax_dev, + struct block_device *bdev, + loff_t offset, size_t length, void *data) +{ + struct dm_holder *holder; + struct list_head *holders = dax_get_holder(dax_dev); + int rc = -ENODEV; + + list_for_each_entry(holder, holders, list) { + rc = dm_dax_corrputed_range_one(holder->md, bdev, offset, + length, data); + if (rc != -ENODEV) + break; + } + return rc; +} + /* * A target may call dm_accept_partial_bio only from the map routine. It is * allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_RESET, @@ -3157,6 +3270,10 @@ static const struct dax_operations dm_dax_ops = { .zero_page_range = dm_dax_zero_page_range, }; +static const struct dax_holder_operations dm_dax_holder_ops = { + .corrupted_range = dm_dax_corrputed_range, +}; + /* * module hooks */ From patchwork Fri Jun 4 01:18:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298757 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82A3BC47083 for ; Fri, 4 Jun 2021 06:25:36 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 259BE6140F for ; Fri, 4 Jun 2021 06:25:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 259BE6140F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-ny1JN5VuP8G2m8YE9JNIMw-1; Fri, 04 Jun 2021 02:25:33 -0400 X-MC-Unique: ny1JN5VuP8G2m8YE9JNIMw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2CD4188352C; Fri, 4 Jun 2021 06:25:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 810C25D705; Fri, 4 Jun 2021 06:25:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 50BE41801265; Fri, 4 Jun 2021 06:25:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541L1XV026879 for ; Thu, 3 Jun 2021 21:21:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BF8810CB263; Fri, 4 Jun 2021 01:21:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9780510CB266 for ; Fri, 4 Jun 2021 01:20:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6EF49805C1D for ; Fri, 4 Jun 2021 01:20:59 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-436-FpoLJsIoPh-rpyJi1HbCEw-1; Thu, 03 Jun 2021 21:20:55 -0400 X-MC-Unique: FpoLJsIoPh-rpyJi1HbCEw-1 IronPort-HdrOrdr: A9a23:9SJqT6lOmHo+bnnG0ZR7u1pBhNHpDfLI3DAbv31ZSRFFG/Fxl6iV8sjzsiWE7gr5OUtQ4OxoV5PhfZqxz/JICMwqTNKftWrdyQyVxeNZnOjfKlTbckWUnINgPOVbAsxD4bbLbGSS4/yU3ODBKadD/DCYytHUuc7ui2dqURpxa7xtqyNwCgOgGEVwQwVcbKBJb6a0145WoSa6Y3QLYoCeDnkBZeLKoNrGj9bIehgDbiRXkjWmvHe57qLgCRiE0lM7WzNL+70r9m/IiEjYy8yYwomG9iM= X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209841" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:19:49 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 7B97E4C36A01; Fri, 4 Jun 2021 09:19:46 +0800 (CST) Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:19:36 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:19:35 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:43 +0800 Message-ID: <20210604011844.1756145-10-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 7B97E4C36A01.A2B39 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 09/10] xfs: Implement ->corrupted_range() for XFS X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This function is used to handle errors which may cause data lost in filesystem. Such as memory failure in fsdax mode. If the rmap feature of XFS enabled, we can query it to find files and metadata which are associated with the corrupt data. For now all we do is kill processes with that file mapped into their address spaces, but future patches could actually do something about corrupt metadata. After that, the memory failure needs to notify the processes who are using those files. Only support data device. Realtime device is not supported for now. Signed-off-by: Shiyang Ruan --- fs/xfs/xfs_fsops.c | 5 +++ fs/xfs/xfs_mount.h | 1 + fs/xfs/xfs_super.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index be9cf88d2ad7..e89ada33d8fc 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -551,6 +551,11 @@ xfs_do_force_shutdown( "Corruption of in-memory data detected. Shutting down filesystem"); if (XFS_ERRLEVEL_HIGH <= xfs_error_level) xfs_stack_trace(); + } else if (flags & SHUTDOWN_CORRUPT_META) { + xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_CORRUPT, +"Corruption of on-disk metadata detected. Shutting down filesystem"); + if (XFS_ERRLEVEL_HIGH <= xfs_error_level) + xfs_stack_trace(); } else if (logerror) { xfs_alert_tag(mp, XFS_PTAG_SHUTDOWN_LOGERROR, "Log I/O Error Detected. Shutting down filesystem"); diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index bb67274ee23f..c62ccf3e07d0 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -276,6 +276,7 @@ void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname, #define SHUTDOWN_LOG_IO_ERROR 0x0002 /* write attempt to the log failed */ #define SHUTDOWN_FORCE_UMOUNT 0x0004 /* shutdown from a forced unmount */ #define SHUTDOWN_CORRUPT_INCORE 0x0008 /* corrupt in-memory data structures */ +#define SHUTDOWN_CORRUPT_META 0x0010 /* corrupt metadata on device */ /* * Flags for xfs_mountfs diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index a2dab05332ac..498edaeb8363 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -36,6 +36,11 @@ #include "xfs_bmap_item.h" #include "xfs_reflink.h" #include "xfs_pwork.h" +#include "xfs_alloc.h" +#include "xfs_rmap.h" +#include "xfs_rmap_btree.h" +#include "xfs_rtalloc.h" +#include "xfs_bit.h" #include #include @@ -392,6 +397,7 @@ xfs_open_devices( struct block_device *logdev = NULL, *rtdev = NULL; int error; + dax_set_holder(dax_ddev, mp->m_super, &fs_dax_holder_ops); /* * Open real time and log devices - order is important. */ @@ -400,6 +406,9 @@ xfs_open_devices( if (error) goto out; dax_logdev = fs_dax_get_by_bdev(logdev); + if (dax_logdev != dax_ddev) + dax_set_holder(dax_logdev, mp->m_super, + &fs_dax_holder_ops); } if (mp->m_rtname) { @@ -414,6 +423,7 @@ xfs_open_devices( goto out_close_rtdev; } dax_rtdev = fs_dax_get_by_bdev(rtdev); + dax_set_holder(dax_rtdev, mp->m_super, &fs_dax_holder_ops); } /* @@ -1076,6 +1086,103 @@ xfs_fs_free_cached_objects( return xfs_reclaim_inodes_nr(XFS_M(sb), sc->nr_to_scan); } +static int +xfs_corrupt_helper( + struct xfs_btree_cur *cur, + struct xfs_rmap_irec *rec, + void *data) +{ + struct xfs_inode *ip; + struct address_space *mapping; + int rc = 0; + int *flags = data; + + if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) || + (rec->rm_flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK))) { + // TODO check and try to fix metadata + xfs_force_shutdown(cur->bc_mp, SHUTDOWN_CORRUPT_META); + return -EFSCORRUPTED; + } + + /* + * Get files that incore, filter out others that are not in use. + */ + rc = xfs_iget(cur->bc_mp, cur->bc_tp, rec->rm_owner, XFS_IGET_INCORE, + 0, &ip); + if (rc) + return rc; + + mapping = VFS_I(ip)->i_mapping; + rc = mf_dax_kill_procs(mapping, rec->rm_offset, *flags); + + // TODO try to fix data + xfs_irele(ip); + + return rc; +} + +static int +xfs_fs_corrupted_range( + struct super_block *sb, + struct block_device *bdev, + loff_t offset, + size_t len, + void *data) +{ + struct xfs_mount *mp = XFS_M(sb); + struct xfs_trans *tp = NULL; + struct xfs_btree_cur *cur = NULL; + struct xfs_rmap_irec rmap_low, rmap_high; + struct xfs_buf *agf_bp = NULL; + xfs_fsblock_t fsbno = XFS_B_TO_FSB(mp, offset); + xfs_filblks_t bcnt = XFS_B_TO_FSB(mp, len); + xfs_agnumber_t agno = XFS_FSB_TO_AGNO(mp, fsbno); + xfs_agblock_t agbno = XFS_FSB_TO_AGBNO(mp, fsbno); + int error = 0; + + if (mp->m_rtdev_targp && mp->m_rtdev_targp->bt_bdev == bdev) { + xfs_warn(mp, "corrupted_range support not available for realtime device!"); + return -EOPNOTSUPP; + } + if (mp->m_logdev_targp && mp->m_logdev_targp->bt_bdev == bdev && + mp->m_logdev_targp != mp->m_ddev_targp) { + xfs_err(mp, "ondisk log corrupt, shutting down fs!"); + xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_META); + return -EFSCORRUPTED; + } + + if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) { + xfs_warn(mp, "corrupted_range needs rmapbt enabled!"); + return -EOPNOTSUPP; + } + + error = xfs_trans_alloc_empty(mp, &tp); + if (error) + return error; + + error = xfs_alloc_read_agf(mp, tp, agno, 0, &agf_bp); + if (error) + goto out_cancel_tp; + + cur = xfs_rmapbt_init_cursor(mp, tp, agf_bp, agno); + + /* Construct a range for rmap query */ + memset(&rmap_low, 0, sizeof(rmap_low)); + memset(&rmap_high, 0xFF, sizeof(rmap_high)); + rmap_low.rm_startblock = rmap_high.rm_startblock = agbno; + rmap_low.rm_blockcount = rmap_high.rm_blockcount = bcnt; + + error = xfs_rmap_query_range(cur, &rmap_low, &rmap_high, + xfs_corrupt_helper, data); + + xfs_btree_del_cursor(cur, error); + xfs_trans_brelse(tp, agf_bp); + +out_cancel_tp: + xfs_trans_cancel(tp); + return error; +} + static const struct super_operations xfs_super_operations = { .alloc_inode = xfs_fs_alloc_inode, .destroy_inode = xfs_fs_destroy_inode, @@ -1089,6 +1196,7 @@ static const struct super_operations xfs_super_operations = { .show_options = xfs_fs_show_options, .nr_cached_objects = xfs_fs_nr_cached_objects, .free_cached_objects = xfs_fs_free_cached_objects, + .corrupted_range = xfs_fs_corrupted_range, }; static int From patchwork Fri Jun 4 01:18:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiyang Ruan X-Patchwork-Id: 12298753 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96F40C47083 for ; Fri, 4 Jun 2021 06:25:33 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12C136140B for ; Fri, 4 Jun 2021 06:25:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12C136140B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fujitsu.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-oNE0XA9EOS6YUz6upoipfA-1; Fri, 04 Jun 2021 02:25:30 -0400 X-MC-Unique: oNE0XA9EOS6YUz6upoipfA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2ABBE107ACE6; Fri, 4 Jun 2021 06:25:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 074A210074FC; Fri, 4 Jun 2021 06:25:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CCA2B85C6; Fri, 4 Jun 2021 06:25:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1541K4kf026759 for ; Thu, 3 Jun 2021 21:20:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 185B420951A4; Fri, 4 Jun 2021 01:20:04 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 141D220951A2 for ; Fri, 4 Jun 2021 01:20:01 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 61251800C00 for ; Fri, 4 Jun 2021 01:20:01 +0000 (UTC) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by relay.mimecast.com with ESMTP id us-mta-584-c0A6rBOjM4WQgFdQZdXntQ-2; Thu, 03 Jun 2021 21:19:56 -0400 X-MC-Unique: c0A6rBOjM4WQgFdQZdXntQ-2 IronPort-HdrOrdr: A9a23:cCF6eK06cXta36UsjGq5FgqjBI4kLtp133Aq2lEZdPU1SL39qynKppkmPHDP5gr5J0tLpTntAsi9qBDnhPtICOsqTNSftWDd0QPGEGgI1/qB/9SPIU3D398Y/aJhXow7M9foEGV95PyQ3CCIV/om3/mLmZrFudvj X-IronPort-AV: E=Sophos;i="5.83,246,1616428800"; d="scan'208";a="109209850" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 04 Jun 2021 09:19:55 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 8C6124C36A03; Fri, 4 Jun 2021 09:19:53 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:19:49 +0800 Received: from G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.80) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 4 Jun 2021 09:19:47 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD07.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Jun 2021 09:19:47 +0800 From: Shiyang Ruan To: , , , , , Date: Fri, 4 Jun 2021 09:18:44 +0800 Message-ID: <20210604011844.1756145-11-ruansy.fnst@fujitsu.com> In-Reply-To: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> References: <20210604011844.1756145-1-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 8C6124C36A03.A0BA1 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@fujitsu.com X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 04 Jun 2021 02:21:36 -0400 Cc: snitzer@redhat.com, darrick.wong@oracle.com, rgoldwyn@suse.de, david@fromorbit.com, dan.j.williams@intel.com, hch@lst.de, agk@redhat.com Subject: [dm-devel] [PATCH v4 10/10] fs/dax: Remove useless functions X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Since owner tracking is triggerred by pmem device, these functions are useless. So remove them. Signed-off-by: Shiyang Ruan --- fs/dax.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 1a7473f46df2..aff1e0f58967 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -334,48 +334,6 @@ static unsigned long dax_end_pfn(void *entry) for (pfn = dax_to_pfn(entry); \ pfn < dax_end_pfn(entry); pfn++) -/* - * TODO: for reflink+dax we need a way to associate a single page with - * multiple address_space instances at different linear_page_index() - * offsets. - */ -static void dax_associate_entry(void *entry, struct address_space *mapping, - struct vm_area_struct *vma, unsigned long address) -{ - unsigned long size = dax_entry_size(entry), pfn, index; - int i = 0; - - if (IS_ENABLED(CONFIG_FS_DAX_LIMITED)) - return; - - index = linear_page_index(vma, address & ~(size - 1)); - for_each_mapped_pfn(entry, pfn) { - struct page *page = pfn_to_page(pfn); - - WARN_ON_ONCE(page->mapping); - page->mapping = mapping; - page->index = index + i++; - } -} - -static void dax_disassociate_entry(void *entry, struct address_space *mapping, - bool trunc) -{ - unsigned long pfn; - - if (IS_ENABLED(CONFIG_FS_DAX_LIMITED)) - return; - - for_each_mapped_pfn(entry, pfn) { - struct page *page = pfn_to_page(pfn); - - WARN_ON_ONCE(trunc && page_ref_count(page) > 1); - WARN_ON_ONCE(page->mapping && page->mapping != mapping); - page->mapping = NULL; - page->index = 0; - } -} - static struct page *dax_busy_page(void *entry) { unsigned long pfn; @@ -554,7 +512,6 @@ static void *grab_mapping_entry(struct xa_state *xas, xas_lock_irq(xas); } - dax_disassociate_entry(entry, mapping, false); xas_store(xas, NULL); /* undo the PMD join */ dax_wake_entry(xas, entry, WAKE_ALL); mapping->nrpages -= PG_PMD_NR; @@ -691,7 +648,6 @@ static int __dax_invalidate_entry(struct address_space *mapping, (xas_get_mark(&xas, PAGECACHE_TAG_DIRTY) || xas_get_mark(&xas, PAGECACHE_TAG_TOWRITE))) goto out; - dax_disassociate_entry(entry, mapping, trunc); xas_store(&xas, NULL); mapping->nrpages -= 1UL << dax_entry_order(entry); ret = 1; @@ -785,8 +741,6 @@ static void *dax_insert_entry(struct xa_state *xas, if (dax_is_zero_entry(entry) || dax_is_empty_entry(entry)) { void *old; - dax_disassociate_entry(entry, mapping, false); - dax_associate_entry(new_entry, mapping, vmf->vma, vmf->address); /* * Only swap our new entry into the page cache if the current * entry is a zero page or an empty entry. If a normal PTE or