From edd23dba81fe3a54e92389f8533fb4dd8d8a241f Mon Sep 17 00:00:00 2001 From: "Adam D. Moss" Date: Fri, 25 Sep 2020 13:49:22 -0700 Subject: [PATCH] Add DB_RF_NOPREFETCH to dbuf_read()s in dnode.c Prefetching of dnodes in dbuf_read() can cause significant mutex contention for some workloads and isn't very helpful. This is because we already get 32 dnodes for each block read, and when iterating over a directory we prefetch the dnodes in the directory. Disable this prefetching to prevent the lock contention. Reviewed-by: Brian Behlendorf Submitted-by: Adam Moss Submitted-by: Matthew Ahrens Signed-off-by: Adam Moss Closes #10877 Closes #10953 --- module/zfs/dnode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module/zfs/dnode.c b/module/zfs/dnode.c index 30d20bfefa..23364dbae8 100644 --- a/module/zfs/dnode.c +++ b/module/zfs/dnode.c @@ -1355,7 +1355,8 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag, int slots, * We do not need to decrypt to read the dnode so it doesn't matter * if we get the encrypted or decrypted version. */ - err = dbuf_read(db, NULL, DB_RF_CANFAIL | DB_RF_NO_DECRYPT); + err = dbuf_read(db, NULL, DB_RF_CANFAIL | + DB_RF_NO_DECRYPT | DB_RF_NOPREFETCH); if (err) { DNODE_STAT_BUMP(dnode_hold_dbuf_read); dbuf_rele(db, FTAG); @@ -2396,7 +2397,8 @@ dnode_next_offset_level(dnode_t *dn, int flags, uint64_t *offset, return (SET_ERROR(ESRCH)); } error = dbuf_read(db, NULL, - DB_RF_CANFAIL | DB_RF_HAVESTRUCT | DB_RF_NO_DECRYPT); + DB_RF_CANFAIL | DB_RF_HAVESTRUCT | + DB_RF_NO_DECRYPT | DB_RF_NOPREFETCH); if (error) { dbuf_rele(db, FTAG); return (error);