blob: dc997c68b93b24462695af587a9d1714cee3ec7f [file] [log] [blame]
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2020 Facebook. All Rights Reserved.
#
# FS QA Test 172
#
# Validate that without no-holes we do not get an i_size that is after a gap in
# the file extents on disk. This is fixed by the following patches
#
# btrfs: use the file extent tree infrastructure
# btrfs: replace all uses of btrfs_ordered_update_i_size
#
. ./common/preamble
_begin_fstest auto quick log replay recoveryloop
_cleanup()
{
cd /
_log_writes_cleanup &> /dev/null
rm -f $tmp.*
}
. ./common/filter
. ./common/dmlogwrites
_require_scratch
_require_log_writes
_require_xfs_io_command "sync_range"
# block-group-tree requires no-holes
_require_btrfs_no_block_group_tree
_log_writes_init $SCRATCH_DEV
_log_writes_mkfs "-O ^no-holes" >> $seqres.full 2>&1
# There's not a straightforward way to commit the transaction without also
# flushing dirty pages, so shorten the commit interval to 1 so we're sure to get
# a commit with our broken file
_log_writes_mount -o commit=1
$XFS_IO_PROG -f -c "pwrite 0 5m" $SCRATCH_MNT/file | _filter_xfs_io
$XFS_IO_PROG -f -c "sync_range -abw 4m 1m" $SCRATCH_MNT/file | _filter_xfs_io
# Now wait for a transaction commit to happen, wait 2x just to be super sure
sleep 2
_log_writes_unmount
_log_writes_remove
cur=$(_log_writes_find_next_fua 0)
echo "cur=$cur" >> $seqres.full
while [ ! -z "$cur" ]; do
_log_writes_replay_log_range $cur $SCRATCH_DEV >> $seqres.full
# We only care about the fs consistency, so just run fsck, we don't have
# to mount the fs to validate it
_check_scratch_fs
cur=$(_log_writes_find_next_fua $(($cur + 1)))
done
# success, all done
status=0
exit