Commit Graph

3141 Commits (ad751f11ecab50ec78a4b50ae95af3e7b2c4f06a)

Author SHA1 Message Date
Andreas Dilger 6267ee49be e2fsck: only restart e2fsck once for inodes in uninit range
Restart e2fsck only once in case of multiple inodes in uninit range.
Display correct inode number during BG_INO_UNINIT and INOREF_IN_USED errors.

Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-28 07:58:52 -04:00
Dark Raven 31a48478df po: update zh_CN.po (from translationproject.org)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-25 22:45:42 -04:00
Eric Sandeen 0d04d88a8d resize2fs: don't try to resize below calculated minimum
Without a force flag, don't allow resize2fs to even start resizing
below what it thinks the minimum safe value is.

This may stop resizes which could otherwise proceed with a bit
of space still left, but seems like a reasonably safe thing to do.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-25 22:40:49 -04:00
Eric Sandeen 69f7c80eaf resize2fs: fix minimum size calculations
The extra padding added to the minimum size calculations:

        /*
         * We need to reserve a few extra blocks if extents are
         * enabled, in case we need to grow the extent tree.  The more
         * we shrink the file system, the more space we need.
         */
        if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)
                blks_needed += (fs->super->s_blocks_count - blks_needed)/500;

can go quite wrong if we've already added up more "blks_needed"
than our current size, and the above subtraction wraps.  This can
easily happen for a filesystem which is almost completely full.

In this case, just return the current fs size as the minimum and
be done with it.

With this fix we could probably call calculate_minimum_resize_size()
for each resize2fs invocation and refuse to resize smaller than that?

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-25 22:40:35 -04:00
Eric Sandeen 53422e8a56 resize2fs: fix ENOSPC corruption case
http://people.redhat.com/esandeen/livecd-creator-imagefile.bz2
contains an image (for now) which, when resized to 578639, corrupts
the filesystem.

This is a bit crazy, I guess, because the fs currently has only
1 free block, but still, we should be graceful about the failure.
Perhaps it would make sense to check the requested valuea against
the minimum value resize2fs would compute for "-P" and fail (at
least without a force).

But in any case, this exposed 2 bugs when moving that one block
required an extent split, which is what hit the ENOSPC.

For starters, ext2fs_extent_set_bmap() in the "(re/un)mapping last
block in extent" case was replacing the old extent before the
new one was created; when the new extent creation failed, it
left us in an inconsistent state.  Simply changing the order of
the two should fix this problem.

Next, ext2fs_extent_insert was calling ext2fs_extent_delete()
on *any* error, including one caused by failure to allocate a new
block to split the node to hold that extent ... the handle was left
unchanged, and we deleted the -original- extent.

As a quick fix for this, just don't do the delete if we fail the split,
though this may need to be smarter.  I don't think we have terribly
consistent behavior about where a handle is left on various errors.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-25 22:37:59 -04:00
Theodore Ts'o 27a407df54 e2fsck: Fix journal replay bug which reverts changes to the bg descriptors
Fix a regression in e2fsprogs 1.41.5 which would undo updates to the
block group descriptors after a journal replay, caused by commit
b7c5b403.  We now use ext2fs_free() instead of ext2fs_close() to make
sure we the library will never try to write out superblock or block
group descriptors.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-25 22:09:59 -04:00
Andreas Dilger 14c5af32f2 e2fsck: initialize error handling before journal replay
One of our customers hit a temporary IO error during an e2fsck run during
the read from the journal.  It seems that the read error resulted in
e2fsck automatically discarding the journals and recreating them on several
filesystems on this node without any prompting from the user:

   end_request: I/O error, dev sdg, sector 484832
   Buffer I/O error on device sdg, logical block 60604
   fsck-sdg[8276]: ls2-OST024c: Superblock has an invalid ext3 journal (inode 8).
   fsck-sdg[8276]: CLEARED.
   fsck-sdg[8276]: *** ext3 journal has been deleted - filesystem is now ext2
   only ***
   fsck-sdg[8276]: ls2-OST024c was not cleanly unmounted, check forced.
   fsck-sdg[8276]: ls2-OST024c: Journal inode is not in use, but contains data.
   CLEARED.
   fsck-sdg[8276]: ls2-OST024c: Recreate journal to make the filesystem ext3
   again?
   fsck-sdg[8276]: FIXED.
   fsck-sdg[8276]: Creating journal (32768 blocks):  Done.
   fsck-sdg[8276]:
   fsck-sdg[8276]: *** journal has been re-created - filesystem is now ext3 again
   ***
   fsck-sdg[8276]: ls2-OST024c: 39818/20183248 files (8.2% non-contiguous), 222122257/779902976 blocks
   fsck-sdg[8276]: exit code 1 (file system errors corrected)

