ZFS and other filesystem semantics.

Zaphod Beeblebrox zbeeble at gmail.com
Mon Dec 15 11:55:42 PST 2008


On Tue, Dec 9, 2008 at 9:01 AM, Christopher Arnold <chris at arnold.se> wrote:


> i have been thinking a bit about filesytem semantics lately. Mainly about
> open files.
>
> Classicly if a file is open the filedescriptor continues accessing the same
> file regardless if it is deleted or someone did a mv and replaced it.
>
> But what happens in ZFS?
>
> * delete file in ZFS
> I guess this is a no brainer, standard unix way of accessing the old file.


When all references to  data  are freed, the data is freed.  directory
entries and open files are both references.


> * The fs get snapshotted and file deleted
> Same as above i guess.


A snapshot counts as a reference


> * The fs gets snapshotted and later the snapshot get deleted...
> What happens here?


A snapshot is a reference.  When the file is "deleted" the snapshot still
references the data.  When the snapshot is deleted, if the data has no other
references, it is freed.


> Or maybe even:
> * The fs gets snapshotted, file deleted, then snapshot deleted.
>
> (These questions are actually just a sidestep from the issue im trying to
> figure out right no. But i guess they are nevertheless interesting.)
>
> The reason i have been thinking about this is that i'm implementing a
> remote RO filesystem with local caching. And to reduce latency i download
> chunks of the files and cache these chunks. I'm trying to keep the
> filesystem stateless, but my issue is that if the file get changed under our
> feet the resulting chunks would be from different files.
>
> Have anyone seen a nice solution to this issue?
>
> Does anyone have any ideas of how to implement unix like semantics over a
> stateless procotol without to much magic?


The semantics you desire are basically reference counting.


More information about the freebsd-fs mailing list