ctl: Avoid an upcast for calling ctl_scsi_path_string

Change the first argument of ctl_scsi_path_string to be the embedded
header structure instead of the union.  Currently union ctl_io and
struct ctl_scsiio have the same alignment, but this changes on i386 if
a new union member is added that contains a uint64_t member (such as
an embedded struct nvme_command for NVMeoF).  In that case, union
ctl_io requires stronger alignment, so the upcast from struct
ctl_scsiio to union ctl_io in ctl_scsi_sense_sbuf raises an increasing
alignment warning on i386.

Avoid the warning by passing struct ctl_io_hdr as the first argument
to ctl_scsi_path_string instead.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44716
This commit is contained in:
John Baldwin 2024-05-02 16:30:20 -07:00
parent 1058c12197
commit 352cf4a64a
5 changed files with 12 additions and 12 deletions

View file

@ -12837,7 +12837,7 @@ ctl_process_done(union ctl_io *io)
char path_str[64];
struct sbuf sb;
ctl_scsi_path_string(io, path_str, sizeof(path_str));
ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str));
sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN);
ctl_io_sbuf(io, &sb);

View file

@ -109,12 +109,12 @@ ctl_scsi_command_string(struct ctl_scsiio *ctsio,
}
void
ctl_scsi_path_string(union ctl_io *io, char *path_str, int len)
ctl_scsi_path_string(struct ctl_io_hdr *hdr, char *path_str, int len)
{
snprintf(path_str, len, "(%u:%u:%u/%u): ",
io->io_hdr.nexus.initid, io->io_hdr.nexus.targ_port,
io->io_hdr.nexus.targ_lun, io->io_hdr.nexus.targ_mapped_lun);
hdr->nexus.initid, hdr->nexus.targ_port,
hdr->nexus.targ_lun, hdr->nexus.targ_mapped_lun);
}
/*
@ -130,7 +130,7 @@ ctl_scsi_sense_sbuf(struct ctl_scsiio *ctsio,
if ((ctsio == NULL) || (sb == NULL))
return(-1);
ctl_scsi_path_string((union ctl_io *)ctsio, path_str, sizeof(path_str));
ctl_scsi_path_string(&ctsio->io_hdr, path_str, sizeof(path_str));
if (flags & SSS_FLAG_PRINT_COMMAND) {
sbuf_cat(sb, path_str);

View file

@ -43,7 +43,7 @@ int ctl_scsi_command_string(struct ctl_scsiio *ctsio,
int ctl_scsi_sense_sbuf(struct ctl_scsiio *ctsio,
struct scsi_inquiry_data *inq_data, struct sbuf *sb,
scsi_sense_string_flags flags);
void ctl_scsi_path_string(union ctl_io *io, char *path_str, int strlen);
void ctl_scsi_path_string(struct ctl_io_hdr *hdr, char *path_str, int strlen);
char *ctl_scsi_sense_string(struct ctl_scsiio *ctsio,
struct scsi_inquiry_data *inq_data, char *str,
int str_len);

View file

@ -731,7 +731,7 @@ ctl_io_sbuf(union ctl_io *io, struct sbuf *sb)
const char *task_desc;
char path_str[64];
ctl_scsi_path_string(io, path_str, sizeof(path_str));
ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str));
switch (io->io_hdr.io_type) {
case CTL_IO_SCSI:
@ -784,7 +784,7 @@ ctl_io_error_sbuf(union ctl_io *io, struct scsi_inquiry_data *inq_data,
}
}
ctl_scsi_path_string(io, path_str, sizeof(path_str));
ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str));
sbuf_cat(sb, path_str);
if (status_desc == NULL)
@ -861,7 +861,7 @@ ctl_data_print(union ctl_io *io)
return;
if (io->scsiio.kern_sg_entries > 0) /* XXX: Implement */
return;
ctl_scsi_path_string(io, path_str, sizeof(path_str));
ctl_scsi_path_string(&io->io_hdr, path_str, sizeof(path_str));
len = min(io->scsiio.kern_data_len, 4096);
for (i = 0; i < len; ) {
sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN);

View file

@ -1245,7 +1245,7 @@ cctl_start_stop(int fd, int lun, int iid, int retries, int start,
goto bailout;
}
ctl_scsi_path_string(io, scsi_path, sizeof(scsi_path));
ctl_scsi_path_string(&io->io_hdr, scsi_path, sizeof(scsi_path));
if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) {
fprintf(stdout, "%s LUN %s successfully\n", scsi_path,
(start) ? "started" : "stopped");
@ -1966,7 +1966,7 @@ cctl_get_inquiry(int fd, int lun, int iid, int retries,
retval = 1;
ctl_io_error_print(io, NULL, stderr);
} else if (path_str != NULL)
ctl_scsi_path_string(io, path_str, path_len);
ctl_scsi_path_string(&io->io_hdr, path_str, path_len);
bailout:
ctl_scsi_free_io(io);
@ -2364,7 +2364,7 @@ cctl_persistent_reserve_out(int fd, int lun, int iid,
}
if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) {
char scsi_path[40];
ctl_scsi_path_string(io, scsi_path, sizeof(scsi_path));
ctl_scsi_path_string(&io->io_hdr, scsi_path, sizeof(scsi_path));
fprintf( stdout, "%sPERSISTENT RESERVE OUT executed "
"successfully\n", scsi_path);
} else