aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorChristian Schwarz <[email protected]>2020-09-25 22:06:34 +0200
committerGitHub <[email protected]>2020-09-25 13:06:34 -0700
commita5c77dc4d53ea86d048a9c251015eed14d57e0a7 (patch)
treebfce3256b1c14d06cc150272b82dc1f0c287036b /module
parent7b8363d7f0ca85a2dde7473d6079147387f2f1fc (diff)
zfs_log_write: simplify data copying code for WR_COPIED records
lr_write_t records that are WR_COPIED have the record data directly appended to them (see lr_write_t type definition). The data is copied from the debuf using dmu_read_by_dnode. This function was called, only for WR_COPIED records, as part of a short-circuiting if-statement's if-expression. I found this side-effectful call to dmu_read_by_dnode pretty hard to spot. This patch improves readability by moving the call to its own line. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: George Wilson <[email protected]> Signed-off-by: Christian Schwarz <[email protected]> Closes #10956
Diffstat (limited to 'module')
-rw-r--r--module/zfs/zfs_log.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/module/zfs/zfs_log.c b/module/zfs/zfs_log.c
index 4eae855f4..fb44007fe 100644
--- a/module/zfs/zfs_log.c
+++ b/module/zfs/zfs_log.c
@@ -584,15 +584,22 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
(wr_state == WR_COPIED ? len : 0));
lr = (lr_write_t *)&itx->itx_lr;
- DB_DNODE_ENTER(db);
- if (wr_state == WR_COPIED && dmu_read_by_dnode(DB_DNODE(db),
- off, len, lr + 1, DMU_READ_NO_PREFETCH) != 0) {
- zil_itx_destroy(itx);
- itx = zil_itx_create(txtype, sizeof (*lr));
- lr = (lr_write_t *)&itx->itx_lr;
- wr_state = WR_NEED_COPY;
+ /*
+ * For WR_COPIED records, copy the data into the lr_write_t.
+ */
+ if (wr_state == WR_COPIED) {
+ int err;
+ DB_DNODE_ENTER(db);
+ err = dmu_read_by_dnode(DB_DNODE(db), off, len, lr + 1,
+ DMU_READ_NO_PREFETCH);
+ if (err != 0) {
+ zil_itx_destroy(itx);
+ itx = zil_itx_create(txtype, sizeof (*lr));
+ lr = (lr_write_t *)&itx->itx_lr;
+ wr_state = WR_NEED_COPY;
+ }
+ DB_DNODE_EXIT(db);
}
- DB_DNODE_EXIT(db);
itx->itx_wr_state = wr_state;
lr->lr_foid = zp->z_id;