From patchwork Sat Apr 23 19:13:36 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: 8918591 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 4890ABF29F for ; Sat, 23 Apr 2016 19:14:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3741020166 for ; Sat, 23 Apr 2016 19:14:01 +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 AC51B201EF for ; Sat, 23 Apr 2016 19:13:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9926D1A207E; Sat, 23 Apr 2016 12:13:59 -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 F31071A207E for ; Sat, 23 Apr 2016 12:13:58 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 23 Apr 2016 12:13:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,523,1455004800"; d="scan'208";a="965085678" Received: from omniknight.lm.intel.com ([10.232.112.171]) by fmsmga002.fm.intel.com with ESMTP; 23 Apr 2016 12:13:58 -0700 From: Vishal Verma To: linux-nvdimm@lists.01.org Subject: [PATCH v3 1/7] block, dax: pass blk_dax_ctl through to drivers Date: Sat, 23 Apr 2016 13:13:36 -0600 Message-Id: <1461438822-3592-2-git-send-email-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1461438822-3592-1-git-send-email-vishal.l.verma@intel.com> References: <1461438822-3592-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, "Kirill A. Shutemov" , 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 This is in preparation for doing badblocks checking against the requested sector range in the driver. Currently we opportunistically return as much data that can be "dax'd" starting at the given sector. When errors are present we want to limit that range to the first encountered error, or fail the dax request if the range encompasses an error. Signed-off-by: Dan Williams --- arch/powerpc/sysdev/axonram.c | 10 +++++----- drivers/block/brd.c | 9 +++++---- drivers/nvdimm/pmem.c | 9 +++++---- drivers/s390/block/dcssblk.c | 12 ++++++------ fs/block_dev.c | 2 +- include/linux/blkdev.h | 3 +-- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c index 0d112b9..d85673f 100644 --- a/arch/powerpc/sysdev/axonram.c +++ b/arch/powerpc/sysdev/axonram.c @@ -139,17 +139,17 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio) /** * axon_ram_direct_access - direct_access() method for block device - * @device, @sector, @data: see block_device_operations method + * @dax: see block_device_operations method */ static long -axon_ram_direct_access(struct block_device *device, sector_t sector, - void __pmem **kaddr, pfn_t *pfn) +axon_ram_direct_access(struct block_device *device, struct blk_dax_ctl *dax) { + sector_t sector = get_start_sect(device) + dax->sector; struct axon_ram_bank *bank = device->bd_disk->private_data; loff_t offset = (loff_t)sector << AXON_RAM_SECTOR_SHIFT; - *kaddr = (void __pmem __force *) bank->io_addr + offset; - *pfn = phys_to_pfn_t(bank->ph_addr + offset, PFN_DEV); + dax->addr = (void __pmem __force *) bank->io_addr + offset; + dax->pfn = phys_to_pfn_t(bank->ph_addr + offset, PFN_DEV); return bank->size - offset; } diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 51a071e..71521c1 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -380,9 +380,10 @@ static int brd_rw_page(struct block_device *bdev, sector_t sector, } #ifdef CONFIG_BLK_DEV_RAM_DAX -static long brd_direct_access(struct block_device *bdev, sector_t sector, - void __pmem **kaddr, pfn_t *pfn) +static long brd_direct_access(struct block_device *bdev, + struct blk_dax_ctl *dax) { + sector_t sector = get_start_sect(bdev) + dax->sector; struct brd_device *brd = bdev->bd_disk->private_data; struct page *page; @@ -391,8 +392,8 @@ static long brd_direct_access(struct block_device *bdev, sector_t sector, page = brd_insert_page(brd, sector); if (!page) return -ENOSPC; - *kaddr = (void __pmem *)page_address(page); - *pfn = page_to_pfn_t(page); + dax->addr = (void __pmem *)page_address(page); + dax->pfn = page_to_pfn_t(page); return PAGE_SIZE; } diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index f798899..f72733c 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -181,14 +181,15 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, return rc; } -static long pmem_direct_access(struct block_device *bdev, sector_t sector, - void __pmem **kaddr, pfn_t *pfn) +static long pmem_direct_access(struct block_device *bdev, + struct blk_dax_ctl *dax) { + sector_t sector = get_start_sect(bdev) + dax->sector; struct pmem_device *pmem = bdev->bd_disk->private_data; resource_size_t offset = sector * 512 + pmem->data_offset; - *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + dax->addr = pmem->virt_addr + offset; + dax->pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); return pmem->size - pmem->pfn_pad - offset; } diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index b839086..613f587 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -30,8 +30,8 @@ static int dcssblk_open(struct block_device *bdev, fmode_t mode); static void dcssblk_release(struct gendisk *disk, fmode_t mode); static blk_qc_t dcssblk_make_request(struct request_queue *q, struct bio *bio); -static long dcssblk_direct_access(struct block_device *bdev, sector_t secnum, - void __pmem **kaddr, pfn_t *pfn); +static long dcssblk_direct_access(struct block_device *bdev, + struct blk_dax_ctl *dax) static char dcssblk_segments[DCSSBLK_PARM_LEN] = "\0"; @@ -883,9 +883,9 @@ fail: } static long -dcssblk_direct_access (struct block_device *bdev, sector_t secnum, - void __pmem **kaddr, pfn_t *pfn) +dcssblk_direct_access(struct block_device *bdev, struct blk_dax_ctl *dax) { + sector_t secnum = get_start_sect(bdev) + dax->sector; struct dcssblk_dev_info *dev_info; unsigned long offset, dev_sz; @@ -894,8 +894,8 @@ dcssblk_direct_access (struct block_device *bdev, sector_t secnum, return -ENODEV; dev_sz = dev_info->end - dev_info->start; offset = secnum * 512; - *kaddr = (void __pmem *) (dev_info->start + offset); - *pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), PFN_DEV); + dax->addr = (void __pmem *) (dev_info->start + offset); + dax->pfn = __pfn_to_pfn_t(PFN_DOWN(dev_info->start + offset), PFN_DEV); return dev_sz - offset; } diff --git a/fs/block_dev.c b/fs/block_dev.c index b25bb23..79defba 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -488,7 +488,7 @@ long bdev_direct_access(struct block_device *bdev, struct blk_dax_ctl *dax) sector += get_start_sect(bdev); if (sector % (PAGE_SIZE / 512)) return -EINVAL; - avail = ops->direct_access(bdev, sector, &dax->addr, &dax->pfn); + avail = ops->direct_access(bdev, dax); if (!avail) return -ERANGE; if (avail > 0 && avail & ~PAGE_MASK) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 669e419..9d8c6d5 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1656,8 +1656,7 @@ struct block_device_operations { int (*rw_page)(struct block_device *, sector_t, struct page *, int rw); int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); - long (*direct_access)(struct block_device *, sector_t, void __pmem **, - pfn_t *); + long (*direct_access)(struct block_device *, struct blk_dax_ctl *dax); unsigned int (*check_events) (struct gendisk *disk, unsigned int clearing); /* ->media_changed() is DEPRECATED, use ->check_events() instead */