diff mbox

[v7,4/6] dax: export a low-level __dax_zero_page_range helper

Message ID 1463000932-31680-5-git-send-email-vishal.l.verma@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Verma, Vishal L May 11, 2016, 9:08 p.m. UTC
From: Christoph Hellwig <hch@lst.de>

This allows XFS to perform zeroing using the iomap infrastructure and
avoid buffer heads.

[vishal: fix conflicts with dax-error-handling]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/dax.c            | 35 ++++++++++++++++++++---------------
 include/linux/dax.h |  7 +++++++
 2 files changed, 27 insertions(+), 15 deletions(-)

Comments

Jan Kara May 12, 2016, 8:41 a.m. UTC | #1
On Wed 11-05-16 15:08:50, Vishal Verma wrote:
> From: Christoph Hellwig <hch@lst.de>
> 
> This allows XFS to perform zeroing using the iomap infrastructure and
> avoid buffer heads.
> 
> [vishal: fix conflicts with dax-error-handling]
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

BTW: You are supposed to add your Signed-off-by when forwarding patches
like this...

								Honza
Verma, Vishal L May 12, 2016, 5:06 p.m. UTC | #2
T24gVGh1LCAyMDE2LTA1LTEyIGF0IDEwOjQxICswMjAwLCBKYW4gS2FyYSB3cm90ZToNCj4gT24g
V2VkIDExLTA1LTE2IDE1OjA4OjUwLCBWaXNoYWwgVmVybWEgd3JvdGU6DQo+ID4gDQo+ID4gRnJv
bTogQ2hyaXN0b3BoIEhlbGx3aWcgPGhjaEBsc3QuZGU+DQo+ID4gDQo+ID4gVGhpcyBhbGxvd3Mg
WEZTIHRvIHBlcmZvcm0gemVyb2luZyB1c2luZyB0aGUgaW9tYXAgaW5mcmFzdHJ1Y3R1cmUNCj4g
PiBhbmQNCj4gPiBhdm9pZCBidWZmZXIgaGVhZHMuDQo+ID4gDQo+ID4gW3Zpc2hhbDogZml4IGNv
bmZsaWN0cyB3aXRoIGRheC1lcnJvci1oYW5kbGluZ10NCj4gPiBTaWduZWQtb2ZmLWJ5OiBDaHJp
c3RvcGggSGVsbHdpZyA8aGNoQGxzdC5kZT4NCj4gTG9va3MgZ29vZC4gWW91IGNhbiBhZGQ6DQo+
IA0KPiBSZXZpZXdlZC1ieTogSmFuIEthcmEgPGphY2tAc3VzZS5jej4NCj4gDQo+IEJUVzogWW91
IGFyZSBzdXBwb3NlZCB0byBhZGQgeW91ciBTaWduZWQtb2ZmLWJ5IHdoZW4gZm9yd2FyZGluZw0K
PiBwYXRjaGVzDQo+IGxpa2UgdGhpcy4uLg0KDQpBaCBJIGRpZG4ndCBrbm93LiBJJ2xsIGFkZCBp
dCB3aGVuIG1ha2luZyB0aGUgc3RhYmxlIHRvcGljIGJyYW5jaCBmb3INCnRoaXMuIFRoYW5rcyEN
Cg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/dax.c b/fs/dax.c
index 0abbbb6..651d4b1 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -947,6 +947,23 @@  int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 }
 EXPORT_SYMBOL_GPL(dax_pfn_mkwrite);
 
+int __dax_zero_page_range(struct block_device *bdev, sector_t sector,
+		unsigned int offset, unsigned int length)
+{
+	struct blk_dax_ctl dax = {
+		.sector		= sector,
+		.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);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(__dax_zero_page_range);
+
 /**
  * dax_zero_page_range - zero a range within a page of a DAX file
  * @inode: The file being truncated
@@ -982,23 +999,11 @@  int dax_zero_page_range(struct inode *inode, loff_t from, unsigned length,
 	bh.b_bdev = inode->i_sb->s_bdev;
 	bh.b_size = PAGE_SIZE;
 	err = get_block(inode, index, &bh, 0);
-	if (err < 0)
+	if (err < 0 || !buffer_written(&bh))
 		return err;
-	if (buffer_written(&bh)) {
-		struct block_device *bdev = bh.b_bdev;
-		struct blk_dax_ctl dax = {
-			.sector = to_sector(&bh, inode),
-			.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);
-	}
-
-	return 0;
+	return __dax_zero_page_range(bh.b_bdev, to_sector(&bh, inode),
+			offset, length);
 }
 EXPORT_SYMBOL_GPL(dax_zero_page_range);
 
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 7f853ff..90fbc99 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -14,12 +14,19 @@  int __dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t);
 
 #ifdef CONFIG_FS_DAX
 struct page *read_dax_sector(struct block_device *bdev, sector_t n);
+int __dax_zero_page_range(struct block_device *bdev, sector_t sector,
+		unsigned int offset, unsigned int length);
 #else
 static inline struct page *read_dax_sector(struct block_device *bdev,
 		sector_t n)
 {
 	return ERR_PTR(-ENXIO);
 }
+static inline int __dax_zero_page_range(struct block_device *bdev,
+		sector_t sector, unsigned int offset, unsigned int length)
+{
+	return -ENXIO;
+}
 #endif
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE