[colug-432] Troubleshooting Suggestions: File Truncation Issue

Rob Funk rfunk at funknet.net
Tue Jan 12 09:43:58 EST 2016


Jeff Frontz wrote:
> 1.   Opens a new file
> 2.  Writes to the file
> 3.  Closes the file
> 4.  Creates a link to its real name
> 5.  Removes the original file
> 6.  stats the file to find a zero size
> 
> Without knowing the details of the particular kernel or
> filesystem/RAID drivers involved, there is the potential for a race
> condition between 2/3 and 6. On Unix/Linux, there is no guarantee that
> data has ever made it to the "disk" (which could include the various
> levels of drivers/caches in between your program and the actual
> hardware).

I remember seeing a lot of discussions about this sort of thing on LWN
a few years ago, in connection with modern filesystems like ext4 and
btrfs. As I recall, one of the filesystems changed the traditional way
writes worked, while still staying within the POSIX spec, so software
broke. At first the userland people were told to add sync calls, but
that was deemed too heavy.

I think the solution was to add a heuristic to the filesystem to
detect when the old idiom was being used, and act the way the software
was expecting.

Unfortunately I don't remember exactly which filesystem this was, but
I'm pretty sure it wasn't XFS.



More information about the colug-432 mailing list