Skip to content

Commit f3283e4

Browse files
committed
Pass flags to more DMU write/hold functions
Over the time many of DMU functions got flags argument to control prefetch, caching, etc. Few functions though left without it, even though closer look shown that many of them do not require prefetch due to their access pattern. This patch adds the flags argument to dmu_write(), dmu_buf_hold_array() and dmu_buf_hold_array_by_bonus(), passing DMU_READ_NO_PREFETCH where applicable. I am going to also pass DMU_UNCACHEDIO to some of them later. Signed-off-by: Alexander Motin <[email protected]>
1 parent 0455150 commit f3283e4

File tree

21 files changed

+67
-47
lines changed

21 files changed

+67
-47
lines changed

cmd/ztest.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,8 @@ ztest_replay_write(void *arg1, void *arg2, boolean_t byteswap)
23062306
}
23072307

23082308
if (abuf == NULL) {
2309-
dmu_write(os, lr->lr_foid, offset, length, data, tx);
2309+
dmu_write(os, lr->lr_foid, offset, length, data, tx,
2310+
DMU_READ_PREFETCH);
23102311
} else {
23112312
memcpy(abuf->b_data, data, length);
23122313
VERIFY0(dmu_assign_arcbuf_by_dbuf(db, offset, abuf, tx, 0));
@@ -5243,7 +5244,8 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
52435244
* We've verified all the old bufwads, and made new ones.
52445245
* Now write them out.
52455246
*/
5246-
dmu_write(os, packobj, packoff, packsize, packbuf, tx);
5247+
dmu_write(os, packobj, packoff, packsize, packbuf, tx,
5248+
DMU_READ_PREFETCH);
52475249

52485250
if (freeit) {
52495251
if (ztest_opts.zo_verbose >= 7) {
@@ -5258,7 +5260,8 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
52585260
" txg %"PRIx64"\n",
52595261
bigoff, bigsize, txg);
52605262
}
5261-
dmu_write(os, bigobj, bigoff, bigsize, bigbuf, tx);
5263+
dmu_write(os, bigobj, bigoff, bigsize, bigbuf, tx,
5264+
DMU_READ_PREFETCH);
52625265
}
52635266

52645267
dmu_tx_commit(tx);
@@ -5513,7 +5516,8 @@ ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id)
55135516
* We've verified all the old bufwads, and made new ones.
55145517
* Now write them out.
55155518
*/
5516-
dmu_write(os, packobj, packoff, packsize, packbuf, tx);
5519+
dmu_write(os, packobj, packoff, packsize, packbuf, tx,
5520+
DMU_READ_PREFETCH);
55175521
if (ztest_opts.zo_verbose >= 7) {
55185522
(void) printf("writing offset %"PRIx64" size %"PRIx64""
55195523
" txg %"PRIx64"\n",
@@ -6119,7 +6123,8 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id)
61196123
"future leak: got %"PRIu64", open txg is %"PRIu64"",
61206124
old_txg, txg);
61216125

6122-
dmu_write(os, od->od_object, 0, sizeof (uint64_t), &txg, tx);
6126+
dmu_write(os, od->od_object, 0, sizeof (uint64_t), &txg, tx,
6127+
DMU_READ_PREFETCH);
61236128

61246129
(void) mutex_enter(&zcl.zcl_callbacks_lock);
61256130

include/sys/dmu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ int dmu_buf_hold(objset_t *os, uint64_t object, uint64_t offset,
625625
const void *tag, dmu_buf_t **, dmu_flags_t flags);
626626
int dmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset,
627627
uint64_t length, int read, const void *tag, int *numbufsp,
628-
dmu_buf_t ***dbpp);
628+
dmu_buf_t ***dbpp, dmu_flags_t flags);
629629
int dmu_buf_hold_noread(objset_t *os, uint64_t object, uint64_t offset,
630630
const void *tag, dmu_buf_t **dbp);
631631
int dmu_buf_hold_by_dnode(dnode_t *dn, uint64_t offset,
@@ -668,7 +668,7 @@ uint64_t dmu_buf_user_refcount(dmu_buf_t *db);
668668
*/
669669
int dmu_buf_hold_array_by_bonus(dmu_buf_t *db, uint64_t offset,
670670
uint64_t length, boolean_t read, const void *tag,
671-
int *numbufsp, dmu_buf_t ***dbpp);
671+
int *numbufsp, dmu_buf_t ***dbpp, dmu_flags_t flags);
672672
void dmu_buf_rele_array(dmu_buf_t **, int numbufs, const void *tag);
673673

