Skip to content

Commit

Permalink
Attempt to fix zil_sync race
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Yao <[email protected]>
  • Loading branch information
Richard Yao authored and ryao committed May 14, 2017
1 parent 26e0a8f commit ebbcf18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions include/sys/zil_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ struct zilog {
uint_t zl_prev_blks[ZIL_PREV_BLKS]; /* size - sector rounded */
uint_t zl_prev_rotor; /* rotor for zl_prev[] */
txg_node_t zl_dirty_link; /* protected by dp_dirty_zilogs list */
kmutex_t zl_writer_lock; /* protects two fields below */
kmutex_t zl_writer_lock; /* protects writer list */
list_t zl_writer_list; /* list of writers */
lwb_t *zl_last_lwb; /* lwb from previous pipeline stage */
};

/*
Expand Down
9 changes: 4 additions & 5 deletions module/zfs/zil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1613,12 +1613,12 @@ zil_commit_writer(zilog_t *zilog)
cv_wait(&prev->zilw_cv_waiter,
&zilog->zl_writer_lock);
}
lwb = zilog->zl_last_lwb;

} else {
lwb = list_tail(&zilog->zl_lwb_list);
}

mutex_enter(&zilog->zl_lock);
lwb = list_tail(&zilog->zl_lwb_list);
mutex_exit(&zilog->zl_lock);

if (lwb == NULL)
lwb = zil_create(zilw);
}
Expand Down Expand Up @@ -1652,7 +1652,6 @@ zil_commit_writer(zilog_t *zilog)
/*
* Signal next thread, if any, for entry into the pipeline.
*/
zilog->zl_last_lwb = lwb;
mutex_enter(&zilog->zl_writer_lock);
if (zilw->zilw_stage == 1) {
zilw->zilw_stage = 2;
Expand Down

0 comments on commit ebbcf18

Please sign in to comment.