Commit Graph

78 Commits (7ba5cc744b842da7a7109fbf8f0c53dbc63bcae1)

Author SHA1 Message Date
Andreas Dilger bbccc6f3c6 misc: fix compile warnings on master branch
Fix compile warnings found on the master branch when using LLVM.

- Add missing format string when using the libintl _() macro
- include <limits.h> header to get PATH_MAX definition
- fix format vs. variable mismatches
- add header block for create_inode.c file
- remove use of bzero(), use ext2fs_get_memzero() instead

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-27 13:14:18 -04:00
Theodore Ts'o f0996c12d5 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/alloc.c
	misc/mke2fs.c
2014-01-30 19:05:16 -05:00
Darrick J. Wong a48da274e2 e2fsck: remove uninit block bitmap calculation
Since libext2fs now detects a BLOCK_UNINIT group and calculates the
group's block bitmap, we no longer need to emulate this behavior in
e2fsck.  We can simply compare the found block map against the
filesystem's, and proceed from there.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-01-11 14:05:02 -05:00
Theodore Ts'o e4681bca17 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.8.in
2013-12-16 01:35:56 -05:00
Darrick J. Wong 69beadcfb2 e2fsck: print cluster ranges when encountering bitmap errors
If pass5 finds bitmap errors in a range of clusters, don't print each
cluster number individually when we could print only the start and end
cluster number.  e2fsck already does this for the non-bigalloc case.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-15 23:53:49 -05:00
Theodore Ts'o 2fae17697a Merge branch 'maint' into next
Conflicts:
	e2fsck/pass2.c
	e2fsck/pass3.c
2013-12-03 00:24:39 -05:00
Theodore Ts'o 3971bfe878 e2fsck: use dgrp_t for block group numbers
Make e2fsck consistently use dgrp_t for bloc group numbers to avoid
-Wconveresion noise.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-02 23:21:31 -05:00
Theodore Ts'o 3c7c6d73f1 e2fsck: use problem_t to suppress some -Wconversion warnings
All code which stores a problem code should use the problem_t type.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-02 20:52:43 -05:00
Darrick J. Wong 2db19bce81 e2fsck: fix incorrect bbitmap checksum failure caused by integer overflow
On a filesystem with more than 2^32 blocks, the block group checksum test will
fail because "i" (the group number) is a 32-bit quantity that is used to
calculate the group's block bitmap block number.  Unfortunately, "i" is not
automatically promoted to 64-bit for this calculation and overflows.  When this
happens, e2fsck will incorrectly report bitmap checksum errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-09-16 09:41:15 -04:00
Theodore Ts'o fd9ca82599 e2fsck: fix gcc -Wall nits
[For 1.43 branch]

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-20 09:17:02 -04:00
Theodore Ts'o 0a7baccf61 Merge branch 'maint' into next 2012-12-17 09:58:50 -05:00
Theodore Ts'o c7e293251f e2fsck: fix pass5 optimization for bigalloc file systems
Commit 53e3120c18 introduced a regression which would case e2fsck to
overrun an array boundary for bigalloc file systems, and most likely
crash.  Fix this by correctly using blocks instead of clusters when
incrementing the loop counter in the fast path optimization case.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-15 22:32:23 -05:00
Theodore Ts'o ccea20f62d Merge branch 'maint' into next
Conflicts:
	misc/tune2fs.c
2012-11-29 19:54:46 -05:00
Theodore Ts'o 53e3120c18 e2fsck: optimize pass 5 for CPU utilization
Add a fast path optimization in e2fsck's pass 5 for the common case
where the block bitmap is correct.  The optimization works by
extracting each block group's block allocation bitmap into a memory
buffer, and comparing it with the expected allocation bitmap using
memcmp().  If it matches, then we can just update the free block
counts and be on our way, and skip checking each bit individually.

