Whamcloud - gitweb
tools/e2fsprogs.git
5 years agoLU-10638 build: add support for Scientific 20/31220/3 v1.42.13.wc6-lustre
Alexander Boyko [Thu, 8 Feb 2018 06:43:40 +0000 (01:43 -0500)]
LU-10638 build: add support for Scientific

Add Scientific to Distro with a reference to RHEL.

Signed-off-by: Alexander Boyko <c17825@cray.com>
Change-Id: I05001ee9233e4cac6b2c6b523a374ffdc243394d
Cray-bug-id: MRP-3882
Reviewed-on: https://review.whamcloud.com/31220
Reviewed-by: Artem Blagodarenko <c17828@cray.com>
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
5 years agoLU-10641 e2fsck: avoid write inode attemp in readonly mode 26/31226/4
Vladimir Saveliev [Wed, 8 Feb 2017 12:45:48 +0000 (14:45 +0200)]
LU-10641 e2fsck: avoid write inode attemp in readonly mode

disconnect_inode() in pass 4 tries to update inode's link count for EA
inodes even in readonly mode. That results in e2fsck -n stop while it
is to continue reporting filesystem inconsistencies.
Move the EA inode's link count update where write access is
guaranteed.

Change-Id: Ie3dcdde160ee9092f21a45fea8f75c4061788072
Signed-off-by: Vladimir Saveliev <c17830@cray.com>
Reviewed-by: Alexandr Boyko <c17825@cray.com>
Reviewed-by: Artem Blagodarenko <c17828@seagate.com>
Cray-bug-id: MRP-4164
Reviewed-on: https://review.whamcloud.com/31226
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
5 years agoLU-8300 e2fsck: print out FID with dirent inode number 66/20866/8
Andreas Dilger [Sat, 18 Jun 2016 10:50:41 +0000 (04:50 -0600)]
LU-8300 e2fsck: print out FID with dirent inode number

When printing out the dirent inode number in e2fsck, also print
out the FID, if available, for reference in the future if needed.

   Entry 'lustre.conf' in /ROOT/etc/yum/protected.d (50132) has
   deleted/unused inode=1964 fid=[0x200000401:0x844:0x0].  Clear? yes

This can be useful if LFSCK is able to rebuild the MDT layout from
the OST object xattrs, but the filename isn't stored on the OST.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Id0ec22c47d83f16c392e93328d2869e7a53ebbe5
Reviewed-on: https://review.whamcloud.com/20866
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Artem Blagodarenko <c17828@cray.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
6 years agoLU-9713 build: Require uptodate libcom_err, libss 34/27834/7
Andreas Dilger [Mon, 26 Jun 2017 22:52:09 +0000 (16:52 -0600)]
LU-9713 build: Require uptodate libcom_err, libss

Ensure that the libcom_err and libext2fs2 packages installed match the
other packages built from e2fsprogs so that modifications to those
libraries (e.g. project quota) are available.

Test-Parameters: clientdistro=sles12sp2 mdsdistro=sles12sp2 ossdistro=sles12sp2

Change-Id: Idc22a029a6950cc1ffb9b6e44181d345db3ebbe5
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-on: https://review.whamcloud.com/27834
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
6 years agoLU-10205 libext2fs: fix buffer overrun in ext2fs_expand_extra_isize 75/29975/2
Jeff Mahoney [Tue, 7 Nov 2017 21:31:43 +0000 (16:31 -0500)]
LU-10205 libext2fs: fix buffer overrun in ext2fs_expand_extra_isize

In ext2fs_expand_extra_isize, we size buffer using 'size' but then
do the memcpy with the rounded-up size, which can overflow the buffer.

