Skip to content

POSIX semantics and ZFS on synchronous + asynchronous writes #17149

Answered by dgiantsidi
dgiantsidi asked this question in Q&A
Discussion options

You must be logged in to vote

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)

zfs_open():
  /* Keep a count of the synchronous opens in the znode */
  if (flag & O_SYNC)
      atomic_inc_32(&zp->z_sync_cnt);

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.
So I do not see how we serialize the writes correctly here.

zfs_log_write():
  if (!(ioflag & (O_SYNC | O_DSYNC)) && …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by dgiantsidi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants