History log of /external/e2fsprogs/lib/ext2fs/extent.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
8f8511aba07c47df779be94eeb5970f2b73000d8 22-Jun-2015 Theodore Ts'o <tytso@mit.edu> libext2fs: fix gcc -Wall nits

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
413b5c76d830ac780680c53861e0e954dbd99532 15-Dec-2014 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: speed up the max extent depth api call

The maximum extent tree depth really only depends on the filesystem
block size, so cache the last result if possible.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
ffe1b28dea615cf2abf3d9b7ff3f97048eb44c1b 14-Dec-2014 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: add a way to check the theoretical maximum extent tree depth

Add an API so that client programs can discover a reasonable maximum
extent tree depth. This will eventually be used by e2fsck as one of
the criteria to decide if an extent-based file should have its extent
tree rebuilt.

Turn some related magic numbers into constants while we're at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
6509eebb6365de75915a197a4672442d4b5a230e 14-Dec-2014 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: set interior tree block goal more intelligently

When we're splitting an extent node, try to allocate the new interior
tree block just prior to the first extent in the block we're trying to
split. The previous logic only set a goal block if we had to split
both the current node and its parent, which is somewhat infrequent.
When that would happen, the goal would start at zero, leading to poor
locality.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
7b486ec08cda3bc67b7f6bdcbcc9cb5783322e6c 14-Dec-2014 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: find inode goal when allocating blocks

Try to be a little smarter about where we go to allocate blocks for a
inode. For a given inode and logical offset, set the goal as if the
file were physically continuous. If it's bmapped, just start looking
at wherever lblk 0 is. If that's not possible (the file has no
lblk>pblk mappings, inline data, etc.) then start looking in the
inode's block group.

