Commit Graph

82 Commits (d1154eb460efe588eaed3d439c1caaca149fa362)

Author SHA1 Message Date
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
Andreas Dilger 931b58e1cb ext2fs: Handle internal journal over 2^32 bytes
The write_journal_inode() code is only setting the low 32-bit i_size
for the journal size, even though it is possible to specify a journal
up to 10M blocks in size.  Trying to create a journal larger than 2GB
will succeed, but an immediate e2fsck would fail.  Store i_size_high
for the journal inode when creating it, and load it upon access.

Use s_jnl_blocks[15] to store the journal i_size_high backup.  This
field is currently unused, as EXT2_N_BLOCKS is 15, so it is using
s_jnl_blocks[0..14], and i_size is in s_jnl_blocks[16].

Rename the "size" argument "num_blocks" for the journal creation functions
to clarify this parameter is in units of filesystem blocks and not bytes.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 12:17:29 -04:00
Theodore Ts'o 0358c9f9a4 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass4.c
	misc/dumpe2fs.c
	resize/online.c
2010-12-13 09:16:09 -05:00
Theodore Ts'o 8718359b40 e2fsck: Open the external journal in exclusive mode
This prevents accidentally replaying and resetting the journal while
it is mounted, due to an accidental attempt to run e2fsck on an LVM
snapshot of a file system with an external journal.

Addresses-Debian-Bug: #587531

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-25 21:14:06 -04: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
Theodore Ts'o 97d26ce9e3 Merge branch 'maint' into next
Conflicts:
	e2fsck/journal.c
	e2fsck/pass1.c
	e2fsck/pass2.c
	misc/mke2fs.c
2010-06-07 12:42:40 -04:00
Eric Sandeen 5750e5f924 e2fsck: mark sparse journal as invalid
For a filesystem that fails with:

journal_bmap: journal block not found at offset 7334 on loop0
JBD: bad block at offset 7334

e2fsck won't actually fix this; it will mark the fs as clean,
so it will mount, but it does not fix that block, and when the
journal reaches this point again it will fail again.

The following simple change to process_journal_block() might be
a little drastic; it will clear & recreate the journal inode if
it's sparse - i.e. if it gets block 0.

I suppose we could be more complicated and try to replay the journal
up to the error, but I'm not sure it's worth it since we're fscking
it anyway.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-05-13 13:14:41 -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
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 24a117abd0 Convert to use io_channel_read_blk64() and io_channel_write_blk64()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:14:24 -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
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
Theodore Ts'o e35d548b59 e2fsck: Fix journal replay for block sizes greater than 8k
E2fsck was using a fixed-size 8k buffer for replaying blocks from the
journal.  So attempts to replay a journal on filesystems greater than
8k would cause e2fsck to crash with a segfault.

