From patchwork Wed Mar 30 01:59:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 8692291 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 30217C0554 for ; Wed, 30 Mar 2016 02:00:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6022320155 for ; Wed, 30 Mar 2016 02:00:25 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2479120351 for ; Wed, 30 Mar 2016 02:00:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4A8711A1F89; Tue, 29 Mar 2016 19:00:53 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ml01.01.org (Postfix) with ESMTP id 7D00A1A1F87 for ; Tue, 29 Mar 2016 19:00:52 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP; 29 Mar 2016 19:00:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,414,1455004800"; d="scan'208";a="75601556" Received: from omniknight.lm.intel.com ([10.232.112.171]) by fmsmga004.fm.intel.com with ESMTP; 29 Mar 2016 19:00:18 -0700 From: Vishal Verma To: linux-nvdimm@lists.01.org Subject: [PATCH v2 3/5] dax: enable dax in the presence of known media errors (badblocks) Date: Tue, 29 Mar 2016 19:59:48 -0600 Message-Id: <1459303190-20072-4-git-send-email-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459303190-20072-1-git-send-email-vishal.l.verma@intel.com> References: <1459303190-20072-1-git-send-email-vishal.l.verma@intel.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jens Axboe , Jan Kara , Andrew Morton , Christoph Hellwig , Dave Chinner , linux-kernel@vger.kernel.org, xfs@oss.sgi.com, linux-block@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Al Viro MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dan Williams 1/ If a mapping overlaps a bad sector fail the request. 2/ Do not opportunistically report more dax-capable capacity than is requested when errors present. [vishal: fix a conflict with system RAM collision patches] Signed-off-by: Dan Williams Reviewed-by: Jeff Moyer --- block/ioctl.c | 9 --------- drivers/nvdimm/pmem.c | 8 ++++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/block/ioctl.c b/block/ioctl.c index d8996bb..cd7f392 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -423,15 +423,6 @@ bool blkdev_dax_capable(struct block_device *bdev) || (bdev->bd_part->nr_sects % (PAGE_SIZE / 512))) return false; - /* - * If the device has known bad blocks, force all I/O through the - * driver / page cache. - * - * TODO: support finer grained dax error handling - */ - if (disk->bb && disk->bb->count) - return false; - return true; } #endif diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index da10554..eac5f93 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -174,9 +174,17 @@ static long pmem_direct_access(struct block_device *bdev, struct pmem_device *pmem = bdev->bd_disk->private_data; resource_size_t offset = sector * 512 + pmem->data_offset; + if (unlikely(is_bad_pmem(&pmem->bb, sector, dax->size))) + return -EIO; dax->addr = pmem->virt_addr + offset; dax->pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + /* + * If badblocks are present, limit known good range to the + * requested range. + */ + if (unlikely(pmem->bb.count)) + return dax->size; return pmem->size - pmem->pfn_pad - offset; }