Commit Graph

26 Commits (4690e621acd4579dae60b6f55f58284ee805e86d)

Author SHA1 Message Date
Theodore Ts'o 9033faf525 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>
2008-08-27 18:37:11 -04:00
Theodore Ts'o da994e9c11 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>
2008-08-22 02:46:16 -04:00
Theodore Ts'o 2047e0a1ee 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>
2008-08-22 02:43:59 -04:00
Theodore Ts'o a9ea7285e6 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>
2008-08-22 02:43:05 -04:00
Manish Katiyar f93d9f653c 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>
2008-08-16 10:52:25 -04:00
Aneesh Kumar K.V ac24e62c4e 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>
2008-07-18 21:16:32 -04:00
Theodore Ts'o 5a299b5685 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>
2008-07-13 16:06:57 -04:00
Theodore Ts'o 92e94afe4c 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>
2008-06-23 14:10:43 -04:00
Theodore Ts'o 8895f43a60 Fix gcc -Wall warnings in libext2fs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07 11:53:56 -04:00
Eric Sandeen c802ad9ed6 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>
2008-06-02 18:52:12 -04:00
Eric Sandeen f4e9963c09 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>
2008-06-02 18:52:05 -04:00
Eric Sandeen 01229db57e 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>
2008-06-02 10:14:08 -04:00
Eric Sandeen 9fd6a96d9b 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>
2008-06-02 10:13:59 -04:00
Theodore Ts'o aa8e2f1c31 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>
2008-06-02 00:14:23 -04:00
Theodore Ts'o 05a32de263 ext2fs_extent_replace: Support uninit extents and check validity of e_len
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-01 22:56:37 -04:00
Eric Sandeen 9817a2ba2d 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>
2008-05-14 13:28:49 -04:00
Eric Sandeen c21ed7705b 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>
2008-04-17 17:16:39 -04:00
Eric Sandeen 5e057d5cad 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>
2008-04-17 17:16:29 -04:00
Eric Sandeen 108e62e316 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>
2008-04-17 17:05:12 -04:00
Eric Sandeen 85b59c40f4 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>
2008-03-20 15:45:27 -04:00
Theodore Ts'o 2d328bb76d Fix miscellaneous gcc -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-17 23:17:13 -04:00
Theodore Ts'o 252b736369 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>
2008-03-14 10:42:50 -04:00
Theodore Ts'o 83d9be1d5d 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>
2008-03-13 23:55:40 -04:00
Valerie Clement e6bbc002c5 Add missing shift for ei_leaf_hi
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-22 15:57:34 -05:00
Valerie Clement d46d67a845 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>
2008-02-22 15:56:23 -05:00
Theodore Ts'o 3eb07f6493 Add support for extents to libext2fs
Initial implemenation of extents support in libext2fs

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-18 20:05:35 -05:00