[ Fixed memory leak --tytso ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
8f358e58fe106d0e1cff51573e9fe97f4d9e7cee 04-Nov-2014 Eric Sandeen <sandeen@redhat.com> libext2: minor sparse endian checker fixup

The sparse checker treats 0 assignments as special, but
doesn't catch a = b = 0; separate them to make it quieter.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
49fed79e7c23783832df3bb137d2db4607fa98a7 03-Aug-2014 Darrick J. Wong <darrick.wong@oracle.com> e2fsck: try to salvage extent blocks with bad checksums

Remove the code that would zap an extent block immediately if the
checksum failed (i.e. strict_csums). Instead, we'll only do that if
the extent block header shows obvious structural problems; if the
header checks out, then we'll iterate the block and see if we can
recover some extents.

Requires a minor modification to ext2fs_extent_get such that the
extent block will be returned in the buffer even if the return code
indicates a checksum error. This brings its behavior in line with
the rest of libext2fs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
14207cf60e0f53b57ef8252a8ae3f6a124465b64 03-Aug-2014 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
configure
misc/Makefile.in
07c479dd977d25986b32218f28987c1f6a370ab8 02-May-2014 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: when appending to a file, don't split an index block in equal halves

When we're appending an extent to the end of a file and the index
block is full, don't split the index block into two half-full index
blocks because this leaves us with under utilized index blocks, at
least in the fallocate case. Instead, copy the last extent from the
full block into the new block. This isn't perfect utilization, but
there's a lot of work involved in teaching extent.c to be able to goto
a nonexistent node in a newly allocated (and empty) extent block.

This patch does not fix the general problem of keeping the extent tree
balanced.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
1bad6f4624b360450b59ac72b62a11cbcead948b 12-May-2014 Darrick J. Wong <darrick.wong@oracle.com> misc: coverity fixes

Fix various small resource leaks and error code handling issues that
Coverity pointed out.

Fixes-Coverity-Bugs: 11919{39-45}, 1174118, 1049160, 1049144
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
acbca26e254f0c39ea07024f49ba40855ba31070 15-Mar-2014 Darrick J. Wong <darrick.wong@oracle.com> 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>
/external/e2fsprogs/lib/ext2fs/extent.c
a14f0a647b206622aff71432ba995dcfd8305a95 14-Mar-2014 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: fix memory leak when drastically shrinking extent tree depth

In ext2fs_extent_free(), h(andle)->max_depth is used as a loop
conditional variable to free all the h->path[].buf pointers. However,
ext2fs_extent_delete() sets max_depth = 0 if we've removed everything
from the extent tree, which causes a subsequent _free() to leak some
buf pointers. max_depth can be re-incremented when splitting extent
nodes, but there's no guarantee that it'll reach the old value before
the free.

Therefore, remember the size of h->paths[] separately, and use that
when freeing the extent handle.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
d5fc19fc96a03bed964c7bd995202dfc88f6c4de 06-Feb-2014 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
156a151f3177a826f8ad7c360440abf6656f5aae 06-Feb-2014 Darrick J. Wong <darrick.wong@oracle.com> libext2fs: try to roll back when splitting an extent fails

If a client asks us to remap a block in the middle of an extent, we
potentially have to allocate a fair number of blocks to handle extent
tree splits. A failure in either of the ext2fs_extent_insert calls
leaves us with an extent tree that no longer maps the logical block in
question and everything that came after it! Therefore, try to roll
back the extent tree changes before returning an error code.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
f0996c12d5f189be2fddafc4b2665345230b3826 31-Jan-2014 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
lib/ext2fs/alloc.c
misc/mke2fs.c
a2acec75c0e056692a70928305edbb29e573b695 16-Jan-2014 Theodore Ts'o <tytso@mit.edu> libext2fs: fix off-by-one bug in ext2fs_extent_insert()

When inserting the first extent into an empty inode, the
ext2fs_extent_insert() leaves path->left set to 1 instead of 0. Since
path->curr is pointing at the last (only) extent in the file,
path->left should be 0.

This is mostly harmless, and gets corrected fairly quickly if the
calling applicaton jumps to a different part of the extent tree ---
for example, by calling ext2fs_extent_goto(), or calling
ext2fs_extent_get with the flags argument set to EXT2_EXTENT_ROOT.
Which is why we hadn't noticed this problem until now.

However, if you insert four extents using ext2fs_extent_insert, the
fourth insert will end up copying too many bytes in the i_block[]
array, since path->left is one larger than it should be. This results
in the inode fields i_generation, i_file_acl, and i_size_high getting
zeroed out.

This problem can be replicated as follows:

% cp /dev/null /tmp/foo.img
% mke2fs -F -t ext4 /tmp/foo.img 100
% debugfs -w /tmp/foo.img
debugfs: write /dev/null foo
debugfs: set_inode_field foo i_size_hi 1
debugfs: stat foo
<----- note that the inode's size is 4294967296
debugfs: extent_open foo
debugfs (extent ino 12): insert --after 0 1 100
debugfs (extent ino 12): insert --after 1 1 101
debugfs (extent ino 12): insert --after 2 1 102
debugfs (extent ino 12): insert --after 3 1 103
debugfs (extent ino 12): extent_close
debugfs: stat foo
<----- note that the inode's size is now 0
debugfs: quit

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
2ffccc82c4b9ed935e45118e325896b70e9e3eb0 26-Dec-2013 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
lib/ext2fs/csum.c
f404167dda29a59d2be2882328aeb074b9899669 17-Dec-2013 Theodore Ts'o <tytso@mit.edu> Clean up sparse warnings

Mostly by adding static and removing excess extern qualifiers. Also
convert a few remaining non-ANSI function declarations to ANSI.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
fc9f162eea8ade980b6347a70a020d43ba215540 10-Sep-2013 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next
a88c2fb508e42be997512732085a2ed887155b9f 09-Sep-2013 Eric Sandeen <sandeen@redhat.com> resize2fs: fix interior extent node corruption

If we have an extent tree like this (from debuge2fs's "ex" command):

Level Entries Logical Physical Length Flags
...
2/ 2 60/ 63 13096 - 13117 650024 - 650045 22
2/ 2 61/ 63 13134 - 13142 650062 - 650070 9
2/ 2 62/ 63 13193 - 13194 650121 - 650122 2
2/ 2 63/ 63 13227 - 13227 650155 - 650155 1 A)
1/ 2 4/ 14 13228 - 17108 655367 3881 B)
2/ 2 1/117 13228 - 13251 650156 - 650179 24 C)
2/ 2 2/117 13275 - 13287 650203 - 650215 13
2/ 2 3/117 13348 - 13353 650276 - 650281 6
...

