Whamcloud - gitweb
tools/e2fsprogs.git
8 years agoLU-7867 debugfs: fix check for out-of-bound xattr value
Andreas Dilger [Fri, 18 Mar 2016 08:03:45 +0000 (02:03 -0600)]
LU-7867 debugfs: fix check for out-of-bound xattr value

Since upsream commit 8a546777119c9c0, the validity check for in-inode
xattrs in internal_dump_inode_extra() has been incorrectly checking
the value size.  The value can go right to the end of the inode.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Id20861df7c973d76a433aecfcfd125ca32ce117b
Reviewed-on: http://review.whamcloud.com/18999
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Jenkins
Reviewed-by: Matt Ezell <ezellma@ornl.gov>
8 years agoLDEV-325 e2fsprogs: even up build version of distros
Niu Yawei [Mon, 7 Mar 2016 16:47:39 +0000 (11:47 -0500)]
LDEV-325 e2fsprogs: even up build version of distros

Change the build version of all distros to 7.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I6e0445f6cca84f5c418a9cc91f19892dd5a7e33f
Reviewed-on: http://review.whamcloud.com/18809
Reviewed-by: Brian J. Murrell <brian.murrell@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
8 years agoLU-7381 e2fsprogs: update build version to 1.42.13.wc4
Andreas Dilger [Fri, 27 Nov 2015 05:54:29 +0000 (22:54 -0700)]
LU-7381 e2fsprogs: update build version to 1.42.13.wc4

Update build version to 1.42.13.wc4

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I2ac0b7e30a3a0aecc0310d838e2a3c9292191e35
Reviewed-on: http://review.whamcloud.com/17431
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
8 years agoLU-7381 e2fsck: fix e2fsck -fD directory truncation
Andreas Dilger [Fri, 13 Nov 2015 05:35:17 +0000 (22:35 -0700)]
LU-7381 e2fsck: fix e2fsck -fD directory truncation

When an extent-mapped directory is compacted by "e2fsck -fD" and
frees enough leaf blocks that it loses an extent tree index block,
the old e2fsck_rehash_dir->ext2fs_block_iterate3->write_dir_block()
code would not free the extent block, which would result in the
extent tree becoming corrupted when it is written out.

    Pass 1: Checking inodes, blocks, and sizes
    Inode 17825800, end of extent exceeds allowed value
            (logical block 710, physical block 570459684, len 1019)

This results in loss of a whole index block of directory leaf blocks
and thousands or millions of files in lost+found.

Fix e2fsck_rehash_dir() to call ext2fs_punch() to free the blocks
at the end of the directory instead of trying to handle this itself
while writing out the directory.  That properly handles all of the
cases of updating the extent tree as well as accounting for blocks
that are released (both leaf blocks and index blocks).

Add a test case for compacting the directory to be smaller than the
index block that originally caused the corruption.

e2fsprogs-commit: 19961cd0003564c63c33ec14e69dfec6d81a2238
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Change-Id: I2e075849423693ebf4468fd7b0f41d6b2f500c1e
Reviewed-on: http://review.whamcloud.com/17153
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
8 years agoLU-7381 libext2fs: fix block-mapped file punch
Andreas Dilger [Fri, 13 Nov 2015 10:48:34 +0000 (03:48 -0700)]
LU-7381 libext2fs: fix block-mapped file punch

If ext2fs_punch() was called with "end = ~0ULL" to indicate truncate
to the end of file it tried to compute "count" for ext2fs_punch_ind()
based on "start" and "end", but incorrectly passed "count = ~0U" even
when "start" was non-zero, causing an overflow in some cases.

The calling convention for ext2fs_punch_ind() was also gratuitously
different from ext2fs_punch() and ext2fs_punch_extent(), passing
"count" instead of "end" as the last parameter.  Fix this by passing
it "end" like the other functions, and handle "count" internally.

Add checks to ext2fs_punch_ind() if "end" is at or beyond the 2^32
indirect block limit so the 32-bit internal variables don't overflow.

e2fsprogs-commit: e158db537754ae1ffb3ec6184051bd1a4226937a
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Change-Id: Ifb8f76c2fbcc9f320dbbe7c1c2c329ce363ebbe5
Reviewed-on: http://review.whamcloud.com/17152
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
8 years agoLU-7368 e2fsck: skip quota update when interrupted
Andreas Dilger [Mon, 2 Nov 2015 08:56:56 +0000 (01:56 -0700)]
LU-7368 e2fsck: skip quota update when interrupted

There is a bug in how e2fsck handles being interrupted by CTRL-C.
If CTRL-C is pressed to kill e2fsck rather than e.g. kill -9, then
the interrupt handler sets E2F_FLAG_CANCEL in the context but doesn't
actually kill the process.  Instead, e2fsck_pass1() checks this flag
before processing the next inode.

If a filesystem is running in fix mode (e2fsck -fy) is interrupted,
and the quota feature is enabled, then the quota file will still be
written to disk even though the inode scan was not complete and the
quota information is totally inaccurate.  Even worse, if the Pass 1
inode and block scan was not finished, then the in-memory block
bitmaps (which are used for block allocation during e2fsck) are also
invalid, so any blocks allocated to the quota files may corrupt other
files if those blocks were actually used.

  e2fsck 1.42.13.wc3 (28-Aug-2015)
  Pass 1: Checking inodes, blocks, and sizes
  ^C[QUOTA WARNING] Usage inconsistent for ID 0:
      actual (6455296, 168) != expected (8568832, 231)
  [QUOTA WARNING] Usage inconsistent for ID 695:
      actual (614932320256, 63981) != expected (2102405386240, 176432)
  Update quota info for quota type 0? yes

  [QUOTA WARNING] Usage inconsistent for ID 0:
      actual (6455296, 168) != expected (8568832, 231)
  [QUOTA WARNING] Usage inconsistent for ID 538:
      actual (614932320256, 63981) != expected (2102405386240, 176432)
  Update quota info for quota type 1? yes

  myth-OST0001: e2fsck canceled.
  myth-OST0001: ***** FILE SYSTEM WAS MODIFIED *****

There may be a desire to flush out modified inodes and such that have
been repaired, so that restarting an interrupted e2fsck will make
progress, but the quota file update is plain wrong unless at least
pass1 has finished, and the journal recreation is also dangerous if
the block bitmaps have not been fully updated.

e2fsprogs-commit: db3d8718be6ad3bdd252b242827fa54914b8ec2e
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Change-Id: I3a8df5965cb496ab1f5e2cba00de892686470b7d
Reviewed-on: http://review.whamcloud.com/17150
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
8 years agolibext2fs: fix parents when modifying extents
Darrick J. Wong [Sat, 15 Mar 2014 15:36:34 +0000 (11:36 -0400)]
libext2fs: fix parents when modifying extents

In ext2fs_extent_set_bmap() and ext2fs_punch_extent(), fix the parents
when altering either end of an extent so that the parent nodes reflect
the added mapping.

There's a slight complication to using fix_parents: if there are two
mappings to an lblk in the tree, the value of handle->path->curr can
point to either extent afterwards), which is documented in a comment.

Some additional color commentary from Darrick:

  In the _set_bmap() case, I noticed that the "remapping last block
  in extent" case would produce symptoms if we are trying to remap a
  block from "extent" to "next_extent", and the two extents are
  pointed to by different index nodes.  _extent_replace(...,
  next_extent) updates e_lblk in the leaf extent, but because there's
  no _extent_fix_parents() call, the index nodes never get updated.

  In the _punch_extent() case, we conclude that we need to split an
  extent into two pieces since we're punching out the middle.  If the
  extent is the last extent in the block, the second extent will be
  inserted into a new leaf node block.  Without _fix_parents(), the
  index node doesn't seem to get updated.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Change-Id: I0fb7af2f6e88c84ef2e4656e2116a4721d57fd45
Reviewed-on: http://review.whamcloud.com/17151
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agoLU-7267 e2fsck: remove duplicated ea value size check
Niu Yawei [Fri, 9 Oct 2015 06:50:32 +0000 (02:50 -0400)]
LU-7267 e2fsck: remove duplicated ea value size check

Remove the duplicated ea value size check in check_ea_in_inode().

Add a regression test by modifying the test in
f_valid_ea_in_inode:
- Enable EA_INODE feature to the image;
- Add a new file which has large xattr, so that this file has both
  extra space in inode and external inode for large ea.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I1c1a4c444ee61d8d7e26ea878bcef56471aa9c42
Reviewed-on: http://review.whamcloud.com/16779
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agoLU-6722 jbd: double minimum journal size for RHEL7
Fan Yong [Fri, 26 Jun 2015 15:29:59 +0000 (23:29 +0800)]
LU-6722 jbd: double minimum journal size for RHEL7

