Skip to content

ZIL: Improve write log size accounting #17373

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

Merged
merged 1 commit into from
May 24, 2025
Merged
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions module/zfs/zfs_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
dmu_buf_impl_t *db = (dmu_buf_impl_t *)sa_get_db(zp->z_sa_hdl);
uint32_t blocksize = zp->z_blksz;
itx_wr_state_t write_state;
uint64_t gen = 0;
ssize_t size = resid;
uint64_t gen = 0, log_size = 0;

if (zil_replaying(zilog, tx) || zp->z_unlinked ||
zfs_xattr_owner_unlinked(zp)) {
Expand Down Expand Up @@ -680,6 +679,10 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
}
}

log_size += itx->itx_size;
if (wr_state == WR_NEED_COPY)
log_size += len;

itx->itx_wr_state = wr_state;
lr->lr_foid = zp->z_id;
lr->lr_offset = off;
Expand All @@ -699,9 +702,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
resid -= len;
}

if (write_state == WR_COPIED || write_state == WR_NEED_COPY) {
dsl_pool_wrlog_count(zilog->zl_dmu_pool, size, tx->tx_txg);
}
dsl_pool_wrlog_count(zilog->zl_dmu_pool, log_size, tx->tx_txg);
}

/*
Expand Down
10 changes: 6 additions & 4 deletions module/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ zvol_log_write(zvol_state_t *zv, dmu_tx_t *tx, uint64_t offset,
uint32_t blocksize = zv->zv_volblocksize;
zilog_t *zilog = zv->zv_zilog;
itx_wr_state_t write_state;
uint64_t sz = size;
uint64_t log_size = 0;

if (zil_replaying(zilog, tx))
return;
Expand Down Expand Up @@ -909,6 +909,10 @@ zvol_log_write(zvol_state_t *zv, dmu_tx_t *tx, uint64_t offset,
wr_state = WR_NEED_COPY;
}

log_size += itx->itx_size;
if (wr_state == WR_NEED_COPY)
log_size += len;

itx->itx_wr_state = wr_state;
lr->lr_foid = ZVOL_OBJ;
lr->lr_offset = offset;
Expand All @@ -924,9 +928,7 @@ zvol_log_write(zvol_state_t *zv, dmu_tx_t *tx, uint64_t offset,
size -= len;
}

if (write_state == WR_COPIED || write_state == WR_NEED_COPY) {
dsl_pool_wrlog_count(zilog->zl_dmu_pool, sz, tx->tx_txg);
}
dsl_pool_wrlog_count(zilog->zl_dmu_pool, log_size, tx->tx_txg);
}

/*
Expand Down
Loading