and we resize the fs in such a way that all of those blocks must
be moved down, we do them one at a time. Eventually we move 1-block
extent A) to a lower block, and then follow it with the other
blocks in the next logical offsets from extent C) in the next
interior node B).

The userspace extent code tries to merge, so when it finds that
logical 13228 can be merged with logical 13227 into a single extent,
it does. And so on, all through extent C), up to block 13250 (why
not 13251? [1]), and eventually move the node block as well.
So we end up with this when all the blocks are moved post-resize:

Level Entries Logical Physical Length Flags
...
2/ 2 120/122 13193 - 13193 33220 - 33220 1
2/ 2 121/122 13194 - 13194 33221 - 33221 1
2/ 2 122/122 13227 - 13250 33222 - 33245 24 D)
1/ 2 5/ 19 13228 - 17108 34676 3881 E) ***
2/ 2 1/222 13251 - 13251 33246 - 33246 1 F)
2/ 2 2/222 13275 - 13286 33247 - 33258 12
...

All those adjacent blocks got moved into extent D), which is nice -
but the next interior node E) was never updated to reflect its new
starting point - it says the leaf extents beneath it start at 13228,
when in fact they start at 13251.

So as we move blocks one by one out of original extent C) above, we
need to keep updating C)'s parent node B) for a proper starting point.
fix_parents() does this.

Once the tree is corrupted like this, more corruption can
ensue post-resize, because we traverse the tree by interior nodes,
relying on their start block to know where we are in the tree.
If it gets off, we'll end up inserting blocks into the wrong part
of the tree, etc.

I have a testcase using fsx to create a complex extent tree which
is then moved during resize; it hit this corruption quite easily,
and with this fix, it succeeds.

Note the first hunk in the commit is for going the other way,
moving the last block of an extent to the extent after it; this
needs the same sort of fix-up, although I haven't seen it in
practice.

[1] We leave the last block because a single-block extent is its
own case, and there is no merging code in that case. \o/

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
827f45243acc16d3d98332db39d5b4eeadf33a0f 05-Jan-2013 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
resize/resize2fs.c
027b0577d4e5081a4d28dff9289559d38a36d533 03-Jan-2013 Theodore Ts'o <tytso@mit.edu> Fix 32-bit overflow problems: dgrp_t * s_blocks_per_group

There are a number of places where we multiply a dgrp_t with
s_blocks_per_group expecting that we will get a blk64_t. This
requires a cast, or using the convenience function
ext2fs_group_first_block2().

This audit was suggested by Eric Sandeen.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
/external/e2fsprogs/lib/ext2fs/extent.c
ab83252174bf450e865e76d7c7347c9c39fccadf 24-Dec-2012 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
e2fsck/problem.c
e2fsck/problem.h
bee7b67ce92bb912fccc0dcce3c71c186c2a988b 23-Dec-2012 Theodore Ts'o <tytso@mit.edu> debugfs: add the ability to manipulate the extent tree directly

This commit adds the functionality which had previously only been in
the tst_extents command to debugfs. The debugfs command extent_open
will open extent tree of a particular inode, and enables a series of
commands which will allow the user to interact with the extent tree
directly. Once the extent tree is closed via extent_open(), these
additional commands will be disabled again.

