public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: Fix file system hang due to corrupt jinode values.
@ 2008-06-15 14:52 Aneesh Kumar K.V
  2008-06-16 13:45 ` Jan Kara
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2008-06-15 14:52 UTC (permalink / raw)
  To: cmm, jack; +Cc: linux-ext4, Aneesh Kumar K.V

While commiting the transaction we set the i_flags
of jbd2_inode to JI_COMMIT_RUNNING. This is needed to ensure
that when we are commiting the transaction we don't release
the inode via iput. In ext4_clear_inode we wait for the
flag to be cleared before we release the inode.

In ext4_new_inode we call iput for different failure cases
before initializing the jbd2_inode. This cause the failure
case to hang in iput as show below. Fix the same by initializing
jbd2_inode early.

 [<c022d20e>] ? prepare_to_wait+0x49/0x4e
 [<c02cf430>] jbd2_journal_release_jbd_inode+0x86/0xcc
 [<c022d0e4>] ? wake_bit_function+0x0/0x43
 [<c02b329b>] ext4_clear_inode+0x45/0x4a
 [<c02748f7>] clear_inode+0x5f/0xae
 [<c0274e8f>] generic_drop_inode+0x119/0x13a
 [<c0274071>] iput+0x4b/0x4e
 [<c02ab200>] ext4_new_inode+0xb29/0xb7a
 [<c0272761>] ? dput+0x19/0xdc
 [<c02cca5f>] ? jbd2_journal_start+0x8c/0xb9
 [<c02b1cb4>] ext4_create+0x81/0xe7
 [<c02b1c33>] ? ext4_create+0x0/0xe7
 [<c026aa3c>] vfs_create+0x6c/0xdb
 [<c026cfd6>] do_filp_open+0x1a6/0x6b5
 [<c026284e>] do_sys_open+0x40/0xb6
 [<c0262906>] sys_open+0x1e/0x26
 [<c0202be6>] syscall_call+0x7/0xb

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 fs/ext4/ialloc.c |    1 -
 fs/ext4/super.c  |    1 +
 2 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 7823405..dc8bfc4 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -820,7 +820,6 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
 	ei->i_state = EXT4_STATE_NEW;
 
 	ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize;
-	jbd2_journal_init_jbd_inode(&ei->jinode, inode);
 
 	ret = inode;
 	if(DQUOT_ALLOC_INODE(inode)) {
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index e207555..fde1ae9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -578,6 +578,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
 	ei->i_allocated_meta_blocks = 0;
 	ei->i_delalloc_reserved_flag = 0;
 	spin_lock_init(&(ei->i_block_reservation_lock));
+	jbd2_journal_init_jbd_inode(&ei->jinode, &ei->vfs_inode);
 	return &ei->vfs_inode;
 }
 
-- 
1.5.6.rc2.15.g457bb.dirty


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

* Re: [PATCH] ext4: Fix file system hang due to corrupt jinode values.
  2008-06-15 14:52 [PATCH] ext4: Fix file system hang due to corrupt jinode values Aneesh Kumar K.V
@ 2008-06-16 13:45 ` Jan Kara
  2008-06-16 16:30   ` Aneesh Kumar K.V
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kara @ 2008-06-16 13:45 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: cmm, linux-ext4

> While commiting the transaction we set the i_flags
> of jbd2_inode to JI_COMMIT_RUNNING. This is needed to ensure
> that when we are commiting the transaction we don't release
> the inode via iput. In ext4_clear_inode we wait for the
> flag to be cleared before we release the inode.
> 
> In ext4_new_inode we call iput for different failure cases
> before initializing the jbd2_inode. This cause the failure
> case to hang in iput as show below. Fix the same by initializing
> jbd2_inode early.
> 
>  [<c022d20e>] ? prepare_to_wait+0x49/0x4e
>  [<c02cf430>] jbd2_journal_release_jbd_inode+0x86/0xcc
>  [<c022d0e4>] ? wake_bit_function+0x0/0x43
>  [<c02b329b>] ext4_clear_inode+0x45/0x4a
>  [<c02748f7>] clear_inode+0x5f/0xae
>  [<c0274e8f>] generic_drop_inode+0x119/0x13a
>  [<c0274071>] iput+0x4b/0x4e
>  [<c02ab200>] ext4_new_inode+0xb29/0xb7a
>  [<c0272761>] ? dput+0x19/0xdc
>  [<c02cca5f>] ? jbd2_journal_start+0x8c/0xb9
>  [<c02b1cb4>] ext4_create+0x81/0xe7
>  [<c02b1c33>] ? ext4_create+0x0/0xe7
>  [<c026aa3c>] vfs_create+0x6c/0xdb
>  [<c026cfd6>] do_filp_open+0x1a6/0x6b5
>  [<c026284e>] do_sys_open+0x40/0xb6
>  [<c0262906>] sys_open+0x1e/0x26
>  [<c0202be6>] syscall_call+0x7/0xb
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
  Oh yes, thanks for fixing this. I think there is place in
super.c which also calls jbd2_journal_init_jbd_inode() and which doesn't
need to call it when you do so already in alloc_inode().

									Honza
> ---
>  fs/ext4/ialloc.c |    1 -
>  fs/ext4/super.c  |    1 +
>  2 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> index 7823405..dc8bfc4 100644
> --- a/fs/ext4/ialloc.c
> +++ b/fs/ext4/ialloc.c
> @@ -820,7 +820,6 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
>  	ei->i_state = EXT4_STATE_NEW;
>  
>  	ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize;
> -	jbd2_journal_init_jbd_inode(&ei->jinode, inode);
>  
>  	ret = inode;
>  	if(DQUOT_ALLOC_INODE(inode)) {
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index e207555..fde1ae9 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -578,6 +578,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
>  	ei->i_allocated_meta_blocks = 0;
>  	ei->i_delalloc_reserved_flag = 0;
>  	spin_lock_init(&(ei->i_block_reservation_lock));
> +	jbd2_journal_init_jbd_inode(&ei->jinode, &ei->vfs_inode);
>  	return &ei->vfs_inode;
>  }
>  
> -- 
> 1.5.6.rc2.15.g457bb.dirty
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

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

* Re: [PATCH] ext4: Fix file system hang due to corrupt jinode values.
  2008-06-16 13:45 ` Jan Kara
@ 2008-06-16 16:30   ` Aneesh Kumar K.V
  2008-06-16 17:27     ` Jan Kara
  0 siblings, 1 reply; 4+ messages in thread
From: Aneesh Kumar K.V @ 2008-06-16 16:30 UTC (permalink / raw)
  To: Jan Kara; +Cc: cmm, linux-ext4

On Mon, Jun 16, 2008 at 03:45:03PM +0200, Jan Kara wrote:
> > While commiting the transaction we set the i_flags
> > of jbd2_inode to JI_COMMIT_RUNNING. This is needed to ensure
> > that when we are commiting the transaction we don't release
> > the inode via iput. In ext4_clear_inode we wait for the
> > flag to be cleared before we release the inode.
> > 
> > In ext4_new_inode we call iput for different failure cases
> > before initializing the jbd2_inode. This cause the failure
> > case to hang in iput as show below. Fix the same by initializing
> > jbd2_inode early.
> > 
> >  [<c022d20e>] ? prepare_to_wait+0x49/0x4e
> >  [<c02cf430>] jbd2_journal_release_jbd_inode+0x86/0xcc
> >  [<c022d0e4>] ? wake_bit_function+0x0/0x43
> >  [<c02b329b>] ext4_clear_inode+0x45/0x4a
> >  [<c02748f7>] clear_inode+0x5f/0xae
> >  [<c0274e8f>] generic_drop_inode+0x119/0x13a
> >  [<c0274071>] iput+0x4b/0x4e
> >  [<c02ab200>] ext4_new_inode+0xb29/0xb7a
> >  [<c0272761>] ? dput+0x19/0xdc
> >  [<c02cca5f>] ? jbd2_journal_start+0x8c/0xb9
> >  [<c02b1cb4>] ext4_create+0x81/0xe7
> >  [<c02b1c33>] ? ext4_create+0x0/0xe7
> >  [<c026aa3c>] vfs_create+0x6c/0xdb
> >  [<c026cfd6>] do_filp_open+0x1a6/0x6b5
> >  [<c026284e>] do_sys_open+0x40/0xb6
> >  [<c0262906>] sys_open+0x1e/0x26
> >  [<c0202be6>] syscall_call+0x7/0xb
> > 
> > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>   Oh yes, thanks for fixing this. I think there is place in
> super.c which also calls jbd2_journal_init_jbd_inode() and which doesn't
> need to call it when you do so already in alloc_inode().
> 

Like this ?

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index fef2574..43d67e0 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3125,7 +3125,6 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 	ei->i_default_acl = EXT4_ACL_NOT_CACHED;
 #endif
 	ei->i_block_alloc_info = NULL;
-	jbd2_journal_init_jbd_inode(&ei->jinode, inode);
 
 	ret = __ext4_get_inode_loc(inode, &iloc, 0);
 	if (ret < 0)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 034f00f..e511b95 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2259,8 +2259,6 @@ static int ext4_mb_init_backend(struct super_block *sb)
 		printk(KERN_ERR "EXT4-fs: can't get new inode\n");
 		goto err_freesgi;
 	}
-	jbd2_journal_init_jbd_inode(&EXT4_I(sbi->s_buddy_cache)->jinode,
-				    sbi->s_buddy_cache);
 	EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
 
 	metalen = sizeof(*meta_group_info) << EXT4_DESC_PER_BLOCK_BITS(sb);

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

* Re: [PATCH] ext4: Fix file system hang due to corrupt jinode values.
  2008-06-16 16:30   ` Aneesh Kumar K.V
@ 2008-06-16 17:27     ` Jan Kara
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2008-06-16 17:27 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: cmm, linux-ext4

> On Mon, Jun 16, 2008 at 03:45:03PM +0200, Jan Kara wrote:
> > > While commiting the transaction we set the i_flags
> > > of jbd2_inode to JI_COMMIT_RUNNING. This is needed to ensure
> > > that when we are commiting the transaction we don't release
> > > the inode via iput. In ext4_clear_inode we wait for the
> > > flag to be cleared before we release the inode.
> > > 
> > > In ext4_new_inode we call iput for different failure cases
> > > before initializing the jbd2_inode. This cause the failure
> > > case to hang in iput as show below. Fix the same by initializing
> > > jbd2_inode early.
> > > 
> > >  [<c022d20e>] ? prepare_to_wait+0x49/0x4e
> > >  [<c02cf430>] jbd2_journal_release_jbd_inode+0x86/0xcc
> > >  [<c022d0e4>] ? wake_bit_function+0x0/0x43
> > >  [<c02b329b>] ext4_clear_inode+0x45/0x4a
> > >  [<c02748f7>] clear_inode+0x5f/0xae
> > >  [<c0274e8f>] generic_drop_inode+0x119/0x13a
> > >  [<c0274071>] iput+0x4b/0x4e
> > >  [<c02ab200>] ext4_new_inode+0xb29/0xb7a
> > >  [<c0272761>] ? dput+0x19/0xdc
> > >  [<c02cca5f>] ? jbd2_journal_start+0x8c/0xb9
> > >  [<c02b1cb4>] ext4_create+0x81/0xe7
> > >  [<c02b1c33>] ? ext4_create+0x0/0xe7
> > >  [<c026aa3c>] vfs_create+0x6c/0xdb
> > >  [<c026cfd6>] do_filp_open+0x1a6/0x6b5
> > >  [<c026284e>] do_sys_open+0x40/0xb6
> > >  [<c0262906>] sys_open+0x1e/0x26
> > >  [<c0202be6>] syscall_call+0x7/0xb
> > > 
> > > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> >   Oh yes, thanks for fixing this. I think there is place in
> > super.c which also calls jbd2_journal_init_jbd_inode() and which doesn't
> > need to call it when you do so already in alloc_inode().
> > 
> 
> Like this ?
  Yes, so it was mballoc.c and inode.c :). Thanks. You can add
Acked-by: Jan Kara <jack@suse.cz>
  to the merged patch (or maybe even fold your fix into the original
patch).

> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index fef2574..43d67e0 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3125,7 +3125,6 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
>  	ei->i_default_acl = EXT4_ACL_NOT_CACHED;
>  #endif
>  	ei->i_block_alloc_info = NULL;
> -	jbd2_journal_init_jbd_inode(&ei->jinode, inode);
>  
>  	ret = __ext4_get_inode_loc(inode, &iloc, 0);
>  	if (ret < 0)
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 034f00f..e511b95 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -2259,8 +2259,6 @@ static int ext4_mb_init_backend(struct super_block *sb)
>  		printk(KERN_ERR "EXT4-fs: can't get new inode\n");
>  		goto err_freesgi;
>  	}
> -	jbd2_journal_init_jbd_inode(&EXT4_I(sbi->s_buddy_cache)->jinode,
> -				    sbi->s_buddy_cache);
>  	EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
>  
>  	metalen = sizeof(*meta_group_info) << EXT4_DESC_PER_BLOCK_BITS(sb);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

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

end of thread, other threads:[~2008-06-16 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-15 14:52 [PATCH] ext4: Fix file system hang due to corrupt jinode values Aneesh Kumar K.V
2008-06-16 13:45 ` Jan Kara
2008-06-16 16:30   ` Aneesh Kumar K.V
2008-06-16 17:27     ` Jan Kara

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