From patchwork Wed Feb 12 17:07:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 11378823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 398211922 for ; Wed, 12 Feb 2020 17:08:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C878C2168B for ; Wed, 12 Feb 2020 17:08:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BIeKNJE9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728731AbgBLRIA (ORCPT ); Wed, 12 Feb 2020 12:08:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22847 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728410AbgBLRH6 (ORCPT ); Wed, 12 Feb 2020 12:07:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581527277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0QSDN4zqZX6JQThUAoXPpSXd0mGJ9FYDGlAgc1x+IyE=; b=BIeKNJE9IH21MlTFoU8IdIDKPcwHbeI0WbdzAR6xD2Vf7bcsWaUkM4t/nTX+M8ykSagalO wwF79z5PFVHeLR8CuBnZDAGyvPJtouL6cAZNNa+4ARyMhgfBeTbgJTQPN7XZBw+dIyJeRP uKOWXOf5rv0wNGekUchZ65qbLnyTXuI= 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-273-k3JbxwhlOA2CwoxrbWTETw-1; Wed, 12 Feb 2020 12:07:51 -0500 X-MC-Unique: k3JbxwhlOA2CwoxrbWTETw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B7008017CC; Wed, 12 Feb 2020 17:07:50 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20668388; Wed, 12 Feb 2020 17:07:47 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id AEE932257D3; Wed, 12 Feb 2020 12:07:46 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, dan.j.williams@intel.com, hch@infradead.org Cc: vgoyal@redhat.com, dm-devel@redhat.com, jack@suse.cz Subject: [PATCH 1/6] dax: Define a helper dax_pgoff() which takes in dax_offset as argument Date: Wed, 12 Feb 2020 12:07:28 -0500 Message-Id: <20200212170733.8092-2-vgoyal@redhat.com> In-Reply-To: <20200212170733.8092-1-vgoyal@redhat.com> References: <20200212170733.8092-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Create a new helper dax_pgoff() which will replace bdev_dax_pgoff(). Difference between two is that dax_pgoff() takes in "sector_t dax_offset" as an argument instead of "struct block_device". dax_offset specifies any offset into dax device which should be added to sector while calculating pgoff. Signed-off-by: Vivek Goyal --- drivers/dax/super.c | 12 ++++++++++++ include/linux/dax.h | 1 + 2 files changed, 13 insertions(+) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 0aa4b6bc5101..e9daa30e4250 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -56,6 +56,18 @@ int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size, } EXPORT_SYMBOL(bdev_dax_pgoff); +int dax_pgoff(sector_t dax_offset, sector_t sector, size_t size, pgoff_t *pgoff) +{ + phys_addr_t phys_off = (dax_offset + sector) * 512; + + if (pgoff) + *pgoff = PHYS_PFN(phys_off); + if (phys_off % PAGE_SIZE || size % PAGE_SIZE) + return -EINVAL; + return 0; +} +EXPORT_SYMBOL(dax_pgoff); + #if IS_ENABLED(CONFIG_FS_DAX) struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev) { diff --git a/include/linux/dax.h b/include/linux/dax.h index 328c2dbb4409..5101a4b5c1f9 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -111,6 +111,7 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma, struct writeback_control; int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); +int dax_pgoff(sector_t dax_offset, sector_t, size_t, pgoff_t *pgoff); #if IS_ENABLED(CONFIG_FS_DAX) bool __bdev_dax_supported(struct block_device *bdev, int blocksize); static inline bool bdev_dax_supported(struct block_device *bdev, int blocksize) From patchwork Wed Feb 12 17:07:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 11378813 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40B8113A4 for ; Wed, 12 Feb 2020 17:07:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1CE4B2173E for ; Wed, 12 Feb 2020 17:07:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jNAPH0t2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728900AbgBLRH6 (ORCPT ); Wed, 12 Feb 2020 12:07:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28359 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728814AbgBLRH4 (ORCPT ); Wed, 12 Feb 2020 12:07:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581527274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wp1678TYHxcRdW/SymzuQImvfcwDJWWzwf8rp6Sn0Cc=; b=jNAPH0t2hM12FJXvx0RLyrVUjnUQp5CVeM4VQiMoM1F6BeflDYI58WIbyWGHBMBdid8qx0 VsWqSbCyAZiGDOgti/lH0Q8kazUlW1MgdaeZdiDSwNb99VgncWlgZ8nIn+2vOBzTcet3S+ IXoirbsii9t8E1CQvRjH35QmmRT9O9I= 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-234-Lvxy7clxM6SiJcwNjeQDmA-1; Wed, 12 Feb 2020 12:07:50 -0500 X-MC-Unique: Lvxy7clxM6SiJcwNjeQDmA-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 A23661800D6B; Wed, 12 Feb 2020 17:07:49 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 281445C101; Wed, 12 Feb 2020 17:07:47 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id B29462257D4; Wed, 12 Feb 2020 12:07:46 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, dan.j.williams@intel.com, hch@infradead.org Cc: vgoyal@redhat.com, dm-devel@redhat.com, jack@suse.cz Subject: [PATCH 2/6] dax,iomap,ext4,ext2,xfs: Save dax_offset in "struct iomap" Date: Wed, 12 Feb 2020 12:07:29 -0500 Message-Id: <20200212170733.8092-3-vgoyal@redhat.com> In-Reply-To: <20200212170733.8092-1-vgoyal@redhat.com> References: <20200212170733.8092-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add a new field "sector_t dax_offset" to "struct iomap". This will be filled by filesystems and dax code will make use of this to convert sector into page offset (dax_pgoff()), instead of bdev_dax_pgoff(). This removes the dependency of having to pass in block device for dax operations. Signed-off-by: Vivek Goyal --- fs/ext2/inode.c | 1 + fs/ext4/inode.c | 1 + fs/xfs/xfs_iomap.c | 2 ++ include/linux/iomap.h | 1 + 4 files changed, 5 insertions(+) diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index c885cf7d724b..5c3379e78d49 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -823,6 +823,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->bdev = inode->i_sb->s_bdev; iomap->offset = (u64)first_block << blkbits; iomap->dax_dev = sbi->s_daxdev; + iomap->dax_offset = get_start_sect(iomap->bdev); if (ret == 0) { iomap->type = IOMAP_HOLE; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 1305b810c44a..0ea7fbb8076f 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3330,6 +3330,7 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap, iomap->bdev = inode->i_sb->s_bdev; iomap->dax_dev = EXT4_SB(inode->i_sb)->s_daxdev; + iomap->dax_offset = get_start_sect(iomap->bdev); iomap->offset = (u64) map->m_lblk << blkbits; iomap->length = (u64) map->m_len << blkbits; diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index bb590a267a7f..ad8b18fc96fd 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -80,6 +80,7 @@ xfs_bmbt_to_iomap( iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount); iomap->bdev = target->bt_bdev; iomap->dax_dev = target->bt_daxdev; + iomap->dax_offset = get_start_sect(iomap->bdev); iomap->flags = flags; if (xfs_ipincount(ip) && @@ -103,6 +104,7 @@ xfs_hole_to_iomap( iomap->length = XFS_FSB_TO_B(ip->i_mount, end_fsb - offset_fsb); iomap->bdev = target->bt_bdev; iomap->dax_dev = target->bt_daxdev; + iomap->dax_offset = get_start_sect(iomap->bdev); } static inline xfs_fileoff_t diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 8b09463dae0d..cac5d667aa74 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -84,6 +84,7 @@ struct iomap { u16 flags; /* flags for mapping */ struct block_device *bdev; /* block device for I/O */ struct dax_device *dax_dev; /* dax_dev for dax operations */ + sector_t dax_offset; /* offset in dax device */ void *inline_data; void *private; /* filesystem private */ const struct iomap_page_ops *page_ops; From patchwork Wed Feb 12 17:07:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 11378811 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B2FD13A4 for ; Wed, 12 Feb 2020 17:07:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2BC2021739 for ; Wed, 12 Feb 2020 17:07:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DkoFj9Ce" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728897AbgBLRHy (ORCPT ); Wed, 12 Feb 2020 12:07:54 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:54223 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728814AbgBLRHy (ORCPT ); Wed, 12 Feb 2020 12:07:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581527273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qAHXFz29ZqKfWinL/vfbLZE3eUCyI3Z/8yBsq8fYK5M=; b=DkoFj9CeEik95tkPwBYPnqs8A7Hj1pU53lwie4lmn/AgStuvQiTdoRwZW1xsr7RCBqYnMF L8zC5vRWUiSTXliYkhz12SV/zOO6+8mvgCw/1mGilJdtunoSJsR7tCuEUatwvfWgEIArSu etABeRr98hInQYd6J8z6g+hhJPX2UhY= 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-273-3iXqSZYVPRmtc7AyYUbG7Q-1; Wed, 12 Feb 2020 12:07:51 -0500 X-MC-Unique: 3iXqSZYVPRmtc7AyYUbG7Q-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 BB896DBA3; Wed, 12 Feb 2020 17:07:49 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26F8F5C1B2; Wed, 12 Feb 2020 17:07:47 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id B766D2257D5; Wed, 12 Feb 2020 12:07:46 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, dan.j.williams@intel.com, hch@infradead.org Cc: vgoyal@redhat.com, dm-devel@redhat.com, jack@suse.cz Subject: [PATCH 3/6] fs/dax.c: Start using dax_pgoff() instead of bdev_dax_pgoff() Date: Wed, 12 Feb 2020 12:07:30 -0500 Message-Id: <20200212170733.8092-4-vgoyal@redhat.com> In-Reply-To: <20200212170733.8092-1-vgoyal@redhat.com> References: <20200212170733.8092-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Replace usage of bdev_dax_pgoff() with dax_pgoff() in fs/dax.c Signed-off-by: Vivek Goyal --- fs/dax.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 35da144375a0..921042a81538 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -680,7 +680,7 @@ int dax_invalidate_mapping_entry_sync(struct address_space *mapping, return __dax_invalidate_entry(mapping, index, false); } -static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, +static int copy_user_dax(struct dax_device *dax_dev, sector_t dax_offset, sector_t sector, size_t size, struct page *to, unsigned long vaddr) { @@ -689,7 +689,7 @@ static int copy_user_dax(struct block_device *bdev, struct dax_device *dax_dev, long rc; int id; - rc = bdev_dax_pgoff(bdev, sector, size, &pgoff); + rc = dax_pgoff(dax_offset, sector, size, &pgoff); if (rc) return rc; @@ -990,7 +990,7 @@ static int dax_iomap_pfn(struct iomap *iomap, loff_t pos, size_t size, int id, rc; long length; - rc = bdev_dax_pgoff(iomap->bdev, sector, size, &pgoff); + rc = dax_pgoff(iomap->dax_offset, sector, size, &pgoff); if (rc) return rc; id = dax_read_lock(); @@ -1065,7 +1065,7 @@ int __dax_zero_page_range(struct block_device *bdev, long rc, id; void *kaddr; - rc = bdev_dax_pgoff(bdev, sector, PAGE_SIZE, &pgoff); + rc = dax_pgoff(get_start_sect(bdev), sector, PAGE_SIZE, &pgoff); if (rc) return rc; @@ -1087,7 +1087,6 @@ static loff_t dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data, struct iomap *iomap, struct iomap *srcmap) { - struct block_device *bdev = iomap->bdev; struct dax_device *dax_dev = iomap->dax_dev; struct iov_iter *iter = data; loff_t end = pos + length, done = 0; @@ -1132,7 +1131,7 @@ dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data, break; } - ret = bdev_dax_pgoff(bdev, sector, size, &pgoff); + ret = dax_pgoff(iomap->dax_offset, sector, size, &pgoff); if (ret) break; @@ -1312,7 +1311,7 @@ static vm_fault_t dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, clear_user_highpage(vmf->cow_page, vaddr); break; case IOMAP_MAPPED: - error = copy_user_dax(iomap.bdev, iomap.dax_dev, + error = copy_user_dax(iomap.dax_dev, iomap.dax_offset, sector, PAGE_SIZE, vmf->cow_page, vaddr); break; default: From patchwork Wed Feb 12 17:07:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 11378817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9ADF314E3 for ; Wed, 12 Feb 2020 17:07:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77C0A24649 for ; Wed, 12 Feb 2020 17:07:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BDtF5561" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728902AbgBLRH6 (ORCPT ); Wed, 12 Feb 2020 12:07:58 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:30196 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728898AbgBLRH4 (ORCPT ); Wed, 12 Feb 2020 12:07:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581527275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4/c2s2GuSGDBWl7JNFoYav/ggi3RBj2wTD17cdDeOIw=; b=BDtF5561WN1SS62WBmKO4rAx8ODzkVCW4ttktz3qB0jH5shWyZIVN6g/t/s+FIIP75gf7I 8OZ8E9uuradkOpbnTN6osCVfS4bLPUQPV2APjyLJDw9T0HvVJtNIiFqrKy2Un2OuWPlre/ SU96itbmQdDI4STxLEUBdoOQIefCdc8= 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-64-tIVHKbPON-S-T3zmRJIxnQ-1; Wed, 12 Feb 2020 12:07:51 -0500 X-MC-Unique: tIVHKbPON-S-T3zmRJIxnQ-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 0762010054E3; Wed, 12 Feb 2020 17:07:50 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3098E60BF1; Wed, 12 Feb 2020 17:07:47 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id BB6FD2257D6; Wed, 12 Feb 2020 12:07:46 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, dan.j.williams@intel.com, hch@infradead.org Cc: vgoyal@redhat.com, dm-devel@redhat.com, jack@suse.cz Subject: [PATCH 4/6] dax, dm/md: Use dax_pgoff() instead of bdev_dax_pgoff() Date: Wed, 12 Feb 2020 12:07:31 -0500 Message-Id: <20200212170733.8092-5-vgoyal@redhat.com> In-Reply-To: <20200212170733.8092-1-vgoyal@redhat.com> References: <20200212170733.8092-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Replace usage of bdev_dax_pgoff() with dax_pgoff(). Signed-off-by: Vivek Goyal --- drivers/md/dm-linear.c | 9 ++++++--- drivers/md/dm-log-writes.c | 9 ++++++--- drivers/md/dm-stripe.c | 8 +++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 8d07fdf63a47..05f654044185 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -167,7 +167,8 @@ static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, sector_t dev_sector, sector = pgoff * PAGE_SECTORS; dev_sector = linear_map_sector(ti, sector); - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); + ret = dax_pgoff(get_start_sect(bdev), dev_sector, nr_pages * PAGE_SIZE, + &pgoff); if (ret) return ret; return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); @@ -182,7 +183,8 @@ static size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, sector_t dev_sector, sector = pgoff * PAGE_SECTORS; dev_sector = linear_map_sector(ti, sector); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + if (dax_pgoff(get_start_sect(bdev), dev_sector, ALIGN(bytes, PAGE_SIZE), + &pgoff)) return 0; return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); } @@ -196,7 +198,8 @@ static size_t linear_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, sector_t dev_sector, sector = pgoff * PAGE_SECTORS; dev_sector = linear_map_sector(ti, sector); - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + if (dax_pgoff(get_start_sect(bdev), dev_sector, ALIGN(bytes, PAGE_SIZE), + &pgoff)) return 0; return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i); } diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c index 99721c76225d..204fbceeb97e 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c @@ -952,7 +952,8 @@ static long log_writes_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, sector_t sector = pgoff * PAGE_SECTORS; int ret; - ret = bdev_dax_pgoff(lc->dev->bdev, sector, nr_pages * PAGE_SIZE, &pgoff); + ret = dax_pgoff(get_start_sect(lc->dev->bdev), sector, + nr_pages * PAGE_SIZE, &pgoff); if (ret) return ret; return dax_direct_access(lc->dev->dax_dev, pgoff, nr_pages, kaddr, pfn); @@ -966,7 +967,8 @@ static size_t log_writes_dax_copy_from_iter(struct dm_target *ti, sector_t sector = pgoff * PAGE_SECTORS; int err; - if (bdev_dax_pgoff(lc->dev->bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + if (dax_pgoff(get_start_sect(lc->dev->bdev), sector, + ALIGN(bytes, PAGE_SIZE), &pgoff)) return 0; /* Don't bother doing anything if logging has been disabled */ @@ -989,7 +991,8 @@ static size_t log_writes_dax_copy_to_iter(struct dm_target *ti, struct log_writes_c *lc = ti->private; sector_t sector = pgoff * PAGE_SECTORS; - if (bdev_dax_pgoff(lc->dev->bdev, sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + if (dax_pgoff(get_start_sect(lc->dev->bdev), sector, + ALIGN(bytes, PAGE_SIZE), &pgoff)) return 0; return dax_copy_to_iter(lc->dev->dax_dev, pgoff, addr, bytes, i); } diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index 63bbcc20f49a..337cdc6e0951 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -316,7 +316,8 @@ static long stripe_dax_direct_access(struct dm_target *ti, pgoff_t pgoff, dax_dev = sc->stripe[stripe].dev->dax_dev; bdev = sc->stripe[stripe].dev->bdev; - ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff); + ret = dax_pgoff(get_start_sect(bdev), dev_sector, nr_pages * PAGE_SIZE, + &pgoff); if (ret) return ret; return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn); @@ -336,7 +337,7 @@ static size_t stripe_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff, dax_dev = sc->stripe[stripe].dev->dax_dev; bdev = sc->stripe[stripe].dev->bdev; - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + if (dax_pgoff(get_start_sect(bdev), dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) return 0; return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i); } @@ -355,7 +356,8 @@ static size_t stripe_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff, dax_dev = sc->stripe[stripe].dev->dax_dev; bdev = sc->stripe[stripe].dev->bdev; - if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff)) + if (dax_pgoff(get_start_sect(bdev), dev_sector, ALIGN(bytes, PAGE_SIZE), + &pgoff)) return 0; return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i); } From patchwork Wed Feb 12 17:07:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 11378825 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A89A19B6 for ; Wed, 12 Feb 2020 17:08:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 481A024671 for ; Wed, 12 Feb 2020 17:08:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gNcbxa1i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728901AbgBLRH6 (ORCPT ); Wed, 12 Feb 2020 12:07:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20896 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728899AbgBLRH4 (ORCPT ); Wed, 12 Feb 2020 12:07:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581527275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Kx97YjoepQpQ0kz210ikU62VnqPVqaOjhm9SlazRBo=; b=gNcbxa1isplaIvP9rBjxqY2ejICIZ/qnU8BEf+6rbzT1vqz273d3oXqK5vyv5SZo7Ejh74 4fxcjGLwl/mXcQgtpT/ZjK+LSzXnQG2imJYukUvz6oayGDHzYO7oQjiyLsuREvTZtgVSw9 /OQFYYMhcpUJR8Fa19OrWJtwCHybt0k= 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-367-e1m5cTtcPZ-n_WXIgSZPsQ-1; Wed, 12 Feb 2020 12:07:51 -0500 X-MC-Unique: e1m5cTtcPZ-n_WXIgSZPsQ-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 432DF800D41; Wed, 12 Feb 2020 17:07:50 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21BC25C1B2; Wed, 12 Feb 2020 17:07:50 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id C052D2257D7; Wed, 12 Feb 2020 12:07:46 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, dan.j.williams@intel.com, hch@infradead.org Cc: vgoyal@redhat.com, dm-devel@redhat.com, jack@suse.cz Subject: [PATCH 5/6] drivers/dax: Use dax_pgoff() instead of bdev_dax_pgoff() Date: Wed, 12 Feb 2020 12:07:32 -0500 Message-Id: <20200212170733.8092-6-vgoyal@redhat.com> In-Reply-To: <20200212170733.8092-1-vgoyal@redhat.com> References: <20200212170733.8092-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Start using dax_pgoff() instead of bdev_dax_pgoff(). Signed-off-by: Vivek Goyal --- drivers/dax/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index e9daa30e4250..ee35ecc61545 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -97,7 +97,7 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev, return false; } - err = bdev_dax_pgoff(bdev, start, PAGE_SIZE, &pgoff); + err = dax_pgoff(get_start_sect(bdev), start, PAGE_SIZE, &pgoff); if (err) { pr_debug("%s: error: unaligned partition for dax\n", bdevname(bdev, buf)); @@ -105,7 +105,7 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev, } last_page = PFN_DOWN((start + sectors - 1) * 512) * PAGE_SIZE / 512; - err = bdev_dax_pgoff(bdev, last_page, PAGE_SIZE, &pgoff_end); + err = dax_pgoff(get_start_sect(bdev), last_page, PAGE_SIZE, &pgoff_end); if (err) { pr_debug("%s: error: unaligned partition for dax\n", bdevname(bdev, buf)); From patchwork Wed Feb 12 17:07:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Goyal X-Patchwork-Id: 11378833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDFA5898F for ; Wed, 12 Feb 2020 17:08:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB4B72173E for ; Wed, 12 Feb 2020 17:08:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FJ4m4E/S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728904AbgBLRIC (ORCPT ); Wed, 12 Feb 2020 12:08:02 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48005 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728898AbgBLRIB (ORCPT ); Wed, 12 Feb 2020 12:08:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581527281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EFXOBK5kg+//3C1Cq5RJK/z4kqT5swnlhwxFrx47y84=; b=FJ4m4E/SZjFryxTLVMQJw308h/yI5Iwp7BxpaHDX7Kx2qE+zdcyUUyesQMjieSu3ITpSmU Nz7pSerQcfCV64fFDvmU3RMnQX84KEtHnHNcb+ZnqTB8yCOXiKngvE/cdvxJa2kKKg/1wz 2NbmK3tk8ymOB2Tzbc+nmUTNJjiUS0k= 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-309-mUGUErWkMiihwvXwGDO0Wg-1; Wed, 12 Feb 2020 12:07:54 -0500 X-MC-Unique: mUGUErWkMiihwvXwGDO0Wg-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 C8EF5107ACCA; Wed, 12 Feb 2020 17:07:52 +0000 (UTC) Received: from horse.redhat.com (unknown [10.18.25.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 200F15D9E2; Wed, 12 Feb 2020 17:07:50 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id CAEF32257D8; Wed, 12 Feb 2020 12:07:46 -0500 (EST) From: Vivek Goyal To: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, dan.j.williams@intel.com, hch@infradead.org Cc: vgoyal@redhat.com, dm-devel@redhat.com, jack@suse.cz Subject: [PATCH 6/6] dax: Remove bdev_dax_pgoff() helper Date: Wed, 12 Feb 2020 12:07:33 -0500 Message-Id: <20200212170733.8092-7-vgoyal@redhat.com> In-Reply-To: <20200212170733.8092-1-vgoyal@redhat.com> References: <20200212170733.8092-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now there don't seem to be anyuser of bdev_dax_pgoff(). All users have been moved to dax_pgoff(). So remove this helper. Signed-off-by: Vivek Goyal --- drivers/dax/super.c | 13 ------------- include/linux/dax.h | 1 - 2 files changed, 14 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index ee35ecc61545..371e391e6b1e 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -43,19 +43,6 @@ EXPORT_SYMBOL_GPL(dax_read_unlock); #ifdef CONFIG_BLOCK #include -int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size, - pgoff_t *pgoff) -{ - phys_addr_t phys_off = (get_start_sect(bdev) + sector) * 512; - - if (pgoff) - *pgoff = PHYS_PFN(phys_off); - if (phys_off % PAGE_SIZE || size % PAGE_SIZE) - return -EINVAL; - return 0; -} -EXPORT_SYMBOL(bdev_dax_pgoff); - int dax_pgoff(sector_t dax_offset, sector_t sector, size_t size, pgoff_t *pgoff) { phys_addr_t phys_off = (dax_offset + sector) * 512; diff --git a/include/linux/dax.h b/include/linux/dax.h index 5101a4b5c1f9..84ed0e993190 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -110,7 +110,6 @@ static inline bool daxdev_mapping_supported(struct vm_area_struct *vma, #endif struct writeback_control; -int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); int dax_pgoff(sector_t dax_offset, sector_t, size_t, pgoff_t *pgoff); #if IS_ENABLED(CONFIG_FS_DAX) bool __bdev_dax_supported(struct block_device *bdev, int blocksize);