In RHEL7 (kernel version >= 3.10.0), the maximum journal transaction
size is reduced to half of the RHEL6 case. That may cause Lustre to
complain that the declared transaction credits too large for very
small journal device. This patch increases the minimum journal size
from 4MB to 8MB for RHEL7 case, then counteract the above limitation
about the journal transaction size.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: Iec8a2c561416cb7b5acce342c8ebcb845c8d7a19
Reviewed-on: http://review.whamcloud.com/15401
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agoLU-5845 build: add support for SUSE_LINUX-12 .spec file
Bob Glossman [Thu, 16 Oct 2014 18:41:07 +0000 (11:41 -0700)]
LU-5845 build: add support for SUSE_LINUX-12 .spec file

Add the SLES 12 .spec file.

Signed-off-by: Bob Glossman <bob.glossman@intel.com>
Change-Id: I3b716c09ea8632d2333aaf61b8a6c881ccd18a88
Reviewed-on: http://review.whamcloud.com/12316
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agoLU-5501 revert: blkid,ext2fs: avoid name clash with __u{8,16,32,64}
Andreas Dilger [Tue, 9 Sep 2014 21:06:06 +0000 (15:06 -0600)]
LU-5501 revert: blkid,ext2fs: avoid name clash with __u{8,16,32,64}

This reverts commit 5023510dd7f0ab40a216d3600ab665e2053cc070.

Temporarily revert this change for the Lustre e2fsprogs, since it
causes Lustre 2.5.3 (only) builds to fail in llverfs.c and llverdev.c.
They include <ext2fs/ext2fs.h>, which includes ext2-types.h, which
only conditionally declares __u32 et.al. with the patch applied.

The Lustre 2.5.3 config.h file defines HAVE___U32 et.al and config.h
is implicitly included into llverfs.c and llverdev.c by libtool in
the Makefile, but these __u* types are not actually declared in any
of the headers included by llverfs.c or llverdev.c, hence failure.

