svn commit: r344992 - stable/11/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Mon Mar 11 01:44:39 UTC 2019
Author: mav
Date: Mon Mar 11 01:44:37 2019
New Revision: 344992
URL: https://svnweb.freebsd.org/changeset/base/344992
Log:
MFC r344489: Free some space in struct ctl_io_hdr for better use.
- Collapse original_sc and serializing_sc fields into one, since they
are never used simultanously, we have only one local I/O and one remote.
- Move remote_sglist and local_sglist fields into CTL_PRIV_BACKEND,
since they are used only on Originating SC in XFER mode, where requests
don't ever reach backends, so we can reuse backend's private storage.
Modified:
stable/11/sys/cam/ctl/ctl.c
stable/11/sys/cam/ctl/ctl_io.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/cam/ctl/ctl.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl.c Mon Mar 11 01:44:18 2019 (r344991)
+++ stable/11/sys/cam/ctl/ctl.c Mon Mar 11 01:44:37 2019 (r344992)
@@ -645,7 +645,7 @@ ctl_ha_datamove(union ctl_io *io)
memset(&msg.dt, 0, sizeof(msg.dt));
msg.hdr.msg_type = CTL_MSG_DATAMOVE;
- msg.hdr.original_sc = io->io_hdr.original_sc;
+ msg.hdr.original_sc = io->io_hdr.remote_io;
msg.hdr.serializing_sc = io;
msg.hdr.nexus = io->io_hdr.nexus;
msg.hdr.status = io->io_hdr.status;
@@ -760,7 +760,7 @@ ctl_ha_done(union ctl_io *io)
if (io->io_hdr.io_type == CTL_IO_SCSI) {
memset(&msg, 0, sizeof(msg));
msg.hdr.msg_type = CTL_MSG_FINISH_IO;
- msg.hdr.original_sc = io->io_hdr.original_sc;
+ msg.hdr.original_sc = io->io_hdr.remote_io;
msg.hdr.nexus = io->io_hdr.nexus;
msg.hdr.status = io->io_hdr.status;
msg.scsi.scsi_status = io->scsiio.scsi_status;
@@ -1433,7 +1433,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e
// populate ctsio from msg
io->io_hdr.io_type = CTL_IO_SCSI;
io->io_hdr.msg_type = CTL_MSG_SERIALIZE;
- io->io_hdr.original_sc = msg->hdr.original_sc;
+ io->io_hdr.remote_io = msg->hdr.original_sc;
io->io_hdr.flags |= CTL_FLAG_FROM_OTHER_SC |
CTL_FLAG_IO_ACTIVE;
/*
@@ -1489,7 +1489,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e
* Keep track of this, we need to send it back over
* when the datamove is complete.
*/
- io->io_hdr.serializing_sc = msg->hdr.serializing_sc;
+ io->io_hdr.remote_io = msg->hdr.serializing_sc;
if (msg->hdr.status == CTL_SUCCESS)
io->io_hdr.status = msg->hdr.status;
@@ -1502,9 +1502,8 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e
CTL_HA_DATAMOVE_SEGMENT + 1;
sgl = malloc(sizeof(*sgl) * i, M_CTL,
M_WAITOK | M_ZERO);
- io->io_hdr.remote_sglist = sgl;
- io->io_hdr.local_sglist =
- &sgl[msg->dt.kern_sg_entries];
+ CTL_RSGL(io) = sgl;
+ CTL_LSGL(io) = &sgl[msg->dt.kern_sg_entries];
io->scsiio.kern_data_ptr = (uint8_t *)sgl;
@@ -1591,7 +1590,7 @@ ctl_isc_event_handler(ctl_ha_channel channel, ctl_ha_e
}
io->io_hdr.flags |= CTL_FLAG_IO_ACTIVE;
io->io_hdr.msg_type = CTL_MSG_R2R;
- io->io_hdr.serializing_sc = msg->hdr.serializing_sc;
+ io->io_hdr.remote_io = msg->hdr.serializing_sc;
ctl_enqueue_isc(io);
break;
@@ -2362,7 +2361,7 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio)
mtx_unlock(&lun->lun_lock);
/* send msg back to other side */
- msg_info.hdr.original_sc = ctsio->io_hdr.original_sc;
+ msg_info.hdr.original_sc = ctsio->io_hdr.remote_io;
msg_info.hdr.serializing_sc = (union ctl_io *)ctsio;
msg_info.hdr.msg_type = CTL_MSG_R2R;
ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info,
@@ -2388,7 +2387,7 @@ ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio)
/*retry_count*/ 0);
badjuju:
ctl_copy_sense_data_back((union ctl_io *)ctsio, &msg_info);
- msg_info.hdr.original_sc = ctsio->io_hdr.original_sc;
+ msg_info.hdr.original_sc = ctsio->io_hdr.remote_io;
msg_info.hdr.serializing_sc = NULL;
msg_info.hdr.msg_type = CTL_MSG_BAD_JUJU;
ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info,
@@ -11075,7 +11074,7 @@ ctl_check_blocked(struct ctl_lun *lun)
cur_blocked->io_hdr.flags &= ~CTL_FLAG_IO_ACTIVE;
msg_info.hdr.original_sc =
- cur_blocked->io_hdr.original_sc;
+ cur_blocked->io_hdr.remote_io;
msg_info.hdr.serializing_sc = cur_blocked;
msg_info.hdr.msg_type = CTL_MSG_R2R;
ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info,
@@ -12512,7 +12511,7 @@ ctl_send_datamove_done(union ctl_io *io, int have_lock
memset(&msg, 0, sizeof(msg));
msg.hdr.msg_type = CTL_MSG_DATAMOVE_DONE;
msg.hdr.original_sc = io;
- msg.hdr.serializing_sc = io->io_hdr.serializing_sc;
+ msg.hdr.serializing_sc = io->io_hdr.remote_io;
msg.hdr.nexus = io->io_hdr.nexus;
msg.hdr.status = io->io_hdr.status;
msg.scsi.kern_data_resid = io->scsiio.kern_data_resid;
@@ -12563,10 +12562,10 @@ ctl_datamove_remote_write_cb(struct ctl_ha_dt_req *rq)
ctl_dt_req_free(rq);
for (i = 0; i < io->scsiio.kern_sg_entries; i++)
- free(io->io_hdr.local_sglist[i].addr, M_CTL);
- free(io->io_hdr.remote_sglist, M_CTL);
- io->io_hdr.remote_sglist = NULL;
- io->io_hdr.local_sglist = NULL;
+ free(CTL_LSGLT(io)[i].addr, M_CTL);
+ free(CTL_RSGL(io), M_CTL);
+ CTL_RSGL(io) = NULL;
+ CTL_LSGL(io) = NULL;
/*
* The data is in local and remote memory, so now we need to send
@@ -12606,7 +12605,7 @@ ctl_datamove_remote_write(union ctl_io *io)
return;
/* Switch the pointer over so the FETD knows what to do */
- io->scsiio.kern_data_ptr = (uint8_t *)io->io_hdr.local_sglist;
+ io->scsiio.kern_data_ptr = (uint8_t *)CTL_LSGL(io);
/*
* Use a custom move done callback, since we need to send completion
@@ -12629,10 +12628,10 @@ ctl_datamove_remote_dm_read_cb(union ctl_io *io)
uint32_t i;
for (i = 0; i < io->scsiio.kern_sg_entries; i++)
- free(io->io_hdr.local_sglist[i].addr, M_CTL);
- free(io->io_hdr.remote_sglist, M_CTL);
- io->io_hdr.remote_sglist = NULL;
- io->io_hdr.local_sglist = NULL;
+ free(CTL_LSGLT(io)[i].addr, M_CTL);
+ free(CTL_RSGL(io), M_CTL);
+ CTL_RSGL(io) = NULL;
+ CTL_LSGL(io) = NULL;
#if 0
scsi_path_string(io, path_str, sizeof(path_str));
@@ -12679,7 +12678,7 @@ ctl_datamove_remote_read_cb(struct ctl_ha_dt_req *rq)
ctl_dt_req_free(rq);
/* Switch the pointer over so the FETD knows what to do */
- io->scsiio.kern_data_ptr = (uint8_t *)io->io_hdr.local_sglist;
+ io->scsiio.kern_data_ptr = (uint8_t *)CTL_LSGL(io);
/*
* Use a custom move done callback, since we need to send completion
@@ -12702,7 +12701,7 @@ ctl_datamove_remote_sgl_setup(union ctl_io *io)
int i;
retval = 0;
- local_sglist = io->io_hdr.local_sglist;
+ local_sglist = CTL_LSGL(io);
len_to_go = io->scsiio.kern_data_len;
/*
@@ -12773,8 +12772,8 @@ ctl_datamove_remote_xfer(union ctl_io *io, unsigned co
return (1);
}
- local_sglist = io->io_hdr.local_sglist;
- remote_sglist = io->io_hdr.remote_sglist;
+ local_sglist = CTL_LSGL(io);
+ remote_sglist = CTL_RSGL(io);
local_used = 0;
remote_used = 0;
total_used = 0;
@@ -12887,10 +12886,10 @@ ctl_datamove_remote_read(union ctl_io *io)
* error if there is a problem.
*/
for (i = 0; i < io->scsiio.kern_sg_entries; i++)
- free(io->io_hdr.local_sglist[i].addr, M_CTL);
- free(io->io_hdr.remote_sglist, M_CTL);
- io->io_hdr.remote_sglist = NULL;
- io->io_hdr.local_sglist = NULL;
+ free(CTL_LSGLT(io)[i].addr, M_CTL);
+ free(CTL_RSGL(io), M_CTL);
+ CTL_RSGL(io) = NULL;
+ CTL_LSGL(io) = NULL;
}
}
@@ -13153,7 +13152,7 @@ bailout:
(io->io_hdr.flags & CTL_FLAG_SENT_2OTHER_SC)) {
memset(&msg, 0, sizeof(msg));
msg.hdr.msg_type = CTL_MSG_FINISH_IO;
- msg.hdr.serializing_sc = io->io_hdr.serializing_sc;
+ msg.hdr.serializing_sc = io->io_hdr.remote_io;
msg.hdr.nexus = io->io_hdr.nexus;
ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg,
sizeof(msg.scsi) - sizeof(msg.scsi.sense_data),
Modified: stable/11/sys/cam/ctl/ctl_io.h
==============================================================================
--- stable/11/sys/cam/ctl/ctl_io.h Mon Mar 11 01:44:18 2019 (r344991)
+++ stable/11/sys/cam/ctl/ctl_io.h Mon Mar 11 01:44:37 2019 (r344992)
@@ -165,6 +165,15 @@ union ctl_priv {
#define CTL_PORT(io) (((struct ctl_softc *)CTL_SOFTC(io))-> \
ctl_ports[(io)->io_hdr.nexus.targ_port])
+/*
+ * These are used only on Originating SC in XFER mode, where requests don't
+ * ever reach backends, so we can reuse backend's private storage.
+ */
+#define CTL_RSGL(io) ((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptrs[0])
+#define CTL_LSGL(io) ((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptrs[1])
+#define CTL_RSGLT(io) ((struct ctl_sg_entry *)CTL_RSGL(io))
+#define CTL_LSGLT(io) ((struct ctl_sg_entry *)CTL_LSGL(io))
+
#define CTL_INVALID_PORTNAME 0xFF
#define CTL_UNMAPPED_IID 0xFF
@@ -227,12 +236,12 @@ struct ctl_io_hdr {
struct bintime dma_bt; /* DMA total ticks */
#endif /* CTL_TIME_IO */
uint32_t num_dmas; /* Number of DMAs */
- union ctl_io *original_sc;
- union ctl_io *serializing_sc;
+ union ctl_io *remote_io; /* I/O counterpart on remote HA side */
+ void *pad1;
void *pool; /* I/O pool */
union ctl_priv ctl_private[CTL_NUM_PRIV];/* CTL private area */
- struct ctl_sg_entry *remote_sglist;
- struct ctl_sg_entry *local_sglist;
+ void *pad2;
+ void *pad3;
STAILQ_ENTRY(ctl_io_hdr) links; /* linked list pointer */
TAILQ_ENTRY(ctl_io_hdr) ooa_links;
TAILQ_ENTRY(ctl_io_hdr) blocked_links;
More information about the svn-src-all
mailing list