The following patch moves the e2fsck error handler initialization earlier
in the e2fsck startup code before the journal is processed, so that the
user will be prompted for an action.  This is the first IO that is not
part of ext2fs_open() where fs->io is first initialized.

It doesn't seem possible to initialize the error handlers for the initial
filesystem open without changing the prototype for ext2fs_open2().  If we
are getting a new ext2fs_open3() prototype for 64-bit it might make sense
to add at least "read_error" as a parameter ("write_error" is not strictly
necessary for the open and could be set afterward).

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-17 23:03:04 -04:00
Theodore Ts'o 5dd3311eeb blkid: Don't use a hard-coded path for /bin/rm in test_probe.in
Addresses-Sourceforge-Bug: #2780205

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-17 22:19:21 -04:00
Theodore Ts'o 0a68b181c1 e2fsck: Don't crash if an inode with a bad extent header is not cleared
If ext2fs_extent_open() fails due to a corrupt extent header, and the
user declines to clear the inode, check_blocks_extents() should bail
out; otherwise, it will cause a core dump due a null pointer
dereference.

Addresses-Sourceforge-Bug: #2791794

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-17 08:42:52 -04:00
Theodore Ts'o 5fdb89e30e Add missing file: lib/ext2fs/fiemap.h
This file is needed so the updated filefrag program will compile.  I
missed a "git add"; oops.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-04 07:39:56 -04:00
Karel Zak 46f3eeca59 blkid: use /sys/block/dm-<N>/dm/name
The Linux kernel (since 2.6.29, patch 784aae735d9b0bba3f8b9faef4c8b30df3bf0128)
exports the real DM device names in /sys/block/<ptname>/dm/name.

The sysfs based solution is nicer and faster than scan for devno in
/dev/mapper/.

CC: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 22:39:20 -04:00
Karel Zak 4271e23942 blkid: use /dev/mapper/<name> rather than /dev/dm-<N>
The libblkid (since v1.41.1) returns private device-mapper names (e.g.
/dev/dm-0). It's because the probe_one() function scans /dev before
/dev/mapper.

brw-rw---- 1 root disk 253, 0 2009-04-27 13:41 /dev/dm-0
brw-rw---- 1 root disk 253, 0 2009-04-27 13:41 /dev/mapper/TestVolGroup-TestLogVolume

Old version:
  # blkid -t LABEL="TEST-LABEL" -o device
  /dev/dm-0

Fixed version:
  # blkid -t LABEL="TEST-LABEL" -o device
  /dev/mapper/TestVolGroup-TestLogVolume

Addresses-Red-Hat-Bug: #497259
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 22:33:13 -04:00
Andreas Dilger ae33f578c0 e2fsck: cleanup whitespace in problem.c and problem.h
Cleanup whitespace in the problem.h and problem.c files.  Removes a
bunch of places where tabs follow spaces, whitespace on empty lines, etc.
I didn't reformat the indenting of the entire problem.h error codes,
but there is some room for doing this...

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 21:10:45 -04:00
Andreas Dilger 7494cbfd59 e2fsck: Add test code in problem.c to verify problem codes
We've hit a number of cases where the error codes in problem.h have
been assigned duplicate values compared to problems in our own e2fsck
patches, and this can lead to confusing and difficult to find bugs
in e2fsck (e.g. wrong problem messages, incorrect repair action, etc).

