aboutsummaryrefslogtreecommitdiff
path: root/sbin/camcontrol
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2023-06-19 20:43:05 +0000
committerWarner Losh <imp@FreeBSD.org>2023-06-19 20:45:43 +0000
commit97e24c3868682bcad5d37a5f1679a87b82acd255 (patch)
tree4e773f65cbd543505a861f3c8d083325a44bd769 /sbin/camcontrol
parentfc78fd9dae66b90da70cd6c62c4d95f8e6da03f1 (diff)
downloadsrc-97e24c3868682bcad5d37a5f1679a87b82acd255.tar.gz
src-97e24c3868682bcad5d37a5f1679a87b82acd255.zip
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
Diffstat (limited to 'sbin/camcontrol')
-rw-r--r--sbin/camcontrol/camcontrol.c31
1 files 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;