From da6c288dfc9c275ff52c7764d8e0ae69c02afa87 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 25 Jun 2021 19:38:31 -0400 Subject: [PATCH 1/7] Help compiller optimize out abd_verify() While abd_verify() does nothing when built without debug, compiler can't optimize it out by itself due to calls to external list_*() and abd_verify_scatter(). This commit makes it explicit. Reviewed-by: Brian Behlendorf Reviewed-by: Adam Moss Reviewed-by: George Melikov Signed-off-by: Alexander Motin Sponsored-By: iXsystems, Inc. Closes #12280 --- module/zfs/abd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/zfs/abd.c b/module/zfs/abd.c index 2d1be9752d4..d5fafccd08a 100644 --- a/module/zfs/abd.c +++ b/module/zfs/abd.c @@ -108,15 +108,14 @@ int zfs_abd_scatter_enabled = B_TRUE; void abd_verify(abd_t *abd) { +#ifdef ZFS_DEBUG ASSERT3U(abd->abd_size, >, 0); ASSERT3U(abd->abd_size, <=, SPA_MAXBLOCKSIZE); ASSERT3U(abd->abd_flags, ==, abd->abd_flags & (ABD_FLAG_LINEAR | ABD_FLAG_OWNER | ABD_FLAG_META | ABD_FLAG_MULTI_ZONE | ABD_FLAG_MULTI_CHUNK | ABD_FLAG_LINEAR_PAGE | ABD_FLAG_GANG | ABD_FLAG_GANG_FREE | ABD_FLAG_ZEROS | ABD_FLAG_ALLOCD)); -#ifdef ZFS_DEBUG IMPLY(abd->abd_parent != NULL, !(abd->abd_flags & ABD_FLAG_OWNER)); -#endif IMPLY(abd->abd_flags & ABD_FLAG_META, abd->abd_flags & ABD_FLAG_OWNER); if (abd_is_linear(abd)) { ASSERT3P(ABD_LINEAR_BUF(abd), !=, NULL); @@ -133,6 +132,7 @@ abd_verify(abd_t *abd) } else { abd_verify_scatter(abd); } +#endif } static void From 57ce66d293de75e44b4d569a7256c7099a4bbdf8 Mon Sep 17 00:00:00 2001 From: Rich Ercolani <214141+rincebrain@users.noreply.github.com> Date: Sat, 26 Jun 2021 01:28:12 -0400 Subject: [PATCH 2/7] Fix build with KASAN The stock zstd code expects some helpers from ASAN if present. This works fine in userland, but in kernel, KASAN also gets detected, and lacks those helpers. So let's make some empty substitutes for that case. Reviewed-by: Brian Behlendorf Signed-off-by: Rich Ercolani Closes #12232 --- module/zstd/zfs_zstd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/module/zstd/zfs_zstd.c b/module/zstd/zfs_zstd.c index fc1b0359aa6..a91ed1be9ef 100644 --- a/module/zstd/zfs_zstd.c +++ b/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) From 4ebda5d4d32dd641ded589f336de4ac4964b92fb Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Sat, 26 Jun 2021 07:43:25 +0200 Subject: [PATCH 3/7] Fix plymouth passphrase prompt with dracut plymouth --command splits the command on spaces which means that zfs-load-key was getting the filesystem name enclosed in single quotes (since 13c59bb76) and failing. This commit fixes it by piping the password directly to the command similar to how it's done in other scripts (initramfs, dracut without plymouth). Reviewed-by: Brian Behlendorf Signed-off-by: Michal Vasilek Related-to: #9193 Related-to: #9202 Closes #12147 --- contrib/dracut/90zfs/zfs-lib.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/dracut/90zfs/zfs-lib.sh.in b/contrib/dracut/90zfs/zfs-lib.sh.in index 10b0b701a23..defc0bfc8e7 100755 --- a/contrib/dracut/90zfs/zfs-lib.sh.in +++ b/contrib/dracut/90zfs/zfs-lib.sh.in @@ -179,8 +179,8 @@ ask_for_password() { # Prompt for password with plymouth, if installed and running. if plymouth --ping 2>/dev/null; then plymouth ask-for-password \ - --prompt "$ply_prompt" --number-of-tries="$ply_tries" \ - --command="$ply_cmd" + --prompt "$ply_prompt" --number-of-tries="$ply_tries" | \ + eval "$ply_cmd" ret=$? else if [ "$tty_echo_off" = yes ]; then From ea478570908b57f9c141c0082cb6b6815938ea17 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 29 Jun 2021 08:59:14 -0400 Subject: [PATCH 4/7] Avoid 64bit division in multilist index functions The number of sublists in a multilist is relatively small. We dont need 64 bits to calculate an index. 32 bits is sufficient and makes the code more efficient. Reviewed-by: Matthew Ahrens Reviewed-by: Brian Behlendorf Reviewed-by: Mark Maybee Signed-off-by: Alexander Motin Sponsored-By: iXsystems, Inc. Closes #12288 --- module/zfs/arc.c | 5 +++-- module/zfs/dbuf.c | 5 +++-- module/zfs/dmu_objset.c | 10 +++++++++- module/zfs/metaslab.c | 7 ++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 7d892f4c7b9..2226539a1e2 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -7459,9 +7459,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/module/zfs/dbuf.c b/module/zfs/dbuf.c index 8e55a613bbf..45886e5739a 100644 --- a/module/zfs/dbuf.c +++ b/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/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index 22deee7f3dc..af107fb8ad6 100644 --- a/module/zfs/dmu_objset.c +++ b/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/module/zfs/metaslab.c b/module/zfs/metaslab.c index 0ddad5b026d..08d7a563542 100644 --- a/module/zfs/metaslab.c +++ b/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 From 0584ad8f94f7df31a1b5b35f27cd8747935317b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 29 Jun 2021 22:33:49 +0300 Subject: [PATCH 5/7] zed: fix sending emails (#12292) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 6fc3099 broke the quoting when invoking the mail program, revert that change. Signed-off-by: Laurențiu Nicola Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter --- cmd/zed/zed.d/zed-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zed/zed.d/zed-functions.sh b/cmd/zed/zed.d/zed-functions.sh index 7dcd6b2d20b..d1ebf7dbcc1 100644 --- a/cmd/zed/zed.d/zed-functions.sh +++ b/cmd/zed/zed.d/zed-functions.sh @@ -263,7 +263,7 @@ zed_notify_email() -e "s/@SUBJECT@/${subject}/g")" # shellcheck disable=SC2086 - ${ZED_EMAIL_PROG} ${ZED_EMAIL_OPTS} < "${pathname}" >/dev/null 2>&1 + eval ${ZED_EMAIL_PROG} ${ZED_EMAIL_OPTS} < "${pathname}" >/dev/null 2>&1 rv=$? if [ "${rv}" -ne 0 ]; then zed_log_err "$(basename "${ZED_EMAIL_PROG}") exit=${rv}" From d3942963eeda0e11bedf04c0a4bc17c2d426aa4e Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 29 Jun 2021 13:16:38 -0700 Subject: [PATCH 6/7] Linux 5.13 compat: META Increase the Linux-Maximum version in the META file to 5.13. All of the required compatibility patches have been merged and the 5.13 kernel has been officially released. Signed-off-by: Brian Behlendorf --- META | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META b/META index 5698d641ca6..ecebf855f9f 100644 --- a/META +++ b/META @@ -6,5 +6,5 @@ Release: rc7 Release-Tags: relext License: CDDL Author: OpenZFS -Linux-Maximum: 5.12 +Linux-Maximum: 5.13 Linux-Minimum: 3.10 From 508fff0e4b0653744fd6ae7857cc860e4d0d80af Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 24 Jun 2021 14:43:02 -0700 Subject: [PATCH 7/7] Tag 2.1.0-rc8 Signed-off-by: Brian Behlendorf --- META | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META b/META index ecebf855f9f..74342ed5ed9 100644 --- a/META +++ b/META @@ -2,7 +2,7 @@ Meta: 1 Name: zfs Branch: 1.0 Version: 2.1.0 -Release: rc7 +Release: rc8 Release-Tags: relext License: CDDL Author: OpenZFS