Skip to content

Commit

Permalink
ZIL: Reduce scope of per-dataset zl_issuer_lock.
Browse files Browse the repository at this point in the history
Before this change ZIL copied all log data while holding the lock.
It caused huge lock contention on workloads with many big parallel
writes.  This change splits the process into two parts: first,
zil_lwb_assign() estimates the log space needed for all transactions,
and zil_lwb_write_close() allocates blocks and zios while holding the
lock, then, after the lock in dropped, zil_lwb_commit() copies the
data, and zil_lwb_write_issue() issues the I/Os.

Signed-off-by:  Alexander Motin <mav@FreeBSD.org>
Sponsored by:   iXsystems, Inc.
  • Loading branch information
amotin committed May 9, 2023
1 parent 3095ca9 commit a871d28
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 152 deletions.
5 changes: 4 additions & 1 deletion include/sys/zil_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern "C" {
* must be held.
*
* After the lwb is "opened", it can transition into the "issued" state
* via zil_lwb_write_issue(). Again, the zilog's "zl_issuer_lock" must
* via zil_lwb_write_close(). Again, the zilog's "zl_issuer_lock" must
* be held when making this transition.
*
* After the lwb's write zio completes, it transitions into the "write
Expand Down Expand Up @@ -94,6 +94,7 @@ typedef struct lwb {
boolean_t lwb_fastwrite; /* is blk marked for fastwrite? */
boolean_t lwb_slog; /* lwb_blk is on SLOG device */
int lwb_nused; /* # used bytes in buffer */
int lwb_nfilled; /* # filled bytes in buffer */
int lwb_sz; /* size of block and buffer */
lwb_state_t lwb_state; /* the state of this lwb */
char *lwb_buf; /* log write buffer */
Expand All @@ -107,6 +108,8 @@ typedef struct lwb {
avl_tree_t lwb_vdev_tree; /* vdevs to flush after lwb write */
kmutex_t lwb_vdev_lock; /* protects lwb_vdev_tree */
hrtime_t lwb_issued_timestamp; /* when was the lwb issued? */
list_node_t lwb_issue_node; /* linkage of lwbs ready for issue */
boolean_t lwb_indirect; /* do not postpone zil_lwb_commit() */
} lwb_t;

/*
Expand Down
Loading

0 comments on commit a871d28

Please sign in to comment.