Whamcloud - gitweb
libext2fs: write_journal_inode should check iterate return value
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Sep 2014 23:12:02 +0000 (16:12 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Sep 2014 16:40:54 +0000 (12:40 -0400)
When creating a journal inode, check the return value from
block_iterate3() because otherwise we fail to capture errors such as
being unable to allocate an extent tree block, which leads to e2fsck
creating broken journals.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/mkjournal.c
tests/f_jnl_etb_alloc_fail/expect.1 [new file with mode: 0644]
tests/f_jnl_etb_alloc_fail/expect.2 [new file with mode: 0644]
tests/f_jnl_etb_alloc_fail/image.gz [new file with mode: 0644]
tests/f_jnl_etb_alloc_fail/name [new file with mode: 0644]

index 96b6d36..85f86bf 100644 (file)
@@ -365,6 +365,8 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
 
        retval = ext2fs_block_iterate3(fs, journal_ino, BLOCK_FLAG_APPEND,
                                       0, mkjournal_proc, &es);
+       if (retval)
+               goto errout;
        if (es.err) {
                retval = es.err;
                goto errout;
diff --git a/tests/f_jnl_etb_alloc_fail/expect.1 b/tests/f_jnl_etb_alloc_fail/expect.1
new file mode 100644 (file)
index 0000000..8f4ebbb
--- /dev/null
@@ -0,0 +1,31 @@
+Superblock has an invalid journal (inode 8).
+Clear? yes
+
+*** ext3 journal has been deleted - filesystem is now ext2 only ***
+
+Superblock has_journal flag is clear, but a journal is present.
+Clear? yes
+
+Pass 1: Checking inodes, blocks, and sizes
+Journal inode is not in use, but contains data.  Clear? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -(32--33) -(35--49) -(83--511) -(513--1087) -1089
+Fix? yes
+
+Free blocks count wrong for group #0 (0, counted=1022).
+Fix? yes
+
+Free blocks count wrong (0, counted=1022).
+Fix? yes
+
+Recreate journal? yes
+
+Creating journal (1024 blocks): Could not allocate block in ext2 filesystem: while trying to create journal
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/128 files (8.3% non-contiguous), 2048/2048 blocks
+Exit status is 1
diff --git a/tests/f_jnl_etb_alloc_fail/expect.2 b/tests/f_jnl_etb_alloc_fail/expect.2
new file mode 100644 (file)
index 0000000..69859dd
--- /dev/null
@@ -0,0 +1,20 @@
+Pass 1: Checking inodes, blocks, and sizes
+Journal inode is not in use, but contains data.  Clear? yes
+
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Block bitmap differences:  -(32--33) -(35--49) -(83--511) -(513--1087) -1089
+Fix? yes
+
+Free blocks count wrong for group #0 (0, counted=1022).
+Fix? yes
+
+Free blocks count wrong (0, counted=1022).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/128 files (8.3% non-contiguous), 1026/2048 blocks
+Exit status is 1
diff --git a/tests/f_jnl_etb_alloc_fail/image.gz b/tests/f_jnl_etb_alloc_fail/image.gz
new file mode 100644 (file)
index 0000000..4cf2dbf
Binary files /dev/null and b/tests/f_jnl_etb_alloc_fail/image.gz differ
diff --git a/tests/f_jnl_etb_alloc_fail/name b/tests/f_jnl_etb_alloc_fail/name
new file mode 100644 (file)
index 0000000..7651fdc
--- /dev/null
@@ -0,0 +1 @@
+can't allocate extent tree block while recreating journal