From nobody Fri Feb 11 00:48:12 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7A1E319CF4B8; Fri, 11 Feb 2022 00:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jvw2h2ynFz51MF; Fri, 11 Feb 2022 00:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644540492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=v9FrdoYsNNoaXevOIJnqzYSZYOoJxwBVL19m26/DRSw=; b=u3G+8xGWoXl5KLGrxHKotebH0ZRO+kTpkEhL8JpU3tQYHMA1TqhRuWcf7iO37E2jiwHDw9 TSD5adsbnO+epJQS3xKHJ0cRVUS38vO3+TkPUh34i+YvZQ5C4+3jdQPPDa8cCdhRTDe1Ij 0cJfekLNlaPCYRsFP/fUZRm804avzIKqmsZ3SOdG0WmxWUXooqusg9pyRU7C1pkMFvqLZq f2yneaHnvlsMvThFwCPE0KYEXbmo3uRHmGmV/Iu3gDBMpgT8qfzyxObs9szxDxI+eWjjT5 lDoBAPsAixBT0eB78jGOus00dgz5n5vMhTJRELkFETJDjjvgAt/xwSaiBiUg8Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3B062244C; Fri, 11 Feb 2022 00:48:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21B0mC39038441; Fri, 11 Feb 2022 00:48:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21B0mCbV038440; Fri, 11 Feb 2022 00:48:12 GMT (envelope-from git) Date: Fri, 11 Feb 2022 00:48:12 GMT Message-Id: <202202110048.21B0mCbV038440@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: d0f858fa2861 - stable/12 - CTL: Fix mode page trucation on HA synchronization. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: d0f858fa28615798dc44aafabb6f5f5673fbd869 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644540492; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=v9FrdoYsNNoaXevOIJnqzYSZYOoJxwBVL19m26/DRSw=; b=pd6BuQXjv862UzQ19yP2vcPQSxeq3Twdnzp58Yt04kymB/6PdF6423WEjn0RqtvPsuhRqq mlnSnIOZm16ZCot4Q8E85Y91MviBBDNVl456sOoPFzzhgAHcYKhum7MYSnTCkqxLeo5Dvh NQalrXz746rP9qb3vgwNREUp1Hpf32hqJTSUoBR5u3qyuOm0sWOQIwK77+/P0u7vRRNHnv 9+cYmXYKU4LBTQqc8I8fmBe5+879JdRUlnv5F+754/d7ibCcxZEeTBOBv7CxC7ap/0sXsS 7qeKkbpWDamonmA+bvoq2vv/t1u7ZfhCbSU3EA5fFzoaba0rEZMQzOfLqQx5zQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644540492; a=rsa-sha256; cv=none; b=Fwxpr/kcB4RsYfWQkNR0s1if3KA4fmvEPvMTA8tKXEXIhry3ifxXeFIiuI5Bmu1l1cR+zd 1MB8vqmcXdix2r4IFVdYEeG13OIjO6DW2yVW2xw6wHpt5ZKnCgcKf0hhvSWqwAOzdFMo/t 1ehM9k1lfkY1XIERybMxXOidLs4rGrn+gzcq8lqWkM9dg/eYYlQ6eZ55GVfmugKk+rnr+A MALRo242Olhj+wYwMKGZwm/IwGK7wJLr+w8AcAPQcc4JkJ9fMvF4dZyEZm3S+xqk2FvMtT S8k3i+DpWca9ZzlEHkXVrUzhtIL/cSmy622b5L7I9HSEKwREo22MzjFIr8Jl4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=d0f858fa28615798dc44aafabb6f5f5673fbd869 commit d0f858fa28615798dc44aafabb6f5f5673fbd869 Author: Alexander Motin AuthorDate: 2022-02-03 15:48:19 +0000 Commit: Alexander Motin CommitDate: 2022-02-11 00:48:06 +0000 CTL: Fix mode page trucation on HA synchronization. Due to variable size of struct ctl_ha_msg_mode ctl_isc_announce_mode() sent only first 4 bytes of modified mode page to the other HA side, that caused its corruption there, noticeable only after failover. I've found alike bug also in ctl_isc_announce_lun(), but there it was sending slightly more than needed, that is a smaller problem. MFC after: 1 week Sponsored by: iXsystems, Inc. (cherry picked from commit 1a8d8a3a909f906ed69cca080a6446e7295bcbbb) --- sys/cam/ctl/ctl.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 020724d033e0..8439b837a01e 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -879,7 +879,7 @@ alloc: i += sizeof(pr_key); } mtx_unlock(&lun->lun_lock); - ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg->port, sizeof(msg->port) + i, + ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg->lun, sizeof(msg->lun) + i, M_WAITOK); free(msg, M_CTL); @@ -994,8 +994,8 @@ ctl_isc_announce_mode(struct ctl_lun *lun, uint32_t initidx, uint8_t page, uint8_t subpage) { struct ctl_softc *softc = lun->ctl_softc; - union ctl_ha_msg msg; - u_int i; + union ctl_ha_msg *msg; + u_int i, l; if (softc->ha_link != CTL_HA_LINK_ONLINE) return; @@ -1011,19 +1011,20 @@ ctl_isc_announce_mode(struct ctl_lun *lun, uint32_t initidx, if (lun->mode_pages.index[i].page_data == NULL) return; - bzero(&msg.mode, sizeof(msg.mode)); - msg.hdr.msg_type = CTL_MSG_MODE_SYNC; - msg.hdr.nexus.targ_port = initidx / CTL_MAX_INIT_PER_PORT; - msg.hdr.nexus.initid = initidx % CTL_MAX_INIT_PER_PORT; - msg.hdr.nexus.targ_lun = lun->lun; - msg.hdr.nexus.targ_mapped_lun = lun->lun; - msg.mode.page_code = page; - msg.mode.subpage = subpage; - msg.mode.page_len = lun->mode_pages.index[i].page_len; - memcpy(msg.mode.data, lun->mode_pages.index[i].page_data, - msg.mode.page_len); - ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg.mode, sizeof(msg.mode), - M_WAITOK); + l = sizeof(msg->mode) + lun->mode_pages.index[i].page_len; + msg = malloc(l, M_CTL, M_WAITOK | M_ZERO); + msg->hdr.msg_type = CTL_MSG_MODE_SYNC; + msg->hdr.nexus.targ_port = initidx / CTL_MAX_INIT_PER_PORT; + msg->hdr.nexus.initid = initidx % CTL_MAX_INIT_PER_PORT; + msg->hdr.nexus.targ_lun = lun->lun; + msg->hdr.nexus.targ_mapped_lun = lun->lun; + msg->mode.page_code = page; + msg->mode.subpage = subpage; + msg->mode.page_len = lun->mode_pages.index[i].page_len; + memcpy(msg->mode.data, lun->mode_pages.index[i].page_data, + msg->mode.page_len); + ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg->mode, l, M_WAITOK); + free(msg, M_CTL); } static void