| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: fstest_puffs.c,v 1.3 2010/09/01 19:41:27 pooka Exp $ */ | | 1 | /* $NetBSD: fstest_puffs.c,v 1.4 2010/10/31 22:05:35 pooka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -62,103 +62,113 @@ readshovel(void *arg) | | | @@ -62,103 +62,113 @@ readshovel(void *arg) |
62 | { | | 62 | { |
63 | struct putter_hdr *phdr; | | 63 | struct putter_hdr *phdr; |
64 | struct puffs_req *preq; | | 64 | struct puffs_req *preq; |
65 | struct puffstestargs *args = arg; | | 65 | struct puffstestargs *args = arg; |
66 | char buf[BUFSIZE]; | | 66 | char buf[BUFSIZE]; |
67 | int comfd, puffsfd; | | 67 | int comfd, puffsfd; |
68 | | | 68 | |
69 | comfd = args->pta_servfd; | | 69 | comfd = args->pta_servfd; |
70 | puffsfd = args->pta_rumpfd; | | 70 | puffsfd = args->pta_rumpfd; |
71 | | | 71 | |
72 | phdr = (void *)buf; | | 72 | phdr = (void *)buf; |
73 | preq = (void *)buf; | | 73 | preq = (void *)buf; |
74 | | | 74 | |
75 | rump_pub_lwproc_newlwp(0); | | 75 | rump_pub_lwproc_newlwp(1); |
76 | | | 76 | |
77 | for (;;) { | | 77 | for (;;) { |
78 | ssize_t n; | | 78 | ssize_t n; |
79 | | | 79 | |
80 | n = rump_sys_read(puffsfd, buf, sizeof(*phdr)); | | 80 | n = rump_sys_read(puffsfd, buf, sizeof(*phdr)); |
81 | if (n <= 0) | | 81 | if (n <= 0) { |
| | | 82 | fprintf(stderr, "readshovel r1 %d / %d\n", n, errno); |
82 | break; | | 83 | break; |
| | | 84 | } |
83 | | | 85 | |
84 | assert(phdr->pth_framelen < BUFSIZE); | | 86 | assert(phdr->pth_framelen < BUFSIZE); |
85 | n = rump_sys_read(puffsfd, buf+sizeof(*phdr), | | 87 | n = rump_sys_read(puffsfd, buf+sizeof(*phdr), |
86 | phdr->pth_framelen - sizeof(*phdr)); | | 88 | phdr->pth_framelen - sizeof(*phdr)); |
87 | if (n <= 0) | | 89 | if (n <= 0) { |
| | | 90 | fprintf(stderr, "readshovel r2 %d / %d\n", n, errno); |
88 | break; | | 91 | break; |
| | | 92 | } |
89 | | | 93 | |
90 | /* Analyze request */ | | 94 | /* Analyze request */ |
91 | if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS) { | | 95 | if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS) { |
92 | assert(preq->preq_optype < PUFFS_VFS_MAX); | | 96 | assert(preq->preq_optype < PUFFS_VFS_MAX); |
93 | args->pta_vfs_toserv_ops[preq->preq_optype]++; | | 97 | args->pta_vfs_toserv_ops[preq->preq_optype]++; |
94 | } else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) { | | 98 | } else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) { |
95 | assert(preq->preq_optype < PUFFS_VN_MAX); | | 99 | assert(preq->preq_optype < PUFFS_VN_MAX); |
96 | args->pta_vn_toserv_ops[preq->preq_optype]++; | | 100 | args->pta_vn_toserv_ops[preq->preq_optype]++; |
97 | } | | 101 | } |
98 | | | 102 | |
99 | n = phdr->pth_framelen; | | 103 | n = phdr->pth_framelen; |
100 | if (write(comfd, buf, n) != n) | | 104 | if (write(comfd, buf, n) != n) { |
| | | 105 | fprintf(stderr, "readshovel write %d / %d\n", n, errno); |
101 | break; | | 106 | break; |
| | | 107 | } |
102 | } | | 108 | } |
103 | | | 109 | |
104 | return NULL; | | 110 | abort(); |
105 | } | | 111 | } |
106 | | | 112 | |
107 | static void * | | 113 | static void * |
108 | writeshovel(void *arg) | | 114 | writeshovel(void *arg) |
109 | { | | 115 | { |
110 | struct puffstestargs *args = arg; | | 116 | struct puffstestargs *args = arg; |
111 | struct putter_hdr *phdr; | | 117 | struct putter_hdr *phdr; |
112 | char buf[BUFSIZE]; | | 118 | char buf[BUFSIZE]; |
113 | size_t toread; | | 119 | size_t toread; |
114 | int comfd, puffsfd; | | 120 | int comfd, puffsfd; |
115 | | | 121 | |
116 | rump_pub_lwproc_newlwp(0); | | 122 | rump_pub_lwproc_newlwp(1); |
117 | | | 123 | |
118 | comfd = args->pta_servfd; | | 124 | comfd = args->pta_servfd; |
119 | puffsfd = args->pta_rumpfd; | | 125 | puffsfd = args->pta_rumpfd; |
120 | | | 126 | |
121 | phdr = (struct putter_hdr *)buf; | | 127 | phdr = (struct putter_hdr *)buf; |
122 | | | 128 | |
123 | for (;;) { | | 129 | for (;;) { |
124 | uint64_t off; | | 130 | uint64_t off; |
125 | ssize_t n; | | 131 | ssize_t n; |
126 | | | 132 | |
127 | /* | | 133 | /* |
128 | * Need to write everything to the "kernel" in one chunk, | | 134 | * Need to write everything to the "kernel" in one chunk, |
129 | * so make sure we have it here. | | 135 | * so make sure we have it here. |
130 | */ | | 136 | */ |
131 | off = 0; | | 137 | off = 0; |
132 | toread = sizeof(struct putter_hdr); | | 138 | toread = sizeof(struct putter_hdr); |
133 | assert(toread < BUFSIZE); | | 139 | assert(toread < BUFSIZE); |
134 | do { | | 140 | do { |
135 | n = read(comfd, buf+off, toread); | | 141 | n = read(comfd, buf+off, toread); |
136 | if (n <= 0) { | | 142 | if (n <= 0) { |
| | | 143 | fprintf(stderr, "writeshovel read %d / %d\n", |
| | | 144 | n, errno); |
137 | break; | | 145 | break; |
138 | } | | 146 | } |
139 | off += n; | | 147 | off += n; |
140 | if (off >= sizeof(struct putter_hdr)) | | 148 | if (off >= sizeof(struct putter_hdr)) |
141 | toread = phdr->pth_framelen - off; | | 149 | toread = phdr->pth_framelen - off; |
142 | else | | 150 | else |
143 | toread = off - sizeof(struct putter_hdr); | | 151 | toread = off - sizeof(struct putter_hdr); |
144 | } while (toread); | | 152 | } while (toread); |
145 | | | 153 | |
146 | n = rump_sys_write(puffsfd, buf, phdr->pth_framelen); | | 154 | n = rump_sys_write(puffsfd, buf, phdr->pth_framelen); |
147 | if ((size_t)n != phdr->pth_framelen) | | 155 | if ((size_t)n != phdr->pth_framelen) { |
| | | 156 | fprintf(stderr, "writeshovel wr %d / %d\n", n, errno); |
148 | break; | | 157 | break; |
| | | 158 | } |
149 | } | | 159 | } |
150 | | | 160 | |
151 | return NULL; | | 161 | abort(); |
152 | } | | 162 | } |
153 | | | 163 | |
154 | static void | | 164 | static void |
155 | rumpshovels(struct puffstestargs *args) | | 165 | rumpshovels(struct puffstestargs *args) |
156 | { | | 166 | { |
157 | pthread_t pt; | | 167 | pthread_t pt; |
158 | int rv; | | 168 | int rv; |
159 | | | 169 | |
160 | if ((rv = rump_init()) == -1) | | 170 | if ((rv = rump_init()) == -1) |
161 | err(1, "rump_init"); | | 171 | err(1, "rump_init"); |
162 | | | 172 | |
163 | if (pthread_create(&pt, NULL, readshovel, args) == -1) | | 173 | if (pthread_create(&pt, NULL, readshovel, args) == -1) |
164 | err(1, "read shovel"); | | 174 | err(1, "read shovel"); |