Commit Graph

944 Commits (bbcd91bb0de943b364670373957a5658c4487692)

Author SHA1 Message Date
Theodore Ts'o b2f5ce5516 mke2fs: throttle allocating groups progress as well
Throttle updates for the "Allocating Groups" progress updates to once
a second as well.  We now do this throttling in libext2fs, so we don't
have to do this for each of mke2fs's progress updates, and because the
updates from ext2fs_allocate_tables() come from within libext2fs
anyway.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-21 12:50:04 -04:00
Theodore Ts'o ab3f5c5aad Allow e2fsprogs to be built using the clang (LLVM) frontend
Since clang uses C99 semantics by default, the main changes required
to allow clang to build e2fsprogs was to add support the C99 inline
semantics, while still allowing us to be built when the legacy (but
still default for gcc) GNU C89 inline semantics are in force.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-09 21:35:39 -04:00
Akira Fujita 321649c9f4 mke2fs: recalculate the reserved blocks when the last BG is dropped
mke2fs -m option can set reserved blocks ratio up to 50%.  But if the
last block group is not big enough to support the necessary data
structures, it gets dropped, we have to recalculate the number of
reserved blocks so that the reserved blocks matches the requested
percentage.

It also avoids a problem where if the user specifies a reserved blocks
of 50%, and after the last partial block group was dropped, if the
number of reserved blocks is greater than 50%, e2fsck will complain.

Steps to reproduce:

1. Create a FS which has the overhead for the last BG
   and specify 50 % for reserved blocks ratio
 # mke2fs -m 50 -t ext4 DEV 1025M

 mke2fs 1.42.5 (29-Jul-2012)
 warning: 256 blocks unused.

 Filesystem label=
 OS type: Linux
 Block size=4096 (log=2)
 Fragment size=4096 (log=2)
 Stride=0 blocks, Stripe width=0 blocks
 656640 inodes, 2621440 blocks
 1310848 blocks (50.00%) reserved for the super user
 ~~~~~~~ <-- Reserved blocks exceed 50% of FS blocks count!

2. e2fsck outputs filesystem corruption
 # e2fsck DEV

 e2fsck 1.42.5 (29-Jul-2012)
 Corruption found in superblock.  (r_blocks_count = 1310848).

 The superblock could not be read or does not describe a correct ext2
 filesystem.  If the device is valid and it really contains an ext2
 filesystem (and not swap or ufs or something else), then the superblock
 is corrupt, and you might try running e2fsck with an alternate superblock:
     e2fsck -b 32768 <device>

Signed-off-by: Akira Fujita <a-fujita@rs.jp.ne.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-09-07 00:09:19 -04:00
Theodore Ts'o d5aa6a82b3 Put ELF_OTHER_LIBS in the right place for the linker
Commit a7c17431b9 attempted to fix a problem where the system
libraries might get used instead of local libraries for things like
-lcom_err.  It tried to accomplish this by moving $(ELF_OTHER_LIBS) to
before $(LDFLAGS).

Unfortunately, this was the wrong fix; $(ELF_OTHER_LIBS) *MUST* be
after the object files, or the linker might not pull in the necessary
library and not include it into the DT_NEEDED section of the shared
library.  The proper fix is to add a -L$(LIB) before $(LDFLAGS), and
then remove the -L option from all of the ELF_OTHER_LIBS definitions
in the library Makefiles.

Addresses-Sourceforge-Bug: #3554345

Cc: Olivier Blin <olivier.blin@softathome.com>
Reported-by:  Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-08-06 12:30:49 -04:00
Theodore Ts'o 3aa8f60aae libext2fs: fix uninit block calculation when inodes_per_block < first_ino
The following commands:

	dd if=/dev/zero of=/tmp/foo count=1 ibs=$(( 256 * 1024 * 1024 ))
	mke2fs -N 256 -t ext4 /tmp/foo

... will cause mke2fs to write until it fills the device.  The cause
for this is that the explicit request for 256 inodes causes the number
of inodes per block group to be 8.  The ext2fs_initialize() function
assumed that all of the reserved inodes would be in the first block
group, which is not true in this case.  This caused the number of
uninitialized inodes in the first block group to be negative, which
then resulted in mke2fs trying to zero out a very large number of
blocks.  Oops.

