Now that we properly negotiate the session params we can enable sending
authorclaudio <claudio@openbsd.org>
Mon, 21 Apr 2014 09:48:31 +0000 (09:48 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 21 Apr 2014 09:48:31 +0000 (09:48 +0000)
of immediate data for write commands. This gives a nice 20% performance
boost on writes compared to the solicited data transaction we did before.

usr.sbin/iscsid/iscsid.c
usr.sbin/iscsid/iscsid.h
usr.sbin/iscsid/vscsi.c

index 08bcdfc..df33932 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: iscsid.c,v 1.12 2014/04/20 22:18:04 claudio Exp $ */
+/*     $OpenBSD: iscsid.c,v 1.13 2014/04/21 09:48:31 claudio Exp $ */
 
 /*
  * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@@ -269,6 +269,16 @@ iscsid_ctrl_dispatch(void *ch, struct pdu *pdu)
                control_compose(ch, CTRL_VSCSI_STATS, vscsi_stats(),
                    sizeof(struct vscsi_stats));
                break;
+       case CTRL_SHOW_SUM:
+               control_compose(ch, CTRL_INITIATOR_CONFIG, &initiator->config,
+                   sizeof(initiator->config));
+
+               TAILQ_FOREACH(s, &initiator->sessions, entry)
+                       control_compose(ch, CTRL_SESSION_CONFIG,
+                           &s->config, sizeof(s->config));
+
+               control_compose(ch, CTRL_SUCCESS, NULL, 0);
+               break;
        default:
                log_warnx("unknown control message type %d", cmh->type);
                control_compose(ch, CTRL_FAILURE, NULL, 0);
index 1bc123d..a530ada 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: iscsid.h,v 1.11 2014/04/20 22:18:04 claudio Exp $ */
+/*     $OpenBSD: iscsid.h,v 1.12 2014/04/21 09:48:31 claudio Exp $ */
 
 /*
  * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@@ -54,6 +54,7 @@ struct ctrlmsghdr {
 #define CTRL_SESSION_CONFIG    5
 #define CTRL_LOG_VERBOSE       6
 #define CTRL_VSCSI_STATS       7
+#define CTRL_SHOW_SUM          8
 
 
 TAILQ_HEAD(session_head, session);
index 0dfafc5..4f796eb 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vscsi.c,v 1.10 2014/04/20 22:18:04 claudio Exp $ */
+/*     $OpenBSD: vscsi.c,v 1.11 2014/04/21 09:48:31 claudio Exp $ */
 
 /*
  * Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@@ -71,10 +71,6 @@ vscsi_dispatch(int fd, short event, void *arg)
        struct session *s;
        struct scsi_task *t;
        struct pdu *p;
-#if 0
-       char *buf;
-       u_int32_t t32;
-#endif
 
        if (!(event & EV_READ)) {
                log_debug("spurious read call");
@@ -121,16 +117,22 @@ vscsi_dispatch(int fd, short event, void *arg)
 
        memcpy(sreq->cdb, &i2t.cmd, i2t.cmdlen);
 
-#if 0
-       if (i2t.direction == VSCSI_DIR_WRITE) {
-               if (!(buf = pdu_alloc(i2t.datalen)))
+       /* include immediate data of up to FirstBurstLength bytes if allowed */
+       if (i2t.direction == VSCSI_DIR_WRITE &&
+           s->active.ImmediateData) {
+               char *buf;
+               u_int32_t t32;
+               size_t size;
+
+               size = i2t.datalen > s->active.FirstBurstLength ?
+                   s->active.FirstBurstLength : i2t.datalen;
+               if (!(buf = pdu_alloc(size)))
                        fatal("vscsi_dispatch");
-               t32 = htonl(i2t.datalen);
+               t32 = htonl(size);
                memcpy(&sreq->ahslen, &t32, sizeof(t32));
-               vscsi_data(VSCSI_DATA_WRITE, i2t.tag, buf, i2t.datalen);
-               pdu_addbuf(p, buf, i2t.datalen, PDU_DATA);
+               vscsi_data(VSCSI_DATA_WRITE, i2t.tag, buf, size);
+               pdu_addbuf(p, buf, size, PDU_DATA);
        }
-#endif
 
        task_init(&t->task, s, 0, t, vscsi_callback, vscsi_fail);
        task_pdu_add(&t->task, p);