aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-08-16 12:10:36 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-08-16 14:00:08 -0700
commit6380ce8db23c88d70b9954ff66477719ea84bf3f (patch)
tree26d8df7f86a194e5317c86350e70b2d423fd6317
parent201dfea1735f6390ae8c85f156f3ef8258116603 (diff)
downloadxfs-linux-6380ce8db23c88d70b9954ff66477719ea84bf3f.tar.gz
ext4: use DAX block device zeroout for FSDAX file ZERO_RANGE operations
Notice: this object is not reachable from any branch.
dax-zeroinit-clear-poison-5.15_2021-08-16
Our current "advice" to people using persistent memory and FSDAX who wish to recover upon receipt of a media error (aka 'hwpoison') event from ACPI is to punch-hole that part of the file and then pwrite it, which will magically cause the pmem to be reinitialized and the poison to be cleared. Punching doesn't make any sense at all -- the (re)allocation on pwrite does not permit the caller to specify where to find blocks, which means that we might not get the same pmem back. This pushes the user farther away from the goal of reinitializing poisoned memory and leads to complaints about unnecessary file fragmentation. Now that we've created a dax_zeroinit_range to perform what amounts to a low level format of pmem, hook it up to ext4. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Notice: this object is not reachable from any branch.
-rw-r--r--fs/ext4/extents.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 92ad64b89d9b5..630ce5338368a 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -29,6 +29,7 @@
#include <linux/fiemap.h>
#include <linux/backing-dev.h>
#include <linux/iomap.h>
+#include <linux/dax.h>
#include "ext4_jbd2.h"
#include "ext4_extents.h"
#include "xattr.h"
@@ -4678,6 +4679,24 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
}
if (mode & FALLOC_FL_ZERO_RANGE) {
+ /*
+ * If the file is in DAX mode, try to use a DAX-specific
+ * function to zero the region.
+ */
+ if (IS_DAX(inode)) {
+ bool did_zeroout = false;
+
+ inode_lock(inode);
+
+ ret = dax_zeroinit_range(inode, offset, len,
+ &did_zeroout, &ext4_iomap_report_ops);
+ if (ret == -EINVAL)
+ ret = 0;
+ if (ret || did_zeroout)
+ goto out;
+
+ inode_unlock(inode);
+ }
ret = ext4_zero_range(file, offset, len, mode);
goto exit;
}