]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
tune2fs: kill external journal if device not found
authorAndreas Dilger <adilger@whamcloud.com>
Sat, 24 Sep 2011 17:17:05 +0000 (13:17 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 24 Sep 2011 18:34:47 +0000 (14:34 -0400)
Continue to remove the external journal device even if the device
cannot be found.

Add a test to verify that the journal device/UUID are actually removed
from the superblock.  It isn't possible to use a real journal device
for testing without loopback devices and such (it must be a block device)
and this would invite complexity and failures in the regression test.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/tune2fs.c
tests/t_ext_jnl_rm/script [new file with mode: 0644]

index 3e1269717237e3ba14b19aba7c07601844af2921..d0d44c8a5c2545d4310d2ade98426106d87411f7 100644 (file)
@@ -184,7 +184,7 @@ static void remove_journal_device(ext2_filsys fs)
                journal_path =
                        ext2fs_find_block_device(fs->super->s_journal_dev);
                if (!journal_path)
-                       return;
+                       goto no_valid_journal;
        }
 
 #ifdef CONFIG_TESTIO_DEBUG
@@ -251,7 +251,9 @@ static void remove_journal_device(ext2_filsys fs)
 
 no_valid_journal:
        if (commit_remove_journal == 0) {
-               fputs(_("Journal NOT removed\n"), stderr);
+               fputs(_("Cannot locate journal device. It was NOT removed\n"
+                       "Use -f option to remove missing journal device.\n"),
+                     stderr);
                exit(1);
        }
        fs->super->s_journal_dev = 0;
diff --git a/tests/t_ext_jnl_rm/script b/tests/t_ext_jnl_rm/script
new file mode 100644 (file)
index 0000000..d7217b6
--- /dev/null
@@ -0,0 +1,28 @@
+printf "remove missing external journal device: "
+OUT=$test_name.log
+
+dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
+
+echo mke2fs -q -F -o Linux -b 1024 $TMPFILE >> $OUT
+$MKE2FS -q -F -o Linux -I 128 -b 1024 $TMPFILE >> $OUT 2>&1
+
+echo "debugfs add journal device/UUID" >> $OUT
+$DEBUGFS -w -f - $TMPFILE <<- EOF >> $OUT 2>&1
+       feature has_journal
+       ssv journal_dev 0x9999
+       ssv journal_uuid 1db3f677-6832-4adb-bafc-8e4059c30a33
+EOF
+
+echo "tune2fs -f -O ^has_journal $TMPFILE" >> $OUT
+$TUNE2FS -f -O ^has_journal $TMPFILE >> $OUT 2>&1
+$DUMPE2FS -h $TMPFILE >> $OUT 2>&1
+if [ "$(grep 'Journal UUID:' $OUT)" ]; then
+       rm -f $test_name.ok
+       mv $test_name.log $test_name.failed
+       echo "failed"
+else
+       echo "ok"
+       mv $test_name.log $test_name.ok
+       rm -f $test_name.failed
+fi
+rm -f $TMPFILE