mirror of
https://github.com/versity/scoutfs.git
synced 2026-04-28 17:06:55 +00:00
There's filefrag already, and that works, but, it's output is very inconsistent between various OS release versions, and it has already meant that we'd needed to adjust tests to account for these little but insignificant changes. A lot more work than useful. It's even more changed in el9. This adds `scoutfs get-fiemap FILE` and prints out block extent info with flags that we care about as an abbreviated letter: U for Unwritten, L for Last, and O for Unknown (as in, "offline"). The -P/--physical and -L/--logical options turn off logical or physical offset display, in case you only want to see the offsets in either units. You can pass -b/--byte to display offsets and lengths in byte values. The block size will then be obtained from fstat() of the queried file (4096 for scoutfs). I've removed all uses of filefrag from our scoutfs tests. Xfstests still calls it but their internal diff takes care of that issue. Where needed and appropriate, the tests are adjusted so that the output of `scoutfs get-fiemap` is as close as it can to what it used to be, so that reading the test results allows the quick view of what might have been going wrong. There are some output strings I have not bothered to update because there's no real value to updating every output string to match, and we just adjust the golden file accordingly. Signed-off-by: Auke Kok <auke.kok@versity.com>
79 lines
2.0 KiB
Bash
79 lines
2.0 KiB
Bash
#
|
|
# Test correctness of the setattr_more ioctl.
|
|
#
|
|
|
|
t_require_commands scoutfs touch mkdir rm stat mknod
|
|
|
|
FILE="$T_D0/file"
|
|
|
|
echo "== 0 data_version arg fails"
|
|
touch "$FILE"
|
|
scoutfs setattr -V 0 -s 1 "$FILE" 2>&1 | t_filter_fs
|
|
rm "$FILE"
|
|
|
|
echo "== args must specify size and offline"
|
|
touch "$FILE"
|
|
scoutfs setattr -V 1 -o -s 0 "$FILE" 2>&1 | t_filter_fs
|
|
rm "$FILE"
|
|
|
|
echo "== only works on regular files"
|
|
mkdir "$T_D0/dir"
|
|
scoutfs setattr -V 1 -s 1 "$T_D0/dir" 2>&1 | t_filter_fs
|
|
rmdir "$T_D0/dir"
|
|
mknod "$T_D0/char" c 1 3
|
|
scoutfs setattr -V 1 -s 1 "$T_D0/char" 2>&1 | t_filter_fs
|
|
rm "$T_D0/char"
|
|
|
|
echo "== non-zero file size fails"
|
|
echo contents > "$FILE"
|
|
scoutfs setattr -V 1 -s 1 "$FILE" 2>&1 | t_filter_fs
|
|
rm "$FILE"
|
|
|
|
echo "== non-zero file data_version fails"
|
|
touch "$FILE"
|
|
truncate -s 1M "$FILE"
|
|
truncate -s 0 "$FILE"
|
|
scoutfs setattr -V 1 -o -s 1 "$FILE" 2>&1 | t_filter_fs
|
|
rm "$FILE"
|
|
|
|
echo "== large size is set"
|
|
touch "$FILE"
|
|
scoutfs setattr -V 1 -s 578437695752307201 "$FILE" 2>&1 | t_filter_fs
|
|
stat -c "%s" "$FILE"
|
|
rm "$FILE"
|
|
|
|
echo "== large data_version is set"
|
|
touch "$FILE"
|
|
scoutfs setattr -V 578437695752307201 -s 1 "$FILE" 2>&1 | t_filter_fs
|
|
scoutfs stat -s data_version "$FILE"
|
|
rm "$FILE"
|
|
|
|
echo "== large ctime is set"
|
|
touch "$FILE"
|
|
# only doing 32bit sec 'cause stat gets confused
|
|
scoutfs setattr -t 67305985.999999999 -V 1 -s 1 "$FILE" 2>&1 | t_filter_fs
|
|
TZ=GMT stat -c "%z" "$FILE"
|
|
rm "$FILE"
|
|
|
|
echo "== large offline extents are created"
|
|
touch "$FILE"
|
|
scoutfs setattr -V 1 -o -s $((10007 * 4096)) "$FILE" 2>&1 | t_filter_fs
|
|
scoutfs get-fiemap "$FILE"
|
|
rm "$FILE"
|
|
|
|
# had a bug where we were creating extents that were too long
|
|
echo "== correct offline extent length"
|
|
touch "$FILE"
|
|
scoutfs setattr -V 1 -o -s 4000000000 "$FILE" 2>&1 | t_filter_fs
|
|
scoutfs stat -s offline_blocks "$FILE"
|
|
rm "$FILE"
|
|
|
|
# Do not fail if data_version is unset - the unset `0` value should not
|
|
# be passed down to attr_x handling code which will -EINVAL on that.
|
|
echo "== omitting data_version should not fail"
|
|
touch "$FILE"
|
|
scoutfs setattr -s 0 -t 1725670311.0 -r 1725670311.0 "$FILE"
|
|
rm "$FILE"
|
|
|
|
t_pass
|