4 ms·
> when you update the content of a file, the mtime of its containing directory is not changed ... if the directory mtime were updated (recursively to the root)
by dspillett 6y ago
> when you update the content of a file, the mtime of its containing directory is not changed ... if the directory mtime were updated (recursively to the root) when contained files changed ... This is probably because of hardlinks
It might be partly due to hardlinks, but I suspect it is mostly an efficiency issue. Modifying a file could mean updating quite a few directories every time if you have a deep tree. For some uses this could be quite a performance hit, and for some media would potentially reduce the life of your hardware too.
IIRC even when updating atime for every access was the usual default for many filesystems, only the current object had its time updated not all its chain of parents.
- Taniwha 6y agoYes imagine recording a video stream, you'd have to update every directory above a file every few mS when files are written, and because file metadata usually gets priority on a spinning disk the heads would go crazy and throughput would go way down - probably couldn't keep up with the incoming stream
- apenwarr 6y agoYou're assuming the inodes of all the parent directories would be flushed to disk every time they change. This is already not the case. It would be just a matter of touching the data structure in memory and eventually flushing it out.
- dspillett 6y agoYou are assuming a modern filesystem and/or cacheing architecture in a machine with enough memory to spare to run it effectively (though in fairness the post you replied to directly did mention a fairly modern use case). Back when the behaviours being discussed became the norm the landscape was pretty different.