Addresses-Sourceforge-Bug: #3528892

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-07-29 13:34:01 -04:00
Theodore Ts'o c1986ecb6f Fix blhc (Build Log Hardening Check) warnings
The Build Log Hardening Check is a debian tool which scans the output
of a package build making sure that the security hardening flags are
used when compiling and linking all of binaries in a package.

For the most part we were passing CFLAGS, CPPFLAGS, and LDFLAGS down
to the compiler and link commands, but there there were one or two
exceptions.  In addition, there where a few places in "make install"
where the V=1 option was not being honored, which triggered blhc
warnings since it couldn't analyze those commands.

The e2fsck.static was the only binary that was not getting built and
packaged with the hardening flags, but I've fixed all of the blhc
warnings so in the future it will be obvious if we regress.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-06-13 16:06:44 -04:00
Theodore Ts'o 0796e66085 lsattr, chattr: add support for btrfs's No_COW flag
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-06-12 17:30:10 -04:00
Theodore Ts'o beb388a473 libext2fs: fix block iterator for extents when truncating inodes
When e2fsck uses the block iterator to release the blocks in an
extent-mapped inode, when the last block in an extent is removed, the
current extent has been removed and the extent cursor is now pointing
at the next inode.  But the block iterator code doesn't know that.  So
when it tries to go the next extent, it will end up skipping an
extent, and so the inode will be incompletely truncated.

The fix is to go to the next extent before calling the callback
function for the current extent.  This way, regardless of whether the
current extent gets removed, the extent cursor is still pointing at
the right place.

Reported-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-06-12 01:34:10 -04:00
Aditya Kali e0e2c7db4d libext2fs: fix i_blocks for extent leaf create/delete with bigalloc
When libext2fs allocates/deletes an extent leaf, the i_blocks
value is incremented/decremented by fs->blocksize / 512. This
is incorrect in case of bigalloc. The correct way here is to
use cluster_size / 512.

The problem is seen if we try to create a large inode using
libext2fs (say using ext2fs_block_iterate3()) on a bigalloc
filesystem. fsck catches this and complains.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-06-10 23:52:11 -04:00
Andreas Dilger 182acd17be libext2fs: don't inline ext2fs_open_file() and ext2fs_stat()
The creation of inline wrappers ext2fs_open_file() and ext2fs_stat()
in commit c859cb1de0 in ext2fs.h caused
difficulties with the use of headers, since the headers for open64()
and stat64() may already be included (and skip the declaration of the
64-bit variants) before ext2fs.h is ever read.  There is no real way
to solve the missing prototypes and resulting compiler warnings inside
ext2fs.h.

Since ext2fs_open_file() and ext2fs_stat() are not performance
critical operations, they do not need to be inline functions at all,
and the needed function headers can be handled properly in one file.

Similarly, posix_memalloc() was having difficulties with headers, and
was being defined in ext2fs.h, but it is now only being used by a
single file, so move the required header there.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-05-28 10:54:12 -04:00
Eric Sandeen 918eeb32e9 libext2fs: fix rbtree backend for extent lengths greater than 2^32
For a completely full filesystem with more than 2^32 blocks, the
rbtree bitmap backend can assemble an extent of used blocks which is
longer than 2^32.  If it does, it will overflow ->count, and corrupt
the rbtree for the bitmaps.

Discovered by completely filling a 32T filesystem using fallocate, and
then observing debugfs, dumpe2fs, and e2fsck all behaving badly.

(Note that filling with only 31 x 1T files did not show the problem,
because freespace was fragmented enough that there was no sufficiently
long range of used blocks.)

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-05-27 22:14:29 -04:00
Theodore Ts'o ae06582867 Change pkg-config files so that both <et/com_err.h> and <com_err.h> work
Change the include path in the Cflags field so that #include
<lib/foo.h> and <foo.h> will work.  We had originally used a C flags
which allowed <foo.h> to work, but many applications (especially those
not using pkg-config) had been using the <lob/foo.h> formulation which
didn't require an explicit -I{$includedir} option to the C compiler.

If those applications then converted over to pkg-config, and the
e2fsprogs libraries were installed with a prefix other than /usr, so
that the header files were in some directory such as
/usr/local/include, a program that used #include <lib/foo.h> would
fail to compile.

