[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1006157: /lib/modules/5.16.0-1-sparc64-smp/kernel/fs/ext4/ext4.ko: [sparc64+ext4] reads see zeros w/ simultaneous write



Package: src:linux
Version: 5.16.7-2
Severity: normal
File: /lib/modules/5.16.0-1-sparc64-smp/kernel/fs/ext4/ext4.ko

Dear Maintainer,

   * What led up to the situation?

The context is an ext4 filesystem on a sparc64 host.  I've observed
this with each of the three sparc64 kernels that I've tested.  Those
kernels were 5.16.0-1-sparc64-smp (this report), 5.15.0-2-sparc64-smp,
and 4.9.0-13-sparc64-smp.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

See the included file for a minimal test program.  It creates two
processes, each of which loops indefinitely.  One opens a file, writes
0x1 to a 256-byte region, and closes the file.  The other process
opens the same file, reads the same region, and prints a message if
any byte is not 0x1.

This thread has more discussion and a more-configurable test program:
https://postgr.es/m/flat/20220116071210.GA735692@rfd.leadboat.com

   * What was the outcome of this action?

The program prints messages, at least ten per second.  The mismatch
always appears at an offset divisible by eight.  Some offsets are more
common than others.  Here's output from 300s of runtime, filtered
through "sort -nk3 | uniq -c":

   1729 mismatch at 8: got 0, want 1
   1878 mismatch at 16: got 0, want 1
   1030 mismatch at 24: got 0, want 1
     41 mismatch at 40: got 0, want 1
    373 mismatch at 48: got 0, want 1
     24 mismatch at 56: got 0, want 1
    349 mismatch at 64: got 0, want 1
  13525 mismatch at 72: got 0, want 1
    401 mismatch at 80: got 0, want 1
    365 mismatch at 88: got 0, want 1
      1 mismatch at 96: got 0, want 1
     32 mismatch at 104: got 0, want 1
     34 mismatch at 112: got 0, want 1
     19 mismatch at 120: got 0, want 1
     34 mismatch at 128: got 0, want 1
    253 mismatch at 136: got 0, want 1
    149 mismatch at 144: got 0, want 1
    138 mismatch at 152: got 0, want 1
      1 mismatch at 160: got 0, want 1
      4 mismatch at 168: got 0, want 1
      7 mismatch at 176: got 0, want 1
      4 mismatch at 184: got 0, want 1
      1 mismatch at 192: got 0, want 1
     83 mismatch at 200: got 0, want 1
     58 mismatch at 208: got 0, want 1
   3301 mismatch at 216: got 0, want 1
      2 mismatch at 232: got 0, want 1
      1 mismatch at 248: got 0, want 1

If I run the program atop an xfs filesystem (still with sparc64), it
prints nothing.  If I run it with x86_64 or powerpc64 (atop ext4), it
prints nothing.

   * What outcome did you expect instead?

I expected the program to print nothing, indicating that the reader
process observes only 0x1 bytes.  That is how x86_64+ext4 behaves.

POSIX is stricter, requiring read() and write() implementations such
that "each call shall either see all of the specified effects of the
other call, or none of them"
(https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_07).
ext4 does not conform, which may be pragmatic.  However, with x86_64
and powerpc64, readers see each byte as either its before-write value
or its after-write value.  They don't see a zero in an offset that
will have been nonzero both before and after the ongoing write().


-- Package-specific info:
** Version:
Linux version 5.16.0-1-sparc64-smp (debian-kernel@lists.debian.org) (gcc-11 (Debian 11.2.0-16) 11.2.0, GNU ld (GNU Binutils for Debian) 2.37.90.20220130) #1 SMP Debian 5.16.7-1 (2022-02-06)

** Command line:
BOOT_IMAGE=/vmlinux-5.16.0-1-sparc64-smp root=/dev/mapper/vg1-nroot ro

** Tainted: E (8192)
 * unsigned module was loaded

** Kernel log:
[344103.150402] null-4.exe[3045591]: segfault at 0 ip 0000010000000990 (rpc 0000010000000984) sp 000007feff952831 error 1 in null-4.exe[10000000000+2000]
[344103.533876] null-4.exe[3045722]: segfault at 8 ip 0000010000000990 (rpc 0000010000000984) sp 000007feffa8c841 error 1 in null-4.exe[10000000000+2000]
[344103.911758] null-4.exe[3045896]: segfault at 8 ip 00000100000007e4 (rpc 00000100000007dc) sp 000007feffeec841 error 1 in null-4.exe[10000000000+2000]
[344104.319288] null-4.exe[3046052]: segfault at 8 ip 00000100000007e4 (rpc 00000100000007dc) sp 000007feffa2e841 error 1 in null-4.exe[10000000000+2000]
[344104.703441] null-4.exe[3046206]: segfault at 8 ip 00000100000007c8 (rpc 00000100000007bc) sp 000007feffeb8841 error 1 in null-4.exe[10000000000+2000]
[344105.411714] null-4.exe[3046494]: segfault at 8 ip 00000100000007e4 (rpc 00000100000007dc) sp 000007feff9ec841 error 1 in null-4.exe[10000000000+2000]
[344105.921598] null-4.exe[3046699]: segfault at 8 ip 00000100000007e4 (rpc 00000100000007dc) sp 000007feffd3a841 error 1 in null-4.exe[10000000000+2000]
[344106.302875] null-5.exe[3046860]: segfault at 0 ip 00000100000009b0 (rpc 00000100000009a4) sp 000007feffbc6831 error 1 in null-5.exe[10000000000+2000]
[344107.467462] show_signal_msg: 2 callbacks suppressed
[344107.467472] null-5.exe[3047293]: segfault at 0 ip 00000100000007f0 (rpc 00000100000007dc) sp 000007feff9a8841 error 1 in null-5.exe[10000000000+2000]
[344107.851298] null-5.exe[3047413]: segfault at 0 ip 00000100000007c4 (rpc 00000100000007bc) sp 000007feff9a2841 error 1 in null-5.exe[10000000000+2000]
[344108.556938] null-5.exe[3047656]: segfault at 0 ip 00000100000007f0 (rpc 00000100000007dc) sp 000007feffb92841 error 1 in null-5.exe[10000000000+2000]
[344109.035546] null-5.exe[3047832]: segfault at 0 ip 00000100000007f0 (rpc 00000100000007dc) sp 000007feffdd2841 error 1 in null-5.exe[10000000000+2000]
[344109.409732] null-6.exe[3047956]: segfault at 0 ip 00000100000009b4 (rpc 00000100000009a4) sp 000007feffe86831 error 1 in null-6.exe[10000000000+2000]
[344109.786747] null-6.exe[3048073]: segfault at 0 ip 0000010000000970 (rpc 0000010000000964) sp 000007feffb0e841 error 1 in null-6.exe[10000000000+2000]
[344110.153802] null-6.exe[3048209]: segfault at 0 ip 00000100000007c8 (rpc 00000100000007bc) sp 000007feffed8841 error 1 in null-6.exe[10000000000+2000]
[344110.552717] null-6.exe[3048355]: segfault at 0 ip 00000100000007c8 (rpc 00000100000007bc) sp 000007feffa20841 error 1 in null-6.exe[10000000000+2000]
[344110.678649] null-1.exe[3048393]: segfault at 0 ip 00000100000009b0 (rpc 00000100000009a4) sp 000007feffae6831 error 1 in null-1.exe[10000000000+2000]
[344110.939707] null-6.exe[3048473]: segfault at 0 ip 00000100000007c8 (rpc 00000100000007bc) sp 000007feff9ae841 error 1 in null-6.exe[10000000000+2000]
[344112.480537] show_signal_msg: 6 callbacks suppressed
[344112.480548] null-7.exe[3049096]: segfault at 0 ip 00000100000009a4 (rpc 000001000000099c) sp 000007feff872841 error 1 in null-7.exe[10000000000+2000]
[344112.870896] null-7.exe[3049245]: segfault at 0 ip 000001000000097c (rpc fff80001003232f4) sp 000007feffca28f1 error 1 in null-7.exe[10000000000+2000]
[344112.930126] null-1.exe[3049262]: segfault at 0 ip 00000100000007c8 (rpc fff80001003232f4) sp 000007feffe748f1 error 1 in null-1.exe[10000000000+2000]
[344113.259241] null-7.exe[3049388]: segfault at 0 ip 00000100000007c8 (rpc fff800010146b2f4) sp 000007feffa308f1 error 1 in null-7.exe[10000000000+2000]
[344113.430856] null-1.exe[3049471]: segfault at 0 ip 00000100000007c8 (rpc fff80001012132f4) sp 000007feff8188f1 error 1 in null-1.exe[10000000000+2000]
[344113.659819] null-7.exe[3049535]: segfault at 0 ip 00000100000007c8 (rpc fff80001012232f4) sp 000007feffc748f1 error 1 in null-7.exe[10000000000+2000]
[344114.028720] null-7.exe[3049666]: segfault at 0 ip 00000100000007c8 (rpc fff800010143f2f4) sp 000007feffcce8f1 error 1 in null-7.exe[10000000000+2000]
[344114.742445] null-7.exe[3049906]: segfault at 0 ip 00000100000007c8 (rpc fff800010139f2f4) sp 000007fefff1e8f1 error 1 in null-7.exe[10000000000+2000]
[344115.221908] null-7.exe[3050039]: segfault at 0 ip 00000100000007c8 (rpc fff80001012132f4) sp 000007feff9e28f1 error 1 in null-7.exe[10000000000+2000]
[344138.157288] pr59667.exe[3058622]: segfault at 0 ip 0000010000000dec (rpc 0000010000000dd0) sp 000007feffc30811 error 1 in pr59667.exe[10000000000+2000]
[344138.538207] pr59667.exe[3058824]: segfault at 0 ip 000001000000097c (rpc 0000010000000964) sp 000007feffc08831 error 1 in pr59667.exe[10000000000+2000]
[344138.923812] pr59667.exe[3058981]: segfault at 0 ip 00000100000007d4 (rpc 00000100000007bc) sp 000007feffe24831 error 1 in pr59667.exe[10000000000+2000]
[344139.319441] pr59667.exe[3059142]: segfault at 0 ip 00000100000007d4 (rpc 00000100000007bc) sp 000007feffc0e831 error 1 in pr59667.exe[10000000000+2000]
[344139.695777] pr59667.exe[3059326]: segfault at 0 ip 00000100000007d4 (rpc 00000100000007bc) sp 000007feffcb6831 error 1 in pr59667.exe[10000000000+2000]
[344140.382101] pr59667.exe[3059611]: segfault at 0 ip 00000100000007d4 (rpc 00000100000007bc) sp 000007feff8f6831 error 1 in pr59667.exe[10000000000+2000]
[344140.850526] pr59667.exe[3059870]: segfault at 0 ip 00000100000007d4 (rpc 00000100000007bc) sp 000007feffafc831 error 1 in pr59667.exe[10000000000+2000]
[344637.731279] pr101373.exe[3215045]: segfault at 0 ip 0000010000000bd0 (rpc 0000000000000000) sp 000007feffab0661 error 1 in pr101373.exe[10000000000+2000]
[344638.136444] pr101373.exe[3215109]: segfault at 0 ip 0000010000000b7c (rpc 0000000000000000) sp 000007feffff0671 error 1 in pr101373.exe[10000000000+2000]
[344638.570767] pr101373.exe[3215227]: segfault at 0 ip 0000010000000b74 (rpc 0000000000000000) sp 000007feff9a0671 error 1 in pr101373.exe[10000000000+2000]
[344639.009221] pr101373.exe[3215329]: segfault at 0 ip 0000010000000b74 (rpc 0000000000000000) sp 000007feffa4e671 error 1 in pr101373.exe[10000000000+2000]
[344639.429674] pr101373.exe[3215430]: segfault at 0 ip 0000010000000b70 (rpc 0000000000000000) sp 000007feffdac671 error 1 in pr101373.exe[10000000000+2000]
[344640.198052] pr101373.exe[3215631]: segfault at 0 ip 0000010000000b74 (rpc 0000000000000000) sp 000007feff9d4671 error 1 in pr101373.exe[10000000000+2000]
[344640.753925] pr101373.exe[3215807]: segfault at 0 ip 0000010000000b74 (rpc 0000000000000000) sp 000007feffe64671 error 1 in pr101373.exe[10000000000+2000]
[344780.681955] null-2.exe[3250247]: segfault at 0 ip 0000010000000af0 (rpc 0000010000000ae4) sp 000007feffa882e1 error 1 in null-2.exe[10000000000+2000]
[344781.062827] null-2.exe[3250322]: segfault at 0 ip 0000010000000af0 (rpc 0000010000000ae4) sp 000007fefff4e2e1 error 1 in null-2.exe[10000000000+2000]
[344781.516945] null-2.exe[3250408]: segfault at 0 ip 0000010000000af0 (rpc 0000010000000ae4) sp 000007feffd2a2e1 error 1 in null-2.exe[10000000000+2000]
[344781.941890] null-2.exe[3250535]: segfault at 0 ip 0000010000000af0 (rpc 0000010000000ae4) sp 000007feffd842e1 error 1 in null-2.exe[10000000000+2000]
[344782.397613] null-3.exe[3250663]: segfault at 0 ip 0000010000000b2c (rpc 0000010000000b20) sp 000007feffd2a2e1 error 1 in null-3.exe[10000000000+2000]
[344782.822533] null-3.exe[3250750]: segfault at 0 ip 0000010000000b2c (rpc 0000010000000b20) sp 000007feffd8c2e1 error 1 in null-3.exe[10000000000+2000]
[344783.246784] null-3.exe[3250834]: segfault at 0 ip 0000010000000b2c (rpc 0000010000000b20) sp 000007feffe522e1 error 1 in null-3.exe[10000000000+2000]
[344783.678958] null-3.exe[3250936]: segfault at 0 ip 0000010000000b2c (rpc 0000010000000b20) sp 000007feffdcc2e1 error 1 in null-3.exe[10000000000+2000]
[344784.097684] null-4.exe[3251038]: segfault at 0 ip 0000010000000a90 (rpc 0000010000000a84) sp 000007fefff382e1 error 1 in null-4.exe[10000000000+2000]
[344784.523369] null-4.exe[3251114]: segfault at 0 ip 0000010000000a90 (rpc 0000010000000a84) sp 000007fefff4a2e1 error 1 in null-4.exe[10000000000+2000]
[344785.806429] show_signal_msg: 2 callbacks suppressed
[344785.806441] null-5.exe[3251366]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffe322e1 error 1 in null-5.exe[10000000000+2000]
[344786.097863] null-1.exe[3251440]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007fefffb42e1 error 1 in null-1.exe[10000000000+2000]
[344786.221598] null-5.exe[3251469]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feff9b62e1 error 1 in null-5.exe[10000000000+2000]
[344786.488518] null-1.exe[3251513]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffd242e1 error 1 in null-1.exe[10000000000+2000]
[344786.645633] null-5.exe[3251564]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffa002e1 error 1 in null-5.exe[10000000000+2000]
[344786.897084] null-1.exe[3251628]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feff9fc2e1 error 1 in null-1.exe[10000000000+2000]
[344787.070756] null-5.exe[3251659]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffeda2e1 error 1 in null-5.exe[10000000000+2000]
[344787.286424] null-1.exe[3251693]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feff8c62e1 error 1 in null-1.exe[10000000000+2000]
[344787.482789] null-6.exe[3251736]: segfault at 0 ip 0000010000000ab4 (rpc 0000010000000aa4) sp 000007feffbd42e1 error 1 in null-6.exe[10000000000+2000]
[344787.700016] null-10.exe[3251774]: segfault at 0 ip 0000010000000b00 (rpc 0000010000000af4) sp 000007feffbf02d1 error 1 in null-10.exe[10000000000+2000]
[344790.935656] show_signal_msg: 14 callbacks suppressed
[344790.935669] null-8.exe[3252508]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffc422e1 error 1 in null-8.exe[10000000000+2000]
[344791.354911] null-8.exe[3252589]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffeca2e1 error 1 in null-8.exe[10000000000+2000]
[344791.759837] null-8.exe[3252664]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffa882e1 error 1 in null-8.exe[10000000000+2000]
[344792.205359] null-8.exe[3252758]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007fefff8a2e1 error 1 in null-8.exe[10000000000+2000]
[344792.602179] null-9.exe[3252855]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffd962e1 error 1 in null-9.exe[10000000000+2000]
[344793.034964] null-9.exe[3252929]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffa0e2e1 error 1 in null-9.exe[10000000000+2000]
[344793.470007] null-9.exe[3253027]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007fefffe82e1 error 1 in null-9.exe[10000000000+2000]
[344793.881336] null-9.exe[3253138]: segfault at 0 ip 0000010000000ab0 (rpc 0000010000000aa4) sp 000007feffa182e1 error 1 in null-9.exe[10000000000+2000]
[344797.340163] pr59667.exe[3254029]: segfault at 0 ip 0000010000000f4c (rpc 0000010000000f30) sp 000007feff8ba2b1 error 1 in pr59667.exe[10000000000+2000]
[344797.757029] pr59667.exe[3254115]: segfault at 0 ip 0000010000000f4c (rpc 0000010000000f30) sp 000007feffdc22b1 error 1 in pr59667.exe[10000000000+2000]
[344798.182111] pr59667.exe[3254210]: segfault at 0 ip 0000010000000f4c (rpc 0000010000000f30) sp 000007feffd882b1 error 1 in pr59667.exe[10000000000+2000]
[344798.616556] pr59667.exe[3254350]: segfault at 0 ip 0000010000000f4c (rpc 0000010000000f30) sp 000007feffab62b1 error 1 in pr59667.exe[10000000000+2000]
[347964.378939] 95989.exe[3564489]: segfault at 0 ip 0000000000000000 (rpc 0000000000102fc8) sp 000007feffd43261 error 1
[398408.552354] sunvdc: vdc_tx_trigger() failure, err=-11
[398408.552434] I/O error, dev vdiskc, sector 577825016 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
[398408.552949] XFS (dm-0): metadata I/O error in "xfs_buf_ioend+0x2a0/0x600 [xfs]" at daddr 0x2270e0f8 len 8 error 5
[465017.175818] sunvdc: vdc_tx_trigger() failure, err=-11
[465017.175897] I/O error, dev vdiskc, sector 72297320 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
[465017.175967] XFS (dm-0): metadata I/O error in "xfs_buf_ioend+0x2a0/0x600 [xfs]" at daddr 0x44f2368 len 8 error 5
[465017.191862] sunvdc: vdc_tx_trigger() failure, err=-11
[465017.191932] I/O error, dev vdiskc, sector 72297320 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
[465017.700101] XFS (dm-0): Failing async write on buffer block 0x44f2368. Retrying async write.
[595602.779423] systemd-journald[665]: Data hash table of /var/log/journal/2281684a63594a1a9ca6df41296a3d19/system.journal has a fill level at 75.0 (174764 of 233016 items, 83886080 file size, 479 bytes per hash table item), suggesting rotation.
[595602.779470] systemd-journald[665]: /var/log/journal/2281684a63594a1a9ca6df41296a3d19/system.journal: Journal header limits reached or header out-of-date, rotating.
[610054.244875] sunvdc: vdc_tx_trigger() failure, err=-11
[610054.244944] I/O error, dev vdiskc, sector 537208608 op 0x1:(WRITE) flags 0x1000 phys_seg 1 prio class 0
[610054.257147] XFS (dm-0): metadata I/O error in "xfs_buf_ioend+0x2a0/0x600 [xfs]" at daddr 0x20051f20 len 8 error 5
[653510.321346] hrtimer: interrupt took 1162 ns
[659470.109338] sunvdc: vdc_tx_trigger() failure, err=-11
[659470.109404] I/O error, dev vdiskc, sector 1169122880 op 0x1:(WRITE) flags 0x1000 phys_seg 4 prio class 0
[659470.124747] sunvdc: vdc_tx_trigger() failure, err=-11
[659470.124797] I/O error, dev vdiskc, sector 1169123264 op 0x1:(WRITE) flags 0x1000 phys_seg 4 prio class 0
[659470.140122] sunvdc: vdc_tx_trigger() failure, err=-11
[659470.140191] I/O error, dev vdiskc, sector 1169123776 op 0x1:(WRITE) flags 0x1000 phys_seg 4 prio class 0
[659470.143175] XFS (dm-0): metadata I/O error in "xfs_buf_ioend+0x2a0/0x600 [xfs]" at daddr 0x45af5e40 len 32 error 5

** Model information
cpu		: UltraSparc T5 (Niagara5)
fpu		: UltraSparc T5 integrated FPU
pmu		: niagara5
prom		: OBP 4.38.17 2019/01/25 08:22
type		: sun4v

** Loaded modules:
xfrm_user(E)
xfrm_algo(E)
crypto_user(E)
af_packet_diag(E)
unix_diag(E)
netlink_diag(E)
tcp_diag(E)
inet_diag(E)
tun(E)
binfmt_misc(E)
xfs(E)
camellia_sparc64(E)
pktcdvd(E)
des_sparc64(E)
libdes(E)
scsi_mod(E)
aes_sparc64(E)
md5_sparc64(E)
scsi_common(E)
cdrom(E)
sha512_sparc64(E)
n2_rng(E)
sha256_sparc64(E)
rng_core(E)
sha1_sparc64(E)
flash(E)
nft_ct(E)
nf_conntrack(E)
nf_defrag_ipv6(E)
nf_defrag_ipv4(E)
nft_counter(E)
nf_tables(E)
libcrc32c(E)
nfnetlink(E)
fuse(E)
configfs(E)
ip_tables(E)
x_tables(E)
autofs4(E)
ext4(E)
crc16(E)
mbcache(E)
jbd2(E)
crc32c_generic(E)
dm_mod(E)
crc32c_sparc64(E)
sunvnet(E)
sunvnet_common(E)
sunvdc(E)

** PCI devices:

** USB devices:
not available



*** sparc64-ext4-zeros.c
/*
 * Stress-test read(), and write() to detect a problem seen with sparc64+ext4.
 * Readers see zeros when they read concurrently with a write, even if the
 * file had no zero at that offset before or after the write.  This program
 * runs indefinitely and will print "mismatch ..." each time that happens.
 */

#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

/*
 * Size of block written in a loop and read in another process's loop.  Values
 * lower than about 128 don't reproduce the problem.
 */
#define BLOCK_SIZE 256
/* Offset of that block within file.  Probably any value works. */
#define OFFSET 0
/* Byte to write to every file offset.  Probably any nonzero value works. */
#define FILL_VALUE 1

static ssize_t
my_pread(int fd, void *buf, size_t count, off_t offset)
{
	if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
		perror("lseek");
	return read(fd, buf, count);
}

static ssize_t
my_pwrite(int fd, const void *buf, size_t count, off_t offset)
{
	if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
		perror("lseek");
	return write(fd, buf, count);
}

static int
reopen(void)
{
	int			fd = open("io-rectitude.tmp", O_RDWR);

	if (fd == -1)
		perror("open");
	return fd;
}

static void
writer(int fd)
{
	char		buf[BLOCK_SIZE];

	memset(buf, FILL_VALUE, sizeof(buf));
	for (;;)
	{
		close(fd);
		fd = reopen();
		errno = 0;
		if (my_pwrite(fd, buf, sizeof(buf), OFFSET) != sizeof(buf))
			perror("pwrite");	/* not a defect */
	}
}

static void
reader(int fd)
{
	for (;;)
	{
		unsigned char buf[BLOCK_SIZE];
		close(fd);
		fd = reopen();
		errno = 0;
		if (my_pread(fd, buf, sizeof(buf), OFFSET) != sizeof(buf))
			perror("pread");	/* not a defect */
		else
		{
			int			i;
			for (i = 0; i < sizeof(buf); ++i)
			{
				if (buf[i] != FILL_VALUE)
				{
					fprintf(stderr, "mismatch at %d: got %d, want %d\n",
							i, buf[i], FILL_VALUE);
					break;
				}
			}
		}
	}
}

int
main(int argc, char **argv)
{
	int			fd;
	unsigned char buf[OFFSET + BLOCK_SIZE];
	pid_t		pid;

	fd = open("io-rectitude.tmp", O_RDWR | O_CREAT | O_TRUNC, 0666);
	if (fd == -1)
	{
		perror("open");
		return 1;
	}
	/* initialize file contents */
	memset(buf, FILL_VALUE, sizeof(buf));
	if (write(fd, buf, sizeof(buf)) != sizeof(buf))
	{
		perror("write");
		return 1;
	}

	pid = fork();
	if (pid == -1)
	{
		perror("fork");
		return 1;
	}
	else if (pid == 0)
		writer(fd);
	else
		reader(fd);

	return 0;					/* unreachable */
}


-- System Information:
Debian Release: bookworm/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'unstable'), (1, 'experimental')
Architecture: sparc64