674674
typedef void dmu_buf_evict_func_t(void *user_ptr);
@@ -924,7 +924,7 @@ int dmu_read(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
924924
int dmu_read_by_dnode(dnode_t *dn, uint64_t offset, uint64_t size, void *buf,
925925
dmu_flags_t flags);
926926
void dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
927-
const void *buf, dmu_tx_t *tx);
927+
const void *buf, dmu_tx_t *tx, dmu_flags_t flags);
928928
int dmu_write_by_dnode(dnode_t *dn, uint64_t offset, uint64_t size,
929929
const void *buf, dmu_tx_t *tx, dmu_flags_t flags);
930930
void dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,

module/os/freebsd/zfs/dmu_os.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
7676
return (0);
7777

7878
err = dmu_buf_hold_array(os, object, offset, size,
79-
FALSE, FTAG, &numbufs, &dbp);
79+
FALSE, FTAG, &numbufs, &dbp, DMU_READ_PREFETCH);
8080
if (err)
8181
return (err);
8282

@@ -147,7 +147,8 @@ dmu_read_pages(objset_t *os, uint64_t object, vm_page_t *ma, int count,
147147
ASSERT3S(last_size, <=, PAGE_SIZE);
148148

149149
err = dmu_buf_hold_array(os, object, IDX_TO_OFF(ma[0]->pindex),
150-
IDX_TO_OFF(count - 1) + last_size, TRUE, FTAG, &numbufs, &dbp);
150+
IDX_TO_OFF(count - 1) + last_size, TRUE, FTAG, &numbufs, &dbp,
151+
DMU_READ_PREFETCH);
151152
if (err != 0)
152153
return (err);
153154

module/os/freebsd/zfs/zfs_acl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,8 @@ zfs_aclset_common(znode_t *zp, zfs_acl_t *aclp, cred_t *cr, dmu_tx_t *tx)
12621262
if (aclnode->z_ace_count == 0)
12631263
continue;
12641264
dmu_write(zfsvfs->z_os, aoid, off,
1265-
aclnode->z_size, aclnode->z_acldata, tx);
1265+
aclnode->z_size, aclnode->z_acldata, tx,
1266+
DMU_READ_NO_PREFETCH);
12661267
off += aclnode->z_size;
12671268
}
12681269
} else {

module/os/freebsd/zfs/zfs_vnops_os.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4481,7 +4481,8 @@ zfs_putpages(struct vnode *vp, vm_page_t *ma, size_t len, int flags,
44814481
for (i = 0; wlen > 0; woff += tocopy, wlen -= tocopy, i++) {
44824482
tocopy = MIN(PAGE_SIZE, wlen);
44834483
va = zfs_map_page(ma[i], &sf);
4484-
dmu_write(zfsvfs->z_os, zp->z_id, woff, tocopy, va, tx);
4484+
dmu_write(zfsvfs->z_os, zp->z_id, woff, tocopy, va, tx,
4485+
DMU_READ_PREFETCH);
44854486
zfs_unmap_page(sf);
44864487
}
44874488
} else {

module/os/linux/zfs/zfs_acl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,8 @@ zfs_aclset_common(znode_t *zp, zfs_acl_t *aclp, cred_t *cr, dmu_tx_t *tx)
14471447
if (aclnode->z_ace_count == 0)
14481448
continue;
14491449
dmu_write(zfsvfs->z_os, aoid, off,
1450-
aclnode->z_size, aclnode->z_acldata, tx);
1450+
aclnode->z_size, aclnode->z_acldata, tx,
1451+
DMU_READ_NO_PREFETCH);
14511452
off += aclnode->z_size;
14521453
}
14531454
} else {

module/os/linux/zfs/zfs_vnops_os.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3892,7 +3892,8 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc,
38923892

38933893
va = kmap(pp);
38943894
ASSERT3U(pglen, <=, PAGE_SIZE);
3895-
dmu_write(zfsvfs->z_os, zp->z_id, pgoff, pglen, va, tx);
3895+
dmu_write(zfsvfs->z_os, zp->z_id, pgoff, pglen, va, tx,
3896+
DMU_READ_PREFETCH);
38963897
kunmap(pp);
38973898

38983899
SA_ADD_BULK_ATTR(bulk, cnt, SA_ZPL_MTIME(zfsvfs), NULL, &mtime, 16);

module/zfs/bpobj.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,8 @@ bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx)
752752
}
753753
dmu_write(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
754754
bpo->bpo_phys->bpo_num_subobjs * sizeof (subobj),
755-
numsubsub * sizeof (subobj), subdb->db_data, tx);
755+
numsubsub * sizeof (subobj), subdb->db_data, tx,
756+
DMU_READ_NO_PREFETCH);
756757
dmu_buf_rele(subdb, FTAG);
757758
bpo->bpo_phys->bpo_num_subobjs += numsubsub;
758759

