Skip to contentSkip to conversation

generic: test zero-byte writes to new file

PATCH Superseded Eric Sandeen 6 participants 14 messages Feb 13, 2025 – Feb 26, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic: test zero-byte writes to new file

A bug was recently fixed in exfat where attempting to do a zero-byte write would yield -EFAULT; test for that here.

---

tests/generic/761 new file +28 -0
new file mode 100755
index 00000000..e933eb83
@@ -0,0 +1,28 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test 761
+#
+# test zero-byte writes
+#
+# exfat had a regression where a zero-byte write to a file would
+# yield -EfAULT. Should work on all filesystems - write should
+# succeed and the zero-byte file should be created.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+[ "$FSTYP" = "exfat" ] && _fixed_by_kernel_commit dda0407a2026 \
+	"exfat: short-circuit zero-byte writes in exfat_file_write_iter"
+
+# Modify as appropriate.
+_require_test
+
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"
+
+# success, all done
+status=0
+exit
tests/generic/761.out new file +2 -0
new file mode 100644
index 00000000..72ebba4c
@@ -0,0 +1,2 @@
+QA output created by 761
+Silence is golden
#1 lore raw
Quoted 26 lines · Eric Sandeen

A bug was recently fixed in exfat where attempting to do a zero-byte write would yield -EFAULT; test for that here.

---

tests/generic/761 new file +14 -0
new file mode 100755
index 00000000..e933eb83
@@ -0,0 +1,28 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test 761
+#
+# test zero-byte writes
+#
+# exfat had a regression where a zero-byte write to a file would
+# yield -EfAULT. Should work on all filesystems - write should
+# succeed and the zero-byte file should be created.
+#
+. ./common/preamble
+_begin_fstest auto quick

tests/generic/761 line 24

Quoted 10 lines
tests/generic/761 new file +10 -0
+
+[ "$FSTYP" = "exfat" ] && _fixed_by_kernel_commit dda0407a2026 \
+	"exfat: short-circuit zero-byte writes in exfat_file_write_iter"
+
+# Modify as appropriate.
+_require_test
+
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

When does the file not get created?

--D

Quoted 14 lines
tests/generic/761 new file +4 -0
+
+# success, all done
+status=0
+exit
tests/generic/761.out new file +2 -0
new file mode 100644
index 00000000..72ebba4c
@@ -0,0 +1,2 @@
+QA output created by 761
+Silence is golden
#2 lore raw
Quoted 31 lines · Darrick J. Wong
Quoted 30 lines · Eric Sandeen

A bug was recently fixed in exfat where attempting to do a zero-byte write would yield -EFAULT; test for that here.

---

tests/generic/761 new file +18 -0
new file mode 100755
index 00000000..e933eb83
@@ -0,0 +1,28 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test 761
+#
+# test zero-byte writes
+#
+# exfat had a regression where a zero-byte write to a file would
+# yield -EfAULT. Should work on all filesystems - write should
+# succeed and the zero-byte file should be created.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+[ "$FSTYP" = "exfat" ] && _fixed_by_kernel_commit dda0407a2026 \
+	"exfat: short-circuit zero-byte writes in exfat_file_write_iter"
+
Quoted 8 lines

tests/generic/761 line 24

Quoted 6 lines
tests/generic/761 new file +6 -0
+# Modify as appropriate.
+_require_test
+
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

When does the file not get created?

In some unknown error case? ;)
There's probably no reason for that test, though of course it's still expected to pass.

In the various discussions of the exfat bug scattered around the internet people kept pointing out that "well, the file does get created" so I probably had that on my mind.

-Eric

Quoted 17 lines

--D

Quoted 14 lines
tests/generic/761 new file +4 -0
+
+# success, all done
+status=0
+exit
tests/generic/761.out new file +2 -0
new file mode 100644
index 00000000..72ebba4c
@@ -0,0 +1,2 @@
+QA output created by 761
+Silence is golden
#3 lore raw
Quoted 1 line · Eric Sandeen

On 2/13/25 1:51 PM, Darrick J. Wong wrote:

...

Quoted 6 lines
Quoted 5 lines

tests/generic/761 line 24

Quoted 3 lines
tests/generic/761 new file +3 -0
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

When does the file not get created?

Quoted 7 lines

In some unknown error case? ;)
There's probably no reason for that test, though of course it's still expected to pass.

In the various discussions of the exfat bug scattered around the internet people kept pointing out that "well, the file does get created" so I probably had that on my mind.

To put a finer point on it, because I can't tell for sure - are you asking me to take that test out?

Thanks,
-Eric

#4 lore raw
Quoted 15 lines · Eric Sandeen
Quoted 1 line · Eric Sandeen

