From mboxrd@z Thu Jan 1 00:00:00 1970 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=-16.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,USER_AGENT_GIT 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 B9D56C433DB for ; Mon, 8 Feb 2021 10:55:51 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (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 440B064E7C for ; Mon, 8 Feb 2021 10:55:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 440B064E7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C5622100EB337; Mon, 8 Feb 2021 02:55:50 -0800 (PST) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=183.91.158.132; helo=heian.cn.fujitsu.com; envelope-from=ruansy.fnst@cn.fujitsu.com; receiver= Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by ml01.01.org (Postfix) with ESMTP id 48F61100EB333 for ; Mon, 8 Feb 2021 02:55:48 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.81,161,1610380800"; d="scan'208";a="104328073" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Feb 2021 18:55:47 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 2C8424CE6F81; Mon, 8 Feb 2021 18:55:41 +0800 (CST) Received: from G08CNEXCHPEKD04.g08.fujitsu.local (10.167.33.200) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 8 Feb 2021 18:55:43 +0800 Received: from irides.mr.mr.mr (10.167.225.141) by G08CNEXCHPEKD04.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 8 Feb 2021 18:55:42 +0800 From: Shiyang Ruan To: , , , , , Subject: [PATCH v3 07/11] pmem: Implement ->corrupted_range() for pmem driver Date: Mon, 8 Feb 2021 18:55:26 +0800 Message-ID: <20210208105530.3072869-8-ruansy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208105530.3072869-1-ruansy.fnst@cn.fujitsu.com> References: <20210208105530.3072869-1-ruansy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 2C8424CE6F81.ABF51 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.fujitsu.com Message-ID-Hash: FFK33C6RM3P6MK7SA2K7LO24PE4BZ6NZ X-Message-ID-Hash: FFK33C6RM3P6MK7SA2K7LO24PE4BZ6NZ X-MailFrom: ruansy.fnst@cn.fujitsu.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: darrick.wong@oracle.com, david@fromorbit.com, hch@lst.de, agk@redhat.com, snitzer@redhat.com, rgoldwyn@suse.de, qi.fuli@fujitsu.com, y-goto@fujitsu.com X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Obtain the superblock of a pmem disk, and call filesystem's ->corrupted_range() to handle the corrupted data. Signed-off-by: Shiyang Ruan --- block/genhd.c | 6 ++++++ drivers/nvdimm/pmem.c | 19 +++++++++++++++++++ include/linux/genhd.h | 1 + 3 files changed, 26 insertions(+) diff --git a/block/genhd.c b/block/genhd.c index 419548e92d82..fd7cf03b65a8 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -936,6 +936,12 @@ struct block_device *bdget_disk(struct gendisk *disk, int partno) return bdev; } +struct block_device *bdget_disk_sector(struct gendisk *disk, sector_t sector) +{ + return disk_map_sector_rcu(disk, sector); +} +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 c77c80e3d155..e38b9f9c7d97 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -253,6 +253,24 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, return blk_status_to_errno(rc); } +static int pmem_corrupted_range(struct gendisk *disk, struct block_device *bdev, + loff_t disk_offset, size_t len, void *data) +{ + loff_t bdev_offset; + sector_t disk_sector = disk_offset >> SECTOR_SHIFT; + int rc = -ENODEV; + + bdev = bdget_disk_sector(disk, disk_sector); + if (!bdev) + return rc; + + bdev_offset = (disk_sector - get_start_sect(bdev)) << SECTOR_SHIFT; + rc = bd_corrupted_range(bdev, bdev_offset, bdev_offset, len, data); + + bdput(bdev); + return rc; +} + /* see "strong" declaration in tools/testing/nvdimm/pmem-dax.c */ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn) @@ -281,6 +299,7 @@ static const struct block_device_operations pmem_fops = { .owner = THIS_MODULE, .submit_bio = pmem_submit_bio, .rw_page = pmem_rw_page, + .corrupted_range = pmem_corrupted_range, }; static int pmem_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 751cbd559bba..996f91b08d48 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -248,6 +248,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); extern void set_disk_ro(struct gendisk *disk, int flag); -- 2.30.0 _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org