Whamcloud - gitweb
tools/e2fsprogs.git
12 years agotests: add basic tests for dir_data feature
Andreas Dilger [Fri, 13 Apr 2012 19:42:42 +0000 (13:42 -0600)]
tests: add basic tests for dir_data feature

Signed-off-by: Pravin Shelar <pravin@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: add support for dir_data feature
Andreas Dilger [Fri, 13 Apr 2012 19:39:26 +0000 (13:39 -0600)]
e2fsck: add support for dir_data feature

Add support for the INCOMPAT_DIRDATA feature, which allows
storing extra data in the directory entry beyond the name.
This allows the Lustre File IDentifier to be accessed in
an efficient manner, and would be useful for expanding a
filesystem to allow more than 2^32 inodes in the future.

  LU-1774 e2fsck: e2fsck -D does not change dirdata content

  Fix dir optimization to preserver dirdata content for dot
  and dotdot entries.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
  Change-Id: Iae190794da75a2080a8e5cc5b95a49e0c894f72f

Signed-off-by: Pravin Shelar <pravin@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: verify large xattr inode support
Andreas Dilger [Fri, 13 Apr 2012 08:14:16 +0000 (02:14 -0600)]
tests: verify large xattr inode support

Verify that inodes with large EAs in a secondary inode are working:
* EA inode needs to have EA_INODE_FL set
* EA inode should reference parent inode number+generation

Signed-off-by: Kalpak Shah <kalpak@sun.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: add support for xattrs in external inodes
Andreas Dilger [Fri, 13 Apr 2012 08:04:53 +0000 (02:04 -0600)]
e2fsck: add support for xattrs in external inodes

Add support for the INCOMPAT_EA_INODE feature, which stores large
extended attributes into an external inode instead of data blocks.
The inode is referenced by the e_value_inum field (formerly the
unused e_value_block field) from the extent header, and stores the
xattr data starting at byte offset 0 in the inode data block.

The xattr inode stores the referring inode number in its i_mtime,
and the parent i_generation in its own i_generation, so that there
is a solid linkage between the two that e2fsck can verify.  The
xattr inode is itself marked with EXT4_EA_INODE_FL as well.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: clean up xattr checking code, add test
Andreas Dilger [Fri, 13 Apr 2012 08:01:12 +0000 (02:01 -0600)]
e2fsck: clean up xattr checking code, add test

Clean up xattr header/list processing for in-inode xattrs instead
of doing lots of explicit pointer math.  Add a regression test for
in-inode xattrs.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: add checks for journal checksum feature
Andreas Dilger [Fri, 13 Apr 2012 07:50:29 +0000 (01:50 -0600)]
tests: add checks for journal checksum feature

f_jchksum_bblk: journal checksum feature where there is a corrupt
block in an uncommitted transaction
f_jchksum_blast_trans: incomplete last trans not considered bad
f_jchksum_remount: check journal mounted by a kernel without
CHECKSUM support after CHECKSUM is in journal superblock

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: create random filesystem, corrupt, e2fsck
Andreas Dilger [Fri, 13 Apr 2012 07:53:39 +0000 (01:53 -0600)]
tests: create random filesystem, corrupt, e2fsck

The f_random_corruption test enables a random subset of filesystem
features, picks one of the valid filesystem block and inode sizes,
and a random device size and creates a new filesystem with those
parameters.

It is possible to disable the running of the test by setting the
environment variable F_RANDOM_CORRUPTION=skip.  By default the test
script is run only one time, but setting the LOOP_COUNT variable
allows the test to run multiple times.

If the script is running as root the filesystem is mounted and
populated with file data to allow a more useful test filesystem
to be generated.  In some cases the kernel may not support the
requested filesystem features and the filesystem cannot be mounted.
This is not considered a test failure.

The resulting filesystem is corrupted with both random data and
by shifting data from one part of the device to another and then
repaired by e2fsck.  In some rare cases the random corruption is
severe enough that the filesystem is not recoverable (e.g. small
filesystem with no backup superblock has bad superblock corruption)
but in most cases "e2fsck -fy" should be able to fix all errors
in some way.

After e2fsck has repaired the filesystem, it is optionally mounted
(if the environment variable MOUNT_AFTER_CORRUPTION=yes is set) and
the test files created in the filesystem are deleted.  This verifies
that the fixes in the filesystem are sufficient for the kernel to
use the filesystem without error.  Since there is some possibility
of the kernel oopsing if there is a filesystem bug, this part of
the test is not enabled by default.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: add test cases for inode badness
Andreas Dilger [Fri, 13 Apr 2012 07:23:17 +0000 (01:23 -0600)]
tests: add test cases for inode badness

Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: track errors/badness found for each inode
Andreas Dilger [Fri, 13 Apr 2012 07:13:58 +0000 (01:13 -0600)]
e2fsck: track errors/badness found for each inode