This commit exports two new functions from lib/ext2fs/extent.c which
had previously been statically defined: ext2fs_extent_node_split() and
ext2fs_extent_goto2().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
eacf6a0878a92836231ee69813cb8764d21140f9 21-Dec-2012 Theodore Ts'o <tytso@mit.edu> libext2fs: ext2fs_extents_fix_parents() should not modify the handle location

Previously, ext2fs_extent_fix_parents() would only avoid modifying the
cursor location associated with the extent handle the cursor was
pointed at a leaf node in the extent tree. This is because it saved
the starting logical block number of the current extent, but not the
"level" of the extent (where level 0 is the leaf node, level 1 is the
interior node which points at blocks containing leaf nodes, etc.)

Fix ext2fs_extent_fix_parents() so it is guaranteed to not change the
current extent in the handle even if the current extent is not at the
bottom of the tree.

Also add a fix_extent command to the tst_extents program to make it
easier to test this function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
789bd401c3bce85d3c2ae4504ca62509aa0a8b88 20-Dec-2012 Eric Sandeen <sandeen@redhat.com> e2fsck: fix incorrect interior node logical start values

An index node's logical start (ei_block) should
match the logical start of the first node (index
or leaf) below it. If we find a node whose start
does not match its parent, fix all of its parents
accordingly.

If it finds such a problem, we'll see:

Pass 1: Checking inodes, blocks, and sizes
Interior extent node level 0 of inode 274258:
Logical start 3666 does not match logical start 4093 at next level. Fix<y>?

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
41275efeeebe46f68b7e3ffb3beb30ff479a2308 31-Jul-2012 Darrick J. Wong <djwong@us.ibm.com> libext2fs: verify and calculate extent tree block checksums

Verify and calculate extent tree block checksums when processing
filesystems.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
e0e2c7db4d753aa0192a4a78974fb01bee8a2fb4 11-Jun-2012 Aditya Kali <adityakali@google.com> 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>
/external/e2fsprogs/lib/ext2fs/extent.c
d1154eb460efe588eaed3d439c1caaca149fa362 18-Sep-2011 Theodore Ts'o <tytso@mit.edu> 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>
/external/e2fsprogs/lib/ext2fs/extent.c
9e30fb23ef85d6b2a58527048cc9208405a38299 16-Sep-2011 Eric Sandeen <sandeen@redhat.com> e2fsprogs: annotate intentional fallthroughs in case statements

Using the /* fallthrough */ comment lets Coverity (and humans)
know that we really do want to fall through in these case statements.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
0bd0e5932046401049502ee99529b984d7cd316e 09-Jul-2011 Andreas Dilger <adilger@whamcloud.com> misc: use EXT2_I_SIZE() consistently to get size

Use the EXT2_I_SIZE() macro consistently to access the inode size.
The i_size/i_size_high combination is open coded in several places.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
f03bb73ceb55791f7a59dbb72cfdbe121c5d204e 22-Jul-2010 Theodore Ts'o <tytso@mit.edu> libext2fs: Don't make a copy of the inode in ext2fs_extent_open2()

Previously, ext2fs_extent_open2() copied the passed-in inode structure
into the extent handle, and the extent functions modified the copy of
the inode structure if necessary due to extent splits, etc. Change
ext2fs_extent_open2() so that the extent functions use the inode
structure passed into ext2fs_extent_open2(). Otherwise the passed-in
inode structure could become out of date due to changes made by the
extent functions.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
92e2d79cfbe67244eff8ded095491cba16e98dcc 20-Jul-2010 Theodore Ts'o <tytso@mit.edu> tst_extents: Fix 64-bit bugs in do_goto_block()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
6d8b37fa7661484ca50a4951cffbf531ab1bccbb 13-Jun-2010 Valerie Aurora Henson <vaurora@redhat.com> libext2fs: More random 64-bit fixes, lots of block_iterate3

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
97d26ce9e3589e9f5fa17014467a9730a884d158 07-Jun-2010 Theodore Ts'o <tytso@mit.edu> Merge branch 'maint' into next

