UFS: The Root of All Evil 277 inconsistencies when directory hierarchies are replicated. Filenames that were linked in the original hierarchy are no longer linked in the replica… This is actually rather an understatement of the true magnitude of the bug. The problem is not just one of “inconsistencies”—in point of fact the copy may be infinitely large if there is any circularity in the symbolic links in the source hierarchy. The solution, as any well-seasoned Unix veteran will tell you, is to use tar6 if you want to copy a hierarchy. No kidding. Simple and ele- gant, right? Disk Usage at 110%? The Unix file system slows down as the disk fills up. Push disk usage much past 90%, and you’ll grind your computer to a halt. The Unix solution takes a page from any good politician and fakes the numbers. Unix’s df command is rigged so that a disk that is 90% filled gets reported as “100%,” 80% gets reported as being “91%” full, and so forth. So you might have 100MB free on your 1000MB disk, but if you try to save a file, Unix will say that the file system is full. 100MB is a large amount of space for a PC-class computer. But for Unix, it’s just spare change. Imagine all of the wasted disk space on the millions of Unix systems throughout the world. Why think when you can just buy bigger disks? It is estimated that there are 100,000,000,000,000 bytes of wasted disk space in the world due to Unix. You could probably fit a copy of a better operating system into the wasted disk space of every Unix system. There is a twist if you happen to be the superuser—or a daemon running as root (which is usually the case anyway). In this case, Unix goes ahead and lets you write out files, even though it kills performance. So when you have that disk with 100MB free and the superuser tries to put out 50MB of new files on the disk, raising it to 950 MB, the disk will be at “105% capacity.” 6“tar” stands for tape archiver it is one of the “standard” Unix programs for making a tape backup of the information on a hard disk. Early versions wouldn’t write backups that were more than one tape long.
278 The File System Weird, huh? It’s sort of like someone who sets his watch five minutes ahead and then arrives five minutes late to all of his appointments, because he knows that his watch is running fast. Don’t Forget to write(2) Most Unix utilities don’t check the result code from the write(2) system call—they just assume that there is enough space left on the device and keep blindly writing. The assumption is that, if a file could be opened, then all of the bytes it contains can be written. Lenny Foner explains it like this: Date: Mon, 13 Nov 89 23:20:51 EST From: foner@ai.mit.edu (Leonard N. Foner) To: UNIX-HATERS Subject: Geez… I just love how an operating system that is really a thinly disguised veneer over a file system can’t quite manage to keep even its file sys- tem substrate functioning. I’m particularly enthralled with the idea that, as the file system gets fuller, it trashes more and more data. I guess this is kinda like “soft clipping” in an audio amplifier: rather than have the amount of useful data you can store suddenly hit a wall, it just slowly gets harder and harder to store anything at all… I’ve seen about 10 messages from people on a variety of Suns today, all complaining about massive file system lossage. This must be closely related to why ‘mv’ and other things right now are trying to read shell commands out of files instead of actually moving the files themselves, and why the shell commands coming out of the files correspond to data that used to be in other files but aren’t actually in the files that ‘mv’ is touching anyway… Performance So why bother with all this? Unix weenies have a single answer to this question: performance. They wish to believe that the Unix file system is just about the fastest, highest-performance file system that’s ever been written. Sadly, they’re wrong. Whether you are running the original UFS or the new and improved FFS, the Unix file system has a number of design flaws that prevent it from ever achieving high performance.