Lines Matching refs:hio
73 struct hio { struct
109 TAILQ_ENTRY(hio) *hio_next;
118 static TAILQ_HEAD(, hio) hio_free_list;
127 static TAILQ_HEAD(, hio) *hio_send_list;
137 static TAILQ_HEAD(, hio) *hio_recv_list;
146 static TAILQ_HEAD(, hio) hio_done_list;
181 #define QUEUE_INSERT1(hio, name, ncomp) do { \ argument
185 TAILQ_INSERT_TAIL(&hio_##name##_list[(ncomp)], (hio), \
190 #define QUEUE_INSERT2(hio, name) do { \ argument
194 TAILQ_INSERT_TAIL(&hio_##name##_list, (hio), hio_##name##_next);\
198 #define QUEUE_TAKE1(hio, name, ncomp, timeout) do { \ argument
203 while (((hio) = TAILQ_FIRST(&hio_##name##_list[(ncomp)])) == NULL && !_last) { \
209 if (hio != NULL) { \
212 TAILQ_REMOVE(&hio_##name##_list[(ncomp)], (hio), \
217 #define QUEUE_TAKE2(hio, name) do { \ argument
219 while (((hio) = TAILQ_FIRST(&hio_##name##_list)) == NULL) { \
225 TAILQ_REMOVE(&hio_##name##_list, (hio), hio_##name##_next); \
229 #define ISFULLSYNC(hio) ((hio)->hio_replication == HAST_REPLICATION_FULLSYNC) argument
230 #define ISMEMSYNC(hio) ((hio)->hio_replication == HAST_REPLICATION_MEMSYNC) argument
231 #define ISASYNC(hio) ((hio)->hio_replication == HAST_REPLICATION_ASYNC) argument
233 #define SYNCREQ(hio) do { \ argument
234 (hio)->hio_ggio.gctl_unit = -1; \
235 (hio)->hio_ggio.gctl_seq = 1; \
237 #define ISSYNCREQ(hio) ((hio)->hio_ggio.gctl_unit == -1) argument
238 #define SYNCREQDONE(hio) do { (hio)->hio_ggio.gctl_unit = -2; } while (0) argument
239 #define ISSYNCREQDONE(hio) ((hio)->hio_ggio.gctl_unit == -2) argument
241 #define ISMEMSYNCWRITE(hio) (ISMEMSYNC(hio) && \ argument
242 (hio)->hio_ggio.gctl_cmd == BIO_WRITE && !ISSYNCREQ(hio))
378 struct hio *hio; in init_environment() local
470 hio = malloc(sizeof(*hio)); in init_environment()
471 if (hio == NULL) { in init_environment()
474 sizeof(*hio)); in init_environment()
476 refcnt_init(&hio->hio_countdown, 0); in init_environment()
477 hio->hio_errors = malloc(sizeof(hio->hio_errors[0]) * ncomps); in init_environment()
478 if (hio->hio_errors == NULL) { in init_environment()
481 sizeof(hio->hio_errors[0]) * ncomps); in init_environment()
483 hio->hio_next = malloc(sizeof(hio->hio_next[0]) * ncomps); in init_environment()
484 if (hio->hio_next == NULL) { in init_environment()
487 sizeof(hio->hio_next[0]) * ncomps); in init_environment()
489 hio->hio_ggio.gctl_version = G_GATE_VERSION; in init_environment()
490 hio->hio_ggio.gctl_data = malloc(MAXPHYS); in init_environment()
491 if (hio->hio_ggio.gctl_data == NULL) { in init_environment()
496 hio->hio_ggio.gctl_length = MAXPHYS; in init_environment()
497 hio->hio_ggio.gctl_error = 0; in init_environment()
498 TAILQ_INSERT_HEAD(&hio_free_list, hio, hio_free_next); in init_environment()
1178 write_complete(struct hast_resource *res, struct hio *hio) in write_complete() argument
1183 PJDLOG_ASSERT(!hio->hio_done); in write_complete()
1185 ggio = &hio->hio_ggio; in write_complete()
1207 hio->hio_done = true; in write_complete()
1226 struct hio *hio; in ggate_recv_thread() local
1232 QUEUE_TAKE2(hio, free); in ggate_recv_thread()
1233 pjdlog_debug(2, "ggate_recv: (%p) Got free request.", hio); in ggate_recv_thread()
1234 ggio = &hio->hio_ggio; in ggate_recv_thread()
1238 hio->hio_done = false; in ggate_recv_thread()
1239 hio->hio_replication = res->hr_replication; in ggate_recv_thread()
1242 hio); in ggate_recv_thread()
1257 hio); in ggate_recv_thread()
1277 hio->hio_errors[ii] = EINVAL; in ggate_recv_thread()
1280 hio); in ggate_recv_thread()
1355 if (ISMEMSYNC(hio)) { in ggate_recv_thread()
1356 hio->hio_memsyncacked = false; in ggate_recv_thread()
1357 refcnt_init(&hio->hio_writecount, ncomps); in ggate_recv_thread()
1368 "ggate_recv: (%p) Moving request to the send queues.", hio); in ggate_recv_thread()
1369 refcnt_init(&hio->hio_countdown, ncomps); in ggate_recv_thread()
1371 QUEUE_INSERT1(hio, send, ii); in ggate_recv_thread()
1386 struct hio *hio; in local_send_thread() local
1397 QUEUE_TAKE1(hio, send, ncomp, 0); in local_send_thread()
1398 pjdlog_debug(2, "local_send: (%p) Got request.", hio); in local_send_thread()
1399 ggio = &hio->hio_ggio; in local_send_thread()
1406 hio->hio_errors[ncomp] = 0; in local_send_thread()
1407 else if (!ISSYNCREQ(hio)) { in local_send_thread()
1420 QUEUE_INSERT1(hio, send, rncomp); in local_send_thread()
1429 hio->hio_errors[ncomp] = errno; in local_send_thread()
1434 hio->hio_errors[ncomp] = EIO; in local_send_thread()
1439 hio->hio_errors[ncomp] = 0; in local_send_thread()
1440 if (ISASYNC(hio)) { in local_send_thread()
1442 write_complete(res, hio); in local_send_thread()
1451 hio->hio_errors[ncomp] = errno; in local_send_thread()
1456 hio->hio_errors[ncomp] = 0; in local_send_thread()
1469 hio->hio_errors[ncomp] = errno; in local_send_thread()
1474 hio->hio_errors[ncomp] = 0; in local_send_thread()
1478 if (ISMEMSYNCWRITE(hio)) { in local_send_thread()
1479 if (refcnt_release(&hio->hio_writecount) == 0) { in local_send_thread()
1480 write_complete(res, hio); in local_send_thread()
1483 if (refcnt_release(&hio->hio_countdown) > 0) in local_send_thread()
1485 if (ISSYNCREQ(hio)) { in local_send_thread()
1487 SYNCREQDONE(hio); in local_send_thread()
1493 hio); in local_send_thread()
1494 QUEUE_INSERT2(hio, done); in local_send_thread()
1548 struct hio *hio; in remote_send_thread() local
1562 QUEUE_TAKE1(hio, send, ncomp, HAST_KEEPALIVE); in remote_send_thread()
1563 if (hio == NULL) { in remote_send_thread()
1571 pjdlog_debug(2, "remote_send: (%p) Got request.", hio); in remote_send_thread()
1572 ggio = &hio->hio_ggio; in remote_send_thread()
1606 if (ISMEMSYNCWRITE(hio)) in remote_send_thread()
1609 hio->hio_errors[ncomp] = nv_error(nv); in remote_send_thread()
1612 hio); in remote_send_thread()
1625 hio->hio_errors[ncomp] = ENOTCONN; in remote_send_thread()
1635 hio); in remote_send_thread()
1638 TAILQ_INSERT_TAIL(&hio_recv_list[ncomp], hio, hio_next[ncomp]); in remote_send_thread()
1643 hio->hio_errors[ncomp] = errno; in remote_send_thread()
1646 "remote_send: (%p) Unable to send request.", hio); in remote_send_thread()
1649 strerror(hio->hio_errors[ncomp])); in remote_send_thread()
1660 if (ISSYNCREQ(hio)) { in remote_send_thread()
1661 if (refcnt_release(&hio->hio_countdown) > 0) in remote_send_thread()
1664 SYNCREQDONE(hio); in remote_send_thread()
1677 if (ISMEMSYNCWRITE(hio)) { in remote_send_thread()
1678 if (refcnt_release(&hio->hio_writecount) == 0) { in remote_send_thread()
1679 if (hio->hio_errors[0] == 0) in remote_send_thread()
1680 write_complete(res, hio); in remote_send_thread()
1684 if (refcnt_release(&hio->hio_countdown) > 0) in remote_send_thread()
1688 hio); in remote_send_thread()
1689 QUEUE_INSERT2(hio, done); in remote_send_thread()
1704 struct hio *hio; in remote_recv_thread() local
1734 hio = TAILQ_FIRST(&hio_recv_list[ncomp]); in remote_recv_thread()
1735 PJDLOG_ASSERT(hio != NULL); in remote_recv_thread()
1736 TAILQ_REMOVE(&hio_recv_list[ncomp], hio, in remote_recv_thread()
1740 hio->hio_errors[ncomp] = ENOTCONN; in remote_recv_thread()
1759 TAILQ_FOREACH(hio, &hio_recv_list[ncomp], hio_next[ncomp]) { in remote_recv_thread()
1760 if (hio->hio_ggio.gctl_seq == seq) { in remote_recv_thread()
1761 TAILQ_REMOVE(&hio_recv_list[ncomp], hio, in remote_recv_thread()
1768 if (hio == NULL) { in remote_recv_thread()
1774 ggio = &hio->hio_ggio; in remote_recv_thread()
1778 hio->hio_errors[ncomp] = error; in remote_recv_thread()
1794 hio->hio_errors[ncomp] = errno; in remote_recv_thread()
1811 hio->hio_errors[ncomp] = 0; in remote_recv_thread()
1814 if (ISMEMSYNCWRITE(hio)) { in remote_recv_thread()
1815 if (!hio->hio_memsyncacked) { in remote_recv_thread()
1817 hio->hio_errors[ncomp] != 0); in remote_recv_thread()
1819 if (refcnt_release(&hio->hio_writecount) == 0) { in remote_recv_thread()
1820 if (hio->hio_errors[0] == 0) in remote_recv_thread()
1821 write_complete(res, hio); in remote_recv_thread()
1823 hio->hio_memsyncacked = true; in remote_recv_thread()
1824 if (hio->hio_errors[ncomp] == 0) { in remote_recv_thread()
1827 "back to the recv queue.", hio); in remote_recv_thread()
1830 hio, hio_next[ncomp]); in remote_recv_thread()
1840 if (refcnt_release(&hio->hio_countdown) > 0) in remote_recv_thread()
1842 if (ISSYNCREQ(hio)) { in remote_recv_thread()
1844 SYNCREQDONE(hio); in remote_recv_thread()
1850 hio); in remote_recv_thread()
1851 QUEUE_INSERT2(hio, done); in remote_recv_thread()
1866 struct hio *hio; in ggate_send_thread() local
1873 QUEUE_TAKE2(hio, done); in ggate_send_thread()
1874 pjdlog_debug(2, "ggate_send: (%p) Got request.", hio); in ggate_send_thread()
1875 ggio = &hio->hio_ggio; in ggate_send_thread()
1877 if (hio->hio_errors[ii] == 0) { in ggate_send_thread()
1894 ggio->gctl_error = hio->hio_errors[1]; in ggate_send_thread()
1896 ggio->gctl_error = hio->hio_errors[0]; in ggate_send_thread()
1918 if (!hio->hio_done) in ggate_send_thread()
1919 write_complete(res, hio); in ggate_send_thread()
1926 if (hio->hio_errors[0]) { in ggate_send_thread()
1943 "ggate_send: (%p) Moving request to the free queue.", hio); in ggate_send_thread()
1944 QUEUE_INSERT2(hio, free); in ggate_send_thread()
1957 struct hio *hio; in sync_thread() local
2066 QUEUE_TAKE2(hio, free); in sync_thread()
2067 pjdlog_debug(2, "sync: (%p) Got free request.", hio); in sync_thread()
2098 SYNCREQ(hio); in sync_thread()
2099 ggio = &hio->hio_ggio; in sync_thread()
2104 hio->hio_done = false; in sync_thread()
2105 hio->hio_replication = res->hr_replication; in sync_thread()
2107 hio->hio_errors[ii] = EINVAL; in sync_thread()
2109 hio); in sync_thread()
2111 hio); in sync_thread()
2130 refcnt_init(&hio->hio_countdown, 1); in sync_thread()
2131 QUEUE_INSERT1(hio, send, ncomp); in sync_thread()
2137 while (!ISSYNCREQDONE(hio)) in sync_thread()
2141 if (hio->hio_errors[ncomp] != 0) { in sync_thread()
2143 strerror(hio->hio_errors[ncomp])); in sync_thread()
2151 SYNCREQ(hio); in sync_thread()
2154 hio->hio_errors[ii] = EINVAL; in sync_thread()
2156 hio); in sync_thread()
2158 hio); in sync_thread()
2179 hio); in sync_thread()
2180 refcnt_init(&hio->hio_countdown, 1); in sync_thread()
2181 QUEUE_INSERT1(hio, send, ncomp); in sync_thread()
2187 while (!ISSYNCREQDONE(hio)) in sync_thread()
2191 if (hio->hio_errors[ncomp] != 0) { in sync_thread()
2193 strerror(hio->hio_errors[ncomp])); in sync_thread()
2205 hio); in sync_thread()
2206 QUEUE_INSERT2(hio, free); in sync_thread()