Conflicts:
e2fsck/journal.c
e2fsck/pass1.c
e2fsck/pass2.c
misc/mke2fs.c
543547a52a20cb7e69d74921b2f691078fd55d83 18-May-2010 Theodore Ts'o <tytso@mit.edu> libe2p, libext2fs: Update file copyright permission states to match COPYING

The top-level COPYING file states that the e2p and ext2fs libraries
are available under the LGPLv2. The files were incorrectly labelled.
Alex Thomas/Luster has been consulted wrt to the ext3_extents.h file;
the rest of the files were primarily authored by Theodore Ts'o.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
48f23054bb8ad0506c0baa9f06ba182acc2aa88b 26-Oct-2009 Valerie Aurora Henson <vaurora@redhat.com> Convert ext2fs_block_alloc_stats() calls to block_alloc_stats2()

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
24a117abd0340d247befbf7687ffb70547fdf218 08-Sep-2009 Valerie Aurora Henson <vaurora@redhat.com> 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>
/external/e2fsprogs/lib/ext2fs/extent.c
8b5ed492de2584ce255cc87f054e987bf4e9c5f3 20-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Avoid creating unneeded new extents in ext2fs_extent_set_bmap()

Avoiding inserting a new extent if it is possible to merge the new
block to the beginning or the end of the previous or next extent.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
64cb68b3eab55f532a1b07e3778b75631e85f44a 20-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Improve debugging printf's in extent.c

Comment out less common debugging printf's, and fix some type
warnings. Add high-level debugging printf's for ext2fs_extent_goto(),
ext2fs_extent_insert(), ext2fs_extent_delete(), ext2fs_extent_replace()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
16e470e65010ba3f0516cf9cdf1bd6c98f064e3f 20-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix regression in ext2fs_extent_set_bmap()

Commit 0dc291611 introduced a regression when unmapping the first
block in an extent. This caused e2fsck -fD to corrupt large
directories if the directory has to shrink by more than one block.
The problem was set_bmap should only go to a next leaf when setting a
first block in an extent, and not when it is unmapping the first block
in an extent.

Addresses-Debian-Bug: #537510

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
25c7e0c3042cb92a71d25cb3c2709a55b9f120a6 12-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix minor gcc -Wall warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
0dc29161125fa4650e4b8832fc0f570435ef0fe3 10-Jul-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Make ext2fs_extent_set_bmap() more robust against ENOSPC

In the case where we ext2fs_extent_set_bmap() is replacing the block
mapping at the beginning of an already-existing extent, insert a new
extent if necessary before shrinking an existing extent, to avoid data
loss if the disk is full.

This mostly addresses the problem described in Red Hat Bugzilla's
statistics are still wrong, but at least the files on the filesystem
are not corrupted. If there is a failure during the
inode_scan_and_fix pass, the simplest thing to do may be to tell the
user to run e2fsck -fy.

Addresses-Red-Hat-Bug: #510379

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
4bd87f22906188b6dba36d4b9ba5fc7acd337699 07-Jul-2009 Eric Sandeen <sandeen@redhat.com> libext2fs: reset handle after inserting new extent

Commit 53422e moved the new extent insertion in
ext2fs_extent_set_bmap() prior to the modification of the original
extent, but the insert function left the handle pointing to the new
extent. This left us modifying the -new- extent, instead of the
original one, and winding up with a corrupt extent tree something
like:

BLOCKS:
(0-1):588791-588792, (0):588791

We need to move back to the previous extent prior
to modification, if we inserted a new one.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
125a36780626cdb0fc4d62fd529486baa8bce54c 18-Jun-2009 Eric Sandeen <sandeen@redhat.com> libext2fs: write only core inode in update_path()

