Whamcloud - gitweb
tools/e2fsprogs.git
12 years agoMerge branch 'maint' into next
Theodore Ts'o [Sun, 19 Aug 2012 22:11:46 +0000 (18:11 -0400)]
Merge branch 'maint' into next

12 years agoutil: respect HAVE_MALLOC_H
Mike Frysinger [Sat, 18 Aug 2012 12:17:41 +0000 (12:17 +0000)]
util: respect HAVE_MALLOC_H

Most places respect this define, but this one doesn't.

Reported-by: Dmitri Bogomolov <4glitch@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsprogs: fix spelling of 'filesystme' in debugfs help
Bryce Harrington [Sat, 18 Aug 2012 00:10:46 +0000 (17:10 -0700)]
e2fsprogs: fix spelling of 'filesystme' in debugfs help

Signed-off-by: Bryce Harrington <bryce@canonical.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotests: remove unused temporary files for MMP tests
Andreas Dilger [Tue, 14 Aug 2012 15:33:24 +0000 (11:33 -0400)]
tests: remove unused temporary files for MMP tests

The MMP tests need to be run on a real disk instead of tmpfs, since
the MMP block access is using O_DIRECT.  As such, they create their
own test files in the local testing directory instead of using the
temporary file created in /tmp by the test_one script.  Delete the
tempfs file before clobbering TMPFILE, otherwise it will leave the
unused file in /tmp after the test is completed.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibe2p/libext2fs: add EXT4_INLINE_DATA_FL flag
Zheng Liu [Tue, 7 Aug 2012 17:56:47 +0000 (13:56 -0400)]
libe2p/libext2fs: add EXT4_INLINE_DATA_FL flag

[ Also teach libe2p's print_flags() function to display this flag so
  that lsattr will allow us to see whether a file has inline data or not.
  --tytso ]

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: rename INCOMPAT_INLINEDATA to INCOMPAT_INLINE_DATA
Theodore Ts'o [Tue, 7 Aug 2012 17:53:22 +0000 (13:53 -0400)]
libext2fs: rename INCOMPAT_INLINEDATA to INCOMPAT_INLINE_DATA

This is what the patches from Zhen Liu uses, so let's make this change
now to keep things easier.  INCOMPAT_INLINE_DATA also looks better
IMHO.  :-)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: refactor the quota feature flag in the supported flags mask
Theodore Ts'o [Tue, 7 Aug 2012 17:46:13 +0000 (13:46 -0400)]
libext2fs: refactor the quota feature flag in the supported flags mask

Handle EXT4_FEATURE_RO_COMPAT_QUOTA the same way we handle INCOMPAT
features, so we don't have to have two definitions for
EXT2_LIB_FEATURE_RO_COMPAT_SUPP depending on whether or not
CONFIG_QUOTA is enabled or not.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoMerge branch 'maint' into next
Theodore Ts'o [Wed, 15 Aug 2012 20:43:55 +0000 (16:43 -0400)]
Merge branch 'maint' into next

12 years agoext4: fix rehashing of the lost+found directory
Theodore Ts'o [Wed, 15 Aug 2012 17:00:14 +0000 (13:00 -0400)]
ext4: fix rehashing of the lost+found directory

Commit 07307114dea didn't correctly handle the lost+found directory
when it added support for metadata checksums.  First of all,
e2fsck_get_lost_and_found() assumed that the inode_dir_map bitmap was
initialized, and it wasn't when it was called earlier by a change in
that commit.  Secondly, it's important that lost+found dirctory is
processed in case its directory checksums are incorrect, but should
preserve any empty dirctory blocks so there space available for e2fsck
to reconnect any orphan inodes.

Fix these problems, to fix test failures: f_holedir2 and f_rehash_dir

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoe2fsck: fix potential segv when handling a read error in a superblock
Jim Keniston [Mon, 6 Aug 2012 22:46:03 +0000 (18:46 -0400)]
e2fsck: fix potential segv when handling a read error in a superblock

When passed a negative count (indicating a byte count rather than
a block count) e2fsck_handle_read_error() treats the data as a full
block, causing unix_write_blk64() (which can handle negative counts
just fine) to try to write too much.  Given a faulty block device,
this resulted in a SEGV when unix_write_blk64() read past the bottom
of the stack copying the data to cache.  (check_backup_super_block ->
unix_read_blk64 -> raw_read_blk -> e2fsck_handle_read_error)

Reported-by: Alex Friedman <alexfr@il.ibm.com>
Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
Signed-off-by: Dan Streetman <ddstreet@us.ibm.com>
Reviewed-by: Mingming Cao <mcao@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoPut ELF_OTHER_LIBS in the right place for the linker
Theodore Ts'o [Sat, 4 Aug 2012 20:56:55 +0000 (16:56 -0400)]
Put ELF_OTHER_LIBS in the right place for the linker

Commit a7c17431b9 attempted to fix a problem where the system
libraries might get used instead of local libraries for things like
-lcom_err.  It tried to accomplish this by moving $(ELF_OTHER_LIBS) to
before $(LDFLAGS).

Unfortunately, this was the wrong fix; $(ELF_OTHER_LIBS) *MUST* be
after the object files, or the linker might not pull in the necessary
library and not include it into the DT_NEEDED section of the shared
library.  The proper fix is to add a -L$(LIB) before $(LDFLAGS), and
then remove the -L option from all of the ELF_OTHER_LIBS definitions
in the library Makefiles.

Addresses-Sourceforge-Bug: #3554345

Cc: Olivier Blin <olivier.blin@softathome.com>
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agodebian: Apply debian packaging fixes for metadata csum
Theodore Ts'o [Fri, 3 Aug 2012 02:06:16 +0000 (22:06 -0400)]
debian: Apply debian packaging fixes for metadata csum

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: when checking the inode's checksum, allow an all-zero inode
Theodore Ts'o [Fri, 3 Aug 2012 00:47:46 +0000 (20:47 -0400)]
libext2fs: when checking the inode's checksum, allow an all-zero inode

When the kernel writes an inode where all of the other inodes in in
the inode table (itable) block are unused, it skips reading the itable
block from disk, and instead uses an all zeros block.  This can cause
e2fsck to complain when it iterates over the inodes using
ext2fs_get_next_inode() since the inode apparently has an invalid
checksum.  Normally the inode won't be returned at all if it is at the
end of the block group's part of the inode table, thanks to the
bg_itable_unused field.  But it's possible for this situation to
happen earlier in the inode table block.

Fix this by changing ext2fs_inode_csum_verify() to allow the inode to
be all zero's; if the checksum fails, and the inode is all zero's,
treat it as a valid checksum.

Reported-by: Tao Ma <boyu.tm@taobao.com>
Reported-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agomke2fs: enable metadata_csum on ext4dev filesystems
Darrick J. Wong [Fri, 3 Aug 2012 00:47:46 +0000 (20:47 -0400)]
mke2fs: enable metadata_csum on ext4dev filesystems

Enable full-power metadata checksumming by default on 'ext4dev'
filesystems.  This should be fairly safe for now, since only
developers should be using this new feature.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: refactor crc32_be code
Darrick J. Wong [Fri, 3 Aug 2012 00:47:46 +0000 (20:47 -0400)]
e2fsck: refactor crc32_be code

Remove crc32_be in favor of the implementation in libext2fs.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: optimize the CRC32c implementation
Darrick J. Wong [Fri, 3 Aug 2012 00:47:46 +0000 (20:47 -0400)]
libext2fs: optimize the CRC32c implementation

The crc32c implementation in the kernel has been refactored a bit to
reduce the amount of code that needs to be maintained, and to speed up
tune2fs/e2fsck on PowerPC by 5-10%.  Port the crc32c changes over, and
provide a crc32_be so that we can remove the duplicate functionality
from e2fsck.  Also drop crc32c_be and crc32_le since neither got used.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: enable support for the metadata checksumming feature
Darrick J. Wong [Fri, 3 Aug 2012 00:47:46 +0000 (20:47 -0400)]
libext2fs: enable support for the metadata checksumming feature

Add metadata checksumming to the list of supported features.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: verify data block checksums when recovering journal
Darrick J. Wong [Fri, 3 Aug 2012 00:47:46 +0000 (20:47 -0400)]
e2fsck: verify data block checksums when recovering journal

Check the data block checksums when recovering the journal.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: check commit block checksum during recovery
Darrick J. Wong [Fri, 3 Aug 2012 00:47:46 +0000 (20:47 -0400)]
e2fsck: check commit block checksum during recovery

When recovering a journal with checksum v2, verify the commit block
checksum.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: check descriptor block checksum when recovering journal
Darrick J. Wong [Fri, 3 Aug 2012 00:47:46 +0000 (20:47 -0400)]
e2fsck: check descriptor block checksum when recovering journal

Verify the descriptor block checksum when recovering a journal.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: check revoke block checksum during recovery
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
e2fsck: check revoke block checksum during recovery

Verify the revoke block checksum when recovering the journal.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: check journal superblock checksum prior to recovery
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
e2fsck: check journal superblock checksum prior to recovery

Ensure that the journal superblock passes checksum before recovering the
filesystem.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: dump feature flags for jbd2 v2 checksums
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
libext2fs: dump feature flags for jbd2 v2 checksums

Modify the dump code to print information about jbd2 v2 checksum data.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: change on-disk journal layout to support metadata checksumming
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
libext2fs: change on-disk journal layout to support metadata checksumming

Define flags and change journal structure definitions to support v2 journal
checksumming.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs: force MMP update when changing metadata_csum flag
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
tune2fs: force MMP update when changing metadata_csum flag

When changing the metadata_csum flag, always force out a new MMP block.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: verify and correct MMP checksum problems
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
e2fsck: verify and correct MMP checksum problems

Check and handle MMP checksum problems by resetting the block.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: add checksum to MMP block
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
libext2fs: add checksum to MMP block

Calculate and verify a checksum of the MMP block.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agomke2fs: warn if not enabling all the features that metadata_csum wants
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
mke2fs: warn if not enabling all the features that metadata_csum wants

The metadata_csum feature works best when two features are enabled.
These features are "extents" (because the block map has no space for
checksums) and "64bit" (this enables storage of full 32-bit checksums
in certain fields).  Print a warning if the user tries to create a
filesystem without those features.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agomke2fs: write new group descriptors with the appropriate checksum
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
mke2fs: write new group descriptors with the appropriate checksum

Update mke2fs to use the helper function to determine if group
descriptors should have checksums calculated.  Since metadata_csum
supersedes uninit_bg, quietly drop uninit_bg if metadata_csum is set,
so that older kernels don't get confused.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs: rewrite block group checksums when changing checksumming feature flags
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
tune2fs: rewrite block group checksums when changing checksumming feature flags

When toggling the metadata_csum and uninit_bg feature flags, we should
rewrite the block groups with the desired checksum.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: ensure block group checksum uses
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
e2fsck: ensure block group checksum uses

Use the helper function to determine if group descriptors have a
checksum.  Ensure that metadata_csum and uninit_bg flags are not set
simultaneously, as part of pass 0.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: block group checksum should use metadata_csum algorithm
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
libext2fs: block group checksum should use metadata_csum algorithm

Change the block group algorithm to use the same algorithm as the rest
of the metadata_csum.  This mostly involves providing a helper
function to tell if group descriptors should have checksums set or
verified, and modifying the gdt checksum code to use the correct
algorithm.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agomke2fs: record the checksum algorithm in use in the superblock
Darrick J. Wong [Fri, 3 Aug 2012 00:47:45 +0000 (20:47 -0400)]
mke2fs: record the checksum algorithm in use in the superblock

Record the type of checksum algorithm we're using for metadata in the
superblock when creating a filesystem.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs: store checksum algorithm type in superblock
Darrick J. Wong [Fri, 3 Aug 2012 00:47:44 +0000 (20:47 -0400)]
tune2fs: store checksum algorithm type in superblock

Actually records the checksum algorithm type in the superblock when
enabling checksumming.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: record the checksum algorithm in use in the superblock
Darrick J. Wong [Fri, 3 Aug 2012 00:47:44 +0000 (20:47 -0400)]
libext2fs: record the checksum algorithm in use in the superblock

Record the type of checksum algorithm we're using for metadata in the
superblock, in case we ever want/need to change the algorithm.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: handle superblock checksum errors gracefully
Darrick J. Wong [Fri, 3 Aug 2012 00:47:44 +0000 (20:47 -0400)]
e2fsck: handle superblock checksum errors gracefully

If e2fsck finds a superblock with an invalid checksum, try the
backups.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: calculate and verify superblock checksums
Darrick J. Wong [Fri, 3 Aug 2012 00:47:44 +0000 (20:47 -0400)]
libext2fs: calculate and verify superblock checksums

Calculate and verify the superblock checksums.  Each copy of the
superblock records the number of the group it's in and the FS UUID, so
we can simply checksum the whole block.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs: rewrite extended attribute block checksums
Darrick J. Wong [Fri, 3 Aug 2012 00:47:44 +0000 (20:47 -0400)]
tune2fs: rewrite extended attribute block checksums

When enabling metadata checksums, rewrite separate extended attribute
blocks.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: check extended attribute block checksums
Darrick J. Wong [Fri, 3 Aug 2012 00:47:44 +0000 (20:47 -0400)]
e2fsck: check extended attribute block checksums

Verify the checksums of separate extended attribute blocks and offer
to clear it if there is a mismatch.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: verify and calculate extended attribute block checksums
Darrick J. Wong [Fri, 3 Aug 2012 00:47:44 +0000 (20:47 -0400)]
libext2fs: verify and calculate extended attribute block checksums

Calculate and verify the checksum for separate (i.e. not in the inode)
extended attribute blocks; the checksum lives in the header.

[ Merged in change from Tao so that we always use the fs checksum seed
  for the xattr blocks. ]

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs: rebuild and checksum directories when necessary
Darrick J. Wong [Fri, 3 Aug 2012 00:47:35 +0000 (20:47 -0400)]
tune2fs: rebuild and checksum directories when necessary

Since all the metadata checksums depend on the fs UUID, tune2fs must
be able to rewrite the checksums of _all_ metadata.  It's not that
hard to add in the bits to resize the directory block structures at
the same time.

[ Merged in fix from Zheng Liu where ctx.errcode wasn't getting
  cleared in rewrite_directory(). ]

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: check directory leaf block checksums
Darrick J. Wong [Thu, 2 Aug 2012 21:27:43 +0000 (17:27 -0400)]
e2fsck: check directory leaf block checksums

Checks that directory leaf blocks have the necessary fake dir_entry at
the end of the block to hold a checksum and that the checksum is
valid.  It will resize the block and/or rebuild the directory if
necessary.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: add checksums to the end of directory leaf nodes
Darrick J. Wong [Thu, 2 Aug 2012 21:27:43 +0000 (17:27 -0400)]
libext2fs: add checksums to the end of directory leaf nodes

Introduce small structures for recording directory tree checksums, and
some API changes to support writing out directory blocks with
checksums.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: verify htree root/node checksums
Darrick J. Wong [Thu, 2 Aug 2012 21:27:30 +0000 (17:27 -0400)]
e2fsck: verify htree root/node checksums

Check htree internal node checksums.  If broken, ask user to clear
the htree index and recreate it later.

[ Move the check for not rehashing the lost+found directory to pass1
  so that we don't end up truncating lost+found when the metadata
  checksum feature is enabled. -- TYT ]

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: add dx_root/dx_node checksum calculation and verification helpers
Darrick J. Wong [Mon, 30 Jul 2012 23:22:04 +0000 (19:22 -0400)]
libext2fs: add dx_root/dx_node checksum calculation and verification helpers

Verify and calculate checksums of htree internal node blocks.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agodebugfs: print htree internal node checksums
Darrick J. Wong [Mon, 30 Jul 2012 23:20:04 +0000 (19:20 -0400)]
debugfs: print htree internal node checksums

Print htree node checksums when dumping a directory index.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: verify extent tree blocks and clear the bad ones
Darrick J. Wong [Mon, 30 Jul 2012 23:18:04 +0000 (19:18 -0400)]
e2fsck: verify extent tree blocks and clear the bad ones

When we encounter an extent tree block that passes the header check
but fails the checksum, offer to clear just that extent block instead
of failing the whole tree, which results in the entire inode being
wiped out.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs: enable extent tree checksums
Darrick J. Wong [Mon, 30 Jul 2012 23:16:04 +0000 (19:16 -0400)]
tune2fs: enable extent tree checksums

Add to tune2fs the ability to recalculate extent tree checksums when
altering the metadata checksum feature flag.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: verify and calculate extent tree block checksums
Darrick J. Wong [Mon, 30 Jul 2012 23:14:04 +0000 (19:14 -0400)]
libext2fs: verify and calculate extent tree block checksums

Verify and calculate extent tree block checksums when processing
filesystems.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs: rewrite block bitmap checksums
Darrick J. Wong [Mon, 30 Jul 2012 23:12:04 +0000 (19:12 -0400)]
tune2fs: rewrite block bitmap checksums

When toggling metadata_csum, mark the block bitmap dirty so that it
gets written with new checksums.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: don't verify bitmap checksums
Darrick J. Wong [Mon, 30 Jul 2012 23:10:04 +0000 (19:10 -0400)]
e2fsck: don't verify bitmap checksums

Since the correct inode and block bitmaps are calculated in pass 5,
don't fail the bitmap read operation in prior passes since (a)
incorrect results won't kill us and (b) if we fail early, we'll never
_get_ to pass 5.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: verify block bitmap checksum
Darrick J. Wong [Mon, 30 Jul 2012 23:08:04 +0000 (19:08 -0400)]
e2fsck: verify block bitmap checksum

Check block bitmap checksum and write a new checksum if the
verification fails.  This is ok because e2fsck has already computed
the correct block bitmap.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agodumpe2fs: display block bitmap checksum
Darrick J. Wong [Mon, 30 Jul 2012 23:06:04 +0000 (19:06 -0400)]
dumpe2fs: display block bitmap checksum

Display the block bitmap checksum when displaying block groups.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: create the block bitmap checksum
Darrick J. Wong [Mon, 30 Jul 2012 23:04:04 +0000 (19:04 -0400)]
libext2fs: create the block bitmap checksum

Calculate and verify the block bitmap checksum.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: verify inode bitmap checksum
Darrick J. Wong [Mon, 30 Jul 2012 23:02:04 +0000 (19:02 -0400)]
e2fsck: verify inode bitmap checksum

Rewrite the block bitmap when the checksum doesn't match.  This is
ok since e2fsck will have already computed the correct inode bitmap.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agodumpe2fs: display inode bitmap checksum
Darrick J. Wong [Mon, 30 Jul 2012 23:00:04 +0000 (19:00 -0400)]
dumpe2fs: display inode bitmap checksum

Display the inode bitmap checksum for each block group.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs: rewrite inode bitmap checksums
Darrick J. Wong [Mon, 30 Jul 2012 22:58:04 +0000 (18:58 -0400)]
tune2fs: rewrite inode bitmap checksums

When toggling metadata_csum, mark the inode bitmap dirty so that they
are written out with new checksums.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: create the inode bitmap checksum
Darrick J. Wong [Mon, 30 Jul 2012 22:56:04 +0000 (18:56 -0400)]
libext2fs: create the inode bitmap checksum

Provide a field in the block group descriptor to store inode bitmap
checksum, and some helper functions to calculate and verify it.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agomke2fs: allow metadata checksums to be turned on at mkfs time
Darrick J. Wong [Mon, 30 Jul 2012 22:54:04 +0000 (18:54 -0400)]
mke2fs: allow metadata checksums to be turned on at mkfs time

Write out reserved inodes with full checksums when writing out a
zeroed table.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: verify and correct inode checksums
Darrick J. Wong [Mon, 30 Jul 2012 22:52:04 +0000 (18:52 -0400)]
e2fsck: verify and correct inode checksums

Detect mismatches of the inode and checksum, and prompt the user to
fix the situation.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs: add inode checksum support
Darrick J. Wong [Mon, 30 Jul 2012 22:50:04 +0000 (18:50 -0400)]
tune2fs: add inode checksum support

This patch adds to tune2fs the ability to toggle the metadata checksum
rocompat feature flag, which will rewrite the inode table with
checksums.  Disallow changing the UUID while the fs is mounted,
because rewriting the metadata objects is racy.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agodebugfs: dump inode checksum when appropriate
Darrick J. Wong [Mon, 30 Jul 2012 22:48:04 +0000 (18:48 -0400)]
debugfs: dump inode checksum when appropriate

Dump inode checksum when displaying inode info.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: add inode checksum support
Darrick J. Wong [Mon, 30 Jul 2012 22:46:04 +0000 (18:46 -0400)]
libext2fs: add inode checksum support

This patch adds the ability for the libext2fs functions to read and
write the inode checksum.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: precompute FS UUID checksum seed
Darrick J. Wong [Mon, 30 Jul 2012 22:44:04 +0000 (18:44 -0400)]
libext2fs: precompute FS UUID checksum seed

Precompute the FS UUID checksum seed that is used for all metadata
checksumming operations and store it in ext2_filsys.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agodebugfs: optionally ignore bad checksums
Darrick J. Wong [Mon, 30 Jul 2012 21:46:15 +0000 (17:46 -0400)]
debugfs: optionally ignore bad checksums

If someone is debugging a badly damaged filesystem, it might be useful
to disable the checksum verifications that will otherwise prevent the
filesystem from loading.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: change ext4 on-disk layout to support metadata checksumming
Darrick J. Wong [Mon, 30 Jul 2012 21:44:15 +0000 (17:44 -0400)]
libext2fs: change ext4 on-disk layout to support metadata checksumming

Define flags and extend ext4 structure definitions to support metadata
checksumming.  Ted Ts'o covered many of these fields in an earlier
patch, but there are more required changes to the disk layout.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: read and write full size inodes
Darrick J. Wong [Mon, 30 Jul 2012 21:42:15 +0000 (17:42 -0400)]
libext2fs: read and write full size inodes

Change libext2fs to read and write full-size inodes in preparation for
the metadata checksumming patchset, which will require this.  Due to
ABI compatibility requirements, this change must be hidden from client
programs.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibext2fs: enforce the block group descriptor size in ext2fs_open()
Theodore Ts'o [Mon, 30 Jul 2012 21:40:15 +0000 (17:40 -0400)]
libext2fs: enforce the block group descriptor size in ext2fs_open()

Since various parts of the library depend on the value of s_desc_size,
check to make sure it is the correct, expected value based on the file
system features.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: remove debugging printf from ext2fs_group_desc_csum
Theodore Ts'o [Mon, 30 Jul 2012 21:39:25 +0000 (17:39 -0400)]
libext2fs: remove debugging printf from ext2fs_group_desc_csum

This reduces the number of C library symbols needed by boot loader
systems such as yaboot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: call numeric_progress functions through a operations struct
Theodore Ts'o [Mon, 30 Jul 2012 21:16:51 +0000 (17:16 -0400)]
libext2fs: call numeric_progress functions through a operations struct

Instead of calling ext2fs_numeric_progress_*() directly from closefs.c
and alloc_tables.c, call it via a operations structure which is only
initialized by the one program (mke2fs) which needs it.

This reduces the number of C library symbols needed by boot loader
systems such as yaboot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: move ext2fs_get_num_dirs to its own file
Theodore Ts'o [Mon, 30 Jul 2012 20:41:52 +0000 (16:41 -0400)]
libext2fs: move ext2fs_get_num_dirs to its own file

This reduces the number of C library symbols needed by boot loader
systems such as yaboot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: use strcpy()/strcat() instead of sprintf() in bmap functions
Theodore Ts'o [Mon, 30 Jul 2012 19:54:12 +0000 (15:54 -0400)]
libext2fs: use strcpy()/strcat() instead of sprintf() in bmap functions

This simplifies the number of C library symbols needed by boot loader
systems such as yaboot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: use abort() instead of perror()/exit()
Theodore Ts'o [Mon, 30 Jul 2012 19:46:26 +0000 (15:46 -0400)]
libext2fs: use abort() instead of perror()/exit()

This simplifies the number of C library symbols needed by boot loader
systems such as yaboot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoe2fsck: add SIGABRT to list of signals processed by sigcatcher
Theodore Ts'o [Mon, 30 Jul 2012 19:45:57 +0000 (15:45 -0400)]
e2fsck: add SIGABRT to list of signals processed by sigcatcher

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: only define ba_print_stats() when needed
Tony Breeds [Mon, 30 Jul 2012 18:51:31 +0000 (14:51 -0400)]
libext2fs: only define ba_print_stats() when needed

If ENABLE_BMAP_STATS isn't defined make ba_print_stats() do nothing.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoAdd support so that all bmap statistics via configure options
Tony Breeds [Mon, 30 Jul 2012 18:44:12 +0000 (14:44 -0400)]
Add support so that all bmap statistics via configure options

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoMake Multi Mount Protection (MMP) optional at configure time.
Tony Breeds [Tue, 26 Jun 2012 01:42:15 +0000 (11:42 +1000)]
Make Multi Mount Protection (MMP) optional at configure time.

Add --{en,dis}able-mmp options for configure, default to enabled.
Also make tools fail gracefully in the event of encoutering a filesystem
with MMP enabled when the tools were compiled with --disable-mmp

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoext2fs.h: Change how we deal with optional incompat features.
Tony Breeds [Tue, 26 Jun 2012 01:42:14 +0000 (11:42 +1000)]
ext2fs.h: Change how we deal with optional incompat features.

Currently EXT2_LIB_FEATURE_INCOMPAT_SUPP is #defined twice once with
EXT2_FEATURE_INCOMPAT_COMPRESSION and once without depending on the
state of ENABLE_COMPRESSION

Change this to use an intermediate symbol so that the definition of
EXT2_LIB_FEATURE_INCOMPAT_SUPP doesn't change as other optional fetures
are added.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoUpdate Release Notes, Changelogs, version.h, etc. for 1.42.5 release v1.42.5
Theodore Ts'o [Mon, 30 Jul 2012 00:38:48 +0000 (20:38 -0400)]
Update Release Notes, Changelogs, version.h, etc. for 1.42.5 release

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoe2fsck: print the number of blocks and inodes in the verbose statistics
Theodore Ts'o [Sun, 29 Jul 2012 23:02:29 +0000 (19:02 -0400)]
e2fsck: print the number of blocks and inodes in the verbose statistics

In addition to the free blocks and free inodes, also print the number
of blocks and inodes in the verbose statistics.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoe2fsck: allow for bigger disks when printing verbose statistics
Theodore Ts'o [Sun, 29 Jul 2012 22:20:04 +0000 (18:20 -0400)]
e2fsck: allow for bigger disks when printing verbose statistics

Disks have gotten bigger, so 8 digits might not be enough.  Allow for
12 digits worth of blocks, which is more than enough for 3 petabytes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoe2fsck: add e2fsck.conf options for extra reporting
Theodore Ts'o [Sun, 29 Jul 2012 21:44:11 +0000 (17:44 -0400)]
e2fsck: add e2fsck.conf options for extra reporting

Add report_time, report_verbose, and report_features options to
e2fsck.conf which enable additional, more verbose reporting by e2fsck.
This is useful for large cloud installations where there are a large
number file systems being managed, and where it may not be obvious
from the e2fsck log files exactly how a particular file system is
configured.

The report_time and report_verbose options, which are the same as the
-tt and -v command line options, respectively, are useful because they
are options specific to e2fsck, and the fsck program does not have a
way of passing certain options only to a specific /sbin/fsck.<fstype>
program.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: fix uninit block calculation when inodes_per_block < first_ino
Theodore Ts'o [Sun, 29 Jul 2012 17:34:01 +0000 (13:34 -0400)]
libext2fs: fix uninit block calculation when inodes_per_block < first_ino

The following commands:

dd if=/dev/zero of=/tmp/foo count=1 ibs=$(( 256 * 1024 * 1024 ))
mke2fs -N 256 -t ext4 /tmp/foo

... will cause mke2fs to write until it fills the device.  The cause
for this is that the explicit request for 256 inodes causes the number
of inodes per block group to be 8.  The ext2fs_initialize() function
assumed that all of the reserved inodes would be in the first block
group, which is not true in this case.  This caused the number of
uninitialized inodes in the first block group to be negative, which
then resulted in mke2fs trying to zero out a very large number of
blocks.  Oops.

Addresses-Sourceforge-Bug: #3528892

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoe2fsck: fix code which uniquifies names in directory entries
Theodore Ts'o [Sun, 29 Jul 2012 17:05:46 +0000 (13:05 -0400)]
e2fsck: fix code which uniquifies names in directory entries

When checking to see whether or not a new name is unique, the code was
using the wrong length parameter, which could cause the anti-collision
loop for a long time trying to find what it thinks is a unique name.

Addresses-Sourceforge-Bug: #3540545

Reported-by: Vitaly Oratovsky <vmo@users.sourceforge.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoLink shared libraries with local libraries instead of system ones
Olivier Blin [Sun, 29 Jul 2012 16:44:53 +0000 (12:44 -0400)]
Link shared libraries with local libraries instead of system ones

ELF_OTHER_LIBS usually contains local search dirs (-L ../..), but it
was added in link command after system search dirs from LDFLAGS.

Libraries and executables were linked with the system libraries if
present, and possibly using static archives instead of shared
libraries.

It could also make final executable link to fail when shared libraries
are enabled: if libext2fs.so is linked with a static libcom_err.a from
system, build system would attempt to link without -lpthread.

This fixes the issue by moving ELF_OTHER_LIBS before LDFLAGS in the
link command.

Addresses-Sourceforge-Bug: #3542572

Reported-by: Olivier Blin <blino@users.sourceforge.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agodebian: set e2fsprogs as Multi-Arch: foreign
Riku Voipio [Sun, 29 Jul 2012 04:22:13 +0000 (00:22 -0400)]
debian: set e2fsprogs as Multi-Arch: foreign

If package foo:i386 depends on e2fsprogs, without Multi-Arch: foreign
statetment, the i386 version of e2fsprogs will be installed. By
setting the foreign field, the already installed (in this example
amd64) e2fsprogs package is enough to satisfy the dependency.

The M-A: foreign field is ignored in pre-multiarch systems, so ifdeffing
it using macros should be unnessary.

Addresses-Debian-Bug: #678395

Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: check a file system mounted read-only if forced
Theodore Ts'o [Sun, 29 Jul 2012 04:16:44 +0000 (00:16 -0400)]
e2fsck: check a file system mounted read-only if forced

Previously e2fsck would only allow a mounted file system to be checked
if it was the root file system and it was mounted read-only.  Now
allow any file system mounted read-only if the -f option is specified.

This makes it easier to test how e2fsck handles checking file systems
which are mounted without having to test on the root file system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoRevert "e2fsck: Skip journal checks if the fs is mounted and doesn't need recovery"
Theodore Ts'o [Sun, 29 Jul 2012 04:01:29 +0000 (00:01 -0400)]
Revert "e2fsck: Skip journal checks if the fs is mounted and doesn't need recovery"

This reverts commit 47c1b8e16668daa6e74cee3c7b8bdf237ffefe70.

The original reason for this commit was to speed up boots for hard
drives.  However, I've measured the time difference on a 1TB laptop
drive, and it's not significant: 70ms vs 10ms when running e2fsck on a
clean file system.

The problem with this optimization is that we don't notice if the
journal superblock has a non-zero s_errno field.  If we don't transfer
the error indicator from the journal superblock to the file system
superblock, then the kernel will transfer it when the file system is
remounted read-write, causing scary messages to appear in the syslog.
(And since there was a bug in the kernel code which didn't clear the
error indicator in the journal superblock, it would never get
cleared.)

Reported-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoe4defrag: handle device symlinks
Eric Sandeen [Sat, 28 Jul 2012 21:48:36 +0000 (17:48 -0400)]
e4defrag: handle device symlinks

Device nodes are commonly accessed via symlinks, i.e.

lrwxrwxrwx. 1 root root 7 Jul 19 13:01 /dev/mapper/testvg-testlv -> ../dm-0

Today, e4defrag on such a device will fail:

File is not regular file
 "/dev/mapper/testvg-testlv"

due to it being a link, and e4defrag on the link target does as well:

Filesystem is not mounted

due to the target not being found in /etc/mtab.

Fix this by checking whether the symlink target is a block device
and if so, using that device in main(), and also changing get_mount_point()
to search for a matching device number, not device name.

Addresses-Red-Hat-Bugzilla: #707209

Reported-by: Peter Hjalmarsson <xake@rymdraket.net>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agofilefrag: fix segfault on virtual fs
Eric Sandeen [Sat, 28 Jul 2012 21:52:13 +0000 (17:52 -0400)]
filefrag: fix segfault on virtual fs

filefrag on a virtual fs like proc segfaults:

Floating point exception

because stat.f_blocks is 0, so the calculation of cylgroups is 0,
which leads to a divide by 0 when calculating expected extents.

Since it's only used for ext2 filesystems anyway, just move
the calculation of expected under "if (is_ext2)" to fix this.

Reported-by: Max Beikirch <maxnet@onlinehome.de>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agochattr: update chattr's man page chattr for No_COW
Liu Bo [Sat, 28 Jul 2012 21:36:40 +0000 (17:36 -0400)]
chattr: update chattr's man page chattr for No_COW

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agofilefrag: fix report of number of extents
Liu Bo [Sat, 28 Jul 2012 21:29:13 +0000 (17:29 -0400)]
filefrag: fix report of number of extents

filefrag has several bugs:

1.
$ touch f1
$ filefrag f1
f1: 1 extent found  ----> bug!
$ filefrag -v f1
Filesystem type is: ef53
File size of f1 is 0 (0 blocks, blocksize 4096)
f1: 0 extents found

2.
$ truncate -s 1m f2
$ filefrag f2
f2: 1 extent found  ----> bug!
$ filefrag -v f2
Filesystem type is: ef53
File size of f2 is 1048576 (256 blocks, blocksize 4096)
f2: 0 extents found

