Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1385714

[PATCH v3 6/7] dax: for truncate/hole-punch, do zeroing through the driver if possible

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Vishal Verma <vishal.l.verma@intel.com>
Newsgroups linux.kernel
Subject [PATCH v3 6/7] dax: for truncate/hole-punch, do zeroing through the driver if possible
Date Sat, 23 Apr 2016 21:20:03 +0200
Message-ID <rrbfZ-8dY-21@gated-at.bofh.it> (permalink)
References <rrbfY-8dY-3@gated-at.bofh.it>
X-Extloop1 1
X-Ironport-Av E=Sophos;i="5.24,523,1455004800"; d="scan'208";a="965085776"
X-Mailer git-send-email 2.5.5
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 70
Organization linux.* mail to news gateway
X-Original-Cc Vishal Verma <vishal.l.verma@intel.com>, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, xfs@oss.sgi.com, linux-ext4@vger.kernel.org, linux-mm@kvack.org, Matthew Wilcox <matthew.r.wilcox@intel.com>, Ross Zwisler <ross.zwisler@linux.intel.com>, Dan Williams <dan.j.williams@intel.com>, Dave Chinner <david@fromorbit.com>, Jan Kara <jack@suse.cz>, Jens Axboe <axboe@fb.com>, Al Viro <viro@zeniv.linux.org.uk>, Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org, Christoph Hellwig <hch@infradead.org>, Jeff Moyer <jmoyer@redhat.com>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
X-Original-Date Sat, 23 Apr 2016 13:13:41 -0600
X-Original-Message-ID <1461438822-3592-7-git-send-email-vishal.l.verma@intel.com>
X-Original-References <1461438822-3592-1-git-send-email-vishal.l.verma@intel.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1385714

Show key headers only | View raw


In the truncate or hole-punch path in dax, we clear out sub-page ranges.
If these sub-page ranges are sector aligned and sized, we can do the
zeroing through the driver instead so that error-clearing is handled
automatically.

For sub-sector ranges, we still have to rely on clear_pmem and have the
possibility of tripping over errors.

Cc: Matthew Wilcox <matthew.r.wilcox@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 fs/dax.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 5948d9b..d8c974e 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1196,6 +1196,20 @@ out:
 }
 EXPORT_SYMBOL_GPL(dax_pfn_mkwrite);
 
+static bool dax_range_is_aligned(struct block_device *bdev,
+				 struct blk_dax_ctl *dax, unsigned int offset,
+				 unsigned int length)
+{
+	unsigned short sector_size = bdev_logical_block_size(bdev);
+
+	if (((u64)dax->addr + offset) % sector_size)
+		return false;
+	if (length % sector_size)
+		return false;
+
+	return true;
+}
+
 /**
  * dax_zero_page_range - zero a range within a page of a DAX file
  * @inode: The file being truncated
@@ -1240,11 +1254,17 @@ int dax_zero_page_range(struct inode *inode, loff_t from, unsigned length,
 			.size = PAGE_SIZE,
 		};
 
-		if (dax_map_atomic(bdev, &dax) < 0)
-			return PTR_ERR(dax.addr);
-		clear_pmem(dax.addr + offset, length);
-		wmb_pmem();
-		dax_unmap_atomic(bdev, &dax);
+		if (dax_range_is_aligned(bdev, &dax, offset, length))
+			return blkdev_issue_zeroout(bdev, dax.sector,
+					length / bdev_logical_block_size(bdev),
+					GFP_NOFS, true);
+		else {
+			if (dax_map_atomic(bdev, &dax) < 0)
+				return PTR_ERR(dax.addr);
+			clear_pmem(dax.addr + offset, length);
+			wmb_pmem();
+			dax_unmap_atomic(bdev, &dax);
+		}
 	}
 
 	return 0;
-- 
2.5.5

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/7] dax: handling media errors Vishal Verma <vishal.l.verma@intel.com> - 2016-04-23 21:20 +0200
  [PATCH v3 7/7] dax: fix a comment in dax_zero_page_range and dax_truncate_page Vishal Verma <vishal.l.verma@intel.com> - 2016-04-23 21:20 +0200
  [PATCH v3 4/7] dax: use sb_issue_zerout instead of calling dax_clear_sectors Vishal Verma <vishal.l.verma@intel.com> - 2016-04-23 21:20 +0200
  [PATCH v3 1/7] block, dax: pass blk_dax_ctl through to drivers Vishal Verma <vishal.l.verma@intel.com> - 2016-04-23 21:20 +0200
  [PATCH v3 2/7] dax: fallback from pmd to pte on error Vishal Verma <vishal.l.verma@intel.com> - 2016-04-23 21:20 +0200
  [PATCH v3 6/7] dax: for truncate/hole-punch, do zeroing through the driver if possible Vishal Verma <vishal.l.verma@intel.com> - 2016-04-23 21:20 +0200
  [PATCH v3 5/7] dax: handle media errors in dax_do_io Vishal Verma <vishal.l.verma@intel.com> - 2016-04-23 21:20 +0200

csiph-web