From nobody Fri Feb 11 00:47:32 2022 X-Original-To: dev-commits-src-branches@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 5017E19CF239; Fri, 11 Feb 2022 00:47:33 +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 4Jvw1x1bKZz51Kq; Fri, 11 Feb 2022 00:47:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644540453; 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=zN5Cq7cRA69SgeYFGamRT9dQnSNGEsPuKbp4WuqPlmk=; b=LOBWKrRw0IVIBlLQOP9Cl47PchBTf3gXV8qBquh1VVVtNZNRyr8IFbmgVc84hbiV58VkhX 211pvSw3SuTxQRzjzqdqVpMGcqVvPYW5Y1gtQWsNl7Wx0LdUThYBpd1KJJbems9uINe/+e fZQWoxIVYVHzbtMCzQhHu7AvBFrlv2UE8Vhcd9Fi8yo0jQrFiU+0zdDfsVkm4T7YCpGmfQ RMK8EKTbQA8FOOEwzY5atTTiITIfzH6ebD5ZxhHqEb+rBQOHjzZ34iAo4GzCcqdDrrLhs5 llhg2UVUjNlpwpCaFAINj8HQhIKmbALkMhD2Ibh2e/kHwR8Z/w0SgFTvTcptpw== 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 179122572; Fri, 11 Feb 2022 00:47:33 +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 21B0lWl6038279; Fri, 11 Feb 2022 00:47:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21B0lWVm038278; Fri, 11 Feb 2022 00:47:32 GMT (envelope-from git) Date: Fri, 11 Feb 2022 00:47:32 GMT Message-Id: <202202110047.21B0lWVm038278@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: ca6728183a0c - stable/13 - CTL: Fix mode page trucation on HA synchronization. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/13 X-Git-Reftype: branch X-Git-Commit: ca6728183a0c948c17a37779020f4d3e30627eb8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644540453; 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=zN5Cq7cRA69SgeYFGamRT9dQnSNGEsPuKbp4WuqPlmk=; b=dLSM/UOXjFvAndk2ooz1rtOOs7v6HXCy2v79KjZrXLOLpOMP2o0uI3C2uOG63WKxo9O6i+ 0Wv1GcqbexM7nRjdLz2dCx1ZGhf8Bk0D9XQpj/avk9pzkVaaADpREbV02otMFclSzbAfsQ 5xS2IYKX+IXPS+hdiTxI0MxWo1iqACr7yTeRY+dNNx/X7fggQHgtTvCuGVkGStNETTKqw5 mmDLuVIdoV3WyYhPEM+Fmpk2cx06j7a6WbMgqI1X82dcBFlDDyMblyPdt2igq47GERP9uJ r6HjocXH0i4T2aWUGrDYDREsoOLg/SctLboDHYn/OsyaXSYaj38bn9fAWcDWBA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644540453; a=rsa-sha256; cv=none; b=WV/xDBhNsJoa/y3sFNnqukFoakw374b2D8I/s2g0GluM6fPwtnAnFXmMsY7kb8sCQ82Pvn JAJncOoUOJPDu3n+AWMnF+CdACgvxQexPSjOugoRUMZIen65fGEMATUdbkobWt2xq8xoGn +m0PyoWEx4zv3AgDIy18tNwMWKDcI8cItuiqFkzJr75xVqfunec7l8jyVx2BK+BI6gd6Kv k3q+Vrf9XJ8YiD+O2rzmyNxHLhKlR02DYrhgUoW2BFjFWcydbV9HumHyiIx7+d5j9aWWuC ErR719KGKoGUQocYsrra2ysQCeHLfkfbXEjHHijwG+poYl/SrhcPlOyp0xktPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=ca6728183a0c948c17a37779020f4d3e30627eb8 commit ca6728183a0c948c17a37779020f4d3e30627eb8 Author: Alexander Motin AuthorDate: 2022-02-03 15:48:19 +0000 Commit: Alexander Motin CommitDate: 2022-02-11 00:47:23 +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 bc7f386bc091..c89c9a7863fe 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