aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorTony Nguyen <[email protected]>2019-08-15 17:36:24 -0600
committerBrian Behlendorf <[email protected]>2019-08-15 17:36:24 -0600
commitc8bbf7c00b3e1d949f928fd3aace234e38906a12 (patch)
tree06e633ce6c954b75afdd99c2109b86bf3112f052 /module
parent0e37a0f4f3bc4feb62a966a7c0dd64544172395f (diff)
Improve write performance by using dmu_read_by_dnode()
In zfs_log_write(), we can use dmu_read_by_dnode() rather than dmu_read() thus avoiding unnecessary dnode_hold() calls. We get a 2-5% performance gain for large sequential_writes tests, >=128K writes to files with recordsize=8K. Testing done on Ubuntu 18.04 with 4.15 kernel, 8vCPUs and SSD storage on VMware ESX. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Closes #9156
Diffstat (limited to 'module')
-rw-r--r--module/zfs/zfs_log.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/module/zfs/zfs_log.c b/module/zfs/zfs_log.c
index 622ce08ac..41b663b65 100644
--- a/module/zfs/zfs_log.c
+++ b/module/zfs/zfs_log.c
@@ -42,6 +42,7 @@
#include <sys/mode.h>
#include <sys/acl.h>
#include <sys/dmu.h>
+#include <sys/dbuf.h>
#include <sys/spa.h>
#include <sys/zfs_fuid.h>
#include <sys/dsl_dataset.h>
@@ -510,6 +511,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
znode_t *zp, offset_t off, ssize_t resid, int ioflag,
zil_callback_t callback, void *callback_data)
{
+ 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;
uintptr_t fsync_cnt;
@@ -556,13 +558,16 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
itx = zil_itx_create(txtype, sizeof (*lr) +
(wr_state == WR_COPIED ? len : 0));
lr = (lr_write_t *)&itx->itx_lr;
- if (wr_state == WR_COPIED && dmu_read(ZTOZSB(zp)->z_os,
- zp->z_id, off, len, lr + 1, DMU_READ_NO_PREFETCH) != 0) {
+
+ 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;
}
+ DB_DNODE_EXIT(db);
itx->itx_wr_state = wr_state;
lr->lr_foid = zp->z_id;