Attached is a test case for the problem.c file to ensure that the
problem table is sorted and does not contain any duplicate values.
Having the problem table sorted allows the correctness checking to be
very simple, and if it ever became important for performance we could
use binary searching of the problem table for the specific problem code.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 21:10:44 -04:00
Kalpak Shah e62847c5db filefrag: Add support to use the FIEMAP ioctl
The FIEMAP ioctl is more efficient and doesn't require root
privileges.  So if it is available, use it in preference to repeated
FIBMAP calls.

Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-02 21:02:29 -04:00
Theodore Ts'o 6d67ee305c Avoid unneeded updates of block group descriptors in ext2fs_closefs()
If the superblock is clean, and we only need to update
s_kbytes_written, then we only need to update the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-02 20:59:04 -04:00
Theodore Ts'o 47c1b8e166 e2fsck: Skip journal checks if the fs is mounted and doesn't need recovery
If we are checking a mounted filesystem (typically the root
filesystem, mounted read/only) and the NEEDS_RECOVERY flag is not set,
skip all of the checks associated with making sure the journal is
consistent.  There is the very slight possibility we could lose if the
NEEDS_RECOVERY flag was somehow cleared even though there was data in
the journal, but this has practically never happend in practice, and
it reduces the number of reads required at boot-time, which is a big
deal when trying to reduce boot times with HDD's.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-28 09:09:44 -04:00
Theodore Ts'o b08c29131a debian: Add a build depends indicating we need a dietlibc newer than 0.30
Addresses-Debian-Bug: #506064

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-25 13:02:15 -04:00
Theodore Ts'o af394b505f debian: Fix distribution name in changelog to be unstable
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-24 08:32:07 -04:00
Theodore Ts'o 898ddb065d Update release notes, version string, etc. for E2fsprogs 1.41.5 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 22:44:16 -04:00
Theodore Ts'o 303f4e007c Update translation template file for 1.41.5 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 22:25:18 -04:00
Theodore Ts'o 41aeae11a6 Update lib/ext2fs/Makefile.in using "make depend"
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 22:24:51 -04:00
Theodore Ts'o 911ec62615 e2fsck: On a 32-bit filesystem, make sure i_file_acl_high is zero
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 21:31:16 -04:00
Theodore Ts'o e60c25b03f Interim commit for Debian release -- 1.41.4-3
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 01:57:51 -04:00
Theodore Ts'o 8203fe506a libext2fs: read the block group descriptors more efficiently
When opening a filesystem, make ext2fs_open2() much more efficient by
reading the normal block group descriptors all at once, instead of one
block at a time.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 01:30:42 -04:00
Theodore Ts'o 982dd30ce8 e2fsck: Reduce unnecessary I/O when checking backup superblock
E2fsck needs to check to see if the backup superblock differs from the
primary superblock.  Previously it was doing so by calling
ext2fs_open(), which does a lot of unnecessary work, including reading
all of the backup block group descriptors.  Avoid this by reading in
the backup superblock directly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 01:27:07 -04:00
Theodore Ts'o 69d0edfd01 e2fsck: Don't test the resize_inode if the filesystem is clean
Move check_resize_inode() out of check_super_block(), since we only
need to test the resize_inode for correctness only if the filesystem
requires checking.  This change avoids a lot of I/O operations which
slows down a 1 second boot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 00:39:06 -04:00
Eric Sandeen 4e60e06847 blkid: remove whole-disk entries from cache when partitions are found
We can get into a situation in blkid where whole disks remain
in the cache, even though partitions are found.  For labels
such as sun disklabels which may have the first partition
beginning at sector 0, this is even somewhat likely.

1) create a sun disklabel w/partitions
2) mkfs the first partition (at sector 0)
3) remove the partition table
4) run blkid - this finds the fs on the whole disk, places in cache
5) recreate the partition table
6) run blkid - this finds the partition, places in cache

And now we have both /dev/sda and /dev/sda1 in cache.

There are heuristics in probe_all to avoid putting the whole disk
in cache if it has partitions, but there is nothing to remove the
whole-disk entry in the above case.  I think the below patch
suffices, although I haven't quite convinced myself that setting
the lens[which]=0; is the right logic for that bit of state...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 22:52:40 -04:00
Theodore Ts'o de7a86e23c mke2fs.8: Clarify in the man page that fs defaults come from mke2fs.conf
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 22:46:48 -04:00
Theodore Ts'o f9110f4480 libext2fs: Skip relative pathnames in /etc/mtab in ismounted.c
The functions which test to see if a device is mounted can get
confused by entries in /etc/mtab for virtual filesystems:

rootfs / rootfs rw 0 0
none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0

If the device name doesn't start with a slash, ignore the /etc/mtab
entry, so that relative pathnames passed into functions such as
ext2fs_check_mount_point() or ext2fs_check_if_mounted() don't return
false positives.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 22:20:22 -04:00
Theodore Ts'o 9266fc7a2f tune2fs: Fix format string warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:13:37 -04:00
Theodore Ts'o 6e6b71d697 logsave: Fix warn_unused_result warnings from gcc
Fixed a potential bug where by partial returns from the write(2)
system call could some bytes to be lost when writing to the log file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:12:40 -04:00
Theodore Ts'o fb72556af8 resize2fs: Print a warning message if the ftruncate system call fails
Resize2fs will attempt to truncate an image file of a filesystem down
to size for the convenience of the system administrator.  If the
truncate operation fails, print a warning message.  This also avoids a
gcc warning message.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:10:36 -04:00
Theodore Ts'o b0258cbcd8 e2fsck: Fix warn_unused_result warnings from gcc
Fixed a potential bug where by partial returns from the write(2)
system call could lost characters to be sent to external progress bar
display program.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:09:41 -04:00
Theodore Ts'o 2af6fe017a debugfs: Fix format string warnings in htree_dump_leaf_node()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:08:36 -04:00
Theodore Ts'o 46d6f84ebe libext2fs: Fix format string type warnings in alloc_stats.c
Fix gcc warnings caused by wrong types passed com_err() in
ext2fs_inode_alloc_stats2 and in ext2fs_block_alloc_stats().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:07:00 -04:00
Theodore Ts'o 935a123f3b libss: Fix warn_unused_result warnings from gcc
Fixed a potential bug where by partial returns from the write system
call could the fallback pager to drop characters.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 14:48:59 -04:00
Theodore Ts'o 9ea68828f3 libss: ss_execute_line: reflect any error codes from system() to the caller
This is primarily to silence a gcc warning, but it's better to reflect
the error from system() up to the caller.  In this case we don't
actually use it for anything, but that's OK.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 14:46:48 -04:00
Theodore Ts'o d3395ae71a libcom_err: Declare prototypes for et_list_lock/unlock in com_err.h
Define the prototypes for et_list_lock() and et_list_unlock() in
com_err.h.  This promotes better error checking and avoids warnings
when compiling the library and programs that call these functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 14:41:32 -04:00
Theodore Ts'o 022c925c5a libe2p: Declare prototypes for the journal feature name functions in e2p.h
Define the prototypes for e2p_jrnl_feature2string() and
e2p_jrnl_string2feature() in e2p.h.  This promotes better error
checking and avoids warnings when compiling the library and programs
that call these functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 14:41:12 -04:00
Theodore Ts'o 14b596d409 configure.in: add --disable-libblkid option
Add an option to switch between the private (in-tree) libblkid and
public (in-system installed) library.  The private version is still
enabled by default.

If --disable-libblkid is specified the findfs(8) program, which is a
variant of tune2fs, is also not built or installed.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 09:18:30 -04:00
Theodore Ts'o 27c3e539b6 Explain the significance of the 'T' attribute in the chattr.1 man page
Addresses-Debian-Bug: #365619

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-21 22:18:19 -04:00
Theodore Ts'o f722c1345a po: Add Chinese (simplified) translation from the Translation Project
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-21 22:09:01 -04:00
Theodore Ts'o ef797135f8 debian: Update debhelper compat level to 7
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-20 08:23:25 -04:00
Theodore Ts'o 7f8da8022e debian: Update copyright files to point the correct common license files
This fixes the Lintian warning:

   The copyright file refers to the versionless symlink in
   /usr/share/common-licenses for the full text of the GPL, LGPL, or GFDL
   license, but the package does not appear to allow distribution under
   later versions of the license. This symlink will change with each
   release of a new version of the license and may therefore point to a
   different version than the package is released under. debian/copyright
   should instead refers to the specific version of the license that the
   package references.

   For example, if the package says something like "you can redistribute it
   and/or modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; version 2 dated June, 1991,"
   the debian/copyright file should refer to
   /usr/share/common-licenses/GPL-2, not /GPL.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-20 07:49:26 -04:00
Theodore Ts'o 2de03c18a6 debian: Put the *-dbg packages in the debug section as requested by Lintian
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-20 07:46:08 -04:00
Theodore Ts'o daf3c82dd0 Interim commit for Debian release -- 1.41.4-2
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-19 23:06:45 -04:00
Theodore Ts'o 2d7361ebfa resize2fs: Fix corruption bug impacting ext4 filesystems with uninit_bg
Due to a fencepost bug, when skipping a block group whose block bitmap
was uninitialized (and hence could not contain any blocks eligible for
relaocation), the block immediately following the block group wasn't
checked as well.  If it was in use and required relocation, it
wouldn't get properly relocated, with the result that an inode using
such a block would end up, post resize, with a pointer to a block now
outside the bounds of the filesystem.

This commit fixes this fencepost error.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18 22:42:13 -04:00
Theodore Ts'o c09043f1ab resize2fs: Fix data corruption bug when shrinking the inode table for ext4
If we need to shrink the inode table, we need to make sure the inodes
contained in the part of the inode table we are vacating don't get
reused as part of the filesystem shrink operation.  This wasn't a
problem with ext3 filesystems, since the inode table was located in
the block group that was going away, so that location was not eligible
for reallocation.

However with ext4 filesystems with flex_bg enabled, it's possible for
a portion of the inode table in the last flex_bg group to be
deallocated, but in a part of the filesystem which could be used as
data blocks.  So we must mark those blocks as reserved to prevent
their reuse, and adjust the minimum filesystem size calculation to
assure that we don't shrink a filesystem too small for the resize
operation to succeed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18 22:32:03 -04:00
Theodore Ts'o 1ac84a948d resize2fs: Fix data corruption bug when growing an ext4 filesystem off-line
When allocating a new set of block group metadata as part of growing
the filesystem, the resize2fs code assumes that the bitmap and inode
table blocks are in their own block group; an assumption which is
changed by the flex_bg feature.  This commit works around the problem
by temporarily turning off flex_bg while allocating the new block
group metadata, to avoid potentially overwriting previously allocated
data blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18 13:31:54 -04:00