summaryrefslogtreecommitdiffstats
path: root/fs/iomap.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-06-21 09:31:39 +1000
committerDave Chinner <david@fromorbit.com>2016-06-21 09:31:39 +1000
commit9a286f0e52a2dac362caf78a458efa8f3c05b99e (patch)
treec723e9b64861d04d0bf846fd6a6bad3284aa5958 /fs/iomap.c
parentae259a9c8593f98aa60d045df978a5482a67c53f (diff)
downloadlinux-9a286f0e52a2dac362caf78a458efa8f3c05b99e.tar.gz
linux-9a286f0e52a2dac362caf78a458efa8f3c05b99e.tar.bz2
linux-9a286f0e52a2dac362caf78a458efa8f3c05b99e.zip
fs: support DAX based iomap zeroing
This avoid needing a separate inefficient get_block based DAX zero_range implementation in file systems. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/iomap.c')
-rw-r--r--fs/iomap.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/fs/iomap.c b/fs/iomap.c
index 8e2fc17c266f..477817c00bac 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -24,6 +24,7 @@
#include <linux/uio.h>
#include <linux/backing-dev.h>
#include <linux/buffer_head.h>
+#include <linux/dax.h>
#include "internal.h"
typedef loff_t (*iomap_actor_t)(struct inode *inode, loff_t pos, loff_t len,
@@ -268,6 +269,15 @@ static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset,
return iomap_write_end(inode, pos, bytes, bytes, page);
}
+static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes,
+ struct iomap *iomap)
+{
+ sector_t sector = iomap->blkno +
+ (((pos & ~(PAGE_SIZE - 1)) - iomap->offset) >> 9);
+
+ return __dax_zero_page_range(iomap->bdev, sector, offset, bytes);
+}
+
static loff_t
iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
void *data, struct iomap *iomap)
@@ -286,7 +296,10 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
offset = pos & (PAGE_SIZE - 1); /* Within page */
bytes = min_t(unsigned, PAGE_SIZE - offset, count);
- status = iomap_zero(inode, pos, offset, bytes, iomap);
+ if (IS_DAX(inode))
+ status = iomap_dax_zero(pos, offset, bytes, iomap);
+ else
+ status = iomap_zero(inode, pos, offset, bytes, iomap);
if (status < 0)
return status;