[PATCH 1/7] ext2: tell DAX the size of allocation holes

From: Ross Zwisler
Date: Mon Aug 15 2016 - 15:13:29 EST


When DAX calls ext2_get_block() and the file offset points to a hole we
currently don't set bh_result->b_size. When we re-enable PMD faults DAX
will need bh_result->b_size to tell it the size of the hole so it can
decide whether to fault in a 4 KiB zero page or a 2 MiB zero page.

For ext2 we always want DAX to use 4 KiB zero pages, so we just tell DAX
that all holes are 4 KiB in size.

Signed-off-by: Ross Zwisler <ross.zwisler@xxxxxxxxxxxxxxx>
---
fs/ext2/inode.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index d5c7d09..c6d9763 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -773,6 +773,12 @@ int ext2_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_
if (ret > 0) {
bh_result->b_size = (ret << inode->i_blkbits);
ret = 0;
+ } else if (ret == 0 && IS_DAX(inode)) {
+ /*
+ * We have hit a hole. Tell DAX it is 4k in size so that it
+ * uses PTE faults.
+ */
+ bh_result->b_size = PAGE_SIZE;
}
return ret;

--
2.9.0