On 2/13/25 1:51 PM, Darrick J. Wong wrote:

...

Quoted 10 lines
Quoted 5 lines

tests/generic/761 line 24

Quoted 3 lines
tests/generic/761 new file +3 -0
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

When does the file not get created?

In some unknown error case? ;)
There's probably no reason for that test, though of course it's still expected to pass.

Quoted 6 lines
Quoted 3 lines

In the various discussions of the exfat bug scattered around the internet people kept pointing out that "well, the file does get created" so I probably had that on my mind.

To put a finer point on it, because I can't tell for sure - are you asking me to take that test out?

Nah, I was just wondering if there was something about the buggy exfat code that either prevented the file from being created, or if the bug was that the empty file got deleted after the zero-byte pwrite and I misunderstood what's going on.

(IOWs I think this test is fine, but could the exfat maintainer clarify?)

--D

Quoted 4 lines

Thanks,
-Eric

#5 lore raw
Quoted 24 lines · Darrick J. Wong
Quoted 15 lines · Eric Sandeen
Quoted 1 line · Eric Sandeen

On 2/13/25 1:51 PM, Darrick J. Wong wrote:

...

Quoted 10 lines
Quoted 5 lines

tests/generic/761 line 24

Quoted 3 lines
tests/generic/761 new file +3 -0
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

When does the file not get created?

In some unknown error case? ;)
There's probably no reason for that test, though of course it's still expected to pass.

Quoted 6 lines
Quoted 3 lines

In the various discussions of the exfat bug scattered around the internet people kept pointing out that "well, the file does get created" so I probably had that on my mind.

To put a finer point on it, because I can't tell for sure - are you asking me to take that test out?

Quoted 7 lines

Nah, I was just wondering if there was something about the buggy exfat code that either prevented the file from being created, or if the bug was that the empty file got deleted after the zero-byte pwrite and I misunderstood what's going on.

(IOWs I think this test is fine, but could the exfat maintainer clarify?)

File was not deleted due to a bug in exFAT. It has caused a misunderstanding because exFAT returns an incorrect errno (-EFAULT) from zero length write.

Thanks.

Quoted 7 lines

--D

Quoted 4 lines

Thanks,
-Eric

#6 lore raw
In reply to Darrick J. Wong
Quoted 20 lines · Darrick J. Wong
Quoted 19 lines · Eric Sandeen
Quoted 1 line · Eric Sandeen

On 2/13/25 1:51 PM, Darrick J. Wong wrote:

...

Quoted 13 lines
Quoted 5 lines

tests/generic/761 line 24

Quoted 3 lines
tests/generic/761 new file +3 -0
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

When does the file not get created?

In some unknown error case? ;)
There's probably no reason for that test, though of course it's still expected to pass.

In the various discussions of the exfat bug scattered around the internet people kept pointing out that "well, the file does get created" so I probably had that on my mind.

Quoted 7 lines
Quoted 2 lines

To put a finer point on it, because I can't tell for sure - are you asking me to take that test out?

Nah, I was just wondering if there was something about the buggy exfat code that either prevented the file from being created, or if the bug was that the empty file got deleted after the zero-byte pwrite and I misunderstood what's going on.

Ah, I see. No, the observable problem was an -EFAULT on the write, and the file /does/ get created as expected. The test probably is extraneous to the original bug, because of course open(O_CREAT) and write(0) are two separate operations. I was just a bit over-eager when writing the test.

Thanks,
-Eric

Quoted 10 lines

(IOWs I think this test is fine, but could the exfat maintainer clarify?)

--D

Quoted 4 lines

Thanks,
-Eric

#7 lore raw
Quoted 29 lines · Eric Sandeen
Quoted 20 lines · Darrick J. Wong
Quoted 19 lines · Eric Sandeen
Quoted 1 line · Eric Sandeen

On 2/13/25 1:51 PM, Darrick J. Wong wrote:

...

Quoted 13 lines
Quoted 5 lines

tests/generic/761 line 24

Quoted 3 lines
tests/generic/761 new file +3 -0
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

When does the file not get created?

In some unknown error case? ;)
There's probably no reason for that test, though of course it's still expected to pass.

In the various discussions of the exfat bug scattered around the internet people kept pointing out that "well, the file does get created" so I probably had that on my mind.

Quoted 7 lines
Quoted 2 lines

To put a finer point on it, because I can't tell for sure - are you asking me to take that test out?

Nah, I was just wondering if there was something about the buggy exfat code that either prevented the file from being created, or if the bug was that the empty file got deleted after the zero-byte pwrite and I misunderstood what's going on.

Quoted 5 lines

