aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 @@
24#include <linux/uio.h> 24#include <linux/uio.h>
25#include <linux/backing-dev.h> 25#include <linux/backing-dev.h>
26#include <linux/buffer_head.h> 26#include <linux/buffer_head.h>
27#include <linux/dax.h>
27#include "internal.h" 28#include "internal.h"
28 29
29typedef loff_t (*iomap_actor_t)(struct inode *inode, loff_t pos, loff_t len, 30typedef 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,
268 return iomap_write_end(inode, pos, bytes, bytes, page); 269 return iomap_write_end(inode, pos, bytes, bytes, page);
269} 270}
270 271
272static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes,
273 struct iomap *iomap)
274{
275 sector_t sector = iomap->blkno +
276 (((pos & ~(PAGE_SIZE - 1)) - iomap->offset) >> 9);
277
278 return __dax_zero_page_range(iomap->bdev, sector, offset, bytes);
279}
280
271static loff_t 281static loff_t
272iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count, 282iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
273 void *data, struct iomap *iomap) 283 void *data, struct iomap *iomap)
@@ -286,7 +296,10 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
286 offset = pos & (PAGE_SIZE - 1); /* Within page */ 296 offset = pos & (PAGE_SIZE - 1); /* Within page */
287 bytes = min_t(unsigned, PAGE_SIZE - offset, count); 297 bytes = min_t(unsigned, PAGE_SIZE - offset, count);
288 298
289 status = iomap_zero(inode, pos, offset, bytes, iomap); 299 if (IS_DAX(inode))
300 status = iomap_dax_zero(pos, offset, bytes, iomap);
301 else
302 status = iomap_zero(inode, pos, offset, bytes, iomap);
290 if (status < 0) 303 if (status < 0)
291 return status; 304 return status;
292 305