From patchwork Fri Jan 20 03:50:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9527309 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 61FC660434 for ; Fri, 20 Jan 2017 03:56:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54A5C2864D for ; Fri, 20 Jan 2017 03:56:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47BB628653; Fri, 20 Jan 2017 03:56:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D4462864D for ; Fri, 20 Jan 2017 03:56:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0K3t5dL003279; Thu, 19 Jan 2017 22:55:05 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v0K3sema002009 for ; Thu, 19 Jan 2017 22:54:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8D5561CDAF8; Fri, 20 Jan 2017 03:54:40 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CAAA1CD1BA; Fri, 20 Jan 2017 03:54:40 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A7F080F6B; Fri, 20 Jan 2017 03:54:31 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jan 2017 19:54:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,257,1477983600"; d="scan'208";a="215537540" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.14]) by fmsmga004.fm.intel.com with ESMTP; 19 Jan 2017 19:54:29 -0800 From: Dan Williams To: linux-nvdimm@ml01.01.org Date: Thu, 19 Jan 2017 19:50:24 -0800 Message-ID: <148488422405.37913.13366670089124790849.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <148488421301.37913.12835362165895864897.stgit@dwillia2-desk3.amr.corp.intel.com> References: <148488421301.37913.12835362165895864897.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 200 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 20 Jan 2017 03:54:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 20 Jan 2017 03:54:31 +0000 (UTC) for IP:'192.55.52.115' DOMAIN:'mga14.intel.com' HELO:'mga14.intel.com' FROM:'dan.j.williams@intel.com' RCPT:'' X-RedHat-Spam-Score: -7.82 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RP_MATCHES_RCVD, SPF_PASS) 192.55.52.115 mga14.intel.com 192.55.52.115 mga14.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: dm-devel@redhat.com Cc: Jan Kara , Mike Snitzer , Toshi Kani , Matthew Wilcox , linux-kernel@vger.kernel.org, Jeff Moyer , Jens Axboe , dm-devel@redhat.com, linux-fsdevel@vger.kernel.org, Ross Zwisler , Christoph Hellwig Subject: [dm-devel] [PATCH 02/13] block, dax: introduce dax_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-Virus-Scanned: ClamAV using ClamSMTP Prepare for the removal of memcpy_to_pmem() and copy_from_iter_pmem() by introducing dax_ops. This allows for driver specific overrides for the routines that transfer data to a dax capable block device. Cc: Cc: Jan Kara Cc: Jens Axboe Cc: Jeff Moyer Cc: Christoph Hellwig Cc: Toshi Kani Cc: Mike Snitzer Cc: Matthew Wilcox Cc: Ross Zwisler Signed-off-by: Dan Williams --- arch/powerpc/sysdev/axonram.c | 6 +++++- drivers/block/brd.c | 6 +++++- drivers/md/dm.c | 6 +++++- drivers/nvdimm/pmem.c | 6 +++++- drivers/s390/block/dcssblk.c | 6 +++++- fs/block_dev.c | 6 ++++-- include/linux/blkdev.h | 8 ++++++-- 7 files changed, 35 insertions(+), 9 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c index ada29eaed6e2..d4f318e7e6f3 100644 --- a/arch/powerpc/sysdev/axonram.c +++ b/arch/powerpc/sysdev/axonram.c @@ -153,9 +153,13 @@ axon_ram_direct_access(struct block_device *device, sector_t sector, return bank->size - offset; } +static const struct dax_operations axon_ram_dax_ops = { + .direct_access = axon_ram_direct_access, +}; + static const struct block_device_operations axon_ram_devops = { .owner = THIS_MODULE, - .direct_access = axon_ram_direct_access + .dax_ops = &axon_ram_dax_ops, }; /** diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 3adc32a3153b..9d06e5da2ab2 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -395,10 +395,14 @@ static long brd_direct_access(struct block_device *bdev, sector_t sector, #define brd_direct_access NULL #endif +static const struct dax_operations brd_dax_ops = { + .direct_access = brd_direct_access, +}; + static const struct block_device_operations brd_fops = { .owner = THIS_MODULE, .rw_page = brd_rw_page, - .direct_access = brd_direct_access, + .dax_ops = &brd_dax_ops, }; /* diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 3086da5664f3..87920a379d20 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2725,13 +2725,17 @@ static const struct pr_ops dm_pr_ops = { .pr_clear = dm_pr_clear, }; +static const struct dax_operations dm_dax_ops = { + .direct_access = dm_blk_direct_access, +}; + static const struct block_device_operations dm_blk_dops = { .open = dm_blk_open, .release = dm_blk_close, .ioctl = dm_blk_ioctl, - .direct_access = dm_blk_direct_access, .getgeo = dm_blk_getgeo, .pr_ops = &dm_pr_ops, + .dax_ops = &dm_dax_ops, .owner = THIS_MODULE }; diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 0d7779384a9f..6e5442174245 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -217,11 +217,15 @@ __weak long pmem_direct_access(struct block_device *bdev, sector_t sector, return pmem->size - pmem->pfn_pad - offset; } +static const struct dax_operations pmem_dax_ops = { + .direct_access = pmem_direct_access, +}; + static const struct block_device_operations pmem_fops = { .owner = THIS_MODULE, .rw_page = pmem_rw_page, - .direct_access = pmem_direct_access, .revalidate_disk = nvdimm_revalidate_disk, + .dax_ops = &pmem_dax_ops, }; static void pmem_release_queue(void *q) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 9d66b4fb174b..6acebe4a47f3 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -36,11 +36,15 @@ static long dcssblk_direct_access(struct block_device *bdev, sector_t secnum, static char dcssblk_segments[DCSSBLK_PARM_LEN] = "\0"; static int dcssblk_major; + +static const struct dax_operations dcssblk_dax_ops = { + .direct_access = dcssblk_direct_access, +}; + static const struct block_device_operations dcssblk_devops = { .owner = THIS_MODULE, .open = dcssblk_open, .release = dcssblk_release, - .direct_access = dcssblk_direct_access, }; struct dcssblk_dev_info { diff --git a/fs/block_dev.c b/fs/block_dev.c index 5db5d1340d69..1acfc7d25768 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -736,6 +736,7 @@ long bdev_direct_access(struct block_device *bdev, struct blk_dax_ctl *dax) sector_t sector = dax->sector; long avail, size = dax->size; const struct block_device_operations *ops = bdev->bd_disk->fops; + const struct dax_operations *dax_ops = ops->dax_ops; /* * The device driver is allowed to sleep, in order to make the @@ -745,7 +746,8 @@ long bdev_direct_access(struct block_device *bdev, struct blk_dax_ctl *dax) if (size < 0) return size; - if (!blk_queue_dax(bdev_get_queue(bdev)) || !ops->direct_access) + if (!blk_queue_dax(bdev_get_queue(bdev)) || !dax_ops + || !dax_ops->direct_access) return -EOPNOTSUPP; if ((sector + DIV_ROUND_UP(size, 512)) > part_nr_sects_read(bdev->bd_part)) @@ -753,7 +755,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, size); + avail = dax_ops->direct_access(bdev, sector, &dax->addr, &dax->pfn, size); if (!avail) return -ERANGE; if (avail > 0 && avail & ~PAGE_MASK) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 83695641bd5e..8afce34823f5 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1863,14 +1863,17 @@ struct blk_dax_ctl { pfn_t pfn; }; +struct dax_operations { + long (*direct_access)(struct block_device *, sector_t, void **, pfn_t *, + long); +}; + struct block_device_operations { int (*open) (struct block_device *, fmode_t); void (*release) (struct gendisk *, fmode_t); int (*rw_page)(struct block_device *, sector_t, struct page *, bool); 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 **, pfn_t *, - long); unsigned int (*check_events) (struct gendisk *disk, unsigned int clearing); /* ->media_changed() is DEPRECATED, use ->check_events() instead */ @@ -1882,6 +1885,7 @@ struct block_device_operations { void (*swap_slot_free_notify) (struct block_device *, unsigned long); struct module *owner; const struct pr_ops *pr_ops; + const struct dax_operations *dax_ops; }; extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,