btrfs-progs: fsck-tests: verify 'btrfs check --repair' fixes corrupted nlink field
PATCH 1/1 btrfs-progs: fsck-tests: verify 'btrfs check --repair' fixes corrupted nlink field
Signed-off-by Lakshmipathi.G <[email protected]>
--- tests/fsck-tests/026-check-inode-link/test.sh | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tests/fsck-tests/026-check-inode-link/test.sh
tests/fsck-tests/026-check-inode-link/test.sh new file +34 -0
@@ -0,0 +1,34 @@ +#!/bin/bash + +source $TOP/tests/common + +check_prereq btrfs-corrupt-block +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper +prepare_test_dev 512M + +# verify that 'btrfs check --repair' fixes corrupted inode nlink field. +test_inode_nlink_field() +{ + run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV + + run_check_mount_test_dev + run_check $SUDO_HELPER touch $TEST_MNT/test_nlink.txt + + # find inode_item id + inode_item=`stat -c%i $TEST_MNT/test_nlink.txt` + run_check_umount_test_dev + + # corrupt nlink field of inode object + run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -i $inode_item \ + -f nlink $TEST_DEV + + $SUDO_HELPER $TOP/btrfs check $TEST_DEV &>> $RESULTS && \ + _fail "btrfs check failed to detect nlink corruption" + run_check $SUDO_HELPER $TOP/btrfs check --repair $TEST_DEV + run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV +} + +test_inode_nlink_field
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines
apply anymore, but I'm expecting some more changes to it so please adapt it to the new file
Not sure what went wrong, will test the next patch with git apply and send it.
Quoted 3 lines
I prefer '
inode_number' or simple 'ino' for the variable name.
Okay, will use inode_number.
Quoted 7 lines
tests/fsck-tests/026-check-inode-link/test.sh line 31
Quoted 5 lines
tests/fsck-tests/026-check-inode-link/test.sh new file +5
-0+ + $SUDO_HELPER $TOP/btrfs check $TEST_DEV &>> $RESULTS && \ + _fail "btrfs check failed to detect nlink corruption" + run_check $SUDO_HELPER $TOP/btrfs check --repair $TEST_DEV + run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEVWhat about using
check_image()here?
I didn't know about check_image(), looks like above 3 lines can be replaced with check_image. Will make the change.
Quoted 4 lines
Thanks,
Qu
Cheers.
Lakshmipathi.G