only supports clearing this filesystem feature.
.TP
.B mmp
-Enable or disable multiple mount protection(MMP) feature. MMP helps to protect
-the filesystem from being multiply mounted and is useful in shared storage
-environments.
+Enable or disable multiple mount protection (MMP) feature. MMP helps to
+protect the filesystem from being multiply mounted and is useful in
+shared storage environments.
.TP
.B sparse_super
Limit the number of backup superblocks to save space on large filesystems.
--- /dev/null
+disable MMP with tune2fs after e2fsck killed
--- /dev/null
+FSCK_OPT=-yf
+
+TMPFILE=test.img
+rm -f $test_name.failed $test_name.ok
+> $TMPFILE
+
+stat -f $TMPFILE | grep -q "Type: tmpfs"
+if [ $? == 0 ]; then
+ rm -f $TMPFILE
+ echo "skipped for tmpfs (no O_DIRECT support)"
+ return 0
+fi
+
+echo "make the test image ..." > $test_name.log
+$MKE2FS -q -F -o Linux -b 1024 -O mmp -E mmp_update_interval=1 $TMPFILE 100 >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "mke2fs -O mmp failed" > $test_name.failed
+ echo "failed"
+ return $status
+fi
+
+# this will cause debugfs to create the $test_name.mark file once it has
+# passed the MMP startup, then continue reading input until it is killed
+MARKFILE=$test_name.new
+rm -f $MARKFILE
+echo "set mmp sequence to EXT2_MMP_SEQ_FSCK..." >> $test_name.log
+( { echo dump_mmp; echo "dump_inode <2> $MARKFILE"; cat /dev/zero; } |
+ $DEBUGFS -w $TMPFILE >> $test_name.log 2>&1 & ) > /dev/null 2>&1 &
+echo "wait until debugfs has started ..." >> $test_name.log
+while [ ! -e $MARKFILE ]; do
+ sleep 1
+done
+rm -f $MARKFILE
+echo "kill debugfs abruptly (simulates e2fsck failure) ..." >> $test_name.log
+killall -9 debugfs >> $test_name.log
+
+
+echo "e2fsck (should fail mmp_seq = EXT2_MMP_SEQ_FSCK) ..." >> $test_name.log
+$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" == 0 ] ; then
+ echo "e2fsck with MMP as EXT2_MMP_SEQ_FSCK ran!" > $test_name.failed
+ echo "failed"
+ return 1
+fi
+
+echo "clear mmp_seq with tune2fs ..." >> $test_name.log
+$TUNE2FS -f -E clear_mmp $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "tune2fs clearing EXT2_MMP_SEQ_FSCK failed" > $test_name.failed
+ echo "failed"
+ return 1
+fi
+
+echo "run e2fsck again (should pass with clean mmp_seq) ..." >> $test_name.log
+$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "e2fsck after clearing EXT2_MMP_SEQ_FSCK failed"> $test_name.failed
+ echo "failed"
+ return $status
+fi
+
+echo "ok"
+rm -f $TMPFILE
--- /dev/null
+Superblock has invalid MMP magic. Fix? yes
+
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 11/16 files (0.0% non-contiguous), 22/100 blocks
+Exit status is 0
--- /dev/null
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 11/16 files (0.0% non-contiguous), 22/100 blocks
+Exit status is 0
--- /dev/null
+repair MMP when it is corrupted
--- /dev/null
+FSCK_OPT=-yf
+
+TMPFILE=test.img
+rm -f $test_name.failed $test_name.ok
+> $TMPFILE
+
+stat -f $TMPFILE | grep -q "Type: tmpfs"
+if [ $? == 0 ] ; then
+ rm -f $TMPFILE
+ echo "skipped for tmpfs (no O_DIRECT support)"
+ return 0
+fi
+
+echo "make the test image ..." > $test_name.log
+$MKE2FS -q -F -o Linux -b 1024 -O mmp -E mmp_update_interval=1 $TMPFILE 100 >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "mke2fs -O mmp failed" > $test_name.failed
+ echo "failed"
+ return $status
+fi
+
+# create a corrupted image
+echo "modify the mmp sequence ..." >> $test_name.log
+$DEBUGFS -w -R "set_mmp_value magic 0x12345678" $TMPFILE >> $test_name.log 2>&1
+
+SKIP_GUNZIP=true
+. $cmd_dir/run_e2fsck
--- /dev/null
+Filesystem label=
+OS type: Linux
+Block size=2048 (log=1)
+Fragment size=2048 (log=1)
+Stride=0 blocks, Stripe width=0 blocks
+16384 inodes, 32768 blocks
+1638 blocks (5.00%) reserved for the super user
+First data block=0
+Maximum filesystem blocks=33554432
+2 block groups
+16384 blocks per group, 16384 fragments per group
+8192 inodes per group
+Superblock backups stored on blocks:
+ 16384
+
+Allocating group tables: 0/2\b\b\b1/2\b\b\b \b\b\bdone
+Writing inode tables: 0/2\b\b\b1/2\b\b\b \b\b\bdone
+Multiple mount protection is enabled with update interval 5 seconds.
+Writing superblocks and filesystem accounting information: 0/2\b\b\b1/2\b\b\b \b\b\bdone
+
+Filesystem features: ext_attr resize_inode dir_index filetype mmp sparse_super
+
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 11/16384 files (0.0% non-contiguous), 1105/32768 blocks
+Exit status is 0
+
+Filesystem volume name: <none>
+Last mounted on: <not available>
+Filesystem magic number: 0xEF53
+Filesystem revision #: 1 (dynamic)
+Filesystem features: ext_attr resize_inode dir_index filetype mmp sparse_super
+Default mount options: (none)
+Filesystem state: clean
+Errors behavior: Continue
+Filesystem OS type: Linux
+Inode count: 16384
+Block count: 32768
+Reserved block count: 1638
+Free blocks: 31663
+Free inodes: 16373
+First block: 0
+Block size: 2048
+Fragment size: 2048
+Reserved GDT blocks: 31
+Blocks per group: 16384
+Fragments per group: 16384
+Inodes per group: 8192
+Inode blocks per group: 512
+Mount count: 0
+Check interval: 15552000 (6 months)
+Reserved blocks uid: 0
+Reserved blocks gid: 0
+First inode: 11
+Inode size: 128
+Default directory hash: half_md4
+MMP block number: 557
+MMP update interval: 5
+
+
+Group 0: (Blocks 0-16383)
+ Primary superblock at 0, Group descriptors at 1-1
+ Reserved GDT blocks at 2-32
+ Block bitmap at 33 (+33), Inode bitmap at 34 (+34)
+ Inode table at 35-546 (+35)
+ 15826 free blocks, 8181 free inodes, 2 directories
+ Free blocks: 558-16383
+ Free inodes: 12-8192
+Group 1: (Blocks 16384-32767)
+ Backup superblock at 16384, Group descriptors at 16385-16385
+ Reserved GDT blocks at 16386-16416
+ Block bitmap at 16417 (+33), Inode bitmap at 16418 (+34)
+ Inode table at 16419-16930 (+35)
+ 15837 free blocks, 8192 free inodes, 0 directories
+ Free blocks: 16931-32767
+ Free inodes: 8193-16384
--- /dev/null
+DESCRIPTION="enable MMP during mke2fs"
+FS_SIZE=65536
+MKE2FS_DEVICE_SECTSIZE=2048
+export MKE2FS_DEVICE_SECTSIZE
+TMPFILE=test.img
+> $TMPFILE
+stat -f $TMPFILE | grep -q "Type: tmpfs"
+if [ $? == 0 ]; then
+ rm -f $TMPFILE
+ echo "skipped for tmpfs (no O_DIRECT support)"
+ return 0
+fi
+MKE2FS_OPTS="-O mmp"
+. $cmd_dir/run_mke2fs
+unset MKE2FS_DEVICE_SECTSIZE
--- /dev/null
+enable MMP using tune2fs
--- /dev/null
+FSCK_OPT=-yf
+
+TMPFILE=test.img
+rm -f $test_name.failed $test_name.ok
+> $TMPFILE
+
+stat -f $TMPFILE | grep -q "Type: tmpfs"
+if [ $? == 0 ] ; then
+ rm -f $TMPFILE
+ echo "skipped for tmpfs (no O_DIRECT support)"
+ return 0
+fi
+
+$MKE2FS -q -F -o Linux -b 1024 $TMPFILE 100 > $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "mke2fs failed" > $test_name.failed
+ echo "failed"
+ return $status
+fi
+
+$TUNE2FS -O mmp -E mmp_update_interval=1 $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "tune2fs -O mmp failed with $status" > $test_name.failed
+ echo "failed"
+ return $status
+fi
+
+$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1
+status=$?
+if [ "$status" = 0 ] ; then
+ echo "ok"
+ touch $test_name.ok
+else
+ echo "e2fsck with MMP enabled failed with $status" > $test_name.failed
+ echo "failed"
+ return $status
+fi
+rm -f $TMPFILE
--- /dev/null
+disable MMP using tune2fs
--- /dev/null
+FSCK_OPT=-yf
+
+TMPFILE=test.img
+rm -f $test_name.failed $test_name.ok
+> $TMPFILE
+
+stat -f $TMPFILE | grep -q "Type: tmpfs"
+if [ $? == 0 ]; then
+ rm -f $TMPFILE
+ echo "skipped for tmpfs (no O_DIRECT support)"
+ return 0
+fi
+
+$MKE2FS -q -F -o Linux -b 1024 -O mmp $TMPFILE 100 > $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "mke2fs -O mmp failed" > $test_name.failed
+ echo "failed"
+ return $status
+fi
+
+$TUNE2FS -O ^mmp $TMPFILE > $test_name.log 2>&1
+status=$?
+if [ "$status" != 0 ] ; then
+ echo "tune2fs -O ^mmp failed" > $test_name.failed
+ echo "failed"
+ return $status
+fi
+
+$FSCK $FSCK_OPT $TMPFILE > $test_name.log 2>&1
+status=$?
+if [ "$status" = 0 ] ; then
+ echo "ok"
+ touch $test_name.ok
+else
+ echo "e2fsck after MMP disable failed" > $test_name.failed
+ echo "failed"
+ return $status
+fi
+rm -f $TMPFILE