3 ms·
Mystery is solved: "In most cases, removing all filenames associated with an inode will reduce the reference counter to zero, but it turns out you can also hav
by RetroTechie 3y ago
Mystery is solved:
"In most cases, removing all filenames associated with an inode will reduce the reference counter to zero, but it turns out you can also have a file referred to by zero file names, but with a non-zero reference counter, which is what was happening here.
The file had a non-zero reference count because it was memory mapped, even though no filename pointed to it. The reference counter doesn’t decrement until you un-map the memory."
At 1st glance this may appear weird, but not when thinking about it.
It means diskspace that isn't referred to by a filename, but which is allocated / used in some way ("reserved" comes to mind).
On the other hand, it does seem weird one could create memory mapped diskspace without somehow assigning a filename to that? Or delete memory mapped file, but have the memory mapping + corresponding diskspace remain? More logical -imho- would be delete mm file -> corresponding RAM either freed, or non-file mapped.
Appearently Java version used (specifically: its GC) isn't good at handling / cleaning up in situations like this.
- marginalia_nu 3y agoYeah I'd call the behavior unexpected rather than wrong. As a design decision it makes a lot of sense, especially given the ideas that went into UNIX filesystems that didn't quite pan out (hard links are a very neat idea in theory, but I'm not sure when I'd ever actually use them).
- somat 3y agoHard links are tags. A file is just a big lump of data with an address(the inode) A name is then linked to the data(If you wanted you could call it a tag, it is almost exactly the same thing). If the data needs more metadata go ahead and link additional names to it. Note that no name is the "real name" with hard links they are all equal. I built a whole music database once where all the metadata and playlists were hardlinks... The main problem encountered was you had to be very careful archiving the structure, it tended to explode into a million duplicate files(this is probably why people don't use hardlinks)