So change the pkg-config files to include both -I{$includedir} and
-I{$includir}/lib.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-05-14 12:45:54 -04:00
Theodore Ts'o 40024fdbaf libext2fs: fix bug in unix_io corrupted > 16TB file systems on 32-bit systems
The code was assuming that "unsigned long" was 64-bit, which of course
it isn't on 32-bit systems.  This caused blocks to get written to the
wrong place.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-05-14 10:55:09 -04:00
Theodore Ts'o 660b4c3b3f Reserve the codepoints for the INCOMPAT features LARGEDATA and INLINEDATA
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-05-11 18:39:27 -04:00
Theodore Ts'o d71520751e Support systems without posix_memalign() and memalign()
MacOS 10.5 doesn't have posix_memalign() nor memalign(), but it does
have valloc().  The Android SDK would like to be built on MacOS 10.5,
so I've added support for a good-enough emulation of memalign()'s
functionality using valloc(), with an explicit test to make sure
valloc() is returning a pointer which is sufficiently aligned given
the requested alignment.  This won't work if you try to operate on a
file system with a 16k blocksize using an e2fsprogs built on MacOS
10.5 system, but it is good enough for the common case of 4k
blocksize file systems, and we will let the memory allocation fail in
the alignment is not good enough.

I've also added a unit test for ext2fs_get_memalign() so we can be
sure it's working as expected.  I've tested the code paths with
HAVE_POSIX_MEMALIGN defined, HAVE_POSIX_MEMALIGN undefined, and
HAVE_POSIX_MEMALIGN and HAVE_MEMALIGN undefined on an x86 Linux
system, and so I know the valloc() code path works OK.  The simplistic
(and less safe) patch at:

https://trac.macports.org/attachment/ticket/33692/patch-lib-ext2fs-inline.c.diff

Shows that using valloc() apparently works OK for MacOS 10.5 (but if
it doesn't the unit test will catch a problem).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-05-11 18:21:08 -04:00
Theodore Ts'o fd1c5a0622 libext2fs: factor out I/O buffer allocation
Create a new function, io_channel_alloc_buf() which allocates I/O
buffers with appropriate alignment if we are using direct I/O.  The
original code was sometimes using a larger alignment factor than
necessary, and would always request an aligned memory buffer even when
it was not necessary since the block device was not opened with
O_DIRECT.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-05-07 14:41:49 -04:00
Theodore Ts'o 07d120848d libext2fs: make read_bitmaps() more efficient when using direct I/O
Read in a full block for each allocation bitmap, to avoid using a
kernel bounce buffer when using direct I/O.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-05-07 14:30:31 -04:00
Theodore Ts'o dd0a2679dd libext2fs: refactor Direct I/O alignment requirement calculations
Create a new function, ext2fs_get_dio_alignment(), which returns the
alignment requirements for direct I/O.  This way we can factor out the
code from MMP and the Unix I/O manager.  The two modules weren't
consistently calculating the alignment factors, and in particular MMP
would sometimes use a larger alignment factor than was strictly
necessary.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-05-07 13:25:44 -04:00
Theodore Ts'o 0a05b90330 libext2fs: move the alignment field from unix_io to the io_manager
The align field which indicated the required data alignment of data
buffers was stored in a field specific to the unix_io manager.  Move
it to the top-level io_channel structure so it can be better
generalized.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-05-07 12:56:07 -04:00
Theodore Ts'o 46f100707c libext2fs: improve testing coverage of tst_bitmaps
Improve the test coverage of tst_bitmaps by:

   (a) adding the ability to test the legacy (32-bit) bitmap code
   (b) adding tests for ext2fs_find_first_zero_inode_bitmap2() and
       ext2fs_find_first_zero_block_bitmap2()

The recent regressions caused by the addition (and use) of
ext2fs_find_first_zero_inode_bitmap2() would have been caught if we
had added these tests first.  (Another object lesson in why unit tests
are critically important!)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-09 14:29:47 -04:00
Theodore Ts'o 38792ca78b libext2fs: use correct types in ext2fs_find_first_zero_block_bitmap2()
Fortunately nothing was using this inline function, so we'll just fix
the types in its function signature, which were nonsensical (this was
caused by a cut-and-paste error).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-09 14:29:47 -04:00
Theodore Ts'o 664c332612 libext2fs: add 32-bit compat code for ext2fs_find_first_zero_generic_bmap()
The lack of 32-bit support was causing febootstrap to crash since it
wasn't passing EXT2_FLAG_64BITS when opening the file system, so we
were still using the legacy bitmaps.

Also add support for bigalloc bitmap into the ffz functions.

Addresses-Red-Hat-Bugzilla: #808421

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-09 14:29:13 -04:00
Theodore Ts'o b24efa2187 Don't assume that the presence of mntent.h means that setmntent() exists
Change autoconf to test for setmntent() and use that to decide whether
to use getmntent() and setmntent(), since some systems don't have
setmntent() but they do have the mntent.h header file.

Also, remove the includes of mntent.h from e2fsck and mke2fs and other
places where it is not needed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-05 15:31:09 -07:00
Theodore Ts'o 304e11c2c1 mke2fs: don't fail creating the journal if /etc/mtab is missing
The ext2fs_add_journal_inode() function calls
ext2fs_check_mount_point(), which can fail if /etc/mtab is missing.
This causes mke2fs to fail in the middle of the file system format
process; mke2fs calls ext2fs_check_mount_point() already (and has
appropriate fallbacks that calls fails), so add a flag so that mke2fs
can request ext2fs_add_journal_inode() to skip trying to call
e2fsck_check_mount_point().

Addresses-Sourceforge-Bug: #3509398

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-04-05 12:30:02 -07: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
Theodore Ts'o 70d7281dcb Update Release Notes, Changelogs, version.h, etc. for 1.42.2 release
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-27 16:20:46 -07:00
Theodore Ts'o 3a6db9bbc8 libext2fs: fix ext2fs_get_memalign when posix_memalign() doesn't exist
Reported by: Gianluigi Tiesi <sherpya@netfarm.it>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-26 15:37:28 -07:00
Sami Liedes 11f359f766 libext2fs: implement fast find_first_zero() for bitarray bitmaps.
With this change the CPU time needed to shrink a 100G filesystem drops
to 0.8% of the original (17 CPU seconds instead of 2057).

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-26 10:36:24 -07:00
Theodore Ts'o 538eb8784a libext2fs: update dirty flags if the uninit flags are cleared
Update the block group descriptor checksum and mark the superblock and
allocation bitmaps as dirty in check_inode_uninit() and
check_block_uninit().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-26 10:36:02 -07:00
Sami Liedes c1a1e7fc24 libext2fs: Implement ext2fs_find_first_zero_generic_bmap().
This function searches a bitmap for the first zero bit within a range.
It checks if there is a bitmap backend specific implementation
available (if the relevant field in bitmap_ops is non-NULL). If not,
it uses a generic and slow method by repeatedly calling test_bmap() in
a loop. Also change ext2fs_new_inode() to use this new function.

This change in itself does not result in a large speedup, rather it
refactors the code in preparation for the introduction of a faster
find_first_zero() for bitarray based bitmaps.

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-25 18:55:14 -04:00
Sami Liedes 5f7c04972f libext2fs: document EXT2_FLAG_64BITS in ext2fs_open2()
From 5c7302de65d689ad84427649aab4d361b21270df Mon Sep 17 00:00:00 2001
From: Sami Liedes <sami.liedes@iki.fi>
Date: Sat, 10 Mar 2012 22:25:55 +0200
Subject: [PATCH] libext2fs: Document EXT2_FLAG_64BITS in ext2fs_open2().

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-22 19:48:57 -04:00
Sami Liedes 75556776d3 libext2fs: move a modulo operation out of a hot loop.
Filesystem shrinking in particular is a heavy user of this loop in
ext2fs_new_inode(). This change makes resize2fs use 24% less CPU time
for shrinking a 100G filesystem.

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-22 19:43:48 -04:00
Lukas Czerner 010dc7b90d e2fsck: remove EXT4_EOFBLOCKS_FL flag handling
We've decided to remove EOFBLOCKS_FL from the ext4 file system entirely,
because it is not actually very useful and it is causing more problems
than it solves. We're going to remove it from e2fsprogs first and then
after the new e2fsprogs version is common enough we can remove the
kernel part as well.

This commit changes e2fsck to not check for EOFBLOCKS_FL. Instead we
simply search for initialized extents past the i_size as this should not
happen. Uninitialized extents can be past the i_size as we can do
fallocate with KEEP_SIZE flag.

Also remove the EXT4_EOFBLOCKS_FL from lib/ext2fs/ext2_fs.h since it is
no longer needed.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-22 19:42:11 -04:00
Theodore Ts'o 37c8db7b20 mke2fs: add option to use direct I/O (mke2fs -D)
This can be useful when using mke2fs on loaded servers, since
otherwise mke2fs can dirty a huge amount of memory very quickly,
leading to other applications not being happy at all.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-22 16:00:49 -04:00
Andreas Dilger 963d0f1a94 tests: add field sizes to inode/super struct tests
In addition to validating the ordering of fields within the inode
and superblock structures, also validate the field sizes.  Otherwise
it is possible to incorrectly change the size of one of these fields
without getting any kind of error from these tests.  Failures would
only show up later in the test image checks if the field that is
changed is before another in-use field.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-03-19 23:54:03 -04:00
Theodore Ts'o 87141781aa dumpe2fs: print the expected block group checksum if it is incorrect
This helps to diagnose problems caused by incorrect block group
checksums.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-15 12:13:25 -04:00
Mike Frysinger 800766ee4a libext2fs: check for fallocate symbol before using it
If we have newer kernel headers which define FALLOC_FL_PUNCH_HOLE, but we
are on an older glibc which lacks fallocate, we end up trying to use the
func anyways.  Check the ifdef that autoconf already set up for us.

Reported-by: Ortwin Glueck <odi@odi.ch>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-03-06 20:21:39 -05:00
Andreas Dilger 7270fbe7fa build: fix compile warnings on OSX
Clean up some compile warnings related to fstat64(), which is
verbosely deprecated on OSX.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-27 01:28:23 -05:00
Mike Frysinger 997a0cf34e libext2fs: include config.h for HAVE_xxx defines
We check HAVE_UNISTD_H but haven't included config.h yet, so we end up
hitting warnings about missing prototypes for close/read/etc... funcs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-27 01:12:53 -05:00
Mike Frysinger b96365f8c2 libext2fs: include sys/time.h for gettimeofday()
Building on my glibc-2.15 system hits a warning:
	gen_bitmap64.c: In function 'ext2fs_alloc_generic_bmap':
	gen_bitmap64.c:127:2: warning: implicit declaration of function
		'gettimeofday' [-Wimplicit-function-declaration]

Include sys/time.h if it's available for the prototype.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-27 01:12:53 -05:00
Theodore Ts'o d9a5d37535 libext2fs: support O_DIRECT functionality for Mac OS X
Darwin uses fcntl(fd, F_NOCACHE, 1) instead of the O_DIRECT flag.

Addresses-SourceForge-Bug: #3140289

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-20 20:45:52 -05:00
Theodore Ts'o 48b8910820 libext2fs: don't mark the superblock as dirty if the fs was opened r/o
If the file system is read/only opened with a backup superblock, and
the file system has uninit_bg enabled, the super block must not be
marked as dirty; otherwise, ext2fs_close() will call ext2fs_flush(),
which will fail, since the file descriptor for the block device was
opened read/only, and then the file descriptor won't actually be
closed.

This is normally not a problem since most of the time the program will
exit shortly after calling ext2fs_close(), and many programs don't
bother checking the error return from ext2fs_close(), especially if
the file system was opened read/only.

A big exception to this is e2fsck, since it opens and close the file
systems during its startup, and to make matters worse, registers an
error handler which will noisly complain about the failed writes
caused by ext2fs_flush().

Fix this by not marking the superblock as dirty if the file system was
opened read/only.  The changes to the block group descriptors to clear
the uninit bits will still happen, so that e2fsck -n will properly
scan the whole file system.  However, those changes will get dropped
when the file system handle is closed.

Addresses-SourceForge-Bug: #3444351

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-20 20:27:58 -05:00
Theodore Ts'o 991211f676 libext2fs, libe2p: Reserve RO_COMPAT_REPLICA feature
The replica is a feature which stores multiple copies of the key
metadata blocks so a single block failure in failure-prone media
(read: certain types of flash storage) doesn't take out the entire
file system.

Discussion on the upstream list proved not to be very positive on this
feature; the arguments were that it added complexity that wasn't
warrented, since common practice in industry is to insist on reliable
media, and if media is unreliable, you're kind of toast anyway (unless
the file system is being used as the back-end store of a cluster file
system where checksuming and data replication is happening above the
local disk file system level).  So, this feature is being developed
out of tree.

