linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ext2/ext3 different block_sizes/i_size/e2fsck question
@ 2010-03-24 19:27 Evgeniy Ivanov
  2010-03-24 23:18 ` Evgeniy Ivanov
  2010-03-25  1:55 ` tytso
  0 siblings, 2 replies; 4+ messages in thread
From: Evgeniy Ivanov @ 2010-03-24 19:27 UTC (permalink / raw)
  To: linux-ext4

Hello,

Sorry for bothering list with my ext2 questions.
I got into trouble with my ext2 implementation and filesystem with
1024 block size. Sometimes when I write files they're written
correctly (md5sum is the same as original, i_size is correct either),
but e2fsck changes i_size to another values (which breaks files). E.g.
67445000->67446784 or 67445248->67446784. I see that new sizes are
numbers of multiples of 1024.
Strange thing is that I can't reproduce this problem with 2048 and
4096 block sizes. I thought the problem was in trash in unused part of
last block (actually it is zeroed), but then it would be reproduceable
in fs with another block size.
How does ext2 decide to fix that files sizes? Any suggestions?

Thanks in advance for any help.


-- 
Evgeniy Ivanov

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

* Re: ext2/ext3 different block_sizes/i_size/e2fsck question
  2010-03-24 19:27 ext2/ext3 different block_sizes/i_size/e2fsck question Evgeniy Ivanov
@ 2010-03-24 23:18 ` Evgeniy Ivanov
  2010-03-25  1:55 ` tytso
  1 sibling, 0 replies; 4+ messages in thread
From: Evgeniy Ivanov @ 2010-03-24 23:18 UTC (permalink / raw)
  To: linux-ext4

I've also noted a very interesting and strange thing. I checked a file
for which e2fsck did 67445000->67446784 i_size change.
debugfs stat comparison between fixed file and file with old size
differs in i_size *only* (all blocks are the same), but cmp shows
difference in 67382273 (it's constant for any bogus file), that is
block 65803 which is the last before triple indirection. How did file
change if e2fsck just had changed i_size and both values are greater
than 67382273?


On Wed, Mar 24, 2010 at 10:27 PM, Evgeniy Ivanov <lolkaantimat@gmail.com> wrote:
> Hello,
>
> Sorry for bothering list with my ext2 questions.
> I got into trouble with my ext2 implementation and filesystem with
> 1024 block size. Sometimes when I write files they're written
> correctly (md5sum is the same as original, i_size is correct either),
> but e2fsck changes i_size to another values (which breaks files). E.g.
> 67445000->67446784 or 67445248->67446784. I see that new sizes are
> numbers of multiples of 1024.
> Strange thing is that I can't reproduce this problem with 2048 and
> 4096 block sizes. I thought the problem was in trash in unused part of
> last block (actually it is zeroed), but then it would be reproduceable
> in fs with another block size.
> How does ext2 decide to fix that files sizes? Any suggestions?
>
> Thanks in advance for any help.
>
>
> --
> Evgeniy Ivanov
>



-- 
Evgeniy Ivanov

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

* Re: ext2/ext3 different block_sizes/i_size/e2fsck question
  2010-03-24 19:27 ext2/ext3 different block_sizes/i_size/e2fsck question Evgeniy Ivanov
  2010-03-24 23:18 ` Evgeniy Ivanov
@ 2010-03-25  1:55 ` tytso
  2010-03-25 22:43   ` Evgeniy Ivanov
  1 sibling, 1 reply; 4+ messages in thread
From: tytso @ 2010-03-25  1:55 UTC (permalink / raw)
  To: Evgeniy Ivanov; +Cc: linux-ext4

On Wed, Mar 24, 2010 at 10:27:24PM +0300, Evgeniy Ivanov wrote:
> 
> Sorry for bothering list with my ext2 questions.
> I got into trouble with my ext2 implementation and filesystem with
> 1024 block size. Sometimes when I write files they're written
> correctly (md5sum is the same as original, i_size is correct either),
> but e2fsck changes i_size to another values (which breaks files). E.g.
> 67445000->67446784 or 67445248->67446784. I see that new sizes are
> numbers of multiples of 1024.
> Strange thing is that I can't reproduce this problem with 2048 and
> 4096 block sizes. I thought the problem was in trash in unused part of
> last block (actually it is zeroed), but then it would be reproduceable
> in fs with another block size.

E2fsck will adjust i_size if it is smaller than the number of blocks
than you have allocated.  So in the case of 67445000->67446784, your
file probably had 65866 1k blocks, and since 67445000 is less than
(655865*1024)+1, e2fsck assumed that your i_size was wrong, and so it
asked for permission to fix it.

Put another way, if you have 2 blocks in 1k file, and i_size is 1024,
it clearly must be wrong.  If it's 1025, maybe we're only using 1 byte
in the last block; but if i_size is less than or equal to 1024, then
why was the 2nd block allocated in the file in the first place?

    	    	      		       - Ted

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

* Re: ext2/ext3 different block_sizes/i_size/e2fsck question
  2010-03-25  1:55 ` tytso
@ 2010-03-25 22:43   ` Evgeniy Ivanov
  0 siblings, 0 replies; 4+ messages in thread
From: Evgeniy Ivanov @ 2010-03-25 22:43 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4

On Thu, Mar 25, 2010 at 4:55 AM,  <tytso@mit.edu> wrote:
> On Wed, Mar 24, 2010 at 10:27:24PM +0300, Evgeniy Ivanov wrote:
>>
>> Sorry for bothering list with my ext2 questions.
>> I got into trouble with my ext2 implementation and filesystem with
>> 1024 block size. Sometimes when I write files they're written
>> correctly (md5sum is the same as original, i_size is correct either),
>> but e2fsck changes i_size to another values (which breaks files). E.g.
>> 67445000->67446784 or 67445248->67446784. I see that new sizes are
>> numbers of multiples of 1024.
>> Strange thing is that I can't reproduce this problem with 2048 and
>> 4096 block sizes. I thought the problem was in trash in unused part of
>> last block (actually it is zeroed), but then it would be reproduceable
>> in fs with another block size.
>
> E2fsck will adjust i_size if it is smaller than the number of blocks
> than you have allocated.  So in the case of 67445000->67446784, your
> file probably had 65866 1k blocks, and since 67445000 is less than
> (655865*1024)+1, e2fsck assumed that your i_size was wrong, and so it
> asked for permission to fix it.
>
> Put another way, if you have 2 blocks in 1k file, and i_size is 1024,
> it clearly must be wrong.  If it's 1025, maybe we're only using 1 byte
> in the last block; but if i_size is less than or equal to 1024, then
> why was the 2nd block allocated in the file in the first place?

Thank you for your explanation.
My problem was in miscalculation of first triple indirect block. I
used following thing "triple_ind_s = doub_ind_s + pow(addr_in_block,
2)" and it was a bad idea to use pow() instead of multiplication or
shifting. It was ok with gcc (and libc), but caused a problem with ACK
(I get value of 1 less, thus each last double indirect block became a
hole instead of data). Since that was both in reading and writing md5
sums were correct (and in Linux I checked them only after e2fsck).
Funny bug :)


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

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

end of thread, other threads:[~2010-03-25 22:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-24 19:27 ext2/ext3 different block_sizes/i_size/e2fsck question Evgeniy Ivanov
2010-03-24 23:18 ` Evgeniy Ivanov
2010-03-25  1:55 ` tytso
2010-03-25 22:43   ` Evgeniy Ivanov

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