Re: [PATCH v3 07/13] generic/1228: Add atomic write multi-fsblock O_[D]SYNC tests

Ojaswin Mujoo
2025-08-10T09:41:57Z

On Wed, Jul 23, 2025 at 07:54:23AM -0700, Darrick J. Wong wrote:
> On Wed, Jul 23, 2025 at 07:23:58PM +0530, Ojaswin Mujoo wrote:
> > On Thu, Jul 17, 2025 at 09:35:10AM -0700, Darrick J. Wong wrote:
> >
> > <snip>
> >
> > > > +verify_atomic_write() {
> > > > + if [[ "$1" == "shutdown" ]]
> > > > + then
> > > > + local do_shutdown=1
> > > > + fi
> > > > +
> > > > + test $bytes_written -eq $awu_max || _fail "atomic write len=$awu_max assertion failed"
> > > > +
> > > > + if [[ $do_shutdown -eq "1" ]]
> > > > + then
> > > > + echo "Shutting down filesystem" >> $seqres.full
> > > > + _scratch_shutdown >> $seqres.full
> > > > + _scratch_cycle_mount >>$seqres.full 2>&1 || _fail "remount failed for Test-3"
> > > > + fi
> > > > +
> > > > + check_data_integrity
> > > > +}
> > > > +
> > > > +mixed_mapping_test() {
> > > > + prep_mixed_mapping
> > > > +
> > > > + echo "+ + Performing O_DSYNC atomic write from 0 to $awu_max" >> $seqres.full
> > > > + bytes_written=$($XFS_IO_PROG -dc "pwrite -DA -V1 -b $awu_max 0 $awu_max" $testfile | \
> > > > + grep wrote | awk -F'[/ ]' '{print $2}')
> > > > +
> > > > + verify_atomic_write $1
> > >
> > > The shutdown happens after the synchronous write completes? If so, then
> > > what part of recovery is this testing?
> > >
> > > --D
> >
> > Right, it is mostly inspired by [1] where sometimes isize update could
> > be lost after dio completion. Although this might not exactly be
> > affected by atomic writes, we added it here out of caution.
> >
> > [1] https://lore.kernel.org/fstests/434beffaf18d39f898518ea9eb1cea4548e77c3a.1695383715.git.ritesh.list@gmail.com/
>
> Ah, so we're racing with background log flush then. Would it improve
> the potential failure detection rate to call shutdown right after the
> pwrite, e.g.
>
> $XFS_IO_PROG -dxc "pwrite -DA..." -c 'shutdown' $testfile
>
> It can take a few milliseconds to walk down the bash functions and
> fork/exec another child process.

Sounds good, I can make that change.

Thanks!
>
> --D
>
> > > > +}
> > > > +
> >