With MALLOC_CHECK_=2, I see:
Error in `../e2fsck/e2fsck': free(): invalid pointer: <addr>

Change-Id: I31be58de12d4d50646c7aa96959de0efc5c279c3
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-on: https://review.whamcloud.com/29975
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
6 years agoLU-10542: fix f_dirdata test failure 59/30959/2
Wang Shilong [Sun, 21 Jan 2018 13:55:20 +0000 (21:55 +0800)]
LU-10542: fix f_dirdata test failure

Time is no long invald, update expect.1 to make
tests pass.

Change-Id: Ie20890997c648a4841284e70225497a47b7d183c
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/30959
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
6 years agoLU-9501 mke2fs: avoid inode number error with large FS 11/27111/3
Alexey Lyashkov [Mon, 15 May 2017 14:45:38 +0000 (17:45 +0300)]
LU-9501 mke2fs: avoid inode number error with large FS

Limit inodes count instead of error return, to use all inodes in
the filesystem.

Change-Id: I76ee0a6c11b099b8c17d90b0778e3c0f0cf1f60a
Signed-off-by: Alexey Lyashkov <alexey.lyashkov@seagate.com>
Reviewed-on: https://review.whamcloud.com/27111
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
6 years agoLU-1365 resize2fs: clear uninit if allocating from new group 31/23831/9 v1.42.13.wc6
Eric Sandeen [Sun, 2 Apr 2017 01:51:39 +0000 (09:51 +0800)]
LU-1365 resize2fs: clear uninit if allocating from new group

If resize2fs_get_alloc_block() allocates from a BLOCK_UNINIT group, we
need to make sure that the UNINIT flag is cleared on both file system
structures which are maintained by resize2fs.  This causes the
modified bitmaps to not get written out, which leads to post-resize2fs
e2fsck errors; used blocks in UNINIT groups, not marked in the block
bitmap.  This was seen on r_ext4_small_bg.

This patch uses clear_block_uninit() to clear the flag,
and my problem goes away.

E2fsprogs-commit: f3745728bc254892da4c569ba3fd8801895f3524

Change-Id: I5aa430cf6a9e7f07088b0accabccbdec5f93647e
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Signed-off-by: Li Xi <lixi@ddn.com>
Reviewed-on: https://review.whamcloud.com/23831
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
6 years agoLU-9160 libext2: readahead for meta_bg 48/25648/5
Alexey Lyashkov [Sat, 18 Feb 2017 20:28:27 +0000 (23:28 +0300)]
LU-9160 libext2: readahead for meta_bg

There are ~37k random IOs with meta_bg option on a 300T target.
It takes something like 20min to finish a simple debugfs start.
Enabling RA for meta blocks saves time dramatically and it
needs just 12s to start debugfs.

Seagate-bug-id: MRP-4159
Change-Id: I6ed500d2068b16c1a5ff3fd281ae88bcbb780bf2
Signed-off-by: Alexey Lyashkov <alexey.lyashkov@seagate.com>
Reviewed-on: https://review.whamcloud.com/25648
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
6 years agoLU-4017 tune2fs: fix BUGs of tuning project quota 81/26581/14
Wang Shilong [Thu, 13 Apr 2017 06:41:20 +0000 (02:41 -0400)]
LU-4017 tune2fs: fix BUGs of tuning project quota

There are several problems for project quota enable/disable:
tune2fs -O ^project did not work, because @clear_ok_features
did not include @EXT4_FEATURE_RO_COMPAT_PROJECT.

update_feature_set() works for -O option, but tune2fs -Q prj/^prj
did not work well, because function handle_quota_options()
did not set and clear @EXT4_FEATURE_RO_COMPAT_PROJECT feature very well.

Change-Id: I85a3d504c3619b219af8a711f8f9a3d22b9715db
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/26581
Tested-by: Jenkins
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
6 years agoLU-8976 libext2fs: fix maximum bg overhead calculation with meta_bg enabled 63/25263/6
Darrick J. Wong [Sat, 24 Oct 2015 04:24:57 +0000 (00:24 -0400)]
LU-8976 libext2fs: fix maximum bg overhead calculation with meta_bg enabled

When meta_bg is enabled at mkfs time, we put at most one group
descriptor block in each blockgroup.  Unfortunately, the calculation
of max overhead per bg doesn't know this, so mkfs fails when it isn't
strictly necessary.  Fix it, since Dave reported that he couldn't
create a 500TB ext4 filesystem.

E2fsprogs-commit: 1abdd04eb1d19488493022f81c03f5b80aa7fcc7
Change-Id: I22ef75037807f811b2133f4f4a62fbad02f1444f
Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-on: https://review.whamcloud.com/25263
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
7 years agoLU-8998 debugfs: handle combined LMA EA and PFID EA 36/19436/5
Fan Yong [Sat, 26 Mar 2016 15:12:59 +0000 (23:12 +0800)]
LU-8998 debugfs: handle combined LMA EA and PFID EA

We need to store the stripe size and stripe count information in
the OST object's PFID EA for the layout LFSCK to recover the MDT
object or its (lost or corrupted) LOV EA. On the other hand, for
PFL file, we also need to store its PFL ID and extent information
in its OST object's PFID EA.

Consider performance, we will store the PFID EA inside the inode
body to avoid extra IO when read/write the PFID EA. Unfortunately,
the space inside current 256-bytes inode for EA is very limited,
and above enlarged PFID EA exceeds such limitation. So we have to
make some hack with the PFID EA and LMA EA combined together. The
patch makes the debugfs tool to handle such case properly.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I1380d16d94d6d05272e22fdfff07ada038685669
Reviewed-on: https://review.whamcloud.com/19436
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
7 years agoLU-8390 build: use correct .spec file for SLES 12 37/21237/6
Bob Glossman [Mon, 11 Jul 2016 18:09:52 +0000 (11:09 -0700)]
LU-8390 build: use correct .spec file for SLES 12

Changes in output from the lsb_release command in SLES 12
resulted in using the wrong .spec file in builds.
This patch corrects the problem for old and new versions.

Signed-off-by: Bob Glossman <bob.glossman@intel.com>
Change-Id: I41d47c305eba7d3dd0d313be5ad8192592291fad
Reviewed-on: http://review.whamcloud.com/21237
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
7 years agoLU-4017 debugfs: add support for the project id field 55/21255/6
Theodore Ts'o [Sat, 5 Mar 2016 17:00:41 +0000 (12:00 -0500)]
LU-4017 debugfs: add support for the project id field

Pick from upstream commit: f3d9ac36a021aab3d84ef7759790839f9a65a1bf

Teach the stat and set_inode_field commands to support the project ID
field

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: Ia633d9857b3026e50308d16a91bc81bde2f3d0da
Reviewed-on: http://review.whamcloud.com/21255
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
7 years agoLU-4017 e2fsprogs: add [ch/ls]attr support for project quota 95/18895/16
Wang Shilong [Wed, 6 Jan 2016 17:18:48 +0000 (12:18 -0500)]
LU-4017 e2fsprogs: add [ch/ls]attr support for project quota

You could use it like
chattr -p <project id> file
lsattr -p file

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: I99ecf92b719c32135668f4dc7b11a85da52e0b2e
Reviewed-on: http://review.whamcloud.com/18895
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Andreas Dilger <andreas.dilger@intel.com>
7 years agoLU-4017 e2fsprogs: add inherit flags for project quota 64/15764/24
Li Xi [Mon, 27 Jun 2016 03:16:17 +0000 (11:16 +0800)]
LU-4017 e2fsprogs: add inherit flags for project quota

This patch add EXT4_PROJINHERIT_FL to enable inherit feature
for project quota.

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: If7c7ee34f48beea32b208528148d42167ca0f2fd
Reviewed-on: http://review.whamcloud.com/15764
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>
7 years agoLU-4017 e2fsprogs: add project quota support 62/15762/22
Li Xi [Fri, 20 Mar 2015 04:46:25 +0000 (12:46 +0800)]
LU-4017 e2fsprogs: add project quota support

Adds project ID support for ext4, this patch implement
it by adding a new internal field of ext4 inode to save
project identifier.

Project inode number is allocated dynamically, to fix
compatibility, project feature is disabled in default.

If users want to use project quota, they can do it by:

mkfs.ext4 -O quota,project <dev>

or enable project later by:

tune2fs -O project <dev>
tune2fs -Q prjquota <dev>

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: I2497c56802f0ab155b16908012a2e83beb70f9cd
Reviewed-on: http://review.whamcloud.com/15762
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>
7 years agoLU-4017 e2fsprogs: add project feature 63/15763/19
Li Xi [Fri, 20 Mar 2015 04:55:39 +0000 (12:55 +0800)]
LU-4017 e2fsprogs: add project feature

This patch add project feature EXT4_FEATURE_RO_COMPAT_PROJECT

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: I6b30b8c7d88e8256a1a3fa7d1651b4495e54f4f6
Reviewed-on: http://review.whamcloud.com/15763
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
7 years agoLU-4017 e2fsprogs: clean up codes for adding new quota type 61/15761/21
Li Xi [Fri, 20 Mar 2015 04:18:37 +0000 (12:18 +0800)]
LU-4017 e2fsprogs: clean up codes for adding new quota type

Adding directory/project quota support to ext4 is widely discussed
these days. E2fsprogs has to be updated if we want that new feature.
As a preparation for it, this patch cleans up quota codes of e2fsprogs
so as to make it easier to add new quota type(s).

Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: I9d2e669c449c77fe97163fa70c4ff37777e23261
Reviewed-on: http://review.whamcloud.com/15761
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
7 years agoLU-4017 e2fsprogs: always read full inode structure 69/18569/20
Wang Shilong [Wed, 24 Feb 2016 11:33:13 +0000 (19:33 +0800)]
LU-4017 e2fsprogs: always read full inode structure

Project quota need use some extra field of inode for
computing quota accounting, this patch tries to use
ext2fs_get_next_inode_full() everywhere to read full
inode into memeory, also fixes a bug that only copy small
inode in the function.

Always use ext2fs_read_inode_full() internally reading
and storing an inode instead of ext2fs_read_inode().
At least for the tools in e2fsprogs they will always have
the full inode data, though we can't control other
e2fsprogs users.

This should not hurt performance, since the full inode
block is always read from disk anyway, and in some cases
it may improve performance because it won't do the
extra reads from disk

Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: If545e37587701ac60933e9b09162429d874254ef
Reviewed-on: http://review.whamcloud.com/18569
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
7 years agoLU-7867 e2fsprogs: update build version to 1.42.13.wc5
Andreas Dilger [Tue, 12 Apr 2016 21:12:52 +0000 (15:12 -0600)]
LU-7867 e2fsprogs: update build version to 1.42.13.wc5

Update build version to 1.42.13.wc5.

Change-Id: I71b437b1cf0d4734a076b435f54bc5e263300c1e
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-on: http://review.whamcloud.com/19493
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Li Xi <lixi@ddn.com>
7 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>
7 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
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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

7 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

7 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

7 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>
7 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>
7 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>
7 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>
7 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>
7 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

7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
7 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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>
8 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

8 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>
8 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>
8 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>
8 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>
8 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>
8 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

8 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>
8 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>
8 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.

8 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>
8 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>
8 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

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>