linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] libext2fs: write only core inode in update_path()
@ 2009-06-17 20:11 number9652
  2009-06-17 20:43 ` Eric Sandeen
  0 siblings, 1 reply; 10+ messages in thread
From: number9652 @ 2009-06-17 20:11 UTC (permalink / raw)
  To: Theodore Tso, Eric Sandeen; +Cc: ext4 development


--- On Wed, 6/17/09, Eric Sandeen wrote:
> Theodore Tso wrote:
> > Probably it would be better/simpler to replace this
> with:
> >
> >         retval =
> ext2fs_write_inode(handle->fs, handle->ino,
>     handle->inode);
>         - Ted
> >   
> Sure, that makes more sense, revised below:
> 
> 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, 

First, sorry for the original bug.  I don't think the above is the right way to fix it, however.  I am concerned that I may have basically broken write_inode_full on any inode with extents.  For example, there is another call to write_inode_full in extent.c that might exhibit this same problem.  I think the right fix would be to return to reading the full inode into memory in the extent_open function.  See the patch below for what I am talking about.

libext2fs: read the full inode in extent_open2

The inode pointed to in the extent handle structure is expected to have the same size as the on-disk inode so the entire inode can be updated and written to disk, but in extent_open2, only 128 bytes was read into the inode, regardless of the on-disk inode size.  Instead, read the entire inode.

Signed-off-by: Nic Case
---
diff --git a/e2fsprogs-1.41.6-orig/lib/ext2fs/extent.c b/e2fsprogs-1.41.6/lib/ext2fs/extent.c
index b7eb617..aebb9bc 100644
--- a/e2fsprogs-1.41.6-orig/lib/ext2fs/extent.c
+++ b/e2fsprogs-1.41.6/lib/ext2fs/extent.c
@@ -189,6 +189,7 @@ extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
 {
 	struct ext2_extent_handle	*handle;
 	errcode_t			retval;
+	int				isize = EXT2_INODE_SIZE(fs->super);
 	int				i;
 	struct ext3_extent_header	*eh;
 
@@ -203,7 +204,7 @@ extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
 		return retval;
 	memset(handle, 0, sizeof(struct ext2_extent_handle));
 
-	retval = ext2fs_get_mem(sizeof(struct ext2_inode), &handle->inode);
+	retval = ext2fs_get_mem(isize, &handle->inode);
 	if (retval)
 		goto errout;
 
@@ -211,10 +212,10 @@ extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
 	handle->fs = fs;
 
 	if (inode) {
-		memcpy(handle->inode, inode, sizeof(struct ext2_inode));
+		memcpy(handle->inode, inode, isize);
 	}
 	else {
-		retval = ext2fs_read_inode(fs, ino, handle->inode);
+		retval = ext2fs_read_inode_full(fs, ino, handle->inode, isize);
 		if (retval)
 			goto errout;
 	}
---



      


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* Re: [PATCH] libext2fs: write only core inode in update_path()
@ 2009-06-17 21:32 number9652
  2009-06-17 21:36 ` Eric Sandeen
  2009-06-17 22:46 ` Theodore Tso
  0 siblings, 2 replies; 10+ messages in thread
From: number9652 @ 2009-06-17 21:32 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Theodore Tso, ext4 development


> number9652 wrote:
> > --- On Wed, 6/17/09, Eric Sandeen wrote:
> > right way to fix it, however.  I am concerned
> that I may have
> > basically broken write_inode_full on any inode with
> extents.  For
> > example, there is another call to write_inode_full in
> extent.c that
> > might exhibit this same problem.  I think the
> right fix would be to
> > return to reading the full inode into memory in the
> extent_open
> 
> If this is the case (that it's broken now), then we really
> need
> something in the regression suite to catch it - all tests
> pass in 1.41.6
> ....
> 
> -Eric
> 
I was too general in my statement above about what it broke.  I think (didn't test) if a program follows this path:
extent_open(...,*handle)
write_inode_full(...,handle->inode,...)
  that it will read uninitialized memory in write_inode_full.  It seems clear that all previously written code assumes that this path is valid, and fixing all that to not assume that would seemingly be much more than just what your patch fixes and require more time to test.  If you only use read/write_inode_full, everything is still okay.

I think that in this case, even when only using the handle to read the inode, we want to have the full inode available (by handle->inode) so it is possible (for example) to check the file creation time with the returned handle structure.

Nic



      


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Something wrong with extent-based journal creation
@ 2009-06-16 22:38 Eric Sandeen
  2009-06-17  0:57 ` [PATCH] libext2fs: write only core inode in update_path() Eric Sandeen
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Sandeen @ 2009-06-16 22:38 UTC (permalink / raw)
  To: ext4 development

I've been tearing my hair out all day on this and not getting anywhere
yet, so punting to the list ;)

I have a user running mke2fs -t ext4 in a virt guest, and a mount
immediately after that fails.

It fails because the journal inode has an invalide i_extra_isize.

I've narrowed it down to the commit (961306d3) which creates the journal
with extent format; if that's commented out, it works fine.

I can't for the life of me see where the problem is coming from, though.

I thought we'd need a write_inode_new (emphasis on new here) for the
journal inode, but switching to that doesn't help.

I can't reproduce this myself... any ideas or suggestions of where to
look? :)

-Eric

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-06-17 23:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-17 20:11 [PATCH] libext2fs: write only core inode in update_path() number9652
2009-06-17 20:43 ` Eric Sandeen
  -- strict thread matches above, loose matches on Subject: below --
2009-06-17 21:32 number9652
2009-06-17 21:36 ` Eric Sandeen
2009-06-17 22:46 ` Theodore Tso
2009-06-16 22:38 Something wrong with extent-based journal creation Eric Sandeen
2009-06-17  0:57 ` [PATCH] libext2fs: write only core inode in update_path() Eric Sandeen
2009-06-17 15:35   ` Theodore Tso
2009-06-17 15:50     ` Eric Sandeen
2009-06-17 22:50       ` Theodore Tso
2009-06-17 23:00         ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).