public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: "Frédéric Bohé" <frederic.bohe@bull.net>
Cc: linux-ext4@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 3/4] ext2fs_block_iterate2: Add BLOCK_FLAG_APPEND support for extent-based files
Date: Wed, 27 Aug 2008 17:14:35 -0400	[thread overview]
Message-ID: <1219871676-18456-3-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1219871676-18456-2-git-send-email-tytso@mit.edu>

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@mit.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


  reply	other threads:[~2008-08-27 21:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-27 17:36 Journal file fragmentation Frédéric Bohé
2008-08-27 20:12 ` Jose R. Santos
2008-08-27 21:06 ` Theodore Tso
2008-08-27 21:14   ` [PATCH 1/4] ext2fs_mkjournal(): Don't allocate an extra block to the journal Theodore Ts'o
2008-08-27 21:14     ` [PATCH 2/4] Create the journal in the middle of the filesystem Theodore Ts'o
2008-08-27 21:14       ` Theodore Ts'o [this message]
2008-08-27 21:14         ` [PATCH 4/4] If the filesystem supports extents create an extent-based journal inode Theodore Ts'o
2008-08-28  9:55       ` [PATCH 2/4] Create the journal in the middle of the filesystem Frédéric Bohé
2008-08-28 13:34         ` Theodore Tso
2008-08-28 13:40           ` Ric Wheeler
2008-08-28 14:36             ` Theodore Tso
2008-08-28 14:38               ` Ric Wheeler
2008-09-03 14:08                 ` Ric Wheeler
2008-08-28 16:16           ` Frédéric Bohé

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=1219871676-18456-3-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=frederic.bohe@bull.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox