Patchwork [V2] ext3: Always set dx_node's fake_dirent explicitly.

login
register
mail settings
Submitter Eric Sandeen
Date March 4, 2011, 10:04 p.m.
Message ID <4D7161D8.8010509@redhat.com>
Download mbox | patch
Permalink /patch/85449/
State Not Applicable
Headers show

Comments

Eric Sandeen - March 4, 2011, 10:04 p.m.
(crossport of 1f7bebb9e911d870fa8f997ddff838e82b5715ea
by Andreas Schlick <schlick@lavabit.com>)

When ext3_dx_add_entry() has to split an index node, it has to ensure that
name_len of dx_node's fake_dirent is also zero, because otherwise e2fsck
won't recognise it as an intermediate htree node and consider the htree to
be corrupted.
    
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

(V2: fix subject and commit and formatting)

While it's a simple one liner, this took me forever to (re-)find.

kill_ext3_now++;

That is all. ;)

--
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

--
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
Andreas Dilger - March 4, 2011, 10:23 p.m.
On 2011-03-04, at 3:04 PM, Eric Sandeen wrote:
> (crossport of 1f7bebb9e911d870fa8f997ddff838e82b5715ea
> by Andreas Schlick <schlick@lavabit.com>)
> 
> When ext3_dx_add_entry() has to split an index node, it has to ensure that
> name_len of dx_node's fake_dirent is also zero, because otherwise e2fsck
> won't recognise it as an intermediate htree node and consider the htree to
> be corrupted.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---

Should also be sent to stable I think.

> (V2: fix subject and commit and formatting)
> 
> While it's a simple one liner, this took me forever to (re-)find.
> 
> kill_ext3_now++;
> 
> That is all. ;)
> 
> diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
> index b27ba71..75c968e 100644
> --- a/fs/ext3/namei.c
> +++ b/fs/ext3/namei.c
> @@ -1540,8 +1540,8 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry,
> 			goto cleanup;
> 		node2 = (struct dx_node *)(bh2->b_data);
> 		entries2 = node2->entries;
> +		memset(&node2->fake, 0, sizeof(struct fake_dirent));
> 		node2->fake.rec_len = ext3_rec_len_to_disk(sb->s_blocksize);
> -		node2->fake.inode = 0;
> 		BUFFER_TRACE(frame->bh, "get_write_access");
> 		err = ext3_journal_get_write_access(handle, frame->bh);
> 		if (err)
> --
> 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
> 
> --
> 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


Cheers, Andreas





--
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 - March 7, 2011, 4:26 p.m.
On Fri 04-03-11 16:04:08, Eric Sandeen wrote:
> (crossport of 1f7bebb9e911d870fa8f997ddff838e82b5715ea
> by Andreas Schlick <schlick@lavabit.com>)
> 
> When ext3_dx_add_entry() has to split an index node, it has to ensure that
> name_len of dx_node's fake_dirent is also zero, because otherwise e2fsck
> won't recognise it as an intermediate htree node and consider the htree to
> be corrupted.
>     
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
  Thanks. Merged - and added CC to stable@kernel.org as Andreas suggested.

> While it's a simple one liner, this took me forever to (re-)find.
  I feel with you :).

								Honza
> 
> diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
> index b27ba71..75c968e 100644
> --- a/fs/ext3/namei.c
> +++ b/fs/ext3/namei.c
> @@ -1540,8 +1540,8 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry,
>  			goto cleanup;
>  		node2 = (struct dx_node *)(bh2->b_data);
>  		entries2 = node2->entries;
> +		memset(&node2->fake, 0, sizeof(struct fake_dirent));
>  		node2->fake.rec_len = ext3_rec_len_to_disk(sb->s_blocksize);
> -		node2->fake.inode = 0;
>  		BUFFER_TRACE(frame->bh, "get_write_access");
>  		err = ext3_journal_get_write_access(handle, frame->bh);
>  		if (err)
Eric Sandeen - March 7, 2011, 4:32 p.m.
On 3/7/11 10:26 AM, Jan Kara wrote:
> On Fri 04-03-11 16:04:08, Eric Sandeen wrote:
>> (crossport of 1f7bebb9e911d870fa8f997ddff838e82b5715ea
>> by Andreas Schlick <schlick@lavabit.com>)
>>
>> When ext3_dx_add_entry() has to split an index node, it has to ensure that
>> name_len of dx_node's fake_dirent is also zero, because otherwise e2fsck
>> won't recognise it as an intermediate htree node and consider the htree to
>> be corrupted.
>>     
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>   Thanks. Merged - and added CC to stable@kernel.org as Andreas suggested.

Thanks!

-Eric

>> While it's a simple one liner, this took me forever to (re-)find.
>   I feel with you :).
> 
> 								Honza
>>
>> diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
>> index b27ba71..75c968e 100644
>> --- a/fs/ext3/namei.c
>> +++ b/fs/ext3/namei.c
>> @@ -1540,8 +1540,8 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry,
>>  			goto cleanup;
>>  		node2 = (struct dx_node *)(bh2->b_data);
>>  		entries2 = node2->entries;
>> +		memset(&node2->fake, 0, sizeof(struct fake_dirent));
>>  		node2->fake.rec_len = ext3_rec_len_to_disk(sb->s_blocksize);
>> -		node2->fake.inode = 0;
>>  		BUFFER_TRACE(frame->bh, "get_write_access");
>>  		err = ext3_journal_get_write_access(handle, frame->bh);
>>  		if (err)

--
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

Patch

diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index b27ba71..75c968e 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1540,8 +1540,8 @@  static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry,
 			goto cleanup;
 		node2 = (struct dx_node *)(bh2->b_data);
 		entries2 = node2->entries;
+		memset(&node2->fake, 0, sizeof(struct fake_dirent));
 		node2->fake.rec_len = ext3_rec_len_to_disk(sb->s_blocksize);
-		node2->fake.inode = 0;
 		BUFFER_TRACE(frame->bh, "get_write_access");
 		err = ext3_journal_get_write_access(handle, frame->bh);
 		if (err)