3.
$ for i in `seq 11 -2 0`; do dd if=/dev/zero of=f4 bs=4k count=1 seek=$i conv=notrunc oflag=sync &>/dev/null; done
$ ll f4
-rw-r--r-- 1 root root 49152 Jun  9 15:09 f4
$ filefrag f4
f4: 7 extents found
$ filefrag -v f4
Filesystem type is: ef53
File size of f4 is 49152 (12 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       1  1109993               1
   1       3  1109992  1109994      1
   2       5  1109991  1109993      1
   3       7  1109990  1109992      1
   4       9  1109989  1109991      1
   5      11  1108207  1109990      1 eof
f4: 7 extents found  -----------------------> but we only have 6 extents, bug!

All of these bugs come from the fact that we've made a mistake on
calculating total extents:

o   we set 1 as default for 'total extents', and this will report 1
    extent found even when we don't get any extent from fiemap.
o   if our first extent does not start from 0(logical addr), total
    extents will be one more than what it should be.

Addresses-Red-Hat-Bugzilla: #840848

Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agologsave: fix fd leak which could cause logsave to hang
Theodore Ts'o [Mon, 23 Jul 2012 22:45:23 +0000 (18:45 -0400)]
logsave: fix fd leak which could cause logsave to hang

The logsave program is leaking a file descriptor when it forks and
execs the program which forks a process which hangs around.  In the
case of /etc/init.d/checkroot, this would be fsck.  This file
descriptor never gets closed, so it's still present when fsck runs
e2fsck, and then if e2fsck has its own logging enabled using (in
/etc/e2fsck.conf):

[options]
    log_dir = /mnt
    log_filename = e2fsck-%N.%h.INFO.%D-%T
    log_dir_wait = true

then e2fsck will fork off a process waiting for /mnt to get remounted
read/write.  This causes logsave to never get an EOF from its pipe, so
it hangs waiting for the read to fail --- which won't happen due to
the file descriptor leak which is still being held open by e2fsck's
forked child process.  And so /etc/init.d/checkroot hangs, and the
root file system never gets remounted read/write, and we deadlock.

Fix the problem by closing the pipe fd so the logsave program doesn't
end up leaking it to its descendent processes.

Addresses-Debian-Bug: #682592

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agotune2fs: fix quota feature removal
Aditya Kali [Fri, 13 Jul 2012 22:25:09 +0000 (15:25 -0700)]
tune2fs: fix quota feature removal

When the last quota inode is removed, the 'quota' feature
flag was not removed from superblock in some cases.
Ex:
 $ mke2fs -t ext4 -O quota <dev>  # creates both usr & grp
                                  # quota inodes
 $ tune2fs -Q ^usrquota <dev>  # removes usr quota inode
 $ tune2fs -Q ^grpquota <dev>  # removes grp quota inode,
                               # but the 'quota' feature flag
                               # was not removed from superblock
This patch removes the 'quota' feature flag from superblock
if none of the quota inodes are set.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck/quota: mark FS invalid if quotas are not fixed
Aditya Kali [Fri, 13 Jul 2012 22:25:08 +0000 (15:25 -0700)]
e2fsck/quota: mark FS invalid if quotas are not fixed

If user chooses to not fix quota info, then the FS should be
marked as having errors. PR_NO_OK prevented this from happening.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agolibquota: fix quota_inode_truncate()
Aditya Kali [Fri, 13 Jul 2012 22:25:07 +0000 (15:25 -0700)]
libquota: fix quota_inode_truncate()

We failed to clear EXT2_FLAG_SUPER_ONLY after deleting the
quota inode and so, the updated block bitmap was not written
back. This caused fsck to complain after running
'tune2fs -O ^quota <dev>'. Clear this flag so that updated
block bitmap gets written. Also, avoid truncating the quota
inode if it is not hidden.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agotune2fs/quota: always create hidden quota files
Aditya Kali [Fri, 13 Jul 2012 22:25:06 +0000 (15:25 -0700)]
tune2fs/quota: always create hidden quota files

Currently 'tune2fs -O quota <dev>' will try to use existing
quota files and write their inode numbers in the superblock.
Next e2fsck run then converts these into hidden quota inodes
(ino #3 & #4). But this approach has problems:
1) Before e2fsck run, the inodes are visible to the user and
   might get corrupted or removed or replaced by the user.
2) Since these are user visible, we have to include
   their block usage in the quota accounting. But once
   these inodes are hidden, e2fsck will have to decrement
   their usage from the quota accounting (which e2fsck
   currently doesn't do and instead reports error).
   (the following used to give e2fsck error previously:
    # assume <dev> has aquota.user & aquota.group files
    $ tune2fs -O quota <dev> # stores ino# of quota files in
                             # ext4 superblock
    $ e2fsck -f <dev>  # hides quota files, but now quota
                       # usage is incorrect.
     << quota errors >>
Instead of making e2fsck complicated, this patch creates the
hidden quota inodes at 'tune2fs -O quota' time iteself. The
usage is computed freshly and limits are copied from the
aquota.user and aquota.group files as earlier.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoFix spelling typo's in man pages for tune2fs and mke2fs
Theodore Ts'o [Sat, 14 Jul 2012 23:58:06 +0000 (19:58 -0400)]
Fix spelling typo's in man pages for tune2fs and mke2fs

Addresses-Debian-Bug: #680114

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agobuild: add generated files to .gitignore
Andreas Dilger [Fri, 6 Jul 2012 01:44:51 +0000 (19:44 -0600)]
build: add generated files to .gitignore

Add a batch of files/wildcards to the list of ignored files, so
that "git status" does not show so many files that should be ignored.
The "*.dSYM" directories are generated during building on MacOS.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoe2fsck: rename "bool" variables
Andreas Dilger [Fri, 6 Jul 2012 01:44:20 +0000 (19:44 -0600)]
e2fsck: rename "bool" variables

Since "bool" is a valid C type, declarations of the form "int bool"
will cause compiler errors if <stdbool.h> is included.  Rename these
variables to avoid this name clash.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>