diff options
author | Martin Matuska <mm@FreeBSD.org> | 2021-06-30 06:02:44 +0000 |
---|---|---|
committer | Martin Matuska <mm@FreeBSD.org> | 2021-06-30 06:02:44 +0000 |
commit | 2617128a21bfb1b1e3065e54d46f9982d37c0bf8 (patch) | |
tree | e67e94bf42a5c3a93fde1a4c41fc62be35bce3a2 /sys/contrib/openzfs/module | |
parent | a00d703f2f438b199d3933d19d535540586b7792 (diff) | |
parent | 4694131a0a05b6db2727c9801f9729b9378d3064 (diff) | |
download | src-2617128a21bfb1b1e3065e54d46f9982d37c0bf8.tar.gz src-2617128a21bfb1b1e3065e54d46f9982d37c0bf8.zip |
zfs: merge openzfs/zfs@4694131a0 (master) into main
Notable upstream pull request merges:
#12253 module/zfs: simplify ddt_stat_add() loop
#12288 Avoid 64bit division in multilist index functions
Obtained from: OpenZFS
OpenZFS commit: 4694131a0a05b6db2727c9801f9729b9378d3064
Diffstat (limited to 'sys/contrib/openzfs/module')
-rw-r--r-- | sys/contrib/openzfs/module/zfs/arc.c | 5 | ||||
-rw-r--r-- | sys/contrib/openzfs/module/zfs/dbuf.c | 5 | ||||
-rw-r--r-- | sys/contrib/openzfs/module/zfs/ddt.c | 4 | ||||
-rw-r--r-- | sys/contrib/openzfs/module/zfs/dmu_objset.c | 10 | ||||
-rw-r--r-- | sys/contrib/openzfs/module/zfs/metaslab.c | 7 | ||||
-rw-r--r-- | sys/contrib/openzfs/module/zstd/zfs_zstd.c | 19 |
6 files changed, 42 insertions, 8 deletions
diff --git a/sys/contrib/openzfs/module/zfs/arc.c b/sys/contrib/openzfs/module/zfs/arc.c index 04d275dd80f4..3484fff3b4d4 100644 --- a/sys/contrib/openzfs/module/zfs/arc.c +++ b/sys/contrib/openzfs/module/zfs/arc.c @@ -7454,9 +7454,10 @@ arc_state_multilist_index_func(multilist_t *ml, void *obj) * Also, the low order bits of the hash value are thought to be * distributed evenly. Otherwise, in the case that the multilist * has a power of two number of sublists, each sublists' usage - * would not be evenly distributed. + * would not be evenly distributed. In this context full 64bit + * division would be a waste of time, so limit it to 32 bits. */ - return (buf_hash(hdr->b_spa, &hdr->b_dva, hdr->b_birth) % + return ((unsigned int)buf_hash(hdr->b_spa, &hdr->b_dva, hdr->b_birth) % multilist_get_num_sublists(ml)); } diff --git a/sys/contrib/openzfs/module/zfs/dbuf.c b/sys/contrib/openzfs/module/zfs/dbuf.c index f9bcd9313f0a..9ce091b80dcb 100644 --- a/sys/contrib/openzfs/module/zfs/dbuf.c +++ b/sys/contrib/openzfs/module/zfs/dbuf.c @@ -622,9 +622,10 @@ dbuf_cache_multilist_index_func(multilist_t *ml, void *obj) * Also, the low order bits of the hash value are thought to be * distributed evenly. Otherwise, in the case that the multilist * has a power of two number of sublists, each sublists' usage - * would not be evenly distributed. + * would not be evenly distributed. In this context full 64bit + * division would be a waste of time, so limit it to 32 bits. */ - return (dbuf_hash(db->db_objset, db->db.db_object, + return ((unsigned int)dbuf_hash(db->db_objset, db->db.db_object, db->db_level, db->db_blkid) % multilist_get_num_sublists(ml)); } diff --git a/sys/contrib/openzfs/module/zfs/ddt.c b/sys/contrib/openzfs/module/zfs/ddt.c index b94a9f54ece3..7b0b1d896761 100644 --- a/sys/contrib/openzfs/module/zfs/ddt.c +++ b/sys/contrib/openzfs/module/zfs/ddt.c @@ -423,8 +423,8 @@ ddt_stat_add(ddt_stat_t *dst, const ddt_stat_t *src, uint64_t neg) ASSERT(neg == 0 || neg == -1ULL); /* add or subtract */ - while (d < d_end) - *d++ += (*s++ ^ neg) - neg; + for (int i = 0; i < d_end - d; i++) + d[i] += (s[i] ^ neg) - neg; } static void diff --git a/sys/contrib/openzfs/module/zfs/dmu_objset.c b/sys/contrib/openzfs/module/zfs/dmu_objset.c index 22deee7f3dc9..af107fb8ad63 100644 --- a/sys/contrib/openzfs/module/zfs/dmu_objset.c +++ b/sys/contrib/openzfs/module/zfs/dmu_objset.c @@ -399,7 +399,15 @@ static unsigned int dnode_multilist_index_func(multilist_t *ml, void *obj) { dnode_t *dn = obj; - return (dnode_hash(dn->dn_objset, dn->dn_object) % + + /* + * The low order bits of the hash value are thought to be + * distributed evenly. Otherwise, in the case that the multilist + * has a power of two number of sublists, each sublists' usage + * would not be evenly distributed. In this context full 64bit + * division would be a waste of time, so limit it to 32 bits. + */ + return ((unsigned int)dnode_hash(dn->dn_objset, dn->dn_object) % multilist_get_num_sublists(ml)); } diff --git a/sys/contrib/openzfs/module/zfs/metaslab.c b/sys/contrib/openzfs/module/zfs/metaslab.c index 92f51806ace5..23f3e2989ae7 100644 --- a/sys/contrib/openzfs/module/zfs/metaslab.c +++ b/sys/contrib/openzfs/module/zfs/metaslab.c @@ -1874,7 +1874,12 @@ static unsigned int metaslab_idx_func(multilist_t *ml, void *arg) { metaslab_t *msp = arg; - return (msp->ms_id % multilist_get_num_sublists(ml)); + + /* + * ms_id values are allocated sequentially, so full 64bit + * division would be a waste of time, so limit it to 32 bits. + */ + return ((unsigned int)msp->ms_id % multilist_get_num_sublists(ml)); } uint64_t diff --git a/sys/contrib/openzfs/module/zstd/zfs_zstd.c b/sys/contrib/openzfs/module/zstd/zfs_zstd.c index 78616c08ba72..3f3983d8d868 100644 --- a/sys/contrib/openzfs/module/zstd/zfs_zstd.c +++ b/sys/contrib/openzfs/module/zstd/zfs_zstd.c @@ -202,6 +202,25 @@ static struct zstd_fallback_mem zstd_dctx_fallback; static struct zstd_pool *zstd_mempool_cctx; static struct zstd_pool *zstd_mempool_dctx; +/* + * The library zstd code expects these if ADDRESS_SANITIZER gets defined, + * and while ASAN does this, KASAN defines that and does not. So to avoid + * changing the external code, we do this. + */ +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define ADDRESS_SANITIZER 1 +#endif +#elif defined(__SANITIZE_ADDRESS__) +#define ADDRESS_SANITIZER 1 +#endif +#if defined(_KERNEL) && defined(ADDRESS_SANITIZER) +void __asan_unpoison_memory_region(void const volatile *addr, size_t size); +void __asan_poison_memory_region(void const volatile *addr, size_t size); +void __asan_unpoison_memory_region(void const volatile *addr, size_t size) {}; +void __asan_poison_memory_region(void const volatile *addr, size_t size) {}; +#endif + static void zstd_mempool_reap(struct zstd_pool *zstd_mempool) |