Addresses-Google-Bug: #7534813

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2012-11-28 19:01:51 -05:00
Darrick J. Wong 387e6384cb e2fsck: ensure block group checksum uses
Use the helper function to determine if group descriptors have a
checksum.  Ensure that metadata_csum and uninit_bg flags are not set
simultaneously, as part of pass 0.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-08-02 20:47:45 -04:00
Darrick J. Wong da670fe0b5 e2fsck: verify block bitmap checksum
Check block bitmap checksum and write a new checksum if the
verification fails.  This is ok because e2fsck has already computed
the correct block bitmap.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-07-30 19:08:04 -04:00
Darrick J. Wong 11ac780e5f e2fsck: verify inode bitmap checksum
Rewrite the block bitmap when the checksum doesn't match.  This is
ok since e2fsck will have already computed the correct inode bitmap.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-07-30 19:02:04 -04:00
Andreas Dilger 2788cc879b e2fsck: quiet harmless inode/blocks errors
Don't consider only an error in the superblock summary as incorrect.
The kernel does not update this field except at unmount time, so
don't print errors during a "-n" run if there is nothing else wrong.
Any other unfixed errors will themselves mark the filesystem invalid.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-04-24 16:22:48 -04:00
Theodore Ts'o e64e6761aa Fix gcc -Wall nitpicks
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-05 12:13:05 -07:00
Lukas Czerner c15386cdee e2fsck: do not discard itable if discard doen't zero data
We do not want to discard inode table if the underlying device does not
return zeros when reading non-provisioned blocks. The reason is that if
the inode table is not zeroed yet, then discard would not help us since
we would have to zero it anyway. In the case that inode table was
already zeroed, then the discard would cause subsequent reads to contain
non-deterministic data so we would not be able to assume that the inode
table was zeroed and we would need to zero it again, which does not
really make sense.

This commit adds check to prevent inode table from being discarded if
the discard does not zero data.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-11 15:38:40 -04:00
Lukas Czerner f0fe5daecd e2fsck: do not discard when in read only mode
When argument '-n' was specified and should run in read-only mode, we
should not attempt to discard anything. In order to do that we have to
check for E2F_OPT_NO flag and clear E2F_OPT_DISCARD flag if E2F_OPT_NO
is set.

This commit fixes the problem when we would mark inode tables as zeroed
(EXT2_BG_INODE_ZEROED) even when e2fsck is running in read-only mode. We
also move the check for E2F_OPT_NO so we can clear E2F_OPT_DISCARD as
early as possible.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-11 15:38:28 -04:00
Theodore Ts'o d2c9c42a0b e2fsck: optimize CPU usage in check_{block,inode}_bitmaps()
The boolean expression (!skip_group || csum_flag) is always true,
since if csum_flag is FALSE, skip_group must also be FALSE.  Hence, we
can just remove the expression from the conditional altogether, thus
simplifying the code and making it easier to read/understand.

Also, in the case where the bit is set in the bitmap, there's no point
repeatedly setting first_free to be ext2fs_block_count(fs->super).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-11 15:38:23 -04:00
Lukas Czerner deae60a087 e2fsck: do not forget to discard last block group
Previously when running e2fsck with '-E discard' argument the end of
the last group has not been discarded. This patch fixes it so we
always discard the end of the last group if needed.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-11 15:38:23 -04:00
Lukas Czerner 467953263e e2fsck: remove last argument from e2fsck_discard_blocks()
Simple code cleanup.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-11 15:38:23 -04:00
Lukas Czerner 57581c1064 e2fsck: discard only unused parts of inode table
When calling e2fsck with '-E discard' option it might happen that
valid inodes are discarded accidentally. This is because we just
discard the part of inode table which lies past the free inode count.
This is terribly wrong (sorry!).

This patch fixes it so only the free parts of an inode table
is discarded, leaving used inodes intact. This was tested with highly
fragmented inode tables with block size 4k and 1k.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Phillip Susi <psusi@ubuntu.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-11 15:38:00 -04:00
Theodore Ts'o e35ff9b92a e2fsck: fix pass5 bug when using two different bitmap backends
The pass5 checks would fail if the expected and current {inode,block}
bitmaps used different back ends that returned different non-zero
values from the test_*_bitmap() functions.  Fix this by changing
"(actual == bitmap)" to "(!actual == !bitmap)".

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-12-18 01:12:44 -05:00
Theodore Ts'o d1154eb460 Shorten compile commands run by the build system
The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and
this was starting to cause some tools heartburn.  It also made "make
V=1" almost useless, since trying to following the individual commands
run by make was lost in the noise of all of the defines.

