Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increment zil_itx_needcopy_bytes properly #7176

Merged
merged 1 commit into from
Mar 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions module/zfs/zil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,8 +1461,7 @@ zil_lwb_commit(zilog_t *zilog, itx_t *itx, lwb_t *lwb)
lrw->lr_offset += dnow;
lrw->lr_length -= dnow;
ZIL_STAT_BUMP(zil_itx_needcopy_count);
ZIL_STAT_INCR(zil_itx_needcopy_bytes,
lrw->lr_length);
ZIL_STAT_INCR(zil_itx_needcopy_bytes, dnow);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This same change should be made when incrementing the zil_itx_copied_bytes above and zil_itx_indirect_bytes below. They can't underflow in the same way but dnow is the accurate length to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dnow will always be zero in those cases because itx_wr_state != WR_NEED_COPY:


        if (lrc->lrc_txtype == TX_WRITE && itx->itx_wr_state == WR_NEED_COPY) {
                dlen = P2ROUNDUP_TYPED(
                    lrw->lr_length, sizeof (uint64_t), uint64_t);
        } else {
                dlen = 0;
        }
        ...
        dnow = MIN(dlen, lwb_sp - reclen);
        ...
               if (itx->itx_wr_state == WR_COPIED) {
                        ZIL_STAT_BUMP(zil_itx_copied_count);
>>>                     ZIL_STAT_INCR(zil_itx_copied_bytes, lrw->lr_length);
                } else {
                ...
                       if (itx->itx_wr_state == WR_NEED_COPY) {
                                ...
                        } else {
                                ASSERT3S(itx->itx_wr_state, ==, WR_INDIRECT);
                                dbuf = NULL;
                                ZIL_STAT_BUMP(zil_itx_indirect_count);
>>>                             ZIL_STAT_INCR(zil_itx_indirect_bytes,
>>>                                lrw->lr_length);
                        }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the simple change is better than where we are now (dnow? :-)

I'd like to consider recording both dnow and lr_length, but that should be a separate PR, if and when it proves useful. And I'd like to move any test case to the separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrisrd good point! OK, then this LGTM and nice job reproducing the issue to veirfy the fix.

} else {
ASSERT3S(itx->itx_wr_state, ==, WR_INDIRECT);
dbuf = NULL;
Expand Down