Kernel: Linux 5.16.0-1-sparc64-smp (SMP w/64 CPU threads)
Kernel taint flags: TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages linux-image-5.16.0-1-sparc64-smp depends on:
ii  initramfs-tools [linux-initramfs-tool]  0.140
ii  kmod                                    29-1
ii  linux-base                              4.8

Versions of packages linux-image-5.16.0-1-sparc64-smp recommends:
ii  apparmor             3.0.3-6
ii  firmware-linux-free  20200122-1

Versions of packages linux-image-5.16.0-1-sparc64-smp suggests:
pn  debian-kernel-handbook  <none>
pn  fdutils                 <none>
ii  grub-ieee1275           2.06-2
pn  linux-doc-5.16          <none>

Versions of packages linux-image-5.16.0-1-sparc64-smp is related to:
pn  firmware-amd-graphics     <none>
pn  firmware-atheros          <none>
pn  firmware-bnx2             <none>
pn  firmware-bnx2x            <none>
pn  firmware-brcm80211        <none>
pn  firmware-cavium           <none>
pn  firmware-intel-sound      <none>
pn  firmware-intelwimax       <none>
pn  firmware-ipw2x00          <none>
pn  firmware-ivtv             <none>
pn  firmware-iwlwifi          <none>
pn  firmware-libertas         <none>
pn  firmware-linux-nonfree    <none>
pn  firmware-misc-nonfree     <none>
pn  firmware-myricom          <none>
pn  firmware-netxen           <none>
pn  firmware-qlogic           <none>
pn  firmware-realtek          <none>
pn  firmware-samsung          <none>
pn  firmware-siano            <none>
pn  firmware-ti-connectivity  <none>
pn  xen-hypervisor            <none>

-- debconf-show failed


Reply to: