Skip to content

Commit

Permalink
ZIL: Reduce scope of 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 zil_lwb_write_issue() in two parts: first
zil_lwb_write_close() does all necessary log space estimations and
block allocations while holding the lock, then zil_lwb_write_issue()
does all heavy lifting (memory copying, zio issuing, etc) later and
out of the lock.

Signed-off-by:  Alexander Motin <mav@FreeBSD.org>
Sponsored by:   iXsystems, Inc.
  • Loading branch information
amotin committed May 8, 2023
1 parent 3095ca9 commit 0252244
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 150 deletions.
4 changes: 3 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,7 @@ 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 */
} lwb_t;

/*
Expand Down
Loading

0 comments on commit 0252244

Please sign in to comment.