Re: Zero length files - an alternative approach?

From: Theodore Tso
Date: Mon Mar 30 2009 - 10:07:23 EST


On Mon, Mar 30, 2009 at 08:41:26AM -0400, Chris Mason wrote:
> >
> > Consider this scenario:
> >
> > 1. Create/write/close newfile
> > 2. Rename newfile to oldfile
>
> 2a. create oldfile again
> 2b. fsync oldfile
>
> > 3. Open/read oldfile. This must return the new contents.
> > 4. System crash and reboot before delayed allocation/flush complete
> > 5. Open/read oldfile. Old contents now returned.
> >
>
> What happens to the new generation of oldfile? We could insert
> dependency tracking so that we know the fsync of oldfile is supposed to
> also fsync the rename'd new file. But then picture a loop of operations
> doing renames and creating files in the place of the old one...that
> dependency tracking gets ugly in a hurry.

If there are any calls to link(2) to create hard links to oldfile or
newfile intermingled in this sequence, life also gets very
entertaining.

> Databases know how to do all of this, but filesystems don't implement
> most of the database transactional features.

Yep, we'd have to implement a rollback log to get this right, which
would also impact performance. My guess is that just aggressively
forcing out the data write before the rename() is going to cost less
in performance, and is certainly much easier to implement.

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/