POSIX semantics and ZFS on synchronous + asynchronous writes #17149
Replies: 2 comments
-
The answer is inside
The moment you open file with |
Beta Was this translation helpful? Give feedback.
-
Hi @amotin , Okay, thank you! What you are saying makes sense! I am working on a previous version (tag: 2.2.4) which has slightly a different implementation for zfs_open() and zfs_write() that was why I was confused. For example, zfs_open increases the counter (so z_sync_cnt != 0, when we open the file with O_SYNC)
But when we write (zfs_write -> zfs_log_write) all itx are by default sync (itx_sync = B_TRUE), unless we enter this piece of code.
However, yes, in the current version, it does make sense. |
Beta Was this translation helpful? Give feedback.
-
Hello,
ZFS (ZIL) does not guarantee any ordering between asynchronous and synchronous
itxs
even for the same object.Example to clarify my understanding:
In a single-threaded application, we execute the following:
By reading the ZIL code it seems that
write(fd, A1)
andwrite(fd, A2)
will be placed to the asynchronousitxs
(avl_tree_t
) and there respective ordering will be preserved (e.g., ifwrite(fd, A2)
is visible then write(fd, A1) has also took effect).When we do the
fsync
we serialize the synchronous and asynchronous writes into the sync list; we append the asynchronous itxs into the synchronous itxs (at the end). Now, the thirdwrite(fd_sync, A3)
will be placed to the synchronousitxs
list. Basically I understand that the list with the synchronousitxs
will now havewrite(fd,A3
->write(fd, A1)
->write(fd, A2)
in this particular order.Is my understanding correct? Shouldn't a read always see the latest write? In case of a crash the latest write appears to be
write(fd,A2)
.What am I missing? :)
Thanks again,
Dimitra
Beta Was this translation helpful? Give feedback.
All reactions