This patch can be dropped once http://review.whamcloud.com/11840
is landed and Lustre 2.5.4 is released.  It is not needed for b2_4-
(doesn't use libtool) or b2_6+ (removes HAVE___U* defines).

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: If16ac468d6b861d79bd84e7963729f5b46500c1e
Reviewed-on: http://review.whamcloud.com/11901
Tested-by: Jenkins
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
8 years agoLU-5307 build: add support for RHEL-7 .spec file
Andreas Dilger [Fri, 18 Jul 2014 20:47:02 +0000 (14:47 -0600)]
LU-5307 build: add support for RHEL-7 .spec file

Add the RHEL 7 .spec file.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I00278b50c3669f56c5297a75b89775fec9476f43

8 years agoLU-1540 e2fsck: add missing symlink NUL terminator
Andreas Dilger [Sat, 14 Jul 2012 02:33:01 +0000 (20:33 -0600)]
LU-1540 e2fsck: add missing symlink NUL terminator

If a long symbolic link target is written into an external block
without a NUL terminator, its length is decided by the inode's size.
Make symlink check add a NUL termination in such cases if needed.

Such faulty symlinks were generated by osd-ldiskfs on the MDS until
Lustre 2.1.3 and Lustre 2.3.  The in-kernel code would handle such
unterminated symlinks correctly, since it used the inode size to
determine the symlink length, but e2fsck would assume the symlink
is broken if there wasn't a trailing NUL.

  LU-2627 e2fsck: check_symlink() SIGSEGV

  Since e2fsck_pass1_check_symlink() calls into check_symlink()
  with pctx == NULL, we should use 'ino' instead of 'pctx->ino'
  in check_symlink().

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
  Change-Id: If9c16f96d0655d5a886ef607f1f47ced6176f8d8

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I4419b30f1adb4a7d273796a936427aa351510213

8 years agoLU-1502 build: enable quota when building
Niu Yawei [Mon, 11 Jun 2012 13:33:55 +0000 (06:33 -0700)]
LU-1502 build: enable quota when building

The quota support is disabled by default, but we need to enable it
explicitly when build e2fsprogs for Lustre 2.4.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: Ic09f7c100b254559a5223460242b3bf465ff0802

8 years agotests: add basic test case for e2scan
Andreas Dilger [Fri, 13 Apr 2012 19:24:30 +0000 (13:24 -0600)]
tests: add basic test case for e2scan

Add a simple test to verify that e2scan is detecting the correct
files in the filesystem based on the modification time.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agoe2scan: a tool for fast namespace/inode scanning
Andreas Dilger [Fri, 13 Apr 2012 19:17:37 +0000 (13:17 -0600)]
e2scan: a tool for fast namespace/inode scanning

e2scan is a tool for efficiently scanning inodes for changes,
or all inodes, and then generating pathnames for the inodes
of interest.

  LU-3612 e2scan: fix missing header for e2scan to enable SQLite
    SQLite function is always disabled due to missing config.h
Signed-off-by: Shuichi Ihara <sihara@ddn.com>
  Change-Id: Ie4b49bd6d04a6f1e25610df51d17b97d3dc4fe5f

  LU-4328 e2scan: Missing copyright attribution
    Copyright headers are added to the files for e2scan.
    A minor correction was made to the header of tst_read_ea.c
Signed-off-by: James Nunez <james.a.nunez@intel.com>
  Change-Id: Icc359e717a0177b83a08f2471d84e68487dafee3

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agoext2fs: add readahead method to improve scanning
Andreas Dilger [Fri, 13 Apr 2012 18:58:53 +0000 (12:58 -0600)]
ext2fs: add readahead method to improve scanning

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

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

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agoext2fs: check if Lustre filesystem is mounted
Andreas Dilger [Fri, 13 Apr 2012 08:16:24 +0000 (02:16 -0600)]
ext2fs: check if Lustre filesystem is mounted

Add a check to ext2fs_check_mount_point() to loo in /proc/fs/lustre/*
to see if Lustre is mounted, since st_rdev of the mountpoint does not
match st_rdev of the block device itself, which confuses libext2fs.

  LU-6093 ext2fs: don't confuse mke2fs by Lustre zfs mount

  check_if_lustre_mounted() by efb735 will mistakenly report the
  device is mounted when there is a ZFS-based Lustre mount.

  This patch fix it by parsing the real device name from the pool
  name exported in Lustre proc file with "zpool" command.

  It also includes a typo fix in check_if_lustre_mounted() and a
  few other code cleanups.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
  Change-Id: I43dabbcd6fa721c569cd9cc0f4a6de93ab761392
  Reviewed-on: http://review.whamcloud.com/14223
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agodebugfs: dump "fid" and "lma" xattrs on inode stat
Andreas Dilger [Fri, 13 Apr 2012 18:55:45 +0000 (12:55 -0600)]
debugfs: dump "fid" and "lma" xattrs on inode stat

Print out the Lustre "fid" and "lma" object xattr contents,
if present, with debugfs stat to simplify debugging.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agoLU-1774 tests: e2fsck -D does not change dirdata
Bobi Jam [Sat, 25 Aug 2012 07:08:59 +0000 (15:08 +0800)]
LU-1774 tests: e2fsck -D does not change dirdata

Add test case for directory optimization to preserve dirdata
content for dot and dotdot entries.

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

8 years agotests: add basic tests for dirdata feature
Andreas Dilger [Fri, 13 Apr 2012 19:42:42 +0000 (13:42 -0600)]
tests: add basic tests for dirdata feature

Signed-off-by: Pravin Shelar <pravin@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
8 years agoe2fsck: add support for dirdata feature
Andreas Dilger [Fri, 13 Apr 2012 19:39:26 +0000 (13:39 -0600)]
e2fsck: add support for dirdata 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.xu@intel.com>
  Change-Id: Iae190794da75a2080a8e5cc5b95a49e0c894f72f

  LU-2462 e2fsprogs Consider DIRENT_LUFID flag in link_proc().

  While adding the new file entry in directory block, link_proc()
  calculates minimum record length of the existing directory entry
  without considering the dirent data size and which leads to
  corruption. Changed the code to use EXT2_DIR_REC_LEN() which will
  return correct record length including dirent data size.

Signed-off-by: Manisha Salve <msalve@ddn.com>
  Change-Id: Ic593c558c47a78183143ec8e99d8385ac94d06f7

  LU-4677 libext2fs, e2fsck: don't use ext2_dir_entry_2

  Due to endian issues, do not use ext2_dir_entry_2 because it will
  have the wrong byte order on directory entries that are swabbed.
  Instead, use the standard practice of mask-and-shift to access the
  file_type and dirdata flags.

Signed-off-by: Pravin Shelar <pravin@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
8 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 <andreas.dilger@intel.com>
8 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 <andreas.dilger@intel.com>
8 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 <andreas.dilger@intel.com>
8 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 <andreas.dilger@intel.com>
8 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.

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.

A second e2fsck run is done to verify that all of the errors are
fixed in the first pass, and that the filesystem is free of errors.

Don't run the random corruption test during RPM builds to avoid
random test failures during package building.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 years agoe2fsck: mark device inodes with EXT4_EXTENTS_FL bad
Andreas Dilger [Thu, 12 Apr 2012 22:15:07 +0000 (16:15 -0600)]
e2fsck: mark device inodes with EXT4_EXTENTS_FL bad

Mark device inodes bad if they have the EXT4_EXTENTS_FL set, since
this should never happen and likely shows the inode is corrupt.

Change-Id: I85ab667b39ff57c658a779e59f692a080217690e
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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.

  LU-4284 build: add missing Provides line in SLES spec file

  Need to add a line in the SUSE spec file for Provides: ldiskfsprogs.
  This is present in the RHEL spec file and is needed to resolve
  dependencies in lustre server rpms at rpm install time.

Signed-off-by: Bob Glossman <bob.glossman@intel.com>
  Change-Id: Ib4821004d27c9a7271ffdbd7403990e586d6c9ca

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I783d58bd78d7c4c66cc85ec5557ae1aaf64016ba

9 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 <andreas.dilger@intel.com>
9 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
bs 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 <andreas.dilger@intel.com>
9 years agofilefrag: Lustre changes to filefrag FIEMAP handling
Andreas Dilger [Thu, 12 Apr 2012 21:31:35 +0000 (15:31 -0600)]
filefrag: Lustre changes to filefrag FIEMAP handling

Add support for multiple-device filesystems by defining a new
fe_device field in the fiemap_extent structure.  This allows
printing the filesystem-relative or linux block device number
associated with each extent of a file.  If a single filesystem
extent is mirrored to multiple block devices, the fe_device
field can be used to disambiguate the multiple copies.

If the "-l" (device-logical) option is given to filefrag, then
all extents for a particular device of a file are returned
before returning extents for the next device.  This makes it
easier to see if extent allocation within a single device is
contiguous, instead of returning all of the blocks of a file
interleaved in file-logical-offset order.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 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 <andreas.dilger@intel.com>
9 years agoLU-5307 build: fix unused/uninitialized variable warnings
Andreas Dilger [Wed, 23 Jul 2014 07:00:45 +0000 (01:00 -0600)]
LU-5307 build: fix unused/uninitialized variable warnings

Fix a few warnings about unused and uninitialized variables.

Also fix util/subst.c to include <sys/time.h> to avoid using
undeclared functions gettimeofday() and futimes().

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Id7deabf6eb1f59ce98ab2cb51b9bf5198c500c1e

9 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 <andreas.dilger@intel.com>
9 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 Lustre-specific build version to distinguish packages from
upstream packages.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
9 years agoRevert "aclocal.m4: update to newer versions of autoconf macros"
Andreas Dilger [Thu, 24 Jul 2014 22:01:42 +0000 (16:01 -0600)]
Revert "aclocal.m4: update to newer versions of autoconf macros"

This patch breaks RPM building on RHEL5 because it requires
autoconf-2.60, but RHEL5 only has autoconf-2.59 available.
Revert the patch, since it doesn't appear to have any benefits
for the distros that Lustre is are building on.

This reverts commit 936139510672e394aa8dd1aa315c8d633fc636e3.

9 years agodebian: remove trailing spaces from control.in file
Theodore Ts'o [Mon, 18 May 2015 06:14:55 +0000 (02:14 -0400)]
debian: remove trailing spaces from control.in file

This were causing lintian failures.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoUpdate release notes, etc. for final 1.42.13 release v1.42.13
Theodore Ts'o [Mon, 18 May 2015 01:10:07 +0000 (21:10 -0400)]
Update release notes, etc. for final 1.42.13 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoMerge remote-tracking branch 'origin/maint' into maint
Theodore Ts'o [Mon, 18 May 2015 01:25:45 +0000 (21:25 -0400)]
Merge remote-tracking branch 'origin/maint' into maint

9 years agoUpdate translation template file
Theodore Ts'o [Mon, 18 May 2015 00:34:58 +0000 (20:34 -0400)]
Update translation template file

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoAdd the Danish translation file from the Translation Project
Theodore Ts'o [Mon, 18 May 2015 00:27:50 +0000 (20:27 -0400)]
Add the Danish translation file from the Translation Project

The Danish translation is now up to 829/1317 messages, which is much
better than it had been before, and better than some of the current
translations which we are including in the e2fsprogs distribution.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update es.po (from translationproject.org)
Antonio Ceballos [Mon, 18 May 2015 00:21:40 +0000 (20:21 -0400)]
po: update es.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update eo.po (from translationproject.org)
Benno Schulenberg [Mon, 18 May 2015 00:21:39 +0000 (20:21 -0400)]
po: update eo.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update de.po (from translationproject.org)
Philipp Thomas [Mon, 18 May 2015 00:21:39 +0000 (20:21 -0400)]
po: update de.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agopo: update ca.po (from translationproject.org)
Àngel Mompó [Mon, 18 May 2015 00:21:39 +0000 (20:21 -0400)]
po: update ca.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: use PROMPT_NONE for FUTURE_SB_LAST_*_FUDGED problems
Theodore Ts'o [Sun, 29 Mar 2015 01:39:54 +0000 (21:39 -0400)]
e2fsck: use PROMPT_NONE for FUTURE_SB_LAST_*_FUDGED problems

This allows us to print a message warning the user that there is
something funny going on with their hardware clock (probably time zone
issues caused by trying to be compatible with legacy OS's such as
Windows), without triggering a full file system check.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: fix potential buffer overflow in closefs()
Theodore Ts'o [Fri, 6 Feb 2015 17:46:39 +0000 (12:46 -0500)]
libext2fs: fix potential buffer overflow in closefs()

The bug fix in f66e6ce4446: "libext2fs: avoid buffer overflow if
s_first_meta_bg is too big" had a typo in the fix for
ext2fs_closefs().  In practice most of the security exposure was from
the openfs path, since this meant if there was a carefully crafted
file system, buffer overrun would be triggered when the file system was
opened.

However, if corrupted file system didn't trip over some corruption
check, and then the file system was modified via tune2fs or debugfs,
such that the superblock was marked dirty and then written out via the
closefs() path, it's possible that the buffer overrun could be
triggered when the file system is closed.

Also clear up a signed vs unsigned warning while we're at it.

Thanks to Nick Kralevich <nnk@google.com> for asking me to look at
compiler warning in the code in question, which led me to notice the
bug in f66e6ce4446.

Addresses: CVE-2015-1572

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agobuildsystem: use 'chmod a-w' instead of 'chmod -w'
Enrico Scholz [Fri, 23 Jan 2015 17:05:17 +0000 (12:05 -0500)]
buildsystem: use 'chmod a-w' instead of 'chmod -w'

'chmod -w' is not portable and can break the build:

| chmod: chmod: ss_err.h: new permissions are r--rw-r--, not r--r--r--
| ss_err.h: new permissions are r--rw-r--, not r--r--r--
| chmod: ss_err.c: new permissions are r--rw-r--, not r--r--r--
| make[2]: *** [ss_err.h] Error 1

This happens because 'chmod -w' is affected by umask. Issue can be
reproduced e.g. by

$ mkdir /tmp/foo
$ setfacl -m d:m:rwx /tmp/foo

$ umask 022
$ touch /tmp/foo/x
$ chmod -w /tmp/foo/x
chmod: /tmp/foo/x: new permissions are r--rw-r--, not r--r--r--

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: fix corruption of Hurd filesystems
Justus Winter [Fri, 23 Jan 2015 15:15:57 +0000 (10:15 -0500)]
e2fsck: fix corruption of Hurd filesystems

Previously, e2fsck accessed the field osd2.linux2.l_i_file_acl_high
field without checking that the filesystem is indeed created for
Linux.  This lead to e2fsck constantly complaining about certain
nodes:

i_file_acl_hi for inode XXX (/dev/console) is 32, should be zero.

By "correcting" this problem, e2fsck would clobber the field
osd2.hurd2.h_i_mode_high.

Properly guard access to the OS dependent fields.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoFix clang warning and a resource leak
Darrick J. Wong [Mon, 19 Jan 2015 21:31:49 +0000 (16:31 -0500)]
Fix clang warning and a resource leak

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: close the progress_fd in the logfile child process
Theodore Ts'o [Tue, 13 Jan 2015 00:42:29 +0000 (19:42 -0500)]
e2fsck: close the progress_fd in the logfile child process

If e2fsck.conf's logging feature is enabled, and e2fsck is being run
via systemd-fsck, there will be a deadlock since systemd-fsck is
waiting for progress_fd pipe to be closed, instead of waiting for the
fsck process to exit --- and so the logfile child process won't exit
until it can write out the logfile, and systemd won't continue the
boot process so that the file system can be remounted read-write.
Oops.

Addresses-Debian-Bug: #775234

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: add sanity check for an invalid itable_used value in inode scan code
Theodore Ts'o [Fri, 26 Dec 2014 04:18:32 +0000 (23:18 -0500)]
libext2fs: add sanity check for an invalid itable_used value in inode scan code

If the number of unused inodes is greater than number of inodes a
block group, this can cause an e2fsck -n run of the file system to
crash.

We should add more checks to e2fsck to detect this case directly, but
this will at least protect progams (tune2fs, dump, etc.) which use the
inode_scan abstraction from crashing on an invalid file system.

Addresses-Debian-Bug: #773795

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agobadblocks: Limit maximum number of bad blocks
Jan Kara [Mon, 15 Dec 2014 01:55:44 +0000 (20:55 -0500)]
badblocks: Limit maximum number of bad blocks

Currently maximum number of bad blocks is not limited in any way.
However our code can really handle at most INT_MAX/2 bad blocks (for
larger numbers binary search indexes start overflowing). So report
number of bad blocks is just too big instead of plain segfaulting.

It won't be too hard to raise the limit but I don't think there's any
real use for disks with over 1 billion of bad blocks...

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoresize2fs: don't require fsck to print min size
Eric Sandeen [Mon, 15 Dec 2014 00:08:59 +0000 (19:08 -0500)]
resize2fs: don't require fsck to print min size

My previous change ended up requiring that the filesystem
be fsck'd after the last mount, even if we are only querying
the minimum size.  This is a bit draconian, and it burned
the Fedora installer, which wants to calculate minimum size
for every filesystem in the box at install time, which in turn
requires a full fsck of every filesystem.

Try this one more time, and separate out the tests to make things
a bit more clear.  If we're only printing the min size, don't
require the fsck, as this is a bit less dangerous/critical.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agomisc: fix infinite loop when finding the start of the hugefile start range
Darrick J. Wong [Wed, 3 Dec 2014 03:00:04 +0000 (22:00 -0500)]
misc: fix infinite loop when finding the start of the hugefile start range

When looking for the start of the hugefile range, the 'next' variable
is incorrectly decremented.  If we happened to find a single free
block, the effect of this decrement is that blk == next, which means
that we never modify the loop control variable, so get_start_block
never returns.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agotune2fs: fix memory leak in inode_scan_and_fix()
Xiaoguang Wang [Wed, 3 Dec 2014 02:06:40 +0000 (21:06 -0500)]
tune2fs: fix memory leak in inode_scan_and_fix()

When we use ext2fs_open_inode_scan() to iterate inodes and finish
jobs, we also need a ext2fs_close_inode_scan(scan) operation, but in
inode_scan_and_fix(), we forgot to call it, fix this error.

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agodebugfs: fix typo in message
Bernhard M. Wiedemann [Tue, 2 Dec 2014 20:23:55 +0000 (15:23 -0500)]
debugfs: fix typo in message

Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: don't allow alloc_stats on bad inode/block numbers
Darrick J. Wong [Mon, 17 Nov 2014 22:59:42 +0000 (17:59 -0500)]
libext2fs: don't allow alloc_stats on bad inode/block numbers

Don't allow callers to feed bad block/inode numbers to
ext2fs_*_alloc_stats2, because evil callers (<cough>resize2fs<cough>)
can corrupt library state this way, leading to a crash.

(There will be a subsequent patch to resize2fs to fix its bad
behavior.)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: fix endian handling error; reduce fragmentation some
Darrick J. Wong [Sat, 8 Nov 2014 02:27:53 +0000 (21:27 -0500)]
libext2fs: fix endian handling error; reduce fragmentation some

If we're going to read the "nr - 1" entry in an indirect block for use
as a "goal" input to the block allocator, we need to byteswap the
entry.  While we're at it, if we're allocating blocks for the zeroth
entry in the indirect block, we might as well use the indirect block
as the starting point to try to reduce fragmentation.

(d_fallocate_blkmap will test this...)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agodumpe2fs: don't crash when the user provides no block device argument
Darrick J. Wong [Sat, 8 Nov 2014 02:26:14 +0000 (21:26 -0500)]
dumpe2fs: don't crash when the user provides no block device argument

If the user doesn't provide any arguments, the guard fails to run and
the whole thing segfaults on ext2fs_open2().  Don't do that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: fix dangling pointer when dir_info array is resized
Darrick J. Wong [Wed, 5 Nov 2014 16:14:26 +0000 (11:14 -0500)]
e2fsck: fix dangling pointer when dir_info array is resized

e2fsck uses an array to store directory usage information during pass
3; the usage context also contains a pointer to the last directory
looked up.  When expanding the dir_info array, this cache pointer
needs to be cleared if the array resize changed the pointer location,
or else we'll later walk off the end of this dead pointer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agoe2fsck: fix reporting of unknown htree block inode number
Darrick J. Wong [Wed, 5 Nov 2014 16:10:31 +0000 (11:10 -0500)]
e2fsck: fix reporting of unknown htree block inode number

Sami Liedes reports that e2fsck fails to report the correct directory
inode number during a pass2 check for unexpected HTREE blocks.
Provide the inode number in the problem report.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: don't memcpy identical pointers when writing a cache block
Darrick J. Wong [Tue, 4 Nov 2014 16:43:08 +0000 (11:43 -0500)]
libext2fs: don't memcpy identical pointers when writing a cache block

Sami Liedes found a scenario where we could memcpy incorrectly:

If a block read fails during an e2fsck run, the UNIX IO manager will
call the io->read_error routine with a pointer to the internal block
cache.  The e2fsck read error handler immediately tries to write the
buffer back out to disk(!), at which point the block write code will
try to copy the buffer contents back into the block cache.  Normally
this is fine, but not when the write buffer is the cache itself!

So, plumb in a trivial check for this condition.  A more thorough
solution would pass a duplicated buffer to the IO error handlers, but
I don't know if that happens frequently enough to be worth the extra
point of failure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: directory iteration mustn't walk off the buffer end
Darrick J. Wong [Sat, 25 Oct 2014 20:56:42 +0000 (13:56 -0700)]
libext2fs: directory iteration mustn't walk off the buffer end

When we're iterating a directory, the loop control code reads the
length of the next directory record, failing to account for the fact
that there must be at least 8 bytes (the minimum size of a directory
entry) left in the buffer to read the next directory record.  Fix the
loop conditional so that we don't read off the end of the buffer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 years agolibext2fs: fix endian handling of ext3_extent_header
Eric Sandeen [Thu, 23 Oct 2014 21:27:32 +0000 (16:27 -0500)]
libext2fs: fix endian handling of ext3_extent_header

This turned up when trying to resize a filesystem containing
a file with many extents on PPC64.

Fix all locations where ext3_extent_header members aren't
handled in an endian-safe manner.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
10 years agoutil: allow subst to build on systems that do not have utimes()
Theodore Ts'o [Mon, 20 Oct 2014 02:02:48 +0000 (22:02 -0400)]
util: allow subst to build on systems that do not have utimes()

Make subst more portable so it can deal with such oler systems that do
not have utimes().  Note that it is important that subst build
correctly without an autoconf-generated config.h (since that is what
happens on a cross-compile), as well as using whatever features are
available as determined by autoconf when doing a native build.  We
currently assume the presence of utime(), but not utimes() or
futimes().

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomke2fs: fix man page discussion of usage type defaults
Eric Whitney [Mon, 13 Oct 2014 08:19:24 +0000 (04:19 -0400)]
mke2fs: fix man page discussion of usage type defaults

The man page description of the file system size thresholds used by
mke2fs to select a usage type when not otherwise specified by the -T
switch does not match the code.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoresize2fs: fix fs->blocksize dereference after fs has been freed
Theodore Ts'o [Wed, 8 Oct 2014 16:09:35 +0000 (12:09 -0400)]
resize2fs: fix fs->blocksize dereference after fs has been freed

Commit 77255cf36944b introduced a use after free bug.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoe2fsck: fix free pointer dereferences
Theodore Ts'o [Wed, 8 Oct 2014 15:18:41 +0000 (11:18 -0400)]
e2fsck: fix free pointer dereferences

Commit 47fee2ef6a23a introduces some free pointer dereference bugs by
not clearing ctx->fs after calling ext2fs_close_free().

Reported-by: Matthias Andree <mandree@FreeBSD.org>
Cc: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoe2fsprogs: add large_file to base mkfs features
Eric Sandeen [Wed, 1 Oct 2014 12:33:54 +0000 (08:33 -0400)]
e2fsprogs: add large_file to base mkfs features

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

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

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

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc: fix build breakage with configure --disable-uuidd --enable-profile
Theodore Ts'o [Fri, 19 Sep 2014 04:26:56 +0000 (00:26 -0400)]
misc: fix build breakage with configure --disable-uuidd --enable-profile

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

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

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

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc: zero s_jnl_blocks when adding journal online or removing external journal
Darrick J. Wong [Fri, 19 Sep 2014 01:24:26 +0000 (21:24 -0400)]
misc: zero s_jnl_blocks when adding journal online or removing external journal

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

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

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

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

Signed-off-by: Michael Forney <forney@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoMerge remote-tracking branch 'origin/maint' into maint
Theodore Ts'o [Thu, 11 Sep 2014 16:26:27 +0000 (12:26 -0400)]
Merge remote-tracking branch 'origin/maint' into maint

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

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

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

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

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

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

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

Addresses-Coverity-Bug: #709517

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoUpdate release notes, etc. for final 1.42.12 release v1.42.12
Theodore Ts'o [Fri, 29 Aug 2014 12:58:27 +0000 (08:58 -0400)]
Update release notes, etc. for final 1.42.12 release

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

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