When `dmu_tx_assign` is called from `zil_lwb_write_issue`, it's possible
for either `ERESTART` or `EIO` to be returned.

If `ERESTART` is returned, this will cause an assertion to fail directly
in `zil_lwb_write_issue`, where the code assumes the return value is
`EIO` if `dmu_tx_assign` returns a non-zero value. This can occur if the
SPA is suspended when `dmu_tx_assign` is called, and most often occurs
when running `zloop`.

If `EIO` is returned, this can cause assertions to fail elsewhere in the
ZIL code. For example, `zil_commit_waiter_timeout` contains the
following logic:

    lwb_t *nlwb = zil_lwb_write_issue(zilog, lwb);
    ASSERT3S(lwb->lwb_state, !=, LWB_STATE_OPENED);

In this case, if `dmu_tx_assign` returned `EIO` from within
`zil_lwb_write_issue`, the `lwb` variable passed in will not be issued
to disk. Thus, it's `lwb_state` field will remain `LWB_STATE_OPENED` and
this assertion will fail. `zil_commit_waiter_timeout` assumes that after
it calls `zil_lwb_write_issue`, the `lwb` will be issued to disk, and
doesn't handle the case where this is not true; i.e. it doesn't handle
the case where `dmu_tx_assign` returns `EIO`.

This change modifies `zil_lwb_write_issue` to verify that the return
code from `dmu_tx_assign` is either `ERESTART` or `0`.

If `EIO` is returned, the system will panic. This behavior is similar to
how we use `VERIFY0` when calling `dmu_tx_assign` elsewhere in the ZFS
code.

If `ERESTART` is returned, `zil_lwb_write_issue` will retry the
operation, and continually attempt to assign the transation until it
succeeds.

Upstream bugs: DLPX-54873
You can view, comment on, or merge this pull request online at:

  https://github.com/openzfs/openzfs/pull/507

-- Commit Summary --

  * 0000 ztest assertion failure in zil_lwb_write_issue (v2)

-- File Changes --

    M usr/src/uts/common/fs/zfs/zil.c (23)

-- Patch Links --

https://github.com/openzfs/openzfs/pull/507.patch
https://github.com/openzfs/openzfs/pull/507.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openzfs/openzfs/pull/507

------------------------------------------
openzfs-developer
Archives: 
https://openzfs.topicbox.com/groups/developer/discussions/T05cff66aac5a33a7-M943c2f8ba73338b5034cd637
Powered by Topicbox: https://topicbox.com

Reply via email to