linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org, jane.chu@oracle.com,
	willy@infradead.org, tytso@mit.edu, linux-ext4@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, sandeen@sandeen.net
Subject: [PATCH 2/2] ext4: use DAX block device zeroout for FSDAX file ZERO_RANGE operations
Date: Mon, 16 Aug 2021 14:05:30 -0700	[thread overview]
Message-ID: <162914793009.197065.11088746748309098255.stgit@magnolia> (raw)
In-Reply-To: <162914791879.197065.12619905059952917229.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

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>
---
 fs/ext4/extents.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)


diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 92ad64b89d9b..630ce5338368 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;
 	}


  parent reply	other threads:[~2021-08-16 21:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16 21:05 [PATCHSET 0/2] dax: fix broken pmem poison narrative Darrick J. Wong
2021-08-16 21:05 ` [PATCH 1/2] xfs: use DAX block device zeroout for FSDAX file ZERO_RANGE operations Darrick J. Wong
2021-08-16 21:05 ` Darrick J. Wong [this message]
2021-08-16 21:14 ` [PATCHSET 0/2] dax: fix broken pmem poison narrative Darrick J. Wong
2021-08-17  7:39 ` Christoph Hellwig
2021-08-17 15:46   ` Darrick J. Wong
2021-08-24 19:25   ` Jane Chu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=162914793009.197065.11088746748309098255.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=jane.chu@oracle.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    --cc=tytso@mit.edu \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).