kernel - Change bundirty() location in I/O sequence

Operating Systems / DragonFlyBSD - Matthew Dillon [apollo.backplane.com] - 21 May 2015 00:18 UTC

- When doing a write BIO, do not bundirty() the buffer prior to issuing the vn_strategy(). Instead, bundirty() the buffer when the I/O is complete, primarily in bpdone().

The I/O's data buffer is protected during the operation by vfs_busy_pages(), so related VM pages cannot be modified while the write is running. And, of course, the buffer itself is locked exclusively for the duration of the opeartion. Thus this change should NOT introduce any redirtying races.

- This change ensures that vp->v_rbdirty_tree remains non-empty until all related write I/Os have completed, removing a race condition for code which checks vp->v_rbdirty_tree to determine e.g. if a file requires synchronization or not.

This race could cause problems because the system buffer flusher might be in the midst of flushing a buffer just as a filesystem decides to sync and starts checking vp->v_rbdirty_tree.

- This should theoretically fix a long-standing but difficult-to-reproduce bug in HAMMER1 where a backend flush occurs at an inopportune time.

ffd3e59 kernel - Change bundirty() location in I/O sequence
sys/kern/vfs_bio.c | 58 ++++++++++++++++++++++++++++++++++++++----------
sys/kern/vfs_cluster.c | 17 ++++++++++++--
sys/kern/vfs_subr.c | 2 ++
sys/kern/vfs_sync.c | 19 ++++++++++------
4 files changed, 75 insertions(+), 21 deletions(-)

Upstream: gitweb.dragonflybsd.org


  • Share