From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH 2/3] libext2fs: allow ext2fs_extent_insert to split if needed
Date: Tue, 20 May 2008 10:15:27 -0500 [thread overview]
Message-ID: <4832EB0F.9040506@redhat.com> (raw)
In-Reply-To: <4832EA22.2070301@redhat.com>
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 sent in.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
lib/ext2fs/ext2fs.h | 4 ++--
lib/ext2fs/extent.c | 15 ++++++++++++---
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 7a1d966..30ca906 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -332,8 +332,8 @@ typedef struct ext2_extent_path *ext2_extent_path_t;
/*
* Flags used by ext2fs_extent_insert()
*/
-
-#define EXT2_EXTENT_INSERT_AFTER 0x0001
+#define EXT2_EXTENT_INSERT_AFTER 0x0001 /* insert after handle loc'n */
+#define EXT2_EXTENT_INSERT_NOSPLIT 0x0002 /* insert may not cause split */
/*
* Data structure returned by ext2fs_extent_get_info()
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index 5ec5c3e..34719d5 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -894,8 +894,17 @@ errcode_t ext2fs_extent_insert(ext2_extent_handle_t handle, int flags,
path = handle->path + handle->level;
- if (path->entries >= path->max_entries)
- return EXT2_ET_CANT_INSERT_EXTENT;
+ if (path->entries >= path->max_entries) {
+ if (flags & EXT2_EXTENT_INSERT_NOSPLIT) {
+ return EXT2_ET_CANT_INSERT_EXTENT;
+ } else {
+ dbg_printf("node full - splitting\n");
+ retval = ext2fs_node_split(handle, 0);
+ if (retval)
+ goto errout;
+ path = handle->path + handle->level;
+ }
+ }
eh = (struct ext3_extent_header *) path->buf;
if (path->curr) {
@@ -1245,7 +1254,7 @@ void do_insert_node(int argc, char *argv[])
}
if (argc != 4) {
- fprintf(stderr, "usage: %s <lblk> <len> <pblk>\n", cmd);
+ fprintf(stderr, "usage: %s [--after] <lblk> <len> <pblk>\n", cmd);
return;
}
-- 1.5.4.1
next prev parent reply other threads:[~2008-05-20 15:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-20 15:11 [PATCH 0/3] e2fsprogs set_bmap & friends V2 Eric Sandeen
2008-05-20 15:14 ` [PATCH 1/3] libext2fs: ext2fs_node_split Eric Sandeen
2008-05-27 4:22 ` Theodore Tso
2008-06-02 6:53 ` Theodore Tso
2008-05-20 15:15 ` Eric Sandeen [this message]
2008-05-20 15:17 ` [PATCH 3/3] libext2fs: add ext2fs_extent_set_bmap Eric Sandeen
2008-05-27 5:20 ` Theodore Tso
[not found] <1210875464-25552-1-git-send-email-sandeen@redhat.com>
2008-05-15 18:17 ` [PATCH 2/3] libext2fs: allow ext2fs_extent_insert to split if needed Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4832EB0F.9040506@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.