So fix this by putting the configure-generated defines in lib/config.h
and the directory pathnames to lib/dirpaths.h.

In addition, clean up some vestigal defines in configure.in and in the
Makefiles to further shorten the cc command lines.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-18 17:34:37 -04:00
Yongqiang Yang 32318ff20f e2fsck: fix error in computing blocks of the ending group
If the blocks of a filesystem is a multiple of blocks_per_group,
blocks of the ending group is computed wrongly.  Use the
new ext2fs_group_blocks_count() helper instead.

Eric Sandeen: Converted to use new blocks per group helper

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16 09:28:44 -04:00
Lukas Czerner 765e03f037 e2fsck: do not attempt to discard if -n was specified
If '-n' option is specified there should be no changes made to the file
system hence we should not attempt to discard the file system. This
commit adds a check into the e2fsck_discard_blocks() condition so it skip
discard if E2F_OPT_NO flag is set.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15 23:55:23 -04:00
Theodore Ts'o fe75afbf33 Fix superblock field s_blocks_count for bigalloc file systems
Treat the s_blocks_count field in the superblock as a free block count
(instead of the number of free clusters) for bigalloc file systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-16 01:38:43 -04:00
Theodore Ts'o 3385a25408 e2fsck: Fix pass5 handling for bigalloc && uninit_bg file systems
The code which simulated handling uninitialized block bitmaps didn't
take bigalloc file systems into account correctly.  Fix it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-15 22:15:34 -04:00
Andreas Dilger cf5301d7f2 misc: clean up compiler warnings
Fix several types of compiler warnings (unused variables/labels),
uninitialized variables, etc that are hit with gcc -Wall.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 10:58:25 -04:00
Theodore Ts'o 44fe08f1fa e2fsck: add basic bigalloc support to check (but not yet repair) file systems
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10 18:58:16 -04:00
Lukas Czerner efa1a355a1 e2fsck: Discard free data and inode blocks.
In Pass 5 when we are checking block and inode bitmaps we have great
opportunity to discard free space and unused inodes on the device,
because bitmaps has just been verified as valid. This commit takes
advantage of this opportunity and discards both, all free space and
unused inodes.

I have added new set of options, 'nodiscard' and 'discard'. When the
underlying devices does not support discard, or discard ends with an
error, or when any kind of error occurs on the filesystem, no further
discard attempt will be made and the e2fsck will behave as it would
with nodiscard option provided.

As an addition, when there is any not-yet-zeroed inode table and
discard zeroes data, then inode table is marked as zeroed.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 21:01:41 -05:00
Valerie Aurora Henson 6dc64392c0 e2fsck: Fix up to be 64-bit block number safe
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 17:00:00 -04:00
Valerie Aurora Henson d7cca6b06f Convert to use block group accessor functions
Convert direct accesses to use the following block group accessor
functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(),
ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(),
ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(),
ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(),
ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(),
ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:43:47 -04:00
Theodore Ts'o cd65a24e75 libext2fs: Convert ext2fs_bg_flag_test() to ext2fs_bg_flags_test()
After cleaning up ext2fs_bg_flag_set() and ext2fs_bg_flag_clear(),
we're left with ext2fs_bg_flag_test().  Convert it to
ext2fs_bg_flags_test().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:42:12 -04:00
Eric Sandeen e633b58ac7 libext2fs: clean up ext2fs_bg_flags_ interfaces
The ext2fs_bg_flag* functions were confusing.

Currently we have this:

void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags);

(_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags)

and these, which can twiddle individual bits in bg_flags:

void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag);

A better interface, after the patch below, is just:

ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */
ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */
ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */

and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:41:32 -04:00
Valerie Aurora Henson 4efbac6fed Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 20:46:34 -04:00
Valerie Aurora Henson c5b7b6babe Fix overflow in calculation of total file system blocks
Blocks per group and group desc count are both 32-bit; multiplied they
produce a 32-bit quantity which overflowed.

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:23:03 -04:00
Theodore Ts'o 732c8cd58f Use accessor functions fields for bg_flags in the block group descriptors
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:15:12 -04:00
Valerie Aurora Henson c5d2f50dee e2fsck: Convert e2fsck to new bitmap interface
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22 22:29:02 -04:00
Jose R. Santos 20f2ccb326 Use new ext2fs_super_and_bgd_loc2 call in libext2fs
The new ext2fs_super_and_bgd_loc2() function has some changes aside
from just blk64_t support.  Lets make sure that the interfaces are
sane by adding libext2fs support early to get the new API tested here.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-11 21:29:30 -04:00
Kazuya Mio 479463aaf6 e2fsck: Speed up pass 5 processing for ext4 filesystems
e2fsck_pass5() checks whether the inode and block allocation bitmaps
are consistent.  However, if EXT2_BG_[INODE/BLOCK]_BITMAP is set to a
ext4's block group, most of its bitmap is uninitialized (0).  In that
case, we can optimize e2fsck's pass 5 by checking the entire range of
an uninitalized block group instead of checking bit by bit.

This can speed up e2fsck pass 5 by up to 80%:

         +-----+--------------------+--------------------+
         |     |     old e2fsck     |     new e2fsck     |
         |Pass |       time(s)      |       time(s)      |
         |     | real | user |system| real | user |system|
         +-----+------+------+------+------+------+------+
         |  1  |  5.70|  3.29|  0.50|  5.66|  3.21|  0.54|
         |  2  |  3.33|  0.80|  0.19|  3.40|  0.82|  0.23|
         |  3  |  0.01|  0.00|  0.00|  0.01|  0.00|  0.00|
         |  4  |  1.04|  1.04|  0.00|  1.05|  1.04|  0.00|
         |  5  | 19.60| 17.27|  0.06|  3.53|  1.21|  0.05|
         +-----+------+------+------+------+------+------+
         |Total| 29.94| 22.57|  0.80| 13.90|  6.47|  0.86|
         +-----+------+------+------+------+------+------+

Comparison of e2fsck time on an ext4 500GB partition (20% blocks used)

Machine environment:
CPU:       Intel(R) Xeon(TM) CPU 3.00GHz
Memory:    1GB
Kernel:    linux-2.6.29-git2

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-09 14:56:30 -04:00
Kazuya Mio e31b32721d e2fsck: remove unused variable in check_block_bitmap()
check_block_bitmap() calculates the block number of superblock in the current
block group but it's not used.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-06 23:24:18 -04:00
Kazuya Mio 01ec1268a5 e2fsck: optimize loop counter when fixing bitmap padding
If unused range of the bitmap has an unmarked bit, check_[inode/block]_end()
marks all bits in the range. However, we know that the checked bits are marked.
So this patch fixes loop counter to mark from the unmarked bit.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-06 23:24:18 -04:00
Ken Chen 9facd076ae Add empty function for init_resource_track() and print_resource_track()
in the case of ! defined RESOURCE_TRACK, so that we can clean up #ifdef
throughout e2fsck source.

Signed-off-by: Ken Chen <kenchen@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-28 09:55:10 -04:00
Theodore Ts'o efc6f628e1 Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27 23:07:54 -04:00
Theodore Ts'o 16b851cdae Remove LAZY_BG feature
This simplifies the code, and using the uninit_bg with the inode table
lazily initialized is just as good.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 23:33:34 -04:00
Theodore Ts'o 4a2924eaa3 e2fsck: Fix pass5 handling of meta_bg and uninit_bg combination
The pass5 lazy block group support didn't understand meta_bg formats
correctly.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-20 18:33:19 -04:00