

---

 b/fs/orangefs/file.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff -puN fs/orangefs/file.c~orangefs-hack fs/orangefs/file.c
--- a/fs/orangefs/file.c~orangefs-hack	2025-04-30 08:30:36.992142576 -0700
+++ b/fs/orangefs/file.c	2025-04-30 08:34:43.002231158 -0700
@@ -360,6 +360,7 @@ out:
 static ssize_t orangefs_file_write_iter(struct kiocb *iocb,
     struct iov_iter *iter)
 {
+	size_t bytes;
 	int ret;
 	orangefs_stats.writes++;
 
@@ -369,6 +370,17 @@ static ssize_t orangefs_file_write_iter(
 			return ret;
 	}
 
+	/*
+	 * This is a hack. There's (probably) an orangefs bug out
+	 * there that does not properly handle faults that happen in
+	 * the middle of a write. Avoid the bug by prefaulting. It
+	 * is possible but unlikely that this fault will be undone
+	 * by reclaim by the time the buggy code is run.
+	 */
+	bytes = iov_iter_count(iter);
+	if (fault_in_iov_iter_readable(iter, bytes) == bytes)
+		return -EFAULT;
+
 	ret = generic_file_write_iter(iocb, iter);
 	return ret;
 }
_
