public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext2: Update also inode on disk when dir is IS_DIRSYNC
@ 2009-01-13 12:42 Jan Kara
  2009-01-13 13:08 ` Pavel Machek
  2009-01-13 23:17 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Kara @ 2009-01-13 12:42 UTC (permalink / raw)
  To: linux-ext4; +Cc: linux-kernel, Andrew Morton, Jan Kara, Pavel Machek

We used to just write changed page for IS_DIRSYNC inodes. But we also have to
update directory inode itself just for the case that we've allocated a new
block and changed i_size.

Signed-off-by: Jan Kara <jack@suse.cz>
CC: Pavel Machek <pavel@suse.cz>
---
 fs/ext2/dir.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

  Andrew, would you please merge the patch? Ext3 and ext4 don't have this
problem BTW.

diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 9a0fc40..7fba549 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -94,11 +94,10 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
 		i_size_write(dir, pos+len);
 		mark_inode_dirty(dir);
 	}
+	unlock_page(page);
 
 	if (IS_DIRSYNC(dir))
-		err = write_one_page(page, 1);
-	else
-		unlock_page(page);
+		err = ext2_sync_inode(dir);
 
 	return err;
 }
-- 
1.6.0.4


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

* Re: [PATCH] ext2: Update also inode on disk when dir is IS_DIRSYNC
  2009-01-13 12:42 [PATCH] ext2: Update also inode on disk when dir is IS_DIRSYNC Jan Kara
@ 2009-01-13 13:08 ` Pavel Machek
  2009-01-13 23:17 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2009-01-13 13:08 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-ext4, linux-kernel, Andrew Morton

> We used to just write changed page for IS_DIRSYNC inodes. But we also have to
> update directory inode itself just for the case that we've allocated a new
> block and changed i_size.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>
> CC: Pavel Machek <pavel@suse.cz>

Tested, and I can't break ext2 in simple tests now.
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [PATCH] ext2: Update also inode on disk when dir is IS_DIRSYNC
  2009-01-13 12:42 [PATCH] ext2: Update also inode on disk when dir is IS_DIRSYNC Jan Kara
  2009-01-13 13:08 ` Pavel Machek
@ 2009-01-13 23:17 ` Andrew Morton
  2009-01-14 15:12   ` Jan Kara
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2009-01-13 23:17 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-ext4, linux-kernel, jack, pavel

On Tue, 13 Jan 2009 13:42:02 +0100
Jan Kara <jack@suse.cz> wrote:

> We used to just write changed page for IS_DIRSYNC inodes. But we also have to
> update directory inode itself just for the case that we've allocated a new
> block and changed i_size.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>
> CC: Pavel Machek <pavel@suse.cz>
> ---
>  fs/ext2/dir.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
>   Andrew, would you please merge the patch? Ext3 and ext4 don't have this
> problem BTW.
> 
> diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
> index 9a0fc40..7fba549 100644
> --- a/fs/ext2/dir.c
> +++ b/fs/ext2/dir.c
> @@ -94,11 +94,10 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
>  		i_size_write(dir, pos+len);
>  		mark_inode_dirty(dir);
>  	}
> +	unlock_page(page);
>  
>  	if (IS_DIRSYNC(dir))
> -		err = write_one_page(page, 1);
> -	else
> -		unlock_page(page);
> +		err = ext2_sync_inode(dir);
>  

But with this change we no longer sync the data page?  Don't we need
something like this:

static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
{
	struct address_space *mapping = page->mapping;
	struct inode *dir = mapping->host;
	int err = 0;

	dir->i_version++;
	block_write_end(NULL, mapping, pos, len, len, page, NULL);

	if (pos+len > dir->i_size) {
		i_size_write(dir, pos+len);
		mark_inode_dirty(dir);
	}

	if (IS_DIRSYNC(dir)) {
		err = write_one_page(page, 1);
		if (err == 0)
			err = ext2_sync_inode(dir);
	} else {
		unlock_page(page);
	}

	return err;
}

?

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

* Re: [PATCH] ext2: Update also inode on disk when dir is IS_DIRSYNC
  2009-01-13 23:17 ` Andrew Morton
@ 2009-01-14 15:12   ` Jan Kara
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2009-01-14 15:12 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Kara, linux-ext4, linux-kernel, pavel

On Tue 13-01-09 15:17:16, Andrew Morton wrote:
> On Tue, 13 Jan 2009 13:42:02 +0100
> Jan Kara <jack@suse.cz> wrote:
> 
> > We used to just write changed page for IS_DIRSYNC inodes. But we also have to
> > update directory inode itself just for the case that we've allocated a new
> > block and changed i_size.
> > 
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > CC: Pavel Machek <pavel@suse.cz>
> > ---
> >  fs/ext2/dir.c |    5 ++---
> >  1 files changed, 2 insertions(+), 3 deletions(-)
> > 
> >   Andrew, would you please merge the patch? Ext3 and ext4 don't have this
> > problem BTW.
> > 
> > diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
> > index 9a0fc40..7fba549 100644
> > --- a/fs/ext2/dir.c
> > +++ b/fs/ext2/dir.c
> > @@ -94,11 +94,10 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
> >  		i_size_write(dir, pos+len);
> >  		mark_inode_dirty(dir);
> >  	}
> > +	unlock_page(page);
> >  
> >  	if (IS_DIRSYNC(dir))
> > -		err = write_one_page(page, 1);
> > -	else
> > -		unlock_page(page);
> > +		err = ext2_sync_inode(dir);
> >  
> 
> But with this change we no longer sync the data page?  Don't we need
> something like this:
  Oh, correct, we do. I was confused by sync_inode() calling fdatawrite()
but did not realize that the way ext2_sync_inode() calls it has start ==
end == 0. Thanks for spotting this.

> static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len)
> {
> 	struct address_space *mapping = page->mapping;
> 	struct inode *dir = mapping->host;
> 	int err = 0;
> 
> 	dir->i_version++;
> 	block_write_end(NULL, mapping, pos, len, len, page, NULL);
> 
> 	if (pos+len > dir->i_size) {
> 		i_size_write(dir, pos+len);
> 		mark_inode_dirty(dir);
> 	}
> 
> 	if (IS_DIRSYNC(dir)) {
> 		err = write_one_page(page, 1);
> 		if (err == 0)
> 			err = ext2_sync_inode(dir);
> 	} else {
> 		unlock_page(page);
> 	}
> 
> 	return err;
> }
> 
> ?
  Yes, I'll send you a new version of the patch and also send refreshed
second patch with blkdev_issue_flush() calls.

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

end of thread, other threads:[~2009-01-14 15:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-13 12:42 [PATCH] ext2: Update also inode on disk when dir is IS_DIRSYNC Jan Kara
2009-01-13 13:08 ` Pavel Machek
2009-01-13 23:17 ` Andrew Morton
2009-01-14 15:12   ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox