UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2006-07-06 05:20 PM

felix
Member
Registered: 2003-12-04
Posts: 171

Re: Bad Blocks and Creation Time..

Hi all,

Long time no see you, I'm near to finish the University so not much time to play with this wonderful things. :)

I got some doubts and probabilitty you specialist can help me...

1 - Blocks marked as Bad blocks have timestamp? Or bad blocks doesn't have the timestamp field as other normal (block) files ? The information about timestamp in normal (blocks) files are in inode, right? So back blocks have inodes?

2 - Use the bad blocks tool with write option can demage the disk (generate bad blocks)? I heard that excessive read/write on disk generate bad blocks... it's true? Something know in average how much is needed to generate a bad block in a block (4k by default, right)?

3 - In Unix we have a funcion called utimes() that allow us to modify the "access time" and "modifyed time", however I could't figure any function to modify the "creation time"... how it can be done (some code snipet example? :))?

Thnak u and sorry for dumb questions

Offline

#2 2006-07-06 07:01 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Bad Blocks and Creation Time..

Bad blocks only exist as hardware as part of a harddisk, they are not some virtual entity like inodes or similar. When detecting badblocks the harddisk is probed to check which blocks are broken and which are fine. The broken ones are bad blocks, and usually their address on the harddisk is stored to a file or printed out. This is way below the filesystem level though, it isn't trivial to know which file is stored in which block.

So to answer 1), no they aren't timestamped, but the textfile storing the bad blocks' addresses might.

To answer 2): the badblocks program tries to detect which blocks are broken. It can do two things to find that out: Read blocks and write blocks. The problem is that reading bad blocks works most of the time. So to find out which blocks are really broken you need to write to it, read its value, and if a different value is returned than was just written, then the block is bad.

Obviously you can't just write the existing value, as nothing would change and you still wouldn't know if the block is really good or not. So another value is written for testing. This means though that your filesystem will be inconsistent after that testwrite, and if writing back the original value fails you end up with a corrupted filesystem. This is why using badblocks with write checking can be dangerous. It will however in the worst case only damage your filesystem, not the hardware.

As for 3), only (slightly sane) way to modify the creation time is by removing the old file and making a new one, which gets a new creation time. The question is why you would want to change the creation time though, it doesn't seem to be very useful...

Offline

#3 2006-07-06 07:27 PM

felix
Member
Registered: 2003-12-04
Posts: 171

Re: Bad Blocks and Creation Time..

Offline

#4 2006-07-06 07:57 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Bad Blocks and Creation Time..

I wouldn't worry about excessive reads/writes to one block, I don't think it will damage that block. Of course it will decrease the lifetime of that block, but not only that block, but the whole HD. If it is decreased significantly depends on how long you keep looping at one place. But the wasted time of doing so and keeping your HD from doing useful work is much worse than any lifetime decrease. ;-)

As a side note. modern harddisk remap bad blocks internally when they detect that a block is bad, as there are always some bad blocks at production. So when you detect bad blocks it means your have serious problems and should replace the HD.

I think a block can handle practically unlimited number of rewrites, but as drives and operating systems do caching and buffering it's hard to achieve a lot of rewriting. If for some reason the block is dead it will be remapped, so it's quite hard to test how many rewrites a single block can handle. Anyway, a head crash or other failure is much more likely than a block reaching its rewrite limit.

So all in all I'd say it isn't true, practically speaking. You could try it out on an old hd though. ;-)

Much better idea: don't try to change the creation time. There are plenty of other more interesting, but as useless things to think about. If you want a though question to think about, here's one: Give a single reason why changing the creation time of a file is useful, in a way that doesn't destroy the purpose or meaning of the creation time.

Offline

#5 2006-07-06 08:27 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Bad Blocks and Creation Time..

What is this "creation time" you're both talking about anyway??  I don't think such
a creature actually exists...  You mention "i_ctime" in the kernel ext3 code, which
corresponds to "st_ctime" in the stat() info, which is the time of the last metadata
change (changing owner, group, perms, etc.), NOT the creation time!  As far as I
know, even if any particular filesystem did support a notion of a file creation time,
there's no way of obtaining it, let alone SETTING it, in anything like a standard
manner...

But, as for why utime()/utimes() doesn't allow changing the "ctime", I don't know...
Probably no one cared enough to bother, since there's not a lot of practical use
for it in the first place...  (Seriously, when's the last time you ever cared about the
time of the last metadata change on a file??  I don't think I EVER have in my life...
I suppose I could invent hypothetical scenarios: you suddenly discover some files
have odd permissions, and you want to find out when the changes were made to
try to narrow down who/what might've changed them... *shrug*  But, in that case,
lack of API for changing ctime is actually a GOOD thing, since it prevents one from
back-dating the changes to prevent you from finding out when they occurred...
Unless of course one has root access and can change the system time: then, all
you need to do is set the system time to whatever you want and do a chmod() or
rename() or whatever syscall you choose that'll update ctime, then change the
system time back to normal...)

Offline

#6 2006-07-06 08:45 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Bad Blocks and Creation Time..

Heh, good one. I assumed it was some obscure field hidden somewhere, I'm daft enough to miss the non-existence of the thing and the fact that he was talking about ctime... Not sure which is worse, ugh. =)

Offline

#7 2006-07-07 10:20 PM

felix
Member
Registered: 2003-12-04
Posts: 171

Re: Bad Blocks and Creation Time..

ls teste
-rw-r--r--  1 root root 4576 Jul  7 20:03 teste


stat teste
Inode: 33366   Type: regular    Mode:  0644   Flags: 0x0   Generation: 176878913
8
User:     0   Group:     0   Size: 4576
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 16
Fragment:  Address: 0    Number: 0    Size: 0
ctime: 0x44ae952d -- Fri Jul  7 20:09:01 2006
atime: 0x44ae93dd -- Fri Jul  7 20:03:25 2006
mtime: 0x44ae93dd -- Fri Jul  7 20:03:25 2006
BLOCKS:
(0-1):77822-77823
TOTAL: 2



echo >> teste
stat teste
Inode: 33366   Type: regular    Mode:  0644   Flags: 0x0   Generation: 176878913
8
User:     0   Group:     0   Size: 4577
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 16
Fragment:  Address: 0    Number: 0    Size: 0
ctime: 0x44ae95f3 -- Fri Jul  7 20:12:19 2006
atime: 0x44ae95af -- Fri Jul  7 20:11:11 2006
mtime: 0x44ae95f3 -- Fri Jul  7 20:12:19 2006
BLOCKS:
(0-1):77822-77823
TOTAL: 2



chmod 700 teste
stat teste
Inode: 33366   Type: regular    Mode:  0700   Flags: 0x0   Generation: 176878913
8
User:     0   Group:     0   Size: 4577
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 16
Fragment:  Address: 0    Number: 0    Size: 0
ctime: 0x44ae9630 -- Fri Jul  7 20:13:20 2006
atime: 0x44ae95af -- Fri Jul  7 20:11:11 2006
mtime: 0x44ae95f3 -- Fri Jul  7 20:12:19 2006
BLOCKS:
(0-1):77822-77823
TOTAL: 2


echo >>teste
stat teste
Inode: 33366   Type: regular    Mode:  0700   Flags: 0x0   Generation: 176878913
8
User:     0   Group:     0   Size: 4579
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 16
Fragment:  Address: 0    Number: 0    Size: 0
ctime: 0x44ae967b -- Fri Jul  7 20:14:35 2006
atime: 0x44ae95af -- Fri Jul  7 20:11:11 2006
mtime: 0x44ae967b -- Fri Jul  7 20:14:35 2006
BLOCKS:
(0-1):77822-77823
TOTAL: 2

Offline

#8 2006-07-08 08:08 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Bad Blocks and Creation Time..

Offline

#9 2006-07-21 05:43 AM

felix
Member
Registered: 2003-12-04
Posts: 171

Re: Bad Blocks and Creation Time..

Offline

#10 2006-07-21 01:25 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Bad Blocks and Creation Time..

Offline

#11 2006-07-21 05:16 PM

felix
Member
Registered: 2003-12-04
Posts: 171

Re: Bad Blocks and Creation Time..

Hi RobSeace,

heheh, you are right, thank you for all clarification. :)

Thank you,

Regards

Offline

Board footer

Powered by FluxBB