Ah, I see. No, the observable problem was an -EFAULT on the write, and the file /does/ get created as expected. The test probably is extraneous to the original bug, because of course open(O_CREAT) and write(0) are two separate operations. I was just a bit over-eager when writing the test.

<nod> Would you mind resending, but with the rm removed?

--D

Quoted 15 lines

Thanks,
-Eric

Quoted 10 lines

(IOWs I think this test is fine, but could the exfat maintainer clarify?)

--D

Quoted 4 lines

Thanks,
-Eric

#8 lore raw
Quoted 1 line · Darrick J. Wong

On Fri, Feb 14, 2025 at 08:36:25AM -0600, Eric Sandeen wrote:

...

Quoted 7 lines
Quoted 5 lines

Ah, I see. No, the observable problem was an -EFAULT on the write, and the file /does/ get created as expected. The test probably is extraneous to the original bug, because of course open(O_CREAT) and write(0) are two separate operations. I was just a bit over-eager when writing the test.

<nod> Would you mind resending, but with the rm removed?

I can. I'm OOTO for a bit so it may be a while, but this isn't urgent. I'll get to it.

Thanks,
-Eric

Quoted 1 line

--D

#9 lore raw
In reply to Eric Sandeen
Quoted 30 lines · Eric Sandeen

A bug was recently fixed in exfat where attempting to do a zero-byte write would yield -EFAULT; test for that here.

---

tests/generic/761 new file +17 -0
new file mode 100755
index 00000000..e933eb83
@@ -0,0 +1,28 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test 761
+#
+# test zero-byte writes
+#
+# exfat had a regression where a zero-byte write to a file would
+# yield -EfAULT. Should work on all filesystems - write should
+# succeed and the zero-byte file should be created.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+[ "$FSTYP" = "exfat" ] && _fixed_by_kernel_commit dda0407a2026 \
+	"exfat: short-circuit zero-byte writes in

exfat_file_write_iter"

tests/generic/761 line 24

Quoted 7 lines
tests/generic/761 new file +7 -0
+
+# Modify as appropriate.
+_require_test
+
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

Minor: Maybe just remove the test file that is created above (since we are using the TEST_DIR)and not leave any test artifacts? Or, maybe use the scratch device?
--NR

Quoted 13 lines
tests/generic/761 new file +4 -0
+
+# success, all done
+status=0
+exit
tests/generic/761.out new file +2 -0
new file mode 100644
index 00000000..72ebba4c
@@ -0,0 +1,2 @@
+QA output created by 761
+Silence is golden
#10 lore raw
Quoted 33 lines · Nirjhar Roy (IBM)
Quoted 32 lines · Eric Sandeen

A bug was recently fixed in exfat where attempting to do a zero-byte write would yield -EFAULT; test for that here.

---

tests/generic/761 new file +17 -0
new file mode 100755
index 00000000..e933eb83
@@ -0,0 +1,28 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test 761
+#
+# test zero-byte writes
+#
+# exfat had a regression where a zero-byte write to a file would
+# yield -EfAULT. Should work on all filesystems - write should
+# succeed and the zero-byte file should be created.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+[ "$FSTYP" = "exfat" ] && _fixed_by_kernel_commit dda0407a2026 \
+	"exfat: short-circuit zero-byte writes in

exfat_file_write_iter"

tests/generic/761 new file +2 -0
+
+# Modify as appropriate.
Quoted 8 lines

tests/generic/761 line 24

Quoted 5 lines
tests/generic/761 new file +5 -0
+_require_test
+
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

Minor: Maybe just remove the test file that is created above (since we are using the TEST_DIR)and not leave any test artifacts? Or, maybe use the scratch device?

Agreed, the _cleanup should remove the testfile.

Using the scratch device (== additional runtime for mkfs) is overkill since this test creates a single file but writes nothing to it.

--D

Quoted 16 lines

--NR

Quoted 13 lines
tests/generic/761 new file +4 -0
+
+# success, all done
+status=0
+exit
tests/generic/761.out new file +2 -0
new file mode 100644
index 00000000..72ebba4c
@@ -0,0 +1,2 @@
+QA output created by 761
+Silence is golden
#11 lore raw
Quoted 42 lines · Darrick J. Wong
Quoted 33 lines · Nirjhar Roy (IBM)
Quoted 32 lines · Eric Sandeen

A bug was recently fixed in exfat where attempting to do a zero-byte write would yield -EFAULT; test for that here.

---

tests/generic/761 new file +17 -0
new file mode 100755
index 00000000..e933eb83
@@ -0,0 +1,28 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test 761
+#
+# test zero-byte writes
+#
+# exfat had a regression where a zero-byte write to a file would
+# yield -EfAULT. Should work on all filesystems - write should
+# succeed and the zero-byte file should be created.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+[ "$FSTYP" = "exfat" ] && _fixed_by_kernel_commit dda0407a2026 \
+	"exfat: short-circuit zero-byte writes in

exfat_file_write_iter"

tests/generic/761 new file +2 -0
+
+# Modify as appropriate.
Quoted 8 lines

tests/generic/761 line 24

Quoted 5 lines
tests/generic/761 new file +5 -0
+_require_test
+
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

Minor: Maybe just remove the test file that is created above (since we are using the TEST_DIR)and not leave any test artifacts? Or, maybe use the scratch device?

Quoted 4 lines

Agreed, the _cleanup should remove the testfile.

Using the scratch device (== additional runtime for mkfs) is overkill since this test creates a single file but writes nothing to it.

Yes, makes sense.

--NR

Quoted 18 lines

--D

Quoted 15 lines

--NR

Quoted 13 lines
tests/generic/761 new file +4 -0
+
+# success, all done
+status=0
+exit
tests/generic/761.out new file +2 -0
new file mode 100644
index 00000000..72ebba4c
@@ -0,0 +1,2 @@
+QA output created by 761
+Silence is golden
Signature · 3 lines
Nirjhar Roy
Linux Kernel Developer
IBM, Bangalore
#12 lore raw
In reply to Darrick J. Wong
Quoted 43 lines · Darrick J. Wong
Quoted 33 lines · Nirjhar Roy (IBM)
Quoted 32 lines · Eric Sandeen

A bug was recently fixed in exfat where attempting to do a zero-byte write would yield -EFAULT; test for that here.

---

tests/generic/761 new file +17 -0
new file mode 100755
index 00000000..e933eb83
@@ -0,0 +1,28 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test 761
+#
+# test zero-byte writes
+#
+# exfat had a regression where a zero-byte write to a file would
+# yield -EfAULT. Should work on all filesystems - write should
+# succeed and the zero-byte file should be created.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+[ "$FSTYP" = "exfat" ] && _fixed_by_kernel_commit dda0407a2026 \
+	"exfat: short-circuit zero-byte writes in

exfat_file_write_iter"

tests/generic/761 new file +2 -0
+
+# Modify as appropriate.
Quoted 8 lines

tests/generic/761 line 24

Quoted 5 lines
tests/generic/761 new file +5 -0
+_require_test
+
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

Minor: Maybe just remove the test file that is created above (since we are using the TEST_DIR)and not leave any test artifacts? Or, maybe use the scratch device?

Quoted 1 line

Agreed, the _cleanup should remove the testfile.

ok. I thought we left stuff lying around to age test, but I'll do whatever folks like to get this one-liner test merged :)

-Eric

#13 lore raw
Quoted 44 lines · Eric Sandeen
Quoted 43 lines · Darrick J. Wong
Quoted 41 lines · Nirjhar Roy (IBM)
Quoted 30 lines · Eric Sandeen

A bug was recently fixed in exfat where attempting to do a zero-byte write would yield -EFAULT; test for that here.

---

tests/generic/761 new file +17 -0
new file mode 100755
index 00000000..e933eb83
@@ -0,0 +1,28 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Red Hat, Inc.  All Rights Reserved.
+#
+# FS QA Test 761
+#
+# test zero-byte writes
+#
+# exfat had a regression where a zero-byte write to a file would
+# yield -EfAULT. Should work on all filesystems - write should
+# succeed and the zero-byte file should be created.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+[ "$FSTYP" = "exfat" ] && _fixed_by_kernel_commit dda0407a2026 \
+	"exfat: short-circuit zero-byte writes in

exfat_file_write_iter"

tests/generic/761 line 24

Quoted 7 lines
tests/generic/761 new file +7 -0
+
+# Modify as appropriate.
+_require_test
+
+rm -f $TEST_DIR/testfile.$seq
+$XFS_IO_PROG -f -c "pwrite 0 0" $TEST_DIR/testfile.$seq
+test -f $TEST_DIR/testfile.$seq || _fail "file not created"

Minor: Maybe just remove the test file that is created above (since we are using the TEST_DIR)and not leave any test artifacts? Or, maybe use the scratch device?

Quoted 4 lines
Quoted 1 line

Agreed, the _cleanup should remove the testfile.

ok. I thought we left stuff lying around to age test, but I'll do whatever folks like to get this one-liner test merged :)

Actually there's not a rule about "must remove the file your create in TEST_DIR". And I remember the TEST_DIR was designed to keep some random files. So from my side, if the file size isn't too large, I'm good to keep it in TEST_DIR :)

Thanks,
Zorro

Quoted 4 lines

-Eric