We reserve the code points so that other people won't accidentally
step on them.  Since it's not upstream, it's a soft reservation, but
it's not like we have any shortage of RO_COMPAT features.  We are a
bit more tight on reserved inodes, but EXT2_BOOT_LOADER_INO and
EXT2_UNDEL_DIR_INO are not currently used anywhere, and
EXT2_EXCLUDE_INO is a reservation for another out-of-tree feature.
There are no features currently being discussed which require a
reserved inode, but if a need were to arise, we can claw back code
point reservations that were never used or not in tree, as those will
always be considered lower priority than in-tree features.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Darrick J. Wong 3ae682bb0a libext2fs: Add ext2fs_file_get_inode_num call (for fuse2fs)
Add a function to return the inode number of an open file.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 15:28:21 -05:00
Theodore Ts'o a204236eaf libext2fs: fix BLOCK_ABORT handling in the block iterator for extents
When processing files that contain extents, the block iterator
functions were not properly handling the BLOCK_ABORT bit.  This could
cause problems such as ext2fs_link() adding a directory entry multiple
times.

Thanks to Darrick Wong <djwong@us.ibm.com> for reporting this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-02-17 14:32:17 -05:00
Darrick J. Wong 9e89dbbd46 libext2fs: when truncating file, punch out blocks at end
Currently, ext2fs_file_set_size2 punches out data blocks between the
end of the file and infinity when truncate_block <= old_truncate
(i.e. when you've made the file longer).  This is not a useful
behavior, particularly since it *fails* to punch out the data blocks
when the file is shortened (i.e. truncate_block < old_truncate).  This
seems to be the result of the test being backwards, so fix the code to
punch only when the file is getting shorter.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-17 14:32:10 -05:00
Andreas Dilger 454ac9d56a libext2fs: quiet spurious group checksum errors
If we have to read the backup group descriptor checksums, the UNINIT
flags are cleared to ensure that all of the inodes in the filesystem
are scanned.  However, the code that reset the UNINIT flags did not
reset the group checksum, and this produced many spurious error
messages in e2fsck.

Group descriptor 0 checksum is invalid.  FIXED.
Group descriptor 1 checksum is invalid.  FIXED.
:
:

Recompute checksums after modifying group descriptors to avoid these
error messages.  Remove expected error messages in f_illitable_flexbg.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-02-07 21:11:21 -05:00
Theodore Ts'o 1f572d1f88 libext2fs: display partial path if fs corrupted in ext2fs_get_pathname()
The function ext2fs_get_pathname() used to return EXT2_ET_NO_DIRECTORY
if one of the directories in an inode's pathname is not a directory.
This is not very useful in an emergency, when the file system is
corrupted.  This commit will cause ext2fs_get_pathname() to return a
partial pathname, which should help system administrators trying to
use debugfs to investigate a corrupted file system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-01-17 15:38:31 -05:00
Mike Frysinger 24d364fc43 libext2fs: change getpagesize to sysconf
Newer versions of glibc no longer export the getpagesize() prototype when
using recent versions of POSIX (_XOPEN_SOURCE).  So building tdb.c gives
use implicit function declaration warnings.  Fix the issue by using the
portable sysconf() function which returns the same answer.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-01-09 21:19:48 -05:00
Lukas Czerner 9288e3be66 libext2fs: add bitmap statistics
This feature is especially useful for better understanding how e2fsprogs
tools (mainly e2fsck) treats bitmaps and what bitmap backend can be most
suitable for particular bitmap. Backend itself (if implemented) can
provide statistics of its own as well.

[ Changed to provide basic statistics when enabled with the
  E2FSPROGS_BITMAPS_STATS environment variable -- tytso]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-12-18 01:12:44 -05:00