[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1219871676-18456-3-git-send-email-tytso@mit.edu>
Date: Wed, 27 Aug 2008 17:14:35 -0400
From: Theodore Ts'o <tytso@....edu>
To: Frédéric Bohé <frederic.bohe@...l.net>
Cc: linux-ext4@...r.kernel.org, Theodore Ts'o <tytso@....edu>
Subject: [PATCH 3/4] ext2fs_block_iterate2: Add BLOCK_FLAG_APPEND support for extent-based files
This is needed so that extent-based inodes (including a journal inode)
can be created via block_iterate.
Signed-off-by: "Theodore Ts'o" <tytso@....edu>
---
lib/ext2fs/block.c | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c
index 14be1ba..2fc3c4a 100644
--- a/lib/ext2fs/block.c
+++ b/lib/ext2fs/block.c
@@ -361,7 +361,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
if (inode.i_flags & EXT4_EXTENTS_FL) {
ext2_extent_handle_t handle;
struct ext2fs_extent extent;
- e2_blkcnt_t blockcnt;
+ e2_blkcnt_t blockcnt = 0;
blk_t blk, new_blk;
int op = EXT2_EXTENT_ROOT;
unsigned int j;
@@ -373,9 +373,29 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
while (1) {
ctx.errcode = ext2fs_extent_get(handle, op, &extent);
if (ctx.errcode) {
- if (ctx.errcode == EXT2_ET_EXTENT_NO_NEXT)
- ctx.errcode = 0;
- break;
+ if (ctx.errcode != EXT2_ET_EXTENT_NO_NEXT)
+ break;
+ ctx.errcode = 0;
+ if (!(flags & BLOCK_FLAG_APPEND))
+ break;
+ blk = 0;
+ r = (*ctx.func)(fs, &blk, blockcnt,
+ 0, 0, priv_data);
+ ret |= r;
+ check_for_ro_violation_goto(&ctx, ret,
+ extent_errout);
+ if (r & BLOCK_CHANGED) {
+ ctx.errcode =
+ ext2fs_extent_set_bmap(handle,
+ (blk64_t) blockcnt++,
+ (blk64_t) blk, 0);
+ if (ctx.errcode)
+ goto errout;
+ continue;
+ } else {
+ ext2fs_extent_free(handle);
+ goto errout;
+ }
}
op = EXT2_EXTENT_NEXT;
--
1.5.6.1.205.ge2c7.dirty
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists