From nobody Mon Jun 19 20:47:06 2023 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 4QlMJV3Y3vz4fk0x; Mon, 19 Jun 2023 20:47:06 +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 4QlMJV2TYGz4RDq; Mon, 19 Jun 2023 20:47:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687207626; 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=BonaccLMMZG2rhjMo/HO3UJPiMdt93mTVZrPBpW3hmE=; b=Ats0rWEBojPZz3hDX6/jqb6QHVMK9W5Sq5wEWUnHlAYIPDJroHrYJXPrgdZxLJXeLp++NR KNsYJimiSiEf1RPhsTNdR7WcAseLPwpVc/yFyMeFszcdaB6vLnFzKQ+O7+Jq8pWXmF5tU2 qG/u0e+1lcN+249BIDBMoSFxJKD5qmIqRHm1r/dzwG+BjmSWuRhvev/QV4olEKBkb3BD48 RgsTmE//9bFfNc99lPZXeLoHoEmYMPbwdBBQ5m2YfPIqYeXkknwyIAY31gsR3LQsvrXLJ+ J+9+RouJUwF7hBkqMS8inABlgE3t49yHgmOWVlaJHJRRdmBkhtM4OBSk8csQqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687207626; 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=BonaccLMMZG2rhjMo/HO3UJPiMdt93mTVZrPBpW3hmE=; b=CsK6uCJYor7ZOytXzQu9OPDdErYQxUjxdDeIpeClBhlbxQ5rMXuuwxzC72Vb0maM7ttLw2 fpPuPWRBKbTe9ArDoV1q3DxrixfyB371gqzWTQHcqUX29W/+//nJdqOCyf1acxWfgZgEhJ +tAKvWrXLK7uBQya1lgwDRRMDshJ0XtuDfX6087Uzucixyeb7F0BRIyGeiaesLst2fNKcZ ub0iqWAQm0G4zvgWLFaliAOAMgIeuWLhHv6t807t9y2TYOJLi222Ai2tEs3IyOf4N3GmRx Y60XFunUVojOvJSeDJj+Hfiyl6izVpfR+iDAVdBUO9p4ais5Dfd7EVgGgKbgeg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687207626; a=rsa-sha256; cv=none; b=W4+M4y0yageEiNp6+ofPpmacZUVpwzPbQEMJQiop1exZQR+Q3cNUBanVe9qhJN8i16j3NY Ro9YfqC67kjgZeTG0+4cVAsuB2etiNpQbj3DRv7NG9oQnJCfGTRm42f4+RlDD41ChkkoL9 OjQ/Y3tnx5Tqb7elQxW3NpmttAXJvU0W5oC8AMe28jeayc2xzj/A5vlPk1JgDO1C1S9EFJ 0MRyx0k1oVhfmar60A5P6xAJiletsRE8DNc5r9hbWAYT2vVqn0nbGYsACQZCEzNeE0UlGW KKXweYzs6Vj8cWRxzCNV840qt8TMOcSx+a1IaEJRuacx6hkk6tPvEuiqtrYSRA== 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 4QlMJV1R7szXKm; Mon, 19 Jun 2023 20:47:06 +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 35JKl6Fx095718; Mon, 19 Jun 2023 20:47:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35JKl66p095717; Mon, 19 Jun 2023 20:47:06 GMT (envelope-from git) Date: Mon, 19 Jun 2023 20:47:06 GMT Message-Id: <202306192047.35JKl66p095717@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 97e24c386868 - main - camcontrol: Simplfiy 12-byte retry logic in defects command 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 97e24c3868682bcad5d37a5f1679a87b82acd255 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=97e24c3868682bcad5d37a5f1679a87b82acd255 commit 97e24c3868682bcad5d37a5f1679a87b82acd255 Author: Warner Losh AuthorDate: 2023-06-19 20:43:05 +0000 Commit: Warner Losh CommitDate: 2023-06-19 20:45:43 +0000 camcontrol: Simplfiy 12-byte retry logic in defects command We always start out using the 10-byte version of READ DEFECT DATA, and then switch to 12-byte when necessary due to errors or data length requirements. We always need to get the length again when we do this, and we're always going to be using 12-byte commands from that point forward. Simplify the logic a bit based on this observation. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D40522 --- sbin/camcontrol/camcontrol.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c index 0a1245e9cc48..c059d64652c5 100644 --- a/sbin/camcontrol/camcontrol.c +++ b/sbin/camcontrol/camcontrol.c @@ -3923,18 +3923,23 @@ readdefects(struct cam_device *device, int argc, char **argv, ccb = cam_getccb(device); -retry_12byte: - /* - * We start off asking for just the header to determine how much - * defect data is available. Some Hitachi drives return an error - * if you ask for more data than the drive has. Once we know the - * length, we retry the command with the returned length. + * We start off asking for just the header to determine how much defect + * data is available. Some Hitachi drives return an error if you ask + * for more data than the drive has. Once we know the length, we retry + * the command with the returned length. When we're retrying the with + * 12-byte command, we're always changing to the 12-byte command and + * need to get the length. Simplify the logic below by always setting + * use_12byte in this case with this slightly more complex logic here. */ - if (!use_12byte) + if (!use_12byte) { dlist_length = sizeof(*hdr10); - else + } else { +retry_12byte: + get_length = true; + use_12byte = true; dlist_length = sizeof(*hdr12); + } retry: if (defect_list != NULL) { @@ -4058,8 +4063,6 @@ next_batch: && (returned_length > 0)) { if (!use_12byte && (returned_length >= max_possible_size)) { - get_length = true; - use_12byte = true; goto retry_12byte; } dlist_length = returned_length + hdr_size; @@ -4075,8 +4078,6 @@ next_batch: * byte command. */ if (!use_12byte) { - get_length = true; - use_12byte = true; goto retry_12byte; } dlist_length = returned_length + hdr_size; @@ -4091,8 +4092,6 @@ next_batch: * byte command. */ if (!use_12byte) { - get_length = true; - use_12byte = true; goto retry_12byte; } dlist_length = returned_length + hdr_size; @@ -4108,8 +4107,6 @@ next_batch: if (!use_12byte && (returned_length >= max_possible_size)) { - get_length = true; - use_12byte = true; goto retry_12byte; } dlist_length = returned_length + @@ -4127,8 +4124,6 @@ next_batch: } else { if (!use_12byte && (returned_length >= max_possible_size)) { - get_length = true; - use_12byte = true; goto retry_12byte; } dlist_length = returned_length + hdr_size;