@@ -777,7 +778,7 @@ bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx)
777778
dmu_write(bpo->bpo_os, bpo->bpo_object,
778779
bpo->bpo_phys->bpo_num_blkptrs * sizeof (blkptr_t),
779780
numbps * sizeof (blkptr_t),
780-
bps->db_data, tx);
781+
bps->db_data, tx, DMU_READ_NO_PREFETCH);
781782
dmu_buf_rele(bps, FTAG);
782783
bpo->bpo_phys->bpo_num_blkptrs += numbps;
783784

@@ -794,7 +795,7 @@ bpobj_enqueue_subobj(bpobj_t *bpo, uint64_t subobj, dmu_tx_t *tx)
794795

795796
dmu_write(bpo->bpo_os, bpo->bpo_phys->bpo_subobjs,
796797
bpo->bpo_phys->bpo_num_subobjs * sizeof (subobj),
797-
sizeof (subobj), &subobj, tx);
798+
sizeof (subobj), &subobj, tx, DMU_READ_NO_PREFETCH);
798799
bpo->bpo_phys->bpo_num_subobjs++;
799800
}
800801

module/zfs/bptree.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg,
137137
bte = kmem_zalloc(sizeof (*bte), KM_SLEEP);
138138
bte->be_birth_txg = birth_txg;
139139
bte->be_bp = *bp;
140-
dmu_write(os, obj, bt->bt_end * sizeof (*bte), sizeof (*bte), bte, tx);
140+
dmu_write(os, obj, bt->bt_end * sizeof (*bte), sizeof (*bte), bte, tx,
141+
DMU_READ_NO_PREFETCH);
141142
kmem_free(bte, sizeof (*bte));
142143

143144
dmu_buf_will_dirty(db, tx);
@@ -247,7 +248,7 @@ bptree_iterate(objset_t *os, uint64_t obj, boolean_t free, bptree_itor_t func,
247248
ZB_DESTROYED_OBJSET);
248249
ASSERT0(bte.be_zb.zb_level);
249250
dmu_write(os, obj, i * sizeof (bte),
250-
sizeof (bte), &bte, tx);
251+
sizeof (bte), &bte, tx, DMU_READ_NO_PREFETCH);
251252
if (err == EIO || err == ECKSUM ||
252253
err == ENXIO) {
253254
/*
@@ -269,7 +270,7 @@ bptree_iterate(objset_t *os, uint64_t obj, boolean_t free, bptree_itor_t func,
269270
*/
270271
bte.be_birth_txg = UINT64_MAX;
271272
dmu_write(os, obj, i * sizeof (bte),
272-
sizeof (bte), &bte, tx);
273+
sizeof (bte), &bte, tx, DMU_READ_NO_PREFETCH);
273274
}
274275

275276
if (!ioerr) {

module/zfs/brt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ brt_vdev_sync(spa_t *spa, brt_vdev_t *brtvd, dmu_tx_t *tx)
809809
*/
810810
dmu_write(spa->spa_meta_objset, brtvd->bv_mos_brtvdev, 0,
811811
brtvd->bv_size * sizeof (brtvd->bv_entcount[0]),
812-
brtvd->bv_entcount, tx);
812+
brtvd->bv_entcount, tx, DMU_READ_NO_PREFETCH);
813813
uint64_t nblocks = BRT_RANGESIZE_TO_NBLOCKS(brtvd->bv_size);
814814
memset(brtvd->bv_bitmap, 0, BT_SIZEOFMAP(nblocks));
815815
brtvd->bv_entcount_dirty = FALSE;

0 commit comments

Comments
 (0)