OSDN Git Service

android-x86/external-e2fsprogs.git
9 years agoMerge branch 'maint' into next
Theodore Ts'o [Wed, 1 Oct 2014 12:36:28 +0000 (08:36 -0400)]
Merge branch 'maint' into next

9 years agoe2fsprogs: add large_file to base mkfs features
Eric Sandeen [Wed, 1 Oct 2014 12:33:54 +0000 (08:33 -0400)]
e2fsprogs: add large_file to base mkfs features

large_file (> 2G) support has been around since at least kernel 2.4;
mkfs of any sufficiently large filesystem sets it "accidentally"
when the resize inode exceeds 2G.  This leaves very small
filesystems lacking the feature, which potentially changes
their behavior & codepaths the first time a > 2G file gets
written.

There's really no reason to be making fresh filesystems which
strive to keep compatibility with 10 year old kernels; just
enable large_file at mkfs time.  This is particularly obvious
for ext4 fielsystems, which set huge_file by default, but not
necessarily large_file.

If old-kernel compatibility is desired, mke2fs.conf can be
modified locally to remove the feature.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: use ~0UL instead of -1UL to avoid static checker warnings
Theodore Ts'o [Sun, 21 Sep 2014 19:36:57 +0000 (15:36 -0400)]
libext2fs: use ~0UL instead of -1UL to avoid static checker warnings

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoMCONFIG: allow developers to override CFLAGS
Theodore Ts'o [Sun, 21 Sep 2014 19:35:21 +0000 (15:35 -0400)]
MCONFIG: allow developers to override CFLAGS

Move other C compiler flags to ALL_CFLAGS so that CFLAGS only controls
the debugging and optimization flags.  This allows a developer to
build with "make CFLAGS=-g" in order to compile w/o optimization.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomisc: if dlopen() is available, use it to load the libmagic library
Theodore Ts'o [Sun, 21 Sep 2014 05:25:58 +0000 (01:25 -0400)]
misc: if dlopen() is available, use it to load the libmagic library

This prevents the libmagic library from being a hard dependency; if
it's not there, we can simply do without it.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
9 years agomisc: use libmagic when libblkid can't identify something
Darrick J. Wong [Sat, 13 Sep 2014 22:12:46 +0000 (15:12 -0700)]
misc: use libmagic when libblkid can't identify something

If we're using check_plausibility() to try to identify something that
obviously isn't an ext* filesystem and libblkid doesn't know what it
is, try libmagic instead.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomisc: add plausibility checks to debugfs/tune2fs/dumpe2fs/e2fsck
Darrick J. Wong [Sat, 13 Sep 2014 22:12:39 +0000 (15:12 -0700)]
misc: add plausibility checks to debugfs/tune2fs/dumpe2fs/e2fsck

If any of these utilities detect a bad superblock magic, call
check_plausibility to see if blkid can identify the passed-in argument
as something else (xfs, partition, etc.) in the hopes of catching a
user error.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomisc: move check_plausibility into a separate file
Darrick J. Wong [Fri, 19 Sep 2014 17:10:21 +0000 (13:10 -0400)]
misc: move check_plausibility into a separate file

Move check_plausibility() into a separate file so that various
programs can use it without having to declare useless global variables
that the util.c functions seem to require.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agodumpe2fs: provide a machine-readable group-only mode
Darrick J. Wong [Fri, 19 Sep 2014 16:16:44 +0000 (12:16 -0400)]
dumpe2fs: provide a machine-readable group-only mode

Spit out just the group descriptor data in a machine readable format.
This is most useful for testing and scripting purposes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoext2fs: add readahead method to improve scanning
Andreas Dilger [Fri, 19 Sep 2014 16:15:21 +0000 (12:15 -0400)]
ext2fs: add readahead method to improve scanning

Add a readahead method for prefetching ranges of disk blocks.  This is
useful for inode table scanning, and other large contiguous ranges of
blocks, and may also prove useful for random block prefetch, since it
will allow reordering of the IO without waiting synchronously for the
reads to complete.

It is currently using the posix_fadvise(POSIX_FADV_WILLNEED)
interface, as this proved most efficient during our testing.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agodebugfs: manage needs_recover feature when messing with the journal
Darrick J. Wong [Fri, 19 Sep 2014 06:01:43 +0000 (02:01 -0400)]
debugfs: manage needs_recover feature when messing with the journal

Set the needs_recover incompat feature when debugfs writes journal
transactions so that we actually replay the journal contents at the
next mount.

Likewise, clear it if we successfully recover the journal.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: use ext2fs_get_mem() instad of ext2fs_get_memalign()
Theodore Ts'o [Fri, 19 Sep 2014 05:30:04 +0000 (01:30 -0400)]
e2fsck: use ext2fs_get_mem() instad of ext2fs_get_memalign()

There is no reason to request a aligned buffer in
check_{inode,block}_bitmap, and this will cause failures for dietlibc,
which doesn't have support for posix_memalign() or any other way to
request an aligned memory allocation.  Fortunately, this is only
needed in very few places where direct I/O is required.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoFix build failures due to missing $(SYSLIBS)
Theodore Ts'o [Fri, 19 Sep 2014 05:05:14 +0000 (01:05 -0400)]
Fix build failures due to missing $(SYSLIBS)

Two link lines were missing $(SYSLIBS), which is needed for dietlibc.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: fix build under dietlibc
Theodore Ts'o [Fri, 19 Sep 2014 04:48:24 +0000 (00:48 -0400)]
e2fsck: fix build under dietlibc

The asm_types.h file needs to include stdio.h and stdlib.h in order to
get integer types included.  So add those includes into jfs_user.h to
avoid a build faliure under dietlibc.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agocreate_inode: don't indiscriminately #include "nls-enable.h"
Theodore Ts'o [Fri, 19 Sep 2014 04:46:41 +0000 (00:46 -0400)]
create_inode: don't indiscriminately #include "nls-enable.h"

The create_inode.h header file is pulled in by debugfs, which is not
internationalized.  It had no business pulling in nls-enable.h; that
header file should only be used in specific .c files that support
internationalization.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoMerge branch 'maint' into next
Theodore Ts'o [Fri, 19 Sep 2014 04:28:46 +0000 (00:28 -0400)]
Merge branch 'maint' into next

9 years agomisc: fix build breakage with configure --disable-uuidd --enable-profile
Theodore Ts'o [Fri, 19 Sep 2014 04:26:56 +0000 (00:26 -0400)]
misc: fix build breakage with configure --disable-uuidd --enable-profile

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoconfigure: disable uuidd by default if libuuid is disabled
Theodore Ts'o [Fri, 19 Sep 2014 04:26:26 +0000 (00:26 -0400)]
configure: disable uuidd by default if libuuid is disabled

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomke2fs: don't depend on <linux/version.h>
Theodore Ts'o [Fri, 19 Sep 2014 04:04:24 +0000 (00:04 -0400)]
mke2fs: don't depend on <linux/version.h>

Define the KERNEL_VERSION macro explicitly instead of using
<linux/version.h>, since it's not available when using dietlibc.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomisc: fix Coverity complaints
Darrick J. Wong [Fri, 19 Sep 2014 01:47:38 +0000 (21:47 -0400)]
misc: fix Coverity complaints

Fix a few problems that Coverity picked up with error handling.

Fixes-Coverity-Bug: 1239278
Fixes-Coverity-Bug: 1239279
Fixes-Coverity-Bug: 1239280
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: free bh when descriptor block checksum fails
Darrick J. Wong [Fri, 19 Sep 2014 01:46:10 +0000 (21:46 -0400)]
e2fsck: free bh when descriptor block checksum fails

Free the buffer head if the journal descriptor block fails checksum
verification.  This has been patched before (see "e2fsck: free bh on
csum verify error in do_one_pass") but apparently the patch was never
committed to jbd2 in the kernel, so when we resync'd the recovery code
with 3.16, the bug came back.  Sigh.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
9 years agoe2fsck: fix sliding the directory block down on bigalloc
Darrick J. Wong [Fri, 19 Sep 2014 01:29:21 +0000 (21:29 -0400)]
e2fsck: fix sliding the directory block down on bigalloc

If we find a hole in a directory on a bigalloc filesystem, we need to
obey the cluster alignment rules when collapsing the gap to avoid
later complaints.

Specifically, the calculation of the new logical cluster number was
incorrect, and we need to ensure that the logical cluster alignment
respects the physical cluster alignment, since we've concluded that
the extent's logical block number is wrong.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: offer to clear overlapping extents
Darrick J. Wong [Fri, 19 Sep 2014 01:29:19 +0000 (21:29 -0400)]
e2fsck: offer to clear overlapping extents

If in the course of iterating extents we find that an otherwise
valid-seeming second extent maps the same logical blocks as a
previously examined first extent, offer to clear the duplicate
mapping.

The test for this is already in f_extents.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoMerge branch 'maint' into next
Theodore Ts'o [Fri, 19 Sep 2014 01:28:59 +0000 (21:28 -0400)]
Merge branch 'maint' into next

9 years agomisc: zero s_jnl_blocks when adding journal online or removing external journal
Darrick J. Wong [Fri, 19 Sep 2014 01:24:26 +0000 (21:24 -0400)]
misc: zero s_jnl_blocks when adding journal online or removing external journal

Erase s_jnl_blocks when removing an external journal, or adding an
internal journal online.  We can't add the backup for the internal
journal because we have no good way to get the indirect block or ETB
addresses, so the best we can do is hope that the user runs e2fsck,
which will correct that.  We are motivated to erase during external
journal removal to state emphatically that there's no journal.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: thomas_reardon@hotmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agofix build with configure --disable-uuid --disable-blkid --enable-profile
Theodore Ts'o [Fri, 19 Sep 2014 01:11:33 +0000 (21:11 -0400)]
fix build with configure --disable-uuid --disable-blkid --enable-profile

We need to make sure PROFILED_LIBUUID and PROFILED_LIBBLKID are
defined when we are using the system uuid and blkid libraries.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoDon't clear BUILD_CFLAGS and BUILD_LDFLAGS when cross-compiling
Michael Forney [Mon, 15 Sep 2014 18:30:00 +0000 (14:30 -0400)]
Don't clear BUILD_CFLAGS and BUILD_LDFLAGS when cross-compiling

Signed-off-by: Michael Forney <forney@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolib/ext2fs: fix Makefile to avoid a build splat when building without VPATH
Theodore Ts'o [Thu, 11 Sep 2014 23:15:22 +0000 (19:15 -0400)]
lib/ext2fs: fix Makefile to avoid a build splat when building without VPATH

When building in the source tree, the order of the includes caused the
compiling of debugfs/journal.c while in the lib/ext2fs directory to
find the version in lib/ext2fs instead of the desired version in
e2fsck/jfs_user.h.

We need to eventually get rid of this whole mess and have only one
jfs_user.h and build the journal-related functions once in an internal
library which is used only by e2fsprogs progams.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reported-by: "Darrick J. Wong" <darrick.wong@oracle.com>
9 years agolibext2fs: check ea value offset when loading
Darrick J. Wong [Thu, 11 Sep 2014 20:17:44 +0000 (13:17 -0700)]
libext2fs: check ea value offset when loading

When reading extended attributes, check e_value_offs to make sure that
it starts in the value area and not the name area.  The attached test
case image will crash the kernel if it is mounted and you append more
than 4096 bytes of data to /a, due to insufficient validation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: expand root dir if linking l+f fails
Darrick J. Wong [Thu, 11 Sep 2014 19:48:04 +0000 (12:48 -0700)]
e2fsck: expand root dir if linking l+f fails

If there isn't space in the root directory to add the lost+found
entry, try expanding the root directory before failing the fsck.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: ignore badblocks if it says badblocks inode is bad
Darrick J. Wong [Thu, 11 Sep 2014 19:44:49 +0000 (12:44 -0700)]
e2fsck: ignore badblocks if it says badblocks inode is bad

If the badblocks list says that the badblocks inode is bad, it's quite
likely that badblocks is broken.  Worse yet, if the root inode is in
the same block as the badblocks inode (likely since they're adjacent),
the filesystem becomes unfixable because pass3 notices the bad root
inode and exits.

So... if we encounter this case, just kill the badblocks inode.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotune2fs: always check disable_uninit_bg() return code
Darrick J. Wong [Thu, 11 Sep 2014 19:43:33 +0000 (12:43 -0700)]
tune2fs: always check disable_uninit_bg() return code

Enhance disable_uninit_bg() to return error codes -- if something goes
wrong, we want to flag the FS as needing a fsck and exit.  Mr. Reardon
discovered that tune2fs -O ^metadata_csum on a FS with a corrupt
bitmap would leave the FS in a weird state.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: test e2fsck recovery of corrupt descriptor blocks
Darrick J. Wong [Thu, 11 Sep 2014 19:31:41 +0000 (12:31 -0700)]
tests: test e2fsck recovery of corrupt descriptor blocks

Test e2fsck' ability to deal with (a) corrupt descriptor block
checksum; (b) obviously bad journal block tid; and (c) corrupt journal
blocks.  These should exercise the journal recovery infinite loop
bugfix earlier in this patchset.

This test also ensures that (with metadata_csum and journal_csum_v3)
journal replay continues past a corrupt journal block.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: test recovery from an external journal
Darrick J. Wong [Mon, 8 Sep 2014 23:14:01 +0000 (16:14 -0700)]
tests: test recovery from an external journal

Add a couple of tests to verify that writing to and recovering from
an external journal work properly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: test e2fsck recovery with broken commit blocks
Darrick J. Wong [Mon, 8 Sep 2014 23:13:48 +0000 (16:13 -0700)]
tests: test e2fsck recovery with broken commit blocks

Test e2fsck' recovery of commit blocks with (a) only a corrupt
checksum and (b) an obviously incorrect tid.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: test e2fsck recovery of corrupt revoke blocks
Darrick J. Wong [Mon, 8 Sep 2014 23:13:41 +0000 (16:13 -0700)]
tests: test e2fsck recovery of corrupt revoke blocks

Test e2fsck' ability to deal with (a) revoke blocks with a bad
checksum and (b) revoke blocks with an obviously bad block number.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: test how e2fsck recovers from corrupt journal superblocks
Darrick J. Wong [Mon, 8 Sep 2014 23:13:35 +0000 (16:13 -0700)]
tests: test how e2fsck recovers from corrupt journal superblocks

Test e2fsck' ability to deal with corrupt journal superblock checksum
and a bad magic.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: test recovery of 32 and 64-bit journals with the v2 checksum
Darrick J. Wong [Mon, 8 Sep 2014 23:13:28 +0000 (16:13 -0700)]
tests: test recovery of 32 and 64-bit journals with the v2 checksum

Add tests to ensure that we know how to recover journals with the
csum_v2 feature set.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: write and replay blocks with the old journal checksum
Darrick J. Wong [Mon, 8 Sep 2014 23:13:22 +0000 (16:13 -0700)]
tests: write and replay blocks with the old journal checksum

Test that we can write and replay transactions with the old journal
checksum algorithm.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: test writing and recovering 32bit csum_v3 journals
Darrick J. Wong [Mon, 8 Sep 2014 23:13:14 +0000 (16:13 -0700)]
tests: test writing and recovering 32bit csum_v3 journals

Simple tests for the 32bit journal transaction creation code when
journal and metadata_csum are enabled.  We test the following:

(a) writing and replaying transactions with multiple
    descriptor blocks
(b) same, but with multiple revoke blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: test writing and recovering 64bit csum_v3 journals
Darrick J. Wong [Mon, 8 Sep 2014 23:13:08 +0000 (16:13 -0700)]
tests: test writing and recovering 64bit csum_v3 journals

Simple tests for the 64bit journal transaction creation code when
journal and metadata_csum are enabled.   We test writing (bad) block
bitmaps out through the journal and replaying them via fsck, with a
few twists:

(a) All bitmaps are committed (fs errors reported)
(b) All the bitmap blocks are revoked (no errors)
(c) The transaction is never committed (no errors)
(d) Same as (a), but debugfs gets to do the replay.

We also test:

(a) writing and replaying transactions with multiple
    descriptor blocks
(b) same, but with multiple revoke blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: test writing and recovering checksum-free 32/64bit journals
Darrick J. Wong [Mon, 8 Sep 2014 23:13:01 +0000 (16:13 -0700)]
tests: test writing and recovering checksum-free 32/64bit journals

Simple tests for the journal transaction creation code.   We test
writing (bad) block bitmaps out through the journal and replaying them
via fsck, with a few twists:

(a) All bitmaps are committed (fs errors reported)
(b) All the bitmap blocks are revoked (no errors)
(c) The transaction is never committed (no errors)
(d) Same as (a), but debugfs gets to do the replay.

We also test:

(a) writing and replaying transactions with multiple
    descriptor blocks
(b) same, but with multiple revoke blocks.
(c) adding the 64bit flag to a journal

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agodebugfs: add the ability to write transactions to the journal
Darrick J. Wong [Mon, 8 Sep 2014 23:12:54 +0000 (16:12 -0700)]
debugfs: add the ability to write transactions to the journal

Extend debugfs with the ability to create transactions and replay the
journal.  This will eventually be used to test kernel recovery and
metadata_csum recovery.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: fix minor errors in journal handling
Darrick J. Wong [Mon, 8 Sep 2014 23:12:48 +0000 (16:12 -0700)]
e2fsck: fix minor errors in journal handling

The journal superblock's s_sequence field seems to track the tid of
the tail (oldest) transaction in the log.  Therefore, when we release
the journal, set the s_sequence to the tail_sequence, because setting
it to the transaction_sequence means that we're setting the tid to
that of the head of the log.  Granted, for replay these two are
usually the same (and s_start == 0 anyway) so thus far we've gotten
lucky and nobody noticed.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agodebugfs: create journal handling routines
Darrick J. Wong [Mon, 8 Sep 2014 23:12:42 +0000 (16:12 -0700)]
debugfs: create journal handling routines

Create a journal.c with routines adapted from e2fsck/journal.c to
handle opening and closing the journal, and setting up the
descriptors, and all that.  Unlike e2fsck's versions which try to
identify and fix problems, the routines here have no way to repair
anything.

[ Modified by tytso to fold debugfs/jfs_user.h into e2fsck/jfs_user.h,
  so we don't have to copy recovery.c and revoke.c into debugfs. --tytso ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomisc: zero s_jnl_blocks when removing internal journal
Darrick J. Wong [Mon, 8 Sep 2014 23:12:35 +0000 (16:12 -0700)]
misc: zero s_jnl_blocks when removing internal journal

When we're removing the internal journal (broken journal, turning it
off, or adding an external journal), zero s_jnl_blocks so that they
can't be picked up by accident later.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agodumpe2fs: display external journal feature flags
Darrick J. Wong [Mon, 8 Sep 2014 23:12:28 +0000 (16:12 -0700)]
dumpe2fs: display external journal feature flags

Display the feature flags of an external journal.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotune2fs: explicitly disallow tuning of journal devices
Darrick J. Wong [Mon, 8 Sep 2014 23:12:21 +0000 (16:12 -0700)]
tune2fs: explicitly disallow tuning of journal devices

Spit out a more specific error if someone tries to modify an
external journal device.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: detect and repair external journal superblock checksum errors
Darrick J. Wong [Mon, 8 Sep 2014 23:12:15 +0000 (16:12 -0700)]
e2fsck: detect and repair external journal superblock checksum errors

Verify the (ext4) superblock checksum of an external journal device
and prompt to correct the checksum if nothing else is wrong with the
superblock.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomke2fs: allow creation of journal device with superblock checksum
Darrick J. Wong [Mon, 8 Sep 2014 23:12:08 +0000 (16:12 -0700)]
mke2fs: allow creation of journal device with superblock checksum

Enable mke2fs to create an external journal device with a superblock
checksum.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: write_journal_inode should check iterate return value
Darrick J. Wong [Mon, 8 Sep 2014 23:12:02 +0000 (16:12 -0700)]
libext2fs: write_journal_inode should check iterate return value

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>
9 years agomisc: don't return ENOMEM if we run out of disk space
Darrick J. Wong [Mon, 8 Sep 2014 23:11:55 +0000 (16:11 -0700)]
misc: don't return ENOMEM if we run out of disk space

If there aren't enough blocks in the FS to allocate all of the
hugefiles, return ENOSPC, not ENOMEM.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: report bad magic over bad sb checksum
Darrick J. Wong [Mon, 8 Sep 2014 23:11:49 +0000 (16:11 -0700)]
libext2fs: report bad magic over bad sb checksum

We don't want ext2fs_open2() to report bad sb checksum on something
that's not even an ext* superblock.  This apparently happens pretty
easily if we try to open an XFS filesystem.  Thus, make it so that a
bad magic number code always trumps the sb checksum error code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck/debugfs: fix descriptor block size handling errors with journal_csum
Darrick J. Wong [Mon, 8 Sep 2014 23:11:43 +0000 (16:11 -0700)]
e2fsck/debugfs: fix descriptor block size handling errors with journal_csum

It turns out that there are some serious problems with the on-disk
format of journal checksum v2.  The foremost is that the function to
calculate descriptor tag size returns sizes that are too big.  This
causes alignment issues on some architectures and is compounded by the
fact that some parts of jbd2 use the structure size (incorrectly) to
determine the presence of a 64bit journal instead of checking the
feature flags.  These errors regrettably lead to the journal
corruption reported by Mr. Reardon.

Therefore, introduce journal checksum v3, which enlarges the
descriptor block tag format to allow for full 32-bit checksums of
journal blocks, fix the journal tag function to return the correct
sizes, and fix the jbd2 recovery code to use feature flags to
determine 64bitness.

Add a few function helpers so we don't have to open-code quite so
many pieces.

Switching to a 16-byte block size was found to increase journal size
overhead by a maximum of 0.1%, to convert a 32-bit journal with no
checksumming to a 32-bit journal with checksum v3 enabled.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoMerge branch 'maint' into next
Theodore Ts'o [Thu, 11 Sep 2014 16:40:43 +0000 (12:40 -0400)]
Merge branch 'maint' into next

Conflicts:
debugfs/debugfs.c
e2fsck/Makefile.in
lib/ext2fs/Makefile.in
tests/test_config

9 years agoMerge remote-tracking branch 'origin/maint' into maint
Theodore Ts'o [Thu, 11 Sep 2014 16:26:27 +0000 (12:26 -0400)]
Merge remote-tracking branch 'origin/maint' into maint

9 years agoe2fsck: notice when the realloc of dir_info fails
Theodore Ts'o [Thu, 11 Sep 2014 16:24:07 +0000 (12:24 -0400)]
e2fsck: notice when the realloc of dir_info fails

If the reallocation of dir_info fails, we will eventually cause e2fsck
to fail with an internal error.  So if the realloc fails, print a
message and bail out with a fatal error early when at the time of the
reallocation failure.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agocompile_et: Allow user to override ET_DIR
Michael Forney [Fri, 5 Sep 2014 22:43:07 +0000 (15:43 -0700)]
compile_et: Allow user to override ET_DIR

Signed-off-by: Michael Forney <forney@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoApply LDFLAGS when building tests
Michael Forney [Fri, 5 Sep 2014 22:42:32 +0000 (15:42 -0700)]
Apply LDFLAGS when building tests

Signed-off-by: Michael Forney <forney@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotests: Add to LD_LIBRARY_PATH instead of overriding
Michael Forney [Fri, 5 Sep 2014 22:35:13 +0000 (15:35 -0700)]
tests: Add to LD_LIBRARY_PATH instead of overriding

Signed-off-by: Michael Forney <forney@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agodebugfs: add better error checking when printing extended attributes
Theodore Ts'o [Fri, 29 Aug 2014 18:20:21 +0000 (14:20 -0400)]
debugfs: add better error checking when printing extended attributes

Check to make sure the length of the name and value fields in the
extended attribute don't result in overrun the bounds of the inode.

Addresses-Coverity-Bug: #709517

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoMerge tag 'v1.42.12' into next
Theodore Ts'o [Fri, 29 Aug 2014 15:38:33 +0000 (11:38 -0400)]
Merge tag 'v1.42.12' into next

v1.42.12

Conflicts:
version.h

9 years agoUpdate release notes, etc. for final 1.42.12 release
Theodore Ts'o [Fri, 29 Aug 2014 12:58:27 +0000 (08:58 -0400)]
Update release notes, etc. for final 1.42.12 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update vi.po (from translationproject.org)
Trần Ngọc Quân [Fri, 29 Aug 2014 12:46:03 +0000 (08:46 -0400)]
po: update vi.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update uk.po (from translationproject.org)
Yuri Chornoivan [Fri, 29 Aug 2014 12:46:03 +0000 (08:46 -0400)]
po: update uk.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update sv.po (from translationproject.org)
Göran Uddeborg [Fri, 29 Aug 2014 12:46:03 +0000 (08:46 -0400)]
po: update sv.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update pl.po (from translationproject.org)
Jakub Bogusz [Fri, 29 Aug 2014 12:46:03 +0000 (08:46 -0400)]
po: update pl.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update nl.po (from translationproject.org)
Benno Schulenberg [Fri, 29 Aug 2014 12:46:03 +0000 (08:46 -0400)]
po: update nl.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update fr.po (from translationproject.org)
Samuel Thibault [Fri, 29 Aug 2014 12:46:02 +0000 (08:46 -0400)]
po: update fr.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update cs.po (from translationproject.org)
Petr Pisar [Fri, 29 Aug 2014 12:46:02 +0000 (08:46 -0400)]
po: update cs.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomke2fs: complain if bigalloc and hugefiles_align_disk is incompatible
Theodore Ts'o [Wed, 27 Aug 2014 13:27:54 +0000 (09:27 -0400)]
mke2fs: complain if bigalloc and hugefiles_align_disk is incompatible

If the starting partition offset is incompatible with the bigalloc
cluster size, complain and exit, instead of creating a file which
would have a logical to physical block mapping which breaks the
cluster alignment requirement.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: fix infinite loop when recovering corrupt journal blocks
Darrick J. Wong [Wed, 27 Aug 2014 03:44:04 +0000 (23:44 -0400)]
e2fsck: fix infinite loop when recovering corrupt journal blocks

When recovering the journal, don't fall into an infinite loop if we
encounter a corrupt journal block.  Instead, just skip the block and
proceed with the full filesystem fsck.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: resync jbd2 revoke code from Linux 3.16
Darrick J. Wong [Wed, 27 Aug 2014 03:39:58 +0000 (23:39 -0400)]
e2fsck: resync jbd2 revoke code from Linux 3.16

Synchronize e2fsck's copy of revoke.c with the kernel's copy in
fs/jbd2.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: resync jbd2 recovery code from Linux 3.16
Darrick J. Wong [Wed, 27 Aug 2014 03:32:14 +0000 (23:32 -0400)]
e2fsck: resync jbd2 recovery code from Linux 3.16

Synchronize e2fsck's copy of recovery.c with the kernel's copy in
fs/jbd2.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agocontrib: add script to help resync journal code with kernel
Darrick J. Wong [Wed, 27 Aug 2014 03:32:05 +0000 (23:32 -0400)]
contrib: add script to help resync journal code with kernel

Add a script that handles (most) of the code massaging necessary to resync
{recovery,revoke}.c from the Linux kernel into e2fsprogs.

Usage: jbd2-resync.sh linux/fs/jbd2/revoke.c e2fsprogs/e2fsck/revoke.c

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsprogs.pot: update POT-Creation-Date
Theodore Ts'o [Tue, 26 Aug 2014 20:34:24 +0000 (16:34 -0400)]
e2fsprogs.pot: update POT-Creation-Date

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: fix spelling error (strage vs storage)
Theodore Ts'o [Tue, 26 Aug 2014 13:40:06 +0000 (09:40 -0400)]
e2fsck: fix spelling error (strage vs storage)

Reported-by: Philipp Thomas <pth@suse.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsprogs: add supported file attributes to ext4.5 manpage
Eric Sandeen [Tue, 26 Aug 2014 01:02:18 +0000 (21:02 -0400)]
e2fsprogs: add supported file attributes to ext4.5 manpage

The chattr(1) manpage now refers users to filesystem-specific
manpages for details on supported attributes, so add those to
ext4.5.

I've left out oddities like being able to set the compressed
or no-tail-packing flags, or setting data journaling on ext2.

That behavior seems like a bug, not a feature.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoMerge branch 'maint' into next
Theodore Ts'o [Mon, 25 Aug 2014 22:37:37 +0000 (18:37 -0400)]
Merge branch 'maint' into next

Conflicts:
RELEASE-NOTES
debian/changelog
version.h

9 years agotests/d_inline_dump: remove version dependency in the expected output
Theodore Ts'o [Mon, 25 Aug 2014 22:04:42 +0000 (18:04 -0400)]
tests/d_inline_dump: remove version dependency in the expected output

Also add the convenience macro $CLEAN_OUTPUT in test_config which can
be used to run the "sed -e $cmd_dir/filter.sed" command to clean up
e2fsprogs command output before comparing with the expected golden
output.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoInterim updates of release notes, etc. in preparation for 1.42.12 release
Theodore Ts'o [Mon, 25 Aug 2014 14:30:53 +0000 (10:30 -0400)]
Interim updates of release notes, etc. in preparation for 1.42.12 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update sv.po (from translationproject.org)
Göran Uddeborg [Mon, 25 Aug 2014 14:05:34 +0000 (10:05 -0400)]
po: update sv.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update fr.po (from translationproject.org)
Samuel Thibault [Mon, 25 Aug 2014 14:05:34 +0000 (10:05 -0400)]
po: update fr.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update es.po (from translationproject.org)
Antonio Ceballos [Mon, 25 Aug 2014 14:05:34 +0000 (10:05 -0400)]
po: update es.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update cs.po (from translationproject.org)
Petr Pisar [Mon, 25 Aug 2014 14:05:34 +0000 (10:05 -0400)]
po: update cs.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomke2fs: improve the error message when a non-existent file is specified
Theodore Ts'o [Mon, 25 Aug 2014 03:54:37 +0000 (23:54 -0400)]
mke2fs: improve the error message when a non-existent file is specified

If the user does not specify the file system size, and the file does
not exist, give an error message like this:

   The file /tmp/foo.img does not exist and no size was specified.

instead of this:

    Creating regular file /tmp/foo.img
    mke2fs: Device size reported to be zero.  Invalid partition specified, or
    partition table wasn't reread after running fdisk, due to
    a modified partition being busy and in use.  You may need to reboot
    to re-read your partition table.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomke2fs.8.in: explain how the fs-size parameter is interpreted
Theodore Ts'o [Mon, 25 Aug 2014 03:53:33 +0000 (23:53 -0400)]
mke2fs.8.in: explain how the fs-size parameter is interpreted

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoresize2fs: clarify the size of blocks in resize2fs's messages
Theodore Ts'o [Mon, 25 Aug 2014 03:23:41 +0000 (23:23 -0400)]
resize2fs: clarify the size of blocks in resize2fs's messages

Addresses-Debian-Bug: #758029

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoresize2fs.8.in: clarify when on-line resizing is supported
Theodore Ts'o [Mon, 25 Aug 2014 02:40:43 +0000 (22:40 -0400)]
resize2fs.8.in: clarify when on-line resizing is supported

Addresses-Debian-Bug: #726760

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agodumpe2fs: complain if extra arguments are given on the command line
Theodore Ts'o [Mon, 25 Aug 2014 02:31:03 +0000 (22:31 -0400)]
dumpe2fs: complain if extra arguments are given on the command line

Addresses-Debian-Bug: #758074

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: on BE, re-swap everything after a damaged dirent so salvage works correctly
Darrick J. Wong [Mon, 25 Aug 2014 02:02:49 +0000 (22:02 -0400)]
e2fsck: on BE, re-swap everything after a damaged dirent so salvage works correctly

On big-endian systems, if the dirent swap routine finds a rec_len that
it doesn't like, it continues processing the block as if rec_len == 8.
This means that the name field gets byte swapped, which means that
salvage will not detect the correct name length (unless the name has a
length that's an exact multiple of four bytes), and it'll discard the
entry (unnecessarily) and the rest of the dirent block.  Therefore,
swap the rest of the block back to disk order, run salvage, and
re-swap anything after the salvaged dirent.

The test case for this is f_inlinedata_repair if you run it on a BE
system.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: fix problems with LE<->BE conversions on BE platforms
Darrick J. Wong [Mon, 25 Aug 2014 02:01:36 +0000 (22:01 -0400)]
libext2fs: fix problems with LE<->BE conversions on BE platforms

Fix more problems that I found when testing on ppc64:

- Inode swap cut and paste error leads to immutable inodes being
  detected as inlinedata inodes, leading to e2fsck incorrectly barfing
  on i_block[] contents.

- Superblock csum/verify must be aware of the fs->super byte order
  when checking for metadata_csum feature flag.  (Hint: in _openfs(),
  fs->super is in LE order for the first csum verification)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: byteswap inode when performing the sanity scan
Darrick J. Wong [Mon, 25 Aug 2014 02:00:56 +0000 (22:00 -0400)]
libext2fs: byteswap inode when performing the sanity scan

On BE platforms, we need to swap the inode bytes after doing the
checksum verification but before looking at i_blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fuzz: fix pwrite64/pwrite usage
Darrick J. Wong [Sun, 24 Aug 2014 23:55:42 +0000 (19:55 -0400)]
e2fuzz: fix pwrite64/pwrite usage

Select pwrite64 or pwrite depending on what autoconf finds.  This
makes e2fuzz find a suitable pwrite variant regardless of platform.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomisc: fix gcc warnings
Darrick J. Wong [Sun, 24 Aug 2014 16:16:23 +0000 (12:16 -0400)]
misc: fix gcc warnings

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: create inlinedata symlinks
Darrick J. Wong [Sun, 24 Aug 2014 01:55:46 +0000 (21:55 -0400)]
libext2fs: create inlinedata symlinks

Add to ext2fs_symlink the ability to create inline data symlinks.

[ Modified by tytso to add more logging to the test script ]

Suggested-by: Pu Hou <houpu.hp@alibaba-inc.com>
Cc: Pu Hou <houpu.hp@alibaba-inc.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agodebugfs: fix set_inode_field block[IND|DIND|TIND]
Theodore Ts'o [Tue, 19 Aug 2014 12:27:59 +0000 (08:27 -0400)]
debugfs: fix set_inode_field block[IND|DIND|TIND]

After we determine that we can't parse the array value as an integer,
we need to restore the square brackets to the field name, so that we
can find a match with block[IND], block[DIND], and block[TIND] in the
inode field table.

Reported-by: Jun He <jhe@cs.wisc.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoMerge branch 'maint' into next
Theodore Ts'o [Fri, 15 Aug 2014 23:01:24 +0000 (19:01 -0400)]
Merge branch 'maint' into next

10 years agofilefrag: fix extent count calculation when using FIBMAP
Theodore Ts'o [Wed, 13 Aug 2014 19:59:20 +0000 (15:59 -0400)]
filefrag: fix extent count calculation when using FIBMAP

The extent count calculation works correctly with the FIBMAP ioctl in
verbose (-v) mode, but without the verbose option, the calculation was
broken because we weren't properly updating the fm_ext data structures
in non-verbose mode.

Addresses-Launchpad-Bug: #1356496

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agotests: convert use of md5sum to crcsum
Theodore Ts'o [Tue, 12 Aug 2014 18:37:19 +0000 (14:37 -0400)]
tests: convert use of md5sum to crcsum

The following tests were using md5sum: i_e2image, u_mke2fs, and
u_tune2fs.  Convert them to use crcsum for better portability (not all
environments have md5sum; some might have sha1sum instead :-)

For our purposes crcsum is quite sufficient.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>