Thanks to Miao Xie <miaox@cn.fujitsu.com> for reporting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-02 18:14:42 -05: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 185c4aeaf2 e2fsck: Add support to check journal checksums
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-06 23:38:38 -04:00
Jose R. Santos 49a7360ba6 Make e2fsck uninit block group aware
This patch has all the necesary pieces to open and fix filesystems created
with the uninit block group feature.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:33:12 -04:00
Theodore Ts'o 2628a1d3e1 Merge branch 'maint' 2007-10-06 12:41:26 -04:00
Theodore Ts'o 0cfce7f749 e2fsck: update the backup superblocks if the feature bitmasks are changed
If e2fsck adds or deletes any of the feature bitmasks, clear
EXT2_FLAG_MASTER_SB_ONLY so the backup superblocks are updated when
e2fsck finishes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-06 12:39:57 -04:00
Theodore Ts'o 2eae093081 Clean up applications to not use EXT2FS_ENABLE_SWAPFS or EXT2_FLAG_SWAP_BYTES
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-08-11 02:57:31 -04:00
Theodore Ts'o 051afbe0d7 e2fsck: Check the all of journal blocks for validity
The original code only checked the direct blocks to make sure the
journal inode was sane.  Unfortunately, if some or all of the indirect
or doubly indirect blocks were corrupted, this would not be caught.
Thanks to Andreas Dilger and Kalpak Shah for noticing this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-21 11:59:06 -04:00
Kalpak Shah ded28ac2ab Write the updated journal inode if s_jnl_blocks was successfully used
If the journal inode was corrected from s_jnl_blocks, write the fixed
journal inode back to disk.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2007-06-21 11:59:06 -04:00
Kalpak Shah 5107d0d196 Recreate journal that had been removed previously due to corruption
If the journal had been removed because it was corrupt, the
E2F_FLAG_JOURNAL_INODE flag will be set.  If this flag is set, then
recreate the filesystem after checking the filesystem.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2007-06-21 11:59:06 -04:00
Theodore Ts'o 058ad1c70c Don't write changes to the backup superblocks by default
This patch changes ext2fs_open() to set EXT2_FLAG_MASTER_SB_ONLY by
default.  This avoids some problems in e2fsck (reported by Jim Garlick)
where a corrupt journal can end up writing the bad superblock to the
backups.  In general, only e2fsck (after the filesystem is clean),
tune2fs, and resize2fs should change the backup superblocks by default.
Most callers of ext2fs_open() should not be touching anything where the
backups should be touched.  So let's change the defaults to avoid
potential problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-18 18:26:50 -04:00
Brian Behlendorf 2bfe0bdba3 [COVERITY] Fix (error case only) memory leak in e2fsck_get_journal
Coverity ID: 43: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2007-03-29 00:19:17 -04:00
Theodore Ts'o 642935c082 Fix misc. gcc -Wall complaints in the misc and e2fsck directories
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-14 23:38:17 -05:00
Theodore Ts'o 2aa362f54a Fix memory leak in e2fsck's error paths
Add missing brelse() calls to avoid memory leaks in error paths.  (Thanks
to Michael C. Thompson for pointing these out; they were originally 
found using Coverity.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-05-14 17:16:29 -04:00
Theodore Ts'o b1c52b26a4 Enhance e2fsck so it can fix external journal hint in the superblock
Check to see if the superblock hint for the external journal needs to
be updated, and if so, offer to update it.  (Addresses Debian Bug:
#355644)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-10 15:25:59 -05:00
Theodore Ts'o 8dceb92407 E2fsck: fix future times in the superblock's last mount or last write fields
Detect if the superblock's last mount field or last write field is in
the future, and offer to fix if so.  (Addresses Debian Bug #327580)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-24 21:59:45 -04:00
Theodore Ts'o 1f3ad14a5a Use a centrally stored current time for "now" which
can be overridden using the E2FSCK_TIME environment 
variable, for better reproducibility for regression tests.
2005-04-14 14:07:53 -04:00
Richard Mortimer 6e4fbbeb50 Attempt recovery if the journal contains illegal blocks 2004-10-04 17:56:24 +01:00
Theodore Ts'o 93effaa456 Fixed potential ordering constraint problem in e2fsck's journal
recovery code by implementing the sync_blockdev function.  Thanks to
Junfeng Yang from the Stanford Metacompilation group for pointing this
out.
2004-05-26 20:58:45 -04:00
Matthias Andree b34cbddbd6 Re-add FreeBSD support.
Tested on FreeBSD 5.2-CURRENT as of 2003-12-28.
Tested on FreeBSD 4.9-STABLE  as of 2003-12-27.
2003-12-28 18:21:26 +01:00
Matthias Andree b969b1b8a5 Fix more compiler warnings. 2003-12-28 13:04:35 +01:00
Theodore Ts'o 544349270e Fix gcc -Wall nitpicks 2003-12-07 01:28:50 -05:00
Theodore Ts'o 27479eb227 journal.c (e2fsck_move_ext3_journal): When moving the journal or
backing up the journal inode, make sure it gets written to
	all the superblocks.
2003-08-21 08:59:38 -04:00
Theodore Ts'o a435ec3449 Add support for backing up the journal inode location in the
superblock.  E2fsck will automatically save the journal information
in the superblock if it is not there already, and will use it if the
journal inode appears to be corrupted.  ext2fs_add_journal_inode() 
will also save the backup information, so that new filesystems
created by mke2fs and filesystems that have journals added via
tune2fs will also have journal location written to the superblock as
well.  Debugfs's logdump command has been enhanced so that it can
use the journal information in the superblock.

The debugfs man page has been improved to more fully describe the
logdump command.

Added two new functions, ext2fs_file_open2() and 
ext2fs_inode_io_intern2() which take a pointer to an inode structure;
this is needed so that e2fsck and debugfs can synthesize a
fake journal inode and use it to access the journal.
2003-08-21 00:40:26 -04:00
Theodore Ts'o c4e3d3f374 ext2fs_getmem(), ext2fs_free_mem(), and ext2fs_resize_mem()
all now take a 'void *' instead of a 'void **' in order to 
avoid pointer aliasing problems with GCC 3.x.
2003-08-01 09:41:07 -04:00
Theodore Ts'o f364093b19 Update debugfs and e2fsck to use the blkid library. 2003-03-01 19:47:44 -05:00
Theodore Ts'o 5e72cdbeb9 unix.c (PRS), journal.c: Set the default level of journal
debugging to be 0, and allow the user to set the level of
	journal debugging by using the E2FSCK_JBD_DEBUG
	environment variable.
2002-11-08 15:35:13 -05:00
Theodore Ts'o 3e69906495 Fix gcc -Wall nits.
Fix format bug if NLS is in use.

Add extra so that the info directory looks OK on OpenWall.
2002-10-13 23:56:28 -04:00
Theodore Ts'o 546a1ff18c Fix various gcc -Wall complaints. 2002-03-07 23:52:56 -05:00
Theodore Ts'o f2d5c93703 Fixed the journal handling so that an offer is made to clear the
journal filesystem in all cases.

Fixed a bug in e2fsck which caused it to give spurious I/O manager
bad messages right before crashes.
2002-03-07 03:13:07 -05:00
Theodore Ts'o d1a2182a18 Cleaned up journal handling code in e2fsck.
Fixed up two minor memory leaks.
2002-02-22 00:17:59 -05:00
Theodore Ts'o d37066a9fa Give the opportunity for e2fsck to run the journal even if
recovery flag is cleared.  If we're using a backup
superblock, run the journal by default.
2001-12-21 23:28:54 -05:00
Theodore Ts'o 8cf93332d1 Fix e2fsck's handling of external journals,and update journal
recovery files from 2.4.17-pre8.
2001-12-16 02:23:36 -05:00
Gabriel Paubert b3b3d465b1 journal.c: fix an endianness bug.
f_badorphan: revert previous, erroneous change.
2001-11-30 13:45:28 +01:00
Andreas Dilger 6a138ed42a Allow a single user for internal journals (the current filesystem)
since this is how the filesystem is created.
2001-11-08 17:50:50 -07:00
Theodore Ts'o 62e3e7fe4f journal.c (clear_v2_journal_fields, e2fsck_journal_load): If the
V2 fields are set on a V1 journal superblock, or an
	internal V2 journal has s_nr_users is non-zero, clear the
	entire journal superblock beyond the V1 superblock.  This
	fixes botched V1->V2 updates.

problem.c, problem.h (PR_0_CLEAR_V2_JOURNAL): Add new problem code.

f_bad_local_jnl: New test which tests for a V2 journal with bad 
	fields caused by a botched V1->V2 upgrade.
2001-10-07 02:13:30 -04:00
Theodore Ts'o 773fd8a1d4 e2fsck.h, journal.c (e2fsck_move_ext3_journal): Add new function
which will automatically relocate the ext3 journal from a
	visible file to an invisible journal file if the
	filesystem has been opened read/write.

super.c (check_super_block): Add call to e2fsck_move_ext3_journal

problem.c, problem.h (PR_0_MOVE_JOURNAL, PR_0_ERR_MOVE_JOURNAL):
	Add new problem codes.
2001-10-06 21:26:27 -04:00
Theodore Ts'o c0a083fac3 * journal.c (recover_ext3_journal): If s_errno is set in the
journal superblock, set the EXT2_ERROR_FS flag in the
	filesystem superblock after the journal is run.
2001-08-07 10:17:41 -04:00