The present e2fsck code checks the inode, per field basis.  It
doesn't take into consideration to total sanity of the inode.
This may cause e2fsck turning a garbage inode into an apparently
sane inode ("It is a vessel of fertilizer, and none may abide
its strength.").

The following patch adds a heuristics to detect the degree of
badness of an inode. icount mechanism is used to keep track of
the badness of every inode.  The badness is increased as various
fields in inode are found to be corrupt.  Badness above a certain
threshold value results in deletion of the inode.  The default
badness threshold value is 7, it can be specified to e2fsck
using "-E inode_badness_threshold=<value>"

This can avoid lengthy pass1b shared block processing, where a
corrupt chunk of the inode table has resulted in a bunch of
garbage inodes suddenly having shared blocks with a lot of good
inodes (or each other).

Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: add tests for expanding inode extra size
Andreas Dilger [Fri, 13 Apr 2012 00:05:03 +0000 (18:05 -0600)]
tests: add tests for expanding inode extra size

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: add support for expanding the inode size
Andreas Dilger [Fri, 13 Apr 2012 00:03:37 +0000 (18:03 -0600)]
e2fsck: add support for expanding the inode size

This patch adds a "-E expand_extra_isize" feature which makes sure
that _every_ used inode has i_extra_isize >= s_min_extra_isize if
s_min_extra_isize is set. Else it makes sure that i_extra_isize
of every inode is equal to sizeof(ext2_inode_large) - 128.

This is useful for the case where nanosecond timestamps or 64-bit
inode version fields are required for all inodes in the filesystem.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: ignore xattr feature in backup superblocks
Andreas Dilger [Fri, 13 Apr 2012 18:25:25 +0000 (12:25 -0600)]
e2fsck: ignore xattr feature in backup superblocks

Since the xattr feature is enabled automatically by the kernel,
it can cause spurious e2fsck runs on a clean filesystem due to
differences between the primary and backup superblocks.

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: PAGE_SIZE larger than blocksize with hole
Andreas Dilger [Thu, 9 Aug 2012 05:23:22 +0000 (23:23 -0600)]
tests: PAGE_SIZE larger than blocksize with hole

Verify correct operation in the case of writing files with allocated
blocks at the end of the file beyond i_size.  This can happen for
PAGE_SIZE > blocksize, or through fallocate().

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: handle preallocation for large PAGE_SIZE
Andreas Dilger [Fri, 13 Apr 2012 07:59:31 +0000 (01:59 -0600)]
e2fsck: handle preallocation for large PAGE_SIZE

Fix handling of block preallocation support in cases where the kernel
PAGE_SIZE is larger than the filesystem blocksize.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: add tests for uninitialized bitmaps
Andreas Dilger [Thu, 12 Apr 2012 23:52:44 +0000 (17:52 -0600)]
tests: add tests for uninitialized bitmaps

Various tests for handing uninitialized block and inode bitmaps,
and inodes beyond the in-use high watermark.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotune2fs: warn if the filesystem journal is dirty
Andreas Dilger [Thu, 12 Apr 2012 23:38:13 +0000 (17:38 -0600)]
tune2fs: warn if the filesystem journal is dirty

Running tune2fs on a filesystem with an unrecovered journal can
cause the tune2fs settings to be reverted when the journal is
replayed.  Print a warning if this is detected so that the user
isn't surprised if it happens.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: allow deleting or zeroing shared blocks
Andreas Dilger [Thu, 12 Apr 2012 23:32:53 +0000 (17:32 -0600)]
e2fsck: allow deleting or zeroing shared blocks

E2fsck fixes files that are found to be sharing blocks by cloning
the shared blocks and giving each file a private copy in pass 1D.

Allowing all files claiming the shared blocks to have copies can
inadvertantly bypass access restrictions.  Deleting all the files,
zeroing the cloned blocks, or placing the files in the /lost+found
directory after cloning may be preferable in some secure environments.

The following patches implement config file and command line options
in e2fsck that allow pass 1D behavior to be tuned according to site
policy.  It adds two extended options and config file counterparts.
On the command line:

 -E clone=dup|zero

    Select the block cloning method.  "dup" is old behavior,
    and is the default.  "zero" is a new method that substitutes
    zero-filled blocks for the shared blocks in all the files
    that claim them.

 -E shared=preserve|lost+found|delete

    Select the disposition of files containing shared blocks.
    "preserve" is the old behavior which remains the default.
    "lost+found" causes files to be unlinked after cloning so
    they will be reconnected to /lost+found in pass 3.
    "delete" skips cloning entirely and simply deletes the files.

In the config file:
  [options]
      clone=dup|zero
      shared=preserve|lost+found|delete

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: parse config file before command-line opts
Andreas Dilger [Thu, 12 Apr 2012 23:24:55 +0000 (17:24 -0600)]
e2fsck: parse config file before command-line opts

The patch changes the order that the config file and command line
are parsed so that command line has precedence.  It also parses
the -E option for every occurrence, otherwise the -E option is
not cumulative.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: invalid value of in-inode EA offset
Andreas Dilger [Thu, 12 Apr 2012 22:57:40 +0000 (16:57 -0600)]
tests: invalid value of in-inode EA offset

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: extent pointing to non-existent block
Andreas Dilger [Fri, 25 May 2012 07:01:28 +0000 (01:01 -0600)]
tests: extent pointing to non-existent block

Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: workaround for old extents tests
Andreas Dilger [Thu, 12 Apr 2012 22:15:07 +0000 (16:15 -0600)]
e2fsck: workaround for old extents tests

The e2fsck_ext2fs_extent_get() part of this patch is a workaround
to handle problems with old Lustre extents patches that didn't
clear the ee_start_hi or ei_leaf_hi fields.

That has been fixed for long time and could be removed as soon
as the f_extent_* tests are fixed to clear these _hi fields.
Otherwise the extents are all marked as corrupt and it ruins those
tests value.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agotests: verify > 65000 subdirectories
Andreas Dilger [Thu, 12 Apr 2012 22:02:12 +0000 (16:02 -0600)]
tests: verify > 65000 subdirectories

Add test case to verify nlink handling of large directories.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoTT-177 build: add .spec file for SLES11 packaging
Andreas Dilger [Fri, 13 Apr 2012 08:23:12 +0000 (02:23 -0600)]
TT-177 build: add .spec file for SLES11 packaging

Include the upstream SLES11 .spec file to ensure the packages we
build match the upstream packages.  Any later patches that change
the packaging should patch the .spec file appropriately.

Add in the SLES-specific patches, excluding the replacement de.po
file, since the original SLES11 de.po file is only against 1.41.4,
and is missing a large number of changes to the translated messages
related to 64-bit format specifiers.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I783d58bd78d7c4c66cc85ec5557ae1aaf64016ba

12 years agobuild: add RHEL6 .spec file for packaging
Andreas Dilger [Fri, 13 Apr 2012 08:19:19 +0000 (02:19 -0600)]
build: add RHEL6 .spec file for packaging

Include the upstream RHEL6 .spec file to ensure the packages we
build match the upstream packages.  Any later patches that change
the packaging should patch the .spec file appropriately.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agobuild: update e2fsprogs.spec for distro builds
Andreas Dilger [Thu, 12 Apr 2012 21:39:04 +0000 (15:39 -0600)]
build: update e2fsprogs.spec for distro builds

Add the distro version to the RPM release number, so that it the
RPM names do not conflict.

Allow the RPM built from upstream to replace the split packages
provided by the distros.  At some point in the future it may be
desirable to also split the RPM built by this spec file, but this
is complicated by the fact that SLES and RHEL have different splits.

Signed-off-by: Girish Shilamkar <girish.shilamkar@sun.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agofilefrag: improvements to filefrag FIEMAP handling
Andreas Dilger [Thu, 12 Apr 2012 21:31:35 +0000 (15:31 -0600)]
filefrag: improvements to filefrag FIEMAP handling

* add support for multiple-device filesystems
* add -k option to print extents in kB-sized units (like df -k)
* add -b {blocksize} to print extents in blocksize units
* add -e option to use in extent format, even for non-extent files.
* add -X option to print extents in hexadecimal format

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoblkid: fix ZFS device detection
Andreas Dilger [Thu, 12 Apr 2012 21:26:49 +0000 (15:26 -0600)]
blkid: fix ZFS device detection

Fix the ZFS device detection by looking at multiple uberblocks to
see if any are present, rather than looking for the ZFS boot block
which is not always present.

There may be up to 128 uberblocks, but the first 4 are not written
to disk on a newly-formatted filesystem so check several of them at
different offsets within the uberblock array.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agoe2fsck: improve in-inode xattr checks
Andreas Dilger [Thu, 12 Apr 2012 21:23:47 +0000 (15:23 -0600)]
e2fsck: improve in-inode xattr checks

Add check for in-inode xattr to make sure that it is not referencing
an offset that is beyond the end of the inode.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agobuild: fix build warnings for MacOS
Andreas Dilger [Fri, 27 Apr 2012 05:22:45 +0000 (23:22 -0600)]
build: fix build warnings for MacOS

The BLKFLSBUF and FDFLUSH ioctls are Linux specific, and do not
really have anything to do with __GNUC__ (which is also used on
OS/X and Solaris).  Only print these warnings on Linux systems.

O_DIRECT is not defined in the OS/X headers.  Since this is only a
performance enhancement, and not required for correct operation,
just ignore it if undefined.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agobuild: quiet some "gcc -Wall" compiler warnings
Andreas Dilger [Tue, 11 Sep 2012 22:15:20 +0000 (16:15 -0600)]
build: quiet some "gcc -Wall" compiler warnings

Quiet a number of simple compiler warnings:
- pointers not initialized by ext2fs_get_mem()
- return without value in non-void function
- dereferencing type-punned pointers
- unused variables

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
12 years agotests: make generated test scripts read-only
Andreas Dilger [Wed, 23 May 2012 21:05:21 +0000 (15:05 -0600)]
tests: make generated test scripts read-only

Make generated test scripts read-only, to avoid errors by developers
editing the generated test scripts and then having them accidentally
clobbered when "make" is run again.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agobuild: update version for Lustre build
Andreas Dilger [Thu, 12 Apr 2012 20:00:07 +0000 (14:00 -0600)]
build: update version for Lustre build

Add Whamcloud-specific build version to distinguish packages from
upstream packages.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
12 years agodebugfs: fix htree command so that all printf's go through the pager
Theodore Ts'o [Sun, 14 Oct 2012 08:54:20 +0000 (04:54 -0400)]
debugfs: fix htree command so that all printf's go through the pager

The "Reading directory block XXX..." message was not being sent
through the pager, which would result in confusing output.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoe2fsck: only consult inode_dir_map if needed in pass4
Theodore Ts'o [Wed, 10 Oct 2012 02:45:40 +0000 (22:45 -0400)]
e2fsck: only consult inode_dir_map if needed in pass4

In e2fsck_pass4(), we were consulting inode_dir_map using
ext2fs_test_inode_bitmap2() for every single inode in the file system.
However, there were many cases where we never needed the result of the
test --- most notably if the inode is not in use.

I was a bit surprised that GCC 4.7 with CFLAGS set to "-g -O2" wasn't
able to optimize this out for us, but here is the pass 4 timing for an
empty 3T file system before this patch:

Pass 4: Memory used: 672k/772k (422k/251k), time:  3.67/ 3.66/ 0.00

and afterwards, we see a 43% improvement:

Pass 4: Memory used: 672k/772k (422k/251k), time:  2.09/ 2.08/ 0.00

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoFix makefiles to compile e2freefrag with profiling
Theodore Ts'o [Sat, 6 Oct 2012 02:01:31 +0000 (22:01 -0400)]
Fix makefiles to compile e2freefrag with profiling

Also fix a bug caused by a stray continuation backslash which caused
the e2fsck/Makefile to fail when profiling is enabled.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
12 years agolibext2fs: further optimize rb_test_bit
Theodore Ts'o [Sat, 6 Oct 2012 01:59:40 +0000 (21:59 -0400)]
libext2fs: further optimize rb_test_bit

Profiling shows that rb_test_bit() is now calling ext2fs_rb_next() a
lot, and this function is now the hot spot when running e2freefrag.
If we cache the results of ext2fs_rb_next(), we can eliminate those
extra calls, which further speeds up both e2freefrag and e2fsck by
reducing the amount of CPU time spent in userspace.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agolibext2fs: remove pointless indirection in rbtree bitmaps
Theodore Ts'o [Sat, 6 Oct 2012 00:57:49 +0000 (20:57 -0400)]
libext2fs: remove pointless indirection in rbtree bitmaps

The code was previously allocating a single 4 or 8 byte pointer for
the rcursor and wcursor fields in the ext2fs_rb_private structure;
this added two extra memory allocations (which could fail), and extra
indirections, for no good reason.  Removing the extra indirection also
makes the code more readable, so it's all upside and no downside.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
12 years agolibext2fs: optimize rb_test_bit
Theodore Ts'o [Fri, 5 Oct 2012 03:38:55 +0000 (23:38 -0400)]
libext2fs: optimize rb_test_bit

Optimize testing for a bit in an rbtree-based bitmap for the case
where the calling application is scanning through the bitmap
sequentially.  Previously, we did this for a set of bits which were
inside an allocated extent, but we did not optimize the case where
there was a large number of bits after an allocated extents which were
not in use.

             1111111111111110000000000000000000
             ^ optimized    ^not optimized

In my tests of a roughly half-filled file system, the run time of
e2freefrag was halved, and the cpu time spent in userspace was during
e2fsck's pass 5 was reduced by a factor of 30%.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
12 years agoe2freefrag: use 64-bit rbtree bitmaps
Theodore Ts'o [Fri, 5 Oct 2012 03:30:23 +0000 (23:30 -0400)]
e2freefrag: use 64-bit rbtree bitmaps

Enable the use of 64-bit bitmaps, so e2freefrag will work on file
systems with the 64-bit feature enabled.  In addition, enable the
rbtree-based bitmaps, which significantly saves the amount of memory
required (from 97 megs to 1.7 megs for an empty 3T file system) at the
cost of additional CPU overhead (but we will claw back some of the
additional CPU overhead in the next commit).

Addresses-Google-Bug: 7269948

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agomke2fs: fix progress suppression to make regression tests reliable v1.42.6
Theodore Ts'o [Sun, 23 Sep 2012 01:26:48 +0000 (21:26 -0400)]
mke2fs: fix progress suppression to make regression tests reliable

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoUpdate Release Notes, Changelogs, version.h, etc. for 1.42.6 release
Theodore Ts'o [Fri, 21 Sep 2012 16:53:14 +0000 (12:53 -0400)]
Update Release Notes, Changelogs, version.h, etc. for 1.42.6 release

12 years agoFix wordwrap.pl so it is more portable
Theodore Ts'o [Fri, 21 Sep 2012 16:31:13 +0000 (12:31 -0400)]
Fix wordwrap.pl so it is more portable

Needed so that wordwrap.pl works with perl 5.14.2

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agomke2fs: throttle allocating groups progress as well
Theodore Ts'o [Fri, 21 Sep 2012 16:06:49 +0000 (12:06 -0400)]
mke2fs: throttle allocating groups progress as well

Throttle updates for the "Allocating Groups" progress updates to once
a second as well.  We now do this throttling in libext2fs, so we don't
have to do this for each of mke2fs's progress updates, and because the
updates from ext2fs_allocate_tables() come from within libext2fs
anyway.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agomke2fs.8: use extents vs extent in the man page
Theodore Ts'o [Fri, 21 Sep 2012 01:59:13 +0000 (21:59 -0400)]
mke2fs.8: use extents vs extent in the man page

We print "extents" for the feature, so we should document "extents" in
the mke2fs's man page, even though we accept both "extent" and
"extents".

Addresses-Sourceforge-Bug: #3559210

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agodebian: adjust build dependencies
Theodore Ts'o [Fri, 21 Sep 2012 00:48:34 +0000 (20:48 -0400)]
debian: adjust build dependencies

Remove dc from the list of dependencies, since it's not used during
the build anymore.

Addresses-Debian-Bug: #677497

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agotests: kill debugfs on interrupted MMP test
Andreas Dilger [Mon, 10 Sep 2012 09:04:47 +0000 (09:04 +0000)]
tests: kill debugfs on interrupted MMP test

If the f_mmp test is interrupted during its test run, then it can
leave debugfs busy-looping in the background.  Since f_mmp is a
relatively long-running test, and is likely to be running during
a parallel test run, this can happen fairly often.

Set a signal trap for the f_mmp test script being killed, so that
the background debugfs command will always be killed by the test.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agomke2fs: disable progress reporting in mke2fs.conf for regression tests
Theodore Ts'o [Mon, 17 Sep 2012 00:43:07 +0000 (20:43 -0400)]
mke2fs: disable progress reporting in mke2fs.conf for regression tests

Add a configuration knob so the regression tests can disable progress
reporting.  This fixes a potential lack of predictability since the
progress reports are now time based (once a second) which is
problematic for regression tests which are comparing the expected
output of mke2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agomke2fs: throttle progress updates to once a second
Theodore Ts'o [Fri, 14 Sep 2012 04:11:07 +0000 (00:11 -0400)]
mke2fs: throttle progress updates to once a second

With lazy itable initialization, the progress updates for writing the
inode table happens so quickly that on a serial console, the time to
write the progress updates can be the bottleneck.  Fix this by only
updating the progress indicator once a second.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoresize2fs: grow uninit_bg file systems more efficiently
Theodore Ts'o [Thu, 13 Sep 2012 22:17:27 +0000 (18:17 -0400)]
resize2fs: grow uninit_bg file systems more efficiently

If the uninit_bg feature is enabled and the kernel supports
lazy_itable_init, skip zeroing the inode table so that the resize
operation can go much more quickly.  Also set the itable_unused fields
so that the first e2fsck after the resize will run faster.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoresize2fs: enforce restrictions if the kernel doesn't do meta_bg resizing
Theodore Ts'o [Thu, 13 Sep 2012 20:56:36 +0000 (16:56 -0400)]
resize2fs: enforce restrictions if the kernel doesn't do meta_bg resizing

Enhance the online resizing code to be more nuanced about resizing
restrictions.  If the kernel supports meta_bg resizing, then we can
skip all of the restrictions.  If the kernel does not support meta_bg
resizing, check more carefully to make sure there are enough reserved
gdt blocks, so that the user gets a clearer error message.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoresize2fs: allow meta_bg/64-bit file systems to be online resized
Theodore Ts'o [Fri, 31 Aug 2012 19:31:50 +0000 (15:31 -0400)]
resize2fs: allow meta_bg/64-bit file systems to be online resized

Resize2fs can't handle resizing flex_bg file systems that do not have
the resize inode, but when the kernel adds support for resizing using
the meta_bg layout, we should allow it be able to resize the file
system.

So move the flex_bg/resize_inode check to the just before we start
doing the off-line resize, instead of doing it earlier where it would
prohibit these file systems for both on-line and off-line resizes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoresize2fs: fix overhead calculation for meta_bg file systems
Theodore Ts'o [Mon, 3 Sep 2012 16:40:54 +0000 (12:40 -0400)]
resize2fs: fix overhead calculation for meta_bg file systems

The file system overhead calculation in calculate_minimum_resize_size
was incorrect meta_bg file systems.  This caused the minimum size to
underflow for very large file systems, which threw resize2fs into a
loop generally lasted longer than the user's patience.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoresize2fs: enforce the 16TB limit on 32-bit file systems correctly
Theodore Ts'o [Fri, 7 Sep 2012 04:05:21 +0000 (00:05 -0400)]
resize2fs: enforce the 16TB limit on 32-bit file systems correctly

The 16TB limit must be enforced regardless of whether the new size is
specified on the command line or implied by the size of the device,
but only if the file system does not support 64-bit block sizes, or
the kernel does not advertise support of meta_bg resizing.

Previously we were unconditionally enforcing it when it was implied by
the device size, but not if the new size was specified on the command
line.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agoAllow e2fsprogs to be built using the clang (LLVM) frontend
Theodore Ts'o [Mon, 10 Sep 2012 01:35:39 +0000 (21:35 -0400)]
Allow e2fsprogs to be built using the clang (LLVM) frontend

Since clang uses C99 semantics by default, the main changes required
to allow clang to build e2fsprogs was to add support the C99 inline
semantics, while still allowing us to be built when the legacy (but
still default for gcc) GNU C89 inline semantics are in force.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 years agomke2fs: recalculate the reserved blocks when the last BG is dropped
Akira Fujita [Thu, 30 Aug 2012 11:16:01 +0000 (20:16 +0900)]
mke2fs: recalculate the reserved blocks when the last BG is dropped

mke2fs -m option can set reserved blocks ratio up to 50%.  But if the
last block group is not big enough to support the necessary data
structures, it gets dropped, we have to recalculate the number of
reserved blocks so that the reserved blocks matches the requested
percentage.

It also avoids a problem where if the user specifies a reserved blocks
of 50%, and after the last partial block group was dropped, if the
number of reserved blocks is greater than 50%, e2fsck will complain.

Steps to reproduce:

1. Create a FS which has the overhead for the last BG
   and specify 50 % for reserved blocks ratio
 # mke2fs -m 50 -t ext4 DEV 1025M

 mke2fs 1.42.5 (29-Jul-2012)
 warning: 256 blocks unused.

 Filesystem label=
 OS type: Linux
 Block size=4096 (log=2)
 Fragment size=4096 (log=2)
 Stride=0 blocks, Stripe width=0 blocks
 656640 inodes, 2621440 blocks
 1310848 blocks (50.00%) reserved for the super user
 ~~~~~~~ <-- Reserved blocks exceed 50% of FS blocks count!

2. e2fsck outputs filesystem corruption
 # e2fsck DEV

 e2fsck 1.42.5 (29-Jul-2012)
 Corruption found in superblock.  (r_blocks_count = 1310848).

 The superblock could not be read or does not describe a correct ext2
 filesystem.  If the device is valid and it really contains an ext2
 filesystem (and not swap or ufs or something else), then the superblock
 is corrupt, and you might try running e2fsck with an alternate superblock:
     e2fsck -b 32768 <device>

Signed-off-by: Akira Fujita <a-fujita@rs.jp.ne.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 years agoconfigure: fix --enable-relative-symlink
Theodore Ts'o [Fri, 7 Sep 2012 03:01:14 +0000 (23:01 -0400)]
configure: fix --enable-relative-symlink

The configure option --enable-relative-symlinks was incorrectly
specified in configure.in, as --enable-symlink-relative-symlinks.  Fix
the configure script so that --enable-relative-symlinks works, as well
as previous incorrect command line option.  We will keep the older,
incorrect --enable-symlink-relative-symlinks for at least two years
before removing it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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 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 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>
13 years agoUpdate debian changelog for 1.42.4-3
Theodore Ts'o [Wed, 13 Jun 2012 20:05:30 +0000 (16:05 -0400)]
Update debian changelog for 1.42.4-3

13 years agochattr: add the -C option to the usage message
Liu Bo [Wed, 13 Jun 2012 19:43:23 +0000 (15:43 -0400)]
chattr: add the -C option to the usage message

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 years agoUpdate version.h using the proper abbreviation for June
Theodore Ts'o [Wed, 13 Jun 2012 19:36:56 +0000 (15:36 -0400)]
Update version.h using the proper abbreviation for June

The configure script uses the date string in version.h to calculate a
version date code.  This only used for tagging prerelease tarball, so
it's not a big deal, but fix this for correctness' sake.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agoFix blhc (Build Log Hardening Check) warnings
Theodore Ts'o [Wed, 13 Jun 2012 19:29:13 +0000 (15:29 -0400)]
Fix blhc (Build Log Hardening Check) warnings

The Build Log Hardening Check is a debian tool which scans the output
of a package build making sure that the security hardening flags are
used when compiling and linking all of binaries in a package.

For the most part we were passing CFLAGS, CPPFLAGS, and LDFLAGS down
to the compiler and link commands, but there there were one or two
exceptions.  In addition, there where a few places in "make install"
where the V=1 option was not being honored, which triggered blhc
warnings since it couldn't analyze those commands.

The e2fsck.static was the only binary that was not getting built and
packaged with the hardening flags, but I've fixed all of the blhc
warnings so in the future it will be obvious if we regress.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agolibquota: remove unneeded #include of <sys/quota.h>
Theodore Ts'o [Tue, 12 Jun 2012 22:25:34 +0000 (18:25 -0400)]
libquota: remove unneeded #include of <sys/quota.h>

The attempted inclusion of sys/quota.h is causing failures in when
building on the hurd and freebsd platforms for Debian.  It's not
necessary any more, so just remove the #include.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agoUpdate Release Notes, Changelogs, version.h, etc. for 1.42.4 release v1.42.4
Theodore Ts'o [Tue, 12 Jun 2012 21:21:38 +0000 (17:21 -0400)]
Update Release Notes, Changelogs, version.h, etc. for 1.42.4 release

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agolsattr, chattr: add support for btrfs's No_COW flag
Theodore Ts'o [Tue, 12 Jun 2012 21:09:39 +0000 (17:09 -0400)]
lsattr, chattr: add support for btrfs's No_COW flag

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agotests: allow e2fsck tests to run on OS/X
Andreas Dilger [Tue, 12 Jun 2012 17:59:56 +0000 (13:59 -0400)]
tests: allow e2fsck tests to run on OS/X

The "mktemp" program requires a template on OS/X.  Allow the test
TMPFILE to be created in the local /tmp directory for both OS/X
and Linux.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 years agotests: add two more tests of orphaned inode handling
Theodore Ts'o [Tue, 12 Jun 2012 05:38:57 +0000 (01:38 -0400)]
tests: add two more tests of orphaned inode handling

Add two tests, f_orphan_indirect_inode, and f_orphan_extents_inode,
which tests the bug fixes in the two previous commits:

e2fsck: update global free blocks/inodes count when truncating orphan inodes
libext2fs: fix block iterator for extents when truncating inodes

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agolibext2fs: fix block iterator for extents when truncating inodes
Theodore Ts'o [Tue, 12 Jun 2012 04:27:39 +0000 (00:27 -0400)]
libext2fs: fix block iterator for extents when truncating inodes

When e2fsck uses the block iterator to release the blocks in an
extent-mapped inode, when the last block in an extent is removed, the
current extent has been removed and the extent cursor is now pointing
at the next inode.  But the block iterator code doesn't know that.  So
when it tries to go the next extent, it will end up skipping an
extent, and so the inode will be incompletely truncated.

The fix is to go to the next extent before calling the callback
function for the current extent.  This way, regardless of whether the
current extent gets removed, the extent cursor is still pointing at
the right place.

Reported-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agoe2fsck: update global free blocks/inodes count when truncating orphan inodes
Theodore Ts'o [Tue, 12 Jun 2012 02:18:25 +0000 (22:18 -0400)]
e2fsck: update global free blocks/inodes count when truncating orphan inodes

By the time we start processing the orphan inode list, we have already
calculated the total expected number of free blocks and inodes in
ctx->free_{blocks,inodes}.  This is used to set the free blocks/inodes
count in the superblock in the case where we don't need to do a full
e2fsck.

We need to update these expected free block counts as we process the
orphan inode list so that superblock values are set correctly.
Otherwise we could have the following happen:

% e2fsck /tmp/test.img
e2fsck 1.42.3 (14-May-2012)
Truncating orphaned inode 12 (uid=0, gid=0, mode=0100644, size=0)
Setting free blocks count to 46 (was 79)
/tmp/test.img: clean, 12/16 files, 54/100 blocks

% e2fsck /tmp/test.img
e2fsck 1.42.3 (14-May-2012)
Setting free blocks count to 79 (was 46)
/tmp/test.img: clean, 12/16 files, 21/100 blocks

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agodebugfs: interpret date strings of the form @dddd
Theodore Ts'o [Tue, 12 Jun 2012 02:02:17 +0000 (22:02 -0400)]
debugfs: interpret date strings of the form @dddd

Debugfs will now interpret date strings of the form @123 as 123
seconds after the start of the epoch.  This is handy when editing an
orphan inode linked list using the inode's deletion time field.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agotests: add new test f_zero_extent_length
Tao Ma [Mon, 11 Jun 2012 03:56:30 +0000 (23:56 -0400)]
tests: add new test f_zero_extent_length

If all of the extents in the last extent tree block (ETB) in a
non-trivial extent tree contain uninitialized extents which are after
the end of the file as defined by i_size, the hueristics will
incorrectly estimate the last entry (and hence the node's e_len field)
in the last entry of each level of the extent tree.

As Tao Ma has noted, since e2fsck was requiring that the length
(e_len) field of interior nodes be non-zero, this was causing false
failures where e2fsck would declare that the extent tree was
corrupted.

This was fixed in commit 9c40d14841: "e2fsck: only check for
zero-length leaf extents".  Add a regression test case to ensure that
this issue remains fixed.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 years agoe2fsck: only check for zero-length leaf extents
Theodore Ts'o [Mon, 11 Jun 2012 04:25:45 +0000 (00:25 -0400)]
e2fsck: only check for zero-length leaf extents

The on-disk format for interior nodes in the extent tree does not
encode the length of each entry in the interior node; instead, it is
synthesized/simulated by the extent library code in libext2fs.
Unfortunately, this simulation is not perfect; in particular it does
not work for the last extent in the extent tree if there are
uninitialized blocks allocated using fallocate with
FALLOC_FL_KEEP_SIZE, and it leads to e2fsck incorrectly complaining
about an invalid zero-length extent.

We only need to worry about the extent length for the leaves of the
tree, since it is there were we are checking an on-disk value, as
opposed to a software-generated simulation.  So restrict the check of
extent length to leaf nodes in the extent tree.

Reported-by: Tao Ma <tm@tao.ma>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agolibext2fs: fix i_blocks for extent leaf create/delete with bigalloc
Aditya Kali [Mon, 11 Jun 2012 03:52:11 +0000 (23:52 -0400)]
libext2fs: fix i_blocks for extent leaf create/delete with bigalloc

When libext2fs allocates/deletes an extent leaf, the i_blocks
value is incremented/decremented by fs->blocksize / 512. This
is incorrect in case of bigalloc. The correct way here is to
use cluster_size / 512.

The problem is seen if we try to create a large inode using
libext2fs (say using ext2fs_block_iterate3()) on a bigalloc
filesystem. fsck catches this and complains.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 years agoe2fsck: correctly propagate error from journal to superblock
Theodore Ts'o [Mon, 11 Jun 2012 03:35:43 +0000 (23:35 -0400)]
e2fsck: correctly propagate error from journal to superblock

If the file system is mounted read-only after a file system error has
been detected, the fact that an error occurred is written to the
journal.  This is important because while the journal is getting
replayed, the error indication in the superblock may very well get
overwritten.

Unfortunately, the code to propagate the error indication from the
journal to superblock was broken because this was being done before
the old file system handle is thrown away and the file system is
re-opened to ensure that no stale data is in the file system handle.
As a result, the error indication in the superblock was never written
out.

To fix this, we need to move the check if the journal's error
indicator has been set after the file system has been freed and
re-open.

Reported-by: Ken Sumrall <ksumrall@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agolibquota: remove unnecessary definitions
Jan Kara [Mon, 4 Jun 2012 16:51:55 +0000 (12:51 -0400)]
libquota: remove unnecessary definitions

Quite some definitions in quota library are not necessary. Remove them.
Also fold quota.h file into quotaio.h since it didn't contain that many
definitions.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 years agotests: fix the e2fsck test script to handle a missing test name
Theodore Ts'o [Fri, 1 Jun 2012 00:13:51 +0000 (20:13 -0400)]
tests: fix the e2fsck test script to handle a missing test name

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