The ext2_extent_handle only has a struct ext2_inode allocated on
it, and the same amount copied into it in that same function,
but in update_path() we're possibly writing out more than that -
for example 256 bytes, from that address. This causes uninitialized
memory to get written to disk, overwriting the parts of the
inode past the osd2 member (the end of the smaller structure).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
7b59b4a8ee4a65ef14eb364cde574d34ec8c014f 15-Jun-2009 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix memory leak in the extents handling function

Each time an extent handle is opened and closed, if the inode has an
extent tree which does not fit in the inode's i_block structure, a
filesystem block buffer was not getting released. Since e2fsck opens
an extent handle for every inode using extents, this can translate to
a very large amount of memory getting lost.

Thanks to Henrik 'Mauritz' Johnson for discovering and pointing out
this leak, which he ran into while running the "rdump" command in
debugfs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
84b239aea4da04c7a569b428d3abf6c720e82645 19-May-2009 number9652 <number9652@yahoo.com> libext2fs: add ext2fs_extent_open2

The patch below adds a function, ext2fs_extent_open2(), that behaves
as ext2fs_extent_open(), but will use the user-supplied inode
structure when opening an extent instead of reading the inode from
disk. It also changes several of the calls to extent_open() to use
this enhancement.

Signed-off-by: Nic Case <number9652@yahoo.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
53422e8a5644e22ea3f6e0efba82a765b72e4308 20-May-2009 Eric Sandeen <sandeen@redhat.com> 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>
/external/e2fsprogs/lib/ext2fs/extent.c
45e338f5332a54295893dba2e32cc093d1316f60 23-Feb-2009 Jim Meyering <jim@meyering.net> remove useless if-before-free tests

In case you're wondering about whether this change is safe from a
portability standpoint, fear not. This has been beaten to death
in other forums. Here are a few threads:

http://thread.gmane.org/gmane.comp.version-control.git/74187
http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12712
http://thread.gmane.org/gmane.emacs.devel/98144
http://thread.gmane.org/gmane.comp.lib.glibc.alpha/13092

There has been debate about whether it's a good idea from a
performance standpoint, too, but imho you'll have a hard time
finding an instance where this sort of change induces a
measurable performance penalty. If you do, please let me know.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
7518c176867099eb529502103106501861a71280 26-Dec-2008 Theodore Ts'o <tytso@mit.edu> e2fsck: Fix an unhandled corruption case in scan_extent_node()

A corrupted interior node in an extent tree would cause e2fsck to
crash with the error message:

Error1: Corrupt extent header on inode 107192
Aborted (core dumped)

Handle this and related failures when scanning an inode's extent tree
more robustly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
efc6f628e15de95bcd13e4f0ee223cb42115d520 28-Aug-2008 Theodore Ts'o <tytso@mit.edu> Remove trailing whitespace for the entire source tree

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
9033faf5257be85aab4baffa53e0bef96ab9c0f5 28-Aug-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix ext2fs_bmap() to work with extents and BMAP_ALLOC

Fix bugs with extents support when allocating blocks.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
da994e9c11749fc9a427e742273b27853b74fe1d 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_extent_set_bmap(): Avoid creating extra extents for resize2fs

When resize2fs moves blocks belonging to an inode, it will call
ext2fs_extent_set_bmap() for logical blocks 0, 1, 2, 3, ...

Optimize for this calling pattern so we don't end up creating a
separate extent for each block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
2047e0a1eec1d128523e116f38b279f9cb8fe06b 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_extent_set_bmap(): fix bug when replacing a single block extent

When replacing a single block extent, make sure we set or clear the
uninitialized extent flag as requested by the caller.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
a9ea7285e6d97fba4fa4af059db73f0413acfcab 22-Aug-2008 Theodore Ts'o <tytso@mit.edu> Fix ext2fs_extent_set_bmap() when setting a block before the first extent

When setting a logical block which is before the first extent in the
extent tree, make sure the new extent goes in front, at the very
beginning of the extent tree. This fixes a bug where previously the
new extent would be inserted out of order in this case.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
f93d9f653c0a617556727a9cafb60486b58ae6a8 15-Aug-2008 Manish Katiyar <mkatiyar@gmail.com> libext2fs : Fix memory leaks in ext2fs_extent_open()

Memory allocated for the ext2_extent_handle is not getting freed from
all the return paths in case of error. Below patch fixes it.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
ac24e62c4e51f63a570a86519e0dcd09d1458ebb 18-Jul-2008 Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> e2fsprogs: Fix tst_extents output on bigendian machine.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
5a299b56857c20273a43add86ecdaf9a6db0e2b8 13-Jul-2008 Theodore Ts'o <tytso@mit.edu> Remove gcc-specific varargs macro in extent.c

Use "#ifdef DEBUG // printf... // #endif" instead of dbg_printf().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
92e94afe4cc52deeef120941e6ac4d8ca4cda55e 23-Jun-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Don't include ss/ss.h except when debugging

extent.c should only try to include ss/ssh.h when it is compiled with
-DDEBUG. Otherwise it's not necessary and it breaks the Debian MIPS
build (and the Debian MIPS build only) because it tries to build
libext2fs without building libss as part of a MIPS-specific build
rule.

Addresses-Debian-Bug: #487675

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
8895f43a60269464f654e9d87c28768875cd703a 07-Jun-2008 Theodore Ts'o <tytso@mit.edu> Fix gcc -Wall warnings in libext2fs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
c802ad9ed6c6756dfb65d31f0f559e90df3825d5 20-May-2008 Eric Sandeen <sandeen@redhat.com> Teach ext2fs_extent_delete() to remove an empty extent node from the tree

ext2fs_extent_delete() will also update the parent node and decrement
the inode block count.

Passing in the EXT2_EXTENT_DELETE_KEEP_EMPTY flag will allow the empty
node to remain.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
f4e9963c0966734d8dc16877753698193b83cd65 20-May-2008 Eric Sandeen <sandeen@redhat.com> libext2fs: add new function ext2fs_extent_set_bmap()

Allows unmapping or remapping single mapped logical blocks,
and mapping currently unmapped blocks.

Also implements ext2fs_extent_fix_parents() to fix parent
index logical starts, if the first index of a node changes
its logical start block.

Currently this can result in unnecessary new single-block extents; I
think perhaps ext2fs_extent_insert should grow a flag to request
merging with a nearby extent?

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
01229db57ee71518f81d87d6bf900c62fe1de100 20-May-2008 Eric Sandeen <sandeen@redhat.com> Teach ext2fs_extent_insert() to split the current node if necessary

If ext2fs_extent_insert finds that the requested node
for insertion is full, it will currently fail.

With this patch it will split as necessary to make room, unless an
EXT2_EXTENT_INSERT_NOSPLIT flag is passed to it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
9fd6a96d9bf089d8d0ece3bba23b0ef19d03c102 20-May-2008 Eric Sandeen <sandeen@redhat.com> libext2fs: Teach extent.c how to split nodes

When called for a given handle, the new function extent_node_split()
will split the current node such that half of the node's entries will
be moved to a new tree block. The parent will then be updated to
point to the (now smaller) original node as well as the new node.

If the root node is requested to be split, it will move all
entries out to a new node, and leave a single entry in the
root pointing to that new node.

If the reqested split node's parent is full it will recursively
split up to the root to make room for the new node's insertion.

If you ask to split a non-root node with only one entry,
it will refuse (we'd have an empty node otherwise).

It also updates the i_blocks count when a new block has
successfully been connected to the tree.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
aa8e2f1c31374bfc6e479aea008896d179b100b4 02-Jun-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_extent_open: If the inode is empty, initialize the extent tree

If the inode's i_block[] array is completely empty, create an empty
extent tree in the in-core inode and set the EXT4_EXTENT_FL inode
flag. This makes it easy to create a new inode using extents.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
05a32de263228ce8f78746143384e5ebe2677d14 02-Jun-2008 Theodore Ts'o <tytso@mit.edu> ext2fs_extent_replace: Support uninit extents and check validity of e_len

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
9817a2ba2d408077dab12090b4b4250d0d9a282a 13-May-2008 Eric Sandeen <sandeen@redhat.com> fix extent_goto for non-0 leaf levels

The logic for stopping at the right level in extent_goto was wrong,
so if you asked it to go to any level other than 0 (the leaf
level) it would fail.

Also add this argument to the tst_extents goto command to test it.

(I thought this was a failure in my split code but it was this
helper that was causing problems...)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
c21ed7705be908a5697095e597849804302edd21 08-Apr-2008 Eric Sandeen <sandeen@redhat.com> Make extent_goto() deterministic when logical block not found

Make sure that extent_goto() leaves us at the last extent
prior to the requested logical block, if the logical block
requested lands in a hole.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
5e057d5cad3e0f3bd9faa3c1124a3a592cb32919 08-Apr-2008 Eric Sandeen <sandeen@redhat.com> Fix ext2fs_extent_insert when at last extent in node

ext2fs_extent_insert() only did a memmove if path->left
was > 0, but if we are at the last extent in the node,
path->left == 0, and this node must be moved before the
current extent is replaced with the newly inserted node.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
108e62e3162fddd423e877dda8faebe8bd96ead5 08-Apr-2008 Eric Sandeen <sandeen@redhat.com> print a bit more info for the tst_extents info command

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
85b59c40f4b37e43e58aef188b07a3b6678ce782 19-Mar-2008 Eric Sandeen <sandeen@redhat.com> Fix ext2fs_extent_get for uninit leaf extents

The ext2fs_extent_get() function was not OR-ing together UNINIT
and LEAF flags in the case where an extent was both; so if we
had an extent which was both uniint and leaf, pass1 would bail
out where depth == max_depth but was not marked as leaf, and
e2fsck (from the next branch) would abort with:

e2fsck 1.40.8 (13-Mar-2008)
Pass 1: Checking inodes, blocks, and sizes
Error1: No 'down' extent
Aborted

Also, if the error is encountered again, print the inode number
to aid debugging until it's properly handled, at least.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
2d328bb76d2d63bdfdba923b54c28bd686bd8fec 18-Mar-2008 Theodore Ts'o <tytso@mit.edu> Fix miscellaneous gcc -Wall warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
252b7363690e71bfd01517d6b348a5996d98ac7f 14-Mar-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix fencepost error in ext2fs_extent_insert()

ext2fs_extent_insert() was copying n-1 of the existing extents when
moving things down to make room for the new extent.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
83d9be1d5daf170066dd0e74afdd8e7063c1855e 14-Mar-2008 Theodore Ts'o <tytso@mit.edu> libext2fs: Fix ext2fs_extent_delete() to always point at a valid entry

When deleting the last entry in a node, back up the current pointer so
it is always pointing at a valid entry.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
e6bbc002c5a3d30df156d4f23bc93a7f2dbde3a1 21-Feb-2008 Valerie Clement <valerie.clement@bull.net> Add missing shift for ei_leaf_hi

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
d46d67a84530e203e8bfa659370b720b17e3f30c 21-Feb-2008 Valerie Clement <valerie.clement@bull.net> Add missing free in ext2fs_extent_free()

handle->path should be freed in ext2fs_extent_free()

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c
3eb07f649350acfd9e145584d57aac3c1b65d0ba 15-Oct-2007 Theodore Ts'o <tytso@mit.edu> Add support for extents to libext2fs

Initial implemenation of extents support in libext2fs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
/external/e2fsprogs/lib/ext2fs/extent.c