Blame view
net/9p/trans_fd.c
23.9 KB
bd238fb43
|
1 2 3 4 5 6 7 |
/* * linux/fs/9p/trans_fd.c * * Fd transport layer. Includes deprecated socket layer. * * Copyright (C) 2006 by Russ Cox <rsc@swtch.com> * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net> |
8a0dc95fd
|
8 |
* Copyright (C) 2004-2008 by Eric Van Hensbergen <ericvh@gmail.com> |
bd238fb43
|
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
* Copyright (C) 1997-2002 by Ron Minnich <rminnich@sarnoff.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to: * Free Software Foundation * 51 Franklin Street, Fifth Floor * Boston, MA 02111-1301 USA * */ |
5d3851530
|
27 |
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
bd238fb43
|
28 29 30 31 |
#include <linux/in.h> #include <linux/module.h> #include <linux/net.h> #include <linux/ipv6.h> |
8a0dc95fd
|
32 |
#include <linux/kthread.h> |
bd238fb43
|
33 34 35 36 37 38 39 |
#include <linux/errno.h> #include <linux/kernel.h> #include <linux/un.h> #include <linux/uaccess.h> #include <linux/inet.h> #include <linux/idr.h> #include <linux/file.h> |
a80d923e1
|
40 |
#include <linux/parser.h> |
5a0e3ad6a
|
41 |
#include <linux/slab.h> |
bd238fb43
|
42 |
#include <net/9p/9p.h> |
8b81ef589
|
43 |
#include <net/9p/client.h> |
bd238fb43
|
44 |
#include <net/9p/transport.h> |
6b18662e2
|
45 |
#include <linux/syscalls.h> /* killme */ |
bd238fb43
|
46 |
#define P9_PORT 564 |
a80d923e1
|
47 |
#define MAX_SOCK_BUF (64*1024) |
8a0dc95fd
|
48 |
#define MAXPOLLWADDR 2 |
a80d923e1
|
49 |
|
ee443996a
|
50 51 52 53 54 55 56 |
/** * struct p9_fd_opts - per-transport options * @rfd: file descriptor for reading (trans=fd) * @wfd: file descriptor for writing (trans=fd) * @port: port to connect to (trans=tcp) * */ |
a80d923e1
|
57 58 59 60 61 |
struct p9_fd_opts { int rfd; int wfd; u16 port; }; |
bd238fb43
|
62 |
|
ee443996a
|
63 64 65 66 67 68 69 |
/** * struct p9_trans_fd - transport state * @rd: reference to file to read from * @wr: reference of file to write to * @conn: connection state reference * */ |
bd238fb43
|
70 71 72 |
struct p9_trans_fd { struct file *rd; struct file *wr; |
8a0dc95fd
|
73 |
struct p9_conn *conn; |
bd238fb43
|
74 |
}; |
a80d923e1
|
75 76 77 78 |
/* * Option Parsing (code inspired by NFS code) * - a little lazy - parse all fd-transport options */ |
bd238fb43
|
79 |
|
a80d923e1
|
80 81 |
enum { /* Options that take integer arguments */ |
55762690e
|
82 |
Opt_port, Opt_rfdno, Opt_wfdno, Opt_err, |
a80d923e1
|
83 |
}; |
bd238fb43
|
84 |
|
a447c0932
|
85 |
static const match_table_t tokens = { |
a80d923e1
|
86 87 88 |
{Opt_port, "port=%u"}, {Opt_rfdno, "rfdno=%u"}, {Opt_wfdno, "wfdno=%u"}, |
55762690e
|
89 |
{Opt_err, NULL}, |
a80d923e1
|
90 |
}; |
bd238fb43
|
91 |
|
8a0dc95fd
|
92 93 94 95 96 97 |
enum { Rworksched = 1, /* read work scheduled or running */ Rpending = 2, /* can read */ Wworksched = 4, /* write work scheduled or running */ Wpending = 8, /* can write */ }; |
992b3f1db
|
98 99 100 101 |
struct p9_poll_wait { struct p9_conn *conn; wait_queue_t wait; wait_queue_head_t *wait_addr; |
ee443996a
|
102 103 104 105 |
}; /** * struct p9_conn - fd mux connection state information |
ee443996a
|
106 |
* @mux_list: list link for mux to manage multiple connections (?) |
8b81ef589
|
107 |
* @client: reference to client instance for this connection |
ee443996a
|
108 |
* @err: error state |
ee443996a
|
109 110 |
* @req_list: accounting for requests which have been sent * @unsent_req_list: accounting for requests that haven't been sent |
1b0a763bd
|
111 112 113 |
* @req: current request being processed (if any) * @tmp_buf: temporary buffer to read in header * @rsize: amount to read for current frame |
ee443996a
|
114 115 116 117 118 |
* @rpos: read position in current frame * @rbuf: current read buffer * @wpos: write position for current frame * @wsize: amount of data to write for current frame * @wbuf: current write buffer |
0e15597eb
|
119 |
* @poll_pending_link: pending links to be polled per conn |
ee443996a
|
120 |
* @poll_wait: array of wait_q's for various worker threads |
ee443996a
|
121 122 123 124 125 126 |
* @pt: poll state * @rq: current read work * @wq: current write work * @wsched: ???? * */ |
8a0dc95fd
|
127 128 |
struct p9_conn { |
8a0dc95fd
|
129 |
struct list_head mux_list; |
8b81ef589
|
130 |
struct p9_client *client; |
8a0dc95fd
|
131 |
int err; |
8a0dc95fd
|
132 133 |
struct list_head req_list; struct list_head unsent_req_list; |
1b0a763bd
|
134 135 136 |
struct p9_req_t *req; char tmp_buf[7]; int rsize; |
8a0dc95fd
|
137 138 139 140 141 |
int rpos; char *rbuf; int wpos; int wsize; char *wbuf; |
992b3f1db
|
142 143 |
struct list_head poll_pending_link; struct p9_poll_wait poll_wait[MAXPOLLWADDR]; |
8a0dc95fd
|
144 145 146 147 148 |
poll_table pt; struct work_struct rq; struct work_struct wq; unsigned long wsched; }; |
aa70c585b
|
149 |
static void p9_poll_workfn(struct work_struct *work); |
992b3f1db
|
150 151 |
static DEFINE_SPINLOCK(p9_poll_lock); static LIST_HEAD(p9_poll_pending_list); |
aa70c585b
|
152 |
static DECLARE_WORK(p9_poll_work, p9_poll_workfn); |
8a0dc95fd
|
153 |
|
992b3f1db
|
154 |
static void p9_mux_poll_stop(struct p9_conn *m) |
8a0dc95fd
|
155 |
{ |
992b3f1db
|
156 157 |
unsigned long flags; int i; |
8a0dc95fd
|
158 |
|
992b3f1db
|
159 160 |
for (i = 0; i < ARRAY_SIZE(m->poll_wait); i++) { struct p9_poll_wait *pwait = &m->poll_wait[i]; |
8a0dc95fd
|
161 |
|
992b3f1db
|
162 163 164 |
if (pwait->wait_addr) { remove_wait_queue(pwait->wait_addr, &pwait->wait); pwait->wait_addr = NULL; |
8a0dc95fd
|
165 |
} |
8a0dc95fd
|
166 |
} |
992b3f1db
|
167 168 169 |
spin_lock_irqsave(&p9_poll_lock, flags); list_del_init(&m->poll_pending_link); spin_unlock_irqrestore(&p9_poll_lock, flags); |
8a0dc95fd
|
170 171 172 |
} /** |
5503ac565
|
173 174 175 |
* p9_conn_cancel - cancel all pending requests with error * @m: mux data * @err: error code |
8a0dc95fd
|
176 |
* |
8a0dc95fd
|
177 |
*/ |
ee443996a
|
178 |
|
51a87c552
|
179 |
static void p9_conn_cancel(struct p9_conn *m, int err) |
8a0dc95fd
|
180 |
{ |
673d62cda
|
181 |
struct p9_req_t *req, *rtmp; |
91b8534fa
|
182 |
unsigned long flags; |
5503ac565
|
183 |
LIST_HEAD(cancel_list); |
8a0dc95fd
|
184 |
|
5d3851530
|
185 186 |
p9_debug(P9_DEBUG_ERROR, "mux %p err %d ", m, err); |
7eb923b80
|
187 |
|
91b8534fa
|
188 |
spin_lock_irqsave(&m->client->lock, flags); |
7eb923b80
|
189 190 191 192 193 194 195 |
if (m->err) { spin_unlock_irqrestore(&m->client->lock, flags); return; } m->err = err; |
5503ac565
|
196 |
list_for_each_entry_safe(req, rtmp, &m->req_list, req_list) { |
673d62cda
|
197 198 199 |
req->status = REQ_STATUS_ERROR; if (!req->t_err) req->t_err = err; |
5503ac565
|
200 201 202 |
list_move(&req->req_list, &cancel_list); } list_for_each_entry_safe(req, rtmp, &m->unsent_req_list, req_list) { |
673d62cda
|
203 204 205 |
req->status = REQ_STATUS_ERROR; if (!req->t_err) req->t_err = err; |
5503ac565
|
206 |
list_move(&req->req_list, &cancel_list); |
8a0dc95fd
|
207 |
} |
91b8534fa
|
208 |
spin_unlock_irqrestore(&m->client->lock, flags); |
8a0dc95fd
|
209 |
|
5503ac565
|
210 |
list_for_each_entry_safe(req, rtmp, &cancel_list, req_list) { |
5d3851530
|
211 212 |
p9_debug(P9_DEBUG_ERROR, "call back req %p ", req); |
1bab88b23
|
213 |
list_del(&req->req_list); |
91b8534fa
|
214 |
p9_client_cb(m->client, req); |
8a0dc95fd
|
215 |
} |
8a0dc95fd
|
216 |
} |
29af9309d
|
217 |
static int |
5503ac565
|
218 |
p9_fd_poll(struct p9_client *client, struct poll_table_struct *pt) |
8a0dc95fd
|
219 |
{ |
5503ac565
|
220 221 |
int ret, n; struct p9_trans_fd *ts = NULL; |
8a0dc95fd
|
222 |
|
5503ac565
|
223 224 |
if (client && client->status == Connected) ts = client->trans; |
7dc5d24be
|
225 |
|
5503ac565
|
226 227 |
if (!ts) return -EREMOTEIO; |
7dc5d24be
|
228 |
|
5503ac565
|
229 230 |
if (!ts->rd->f_op || !ts->rd->f_op->poll) return -EIO; |
8a0dc95fd
|
231 |
|
5503ac565
|
232 233 |
if (!ts->wr->f_op || !ts->wr->f_op->poll) return -EIO; |
992b3f1db
|
234 |
|
5503ac565
|
235 236 237 |
ret = ts->rd->f_op->poll(ts->rd, pt); if (ret < 0) return ret; |
992b3f1db
|
238 |
|
5503ac565
|
239 240 241 242 243 244 245 246 |
if (ts->rd != ts->wr) { n = ts->wr->f_op->poll(ts->wr, pt); if (n < 0) return n; ret = (ret & ~POLLOUT) | (n & ~POLLIN); } return ret; |
992b3f1db
|
247 |
} |
8a0dc95fd
|
248 |
/** |
5503ac565
|
249 250 251 252 |
* p9_fd_read- read from a fd * @client: client instance * @v: buffer to receive data into * @len: size of receive buffer |
ee443996a
|
253 |
* |
8a0dc95fd
|
254 |
*/ |
ee443996a
|
255 |
|
5503ac565
|
256 |
static int p9_fd_read(struct p9_client *client, void *v, int len) |
8a0dc95fd
|
257 |
{ |
5503ac565
|
258 259 |
int ret; struct p9_trans_fd *ts = NULL; |
8a0dc95fd
|
260 |
|
5503ac565
|
261 262 |
if (client && client->status != Disconnected) ts = client->trans; |
8a0dc95fd
|
263 |
|
5503ac565
|
264 265 |
if (!ts) return -EREMOTEIO; |
8a0dc95fd
|
266 |
|
5503ac565
|
267 |
if (!(ts->rd->f_flags & O_NONBLOCK)) |
5d3851530
|
268 269 |
p9_debug(P9_DEBUG_ERROR, "blocking read ... "); |
8a0dc95fd
|
270 |
|
5503ac565
|
271 272 273 274 |
ret = kernel_read(ts->rd, ts->rd->f_pos, v, len); if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN) client->status = Disconnected; return ret; |
8a0dc95fd
|
275 276 277 |
} /** |
5503ac565
|
278 279 |
* p9_read_work - called when there is some data to be read from a transport * @work: container of work to be done |
ee443996a
|
280 |
* |
8a0dc95fd
|
281 |
*/ |
ee443996a
|
282 |
|
5503ac565
|
283 |
static void p9_read_work(struct work_struct *work) |
8a0dc95fd
|
284 |
{ |
5503ac565
|
285 286 |
int n, err; struct p9_conn *m; |
5503ac565
|
287 288 |
m = container_of(work, struct p9_conn, rq); |
8a0dc95fd
|
289 290 291 |
if (m->err < 0) return; |
5d3851530
|
292 293 |
p9_debug(P9_DEBUG_TRANS, "start mux %p pos %d ", m, m->rpos); |
8a0dc95fd
|
294 |
|
1b0a763bd
|
295 296 |
if (!m->rbuf) { m->rbuf = m->tmp_buf; |
5503ac565
|
297 |
m->rpos = 0; |
1b0a763bd
|
298 |
m->rsize = 7; /* start by reading header */ |
8a0dc95fd
|
299 |
} |
5503ac565
|
300 |
clear_bit(Rpending, &m->wsched); |
5d3851530
|
301 302 303 |
p9_debug(P9_DEBUG_TRANS, "read mux %p pos %d size: %d = %d ", m, m->rpos, m->rsize, m->rsize-m->rpos); |
5503ac565
|
304 |
err = p9_fd_read(m->client, m->rbuf + m->rpos, |
1b0a763bd
|
305 |
m->rsize - m->rpos); |
5d3851530
|
306 307 |
p9_debug(P9_DEBUG_TRANS, "mux %p got %d bytes ", m, err); |
5503ac565
|
308 |
if (err == -EAGAIN) { |
0462194d3
|
309 |
goto end_clear; |
8a0dc95fd
|
310 |
} |
8a0dc95fd
|
311 |
|
5503ac565
|
312 313 314 315 |
if (err <= 0) goto error; m->rpos += err; |
1b0a763bd
|
316 317 318 |
if ((!m->req) && (m->rpos == m->rsize)) { /* header read in */ u16 tag; |
5d3851530
|
319 320 |
p9_debug(P9_DEBUG_TRANS, "got new header "); |
1b0a763bd
|
321 322 |
n = le32_to_cpu(*(__le32 *) m->rbuf); /* read packet size */ |
5503ac565
|
323 |
if (n >= m->client->msize) { |
5d3851530
|
324 325 326 |
p9_debug(P9_DEBUG_ERROR, "requested packet size too big: %d ", n); |
5503ac565
|
327 328 329 |
err = -EIO; goto error; } |
1b0a763bd
|
330 |
tag = le16_to_cpu(*(__le16 *) (m->rbuf+5)); /* read tag */ |
5d3851530
|
331 332 333 |
p9_debug(P9_DEBUG_TRANS, "mux %p pkt: size: %d bytes tag: %d ", m, n, tag); |
1b0a763bd
|
334 335 |
m->req = p9_tag_lookup(m->client, tag); |
1bab88b23
|
336 337 |
if (!m->req || (m->req->status != REQ_STATUS_SENT && m->req->status != REQ_STATUS_FLSH)) { |
5d3851530
|
338 339 340 |
p9_debug(P9_DEBUG_ERROR, "Unexpected packet tag %d ", tag); |
1b0a763bd
|
341 342 343 344 345 346 |
err = -EIO; goto error; } if (m->req->rc == NULL) { m->req->rc = kmalloc(sizeof(struct p9_fcall) + |
eeff66ef6
|
347 |
m->client->msize, GFP_NOFS); |
1b0a763bd
|
348 349 350 351 352 353 354 355 356 357 |
if (!m->req->rc) { m->req = NULL; err = -ENOMEM; goto error; } } m->rbuf = (char *)m->req->rc + sizeof(struct p9_fcall); memcpy(m->rbuf, m->tmp_buf, m->rsize); m->rsize = n; } |
5503ac565
|
358 |
|
1b0a763bd
|
359 360 |
/* not an else because some packets (like clunk) have no payload */ if ((m->req) && (m->rpos == m->rsize)) { /* packet is read in */ |
5d3851530
|
361 362 |
p9_debug(P9_DEBUG_TRANS, "got new packet "); |
7eb923b80
|
363 |
spin_lock(&m->client->lock); |
1bab88b23
|
364 365 |
if (m->req->status != REQ_STATUS_ERROR) m->req->status = REQ_STATUS_RCVD; |
91b8534fa
|
366 |
list_del(&m->req->req_list); |
7eb923b80
|
367 |
spin_unlock(&m->client->lock); |
91b8534fa
|
368 |
p9_client_cb(m->client, m->req); |
1b0a763bd
|
369 370 371 |
m->rbuf = NULL; m->rpos = 0; m->rsize = 0; |
1b0a763bd
|
372 |
m->req = NULL; |
5503ac565
|
373 |
} |
0462194d3
|
374 375 |
end_clear: clear_bit(Rworksched, &m->wsched); |
5503ac565
|
376 377 378 379 380 |
if (!list_empty(&m->req_list)) { if (test_and_clear_bit(Rpending, &m->wsched)) n = POLLIN; else n = p9_fd_poll(m->client, NULL); |
0462194d3
|
381 |
if ((n & POLLIN) && !test_and_set_bit(Rworksched, &m->wsched)) { |
5d3851530
|
382 383 |
p9_debug(P9_DEBUG_TRANS, "sched read work %p ", m); |
61edeeed9
|
384 |
schedule_work(&m->rq); |
0462194d3
|
385 386 |
} } |
5503ac565
|
387 388 |
return; |
5503ac565
|
389 390 391 392 393 394 395 396 397 398 |
error: p9_conn_cancel(m, err); clear_bit(Rworksched, &m->wsched); } /** * p9_fd_write - write to a socket * @client: client instance * @v: buffer to send data from * @len: size of send buffer |
ee443996a
|
399 |
* |
8a0dc95fd
|
400 |
*/ |
ee443996a
|
401 |
|
5503ac565
|
402 |
static int p9_fd_write(struct p9_client *client, void *v, int len) |
8a0dc95fd
|
403 |
{ |
5503ac565
|
404 405 406 |
int ret; mm_segment_t oldfs; struct p9_trans_fd *ts = NULL; |
8a0dc95fd
|
407 |
|
5503ac565
|
408 409 |
if (client && client->status != Disconnected) ts = client->trans; |
8a0dc95fd
|
410 |
|
5503ac565
|
411 412 |
if (!ts) return -EREMOTEIO; |
8a0dc95fd
|
413 |
|
5503ac565
|
414 |
if (!(ts->wr->f_flags & O_NONBLOCK)) |
5d3851530
|
415 416 |
p9_debug(P9_DEBUG_ERROR, "blocking write ... "); |
992b3f1db
|
417 |
|
5503ac565
|
418 419 420 |
oldfs = get_fs(); set_fs(get_ds()); /* The cast to a user pointer is valid due to the set_fs() */ |
e3db6cb42
|
421 |
ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos); |
5503ac565
|
422 |
set_fs(oldfs); |
992b3f1db
|
423 |
|
5503ac565
|
424 425 426 |
if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN) client->status = Disconnected; return ret; |
8a0dc95fd
|
427 428 429 430 |
} /** * p9_write_work - called when a transport can send some data |
ee443996a
|
431 432 |
* @work: container for work to be done * |
8a0dc95fd
|
433 |
*/ |
ee443996a
|
434 |
|
8a0dc95fd
|
435 436 437 438 |
static void p9_write_work(struct work_struct *work) { int n, err; struct p9_conn *m; |
673d62cda
|
439 |
struct p9_req_t *req; |
8a0dc95fd
|
440 441 442 443 444 445 446 447 448 |
m = container_of(work, struct p9_conn, wq); if (m->err < 0) { clear_bit(Wworksched, &m->wsched); return; } if (!m->wsize) { |
759f42987
|
449 |
spin_lock(&m->client->lock); |
8a0dc95fd
|
450 451 |
if (list_empty(&m->unsent_req_list)) { clear_bit(Wworksched, &m->wsched); |
759f42987
|
452 |
spin_unlock(&m->client->lock); |
8a0dc95fd
|
453 454 |
return; } |
673d62cda
|
455 |
req = list_entry(m->unsent_req_list.next, struct p9_req_t, |
8a0dc95fd
|
456 |
req_list); |
673d62cda
|
457 |
req->status = REQ_STATUS_SENT; |
5d3851530
|
458 459 |
p9_debug(P9_DEBUG_TRANS, "move req %p ", req); |
8a0dc95fd
|
460 |
list_move_tail(&req->req_list, &m->req_list); |
8a0dc95fd
|
461 |
|
673d62cda
|
462 463 |
m->wbuf = req->tc->sdata; m->wsize = req->tc->size; |
8a0dc95fd
|
464 |
m->wpos = 0; |
673d62cda
|
465 |
spin_unlock(&m->client->lock); |
8a0dc95fd
|
466 |
} |
5d3851530
|
467 468 469 |
p9_debug(P9_DEBUG_TRANS, "mux %p pos %d size %d ", m, m->wpos, m->wsize); |
8a0dc95fd
|
470 |
clear_bit(Wpending, &m->wsched); |
8b81ef589
|
471 |
err = p9_fd_write(m->client, m->wbuf + m->wpos, m->wsize - m->wpos); |
5d3851530
|
472 473 |
p9_debug(P9_DEBUG_TRANS, "mux %p sent %d bytes ", m, err); |
584a8c13d
|
474 475 |
if (err == -EAGAIN) goto end_clear; |
8a0dc95fd
|
476 477 478 479 480 481 482 483 484 485 486 |
if (err < 0) goto error; else if (err == 0) { err = -EREMOTEIO; goto error; } m->wpos += err; if (m->wpos == m->wsize) m->wpos = m->wsize = 0; |
584a8c13d
|
487 488 |
end_clear: clear_bit(Wworksched, &m->wsched); |
1957b3a86
|
489 |
if (m->wsize || !list_empty(&m->unsent_req_list)) { |
8a0dc95fd
|
490 491 492 |
if (test_and_clear_bit(Wpending, &m->wsched)) n = POLLOUT; else |
8b81ef589
|
493 |
n = p9_fd_poll(m->client, NULL); |
8a0dc95fd
|
494 |
|
584a8c13d
|
495 496 |
if ((n & POLLOUT) && !test_and_set_bit(Wworksched, &m->wsched)) { |
5d3851530
|
497 498 |
p9_debug(P9_DEBUG_TRANS, "sched write work %p ", m); |
61edeeed9
|
499 |
schedule_work(&m->wq); |
584a8c13d
|
500 501 |
} } |
8a0dc95fd
|
502 503 504 505 506 507 508 |
return; error: p9_conn_cancel(m, err); clear_bit(Wworksched, &m->wsched); } |
95c961747
|
509 |
static int p9_pollwake(wait_queue_t *wait, unsigned int mode, int sync, void *key) |
8a0dc95fd
|
510 |
{ |
5503ac565
|
511 512 513 514 |
struct p9_poll_wait *pwait = container_of(wait, struct p9_poll_wait, wait); struct p9_conn *m = pwait->conn; unsigned long flags; |
8a0dc95fd
|
515 |
|
5503ac565
|
516 517 518 519 |
spin_lock_irqsave(&p9_poll_lock, flags); if (list_empty(&m->poll_pending_link)) list_add_tail(&m->poll_pending_link, &p9_poll_pending_list); spin_unlock_irqrestore(&p9_poll_lock, flags); |
8a0dc95fd
|
520 |
|
aa70c585b
|
521 522 |
schedule_work(&p9_poll_work); return 1; |
8a0dc95fd
|
523 524 525 |
} /** |
5503ac565
|
526 527 528 529 |
* p9_pollwait - add poll task to the wait queue * @filp: file pointer being polled * @wait_address: wait_q to block on * @p: poll state |
ee443996a
|
530 |
* |
5503ac565
|
531 |
* called by files poll operation to add v9fs-poll task to files wait queue |
8a0dc95fd
|
532 |
*/ |
ee443996a
|
533 |
|
5503ac565
|
534 535 |
static void p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p) |
8a0dc95fd
|
536 |
{ |
5503ac565
|
537 538 539 |
struct p9_conn *m = container_of(p, struct p9_conn, pt); struct p9_poll_wait *pwait = NULL; int i; |
8a0dc95fd
|
540 |
|
5503ac565
|
541 542 543 544 |
for (i = 0; i < ARRAY_SIZE(m->poll_wait); i++) { if (m->poll_wait[i].wait_addr == NULL) { pwait = &m->poll_wait[i]; break; |
8a0dc95fd
|
545 |
} |
8a0dc95fd
|
546 |
} |
5503ac565
|
547 |
if (!pwait) { |
5d3851530
|
548 549 |
p9_debug(P9_DEBUG_ERROR, "not enough wait_address slots "); |
8a0dc95fd
|
550 551 |
return; } |
5503ac565
|
552 553 554 555 556 |
pwait->conn = m; pwait->wait_addr = wait_address; init_waitqueue_func_entry(&pwait->wait, p9_pollwake); add_wait_queue(wait_address, &pwait->wait); } |
8a0dc95fd
|
557 |
|
5503ac565
|
558 559 560 561 562 563 |
/** * p9_conn_create - allocate and initialize the per-session mux data * @client: client instance * * Note: Creates the polling task if this is the first session. */ |
8a0dc95fd
|
564 |
|
5503ac565
|
565 566 |
static struct p9_conn *p9_conn_create(struct p9_client *client) { |
95820a365
|
567 |
int n; |
5503ac565
|
568 |
struct p9_conn *m; |
8a0dc95fd
|
569 |
|
5d3851530
|
570 571 |
p9_debug(P9_DEBUG_TRANS, "client %p msize %d ", client, client->msize); |
5503ac565
|
572 573 574 |
m = kzalloc(sizeof(struct p9_conn), GFP_KERNEL); if (!m) return ERR_PTR(-ENOMEM); |
8a0dc95fd
|
575 |
|
5503ac565
|
576 577 |
INIT_LIST_HEAD(&m->mux_list); m->client = client; |
8a0dc95fd
|
578 |
|
5503ac565
|
579 580 581 582 583 584 |
INIT_LIST_HEAD(&m->req_list); INIT_LIST_HEAD(&m->unsent_req_list); INIT_WORK(&m->rq, p9_read_work); INIT_WORK(&m->wq, p9_write_work); INIT_LIST_HEAD(&m->poll_pending_link); init_poll_funcptr(&m->pt, p9_pollwait); |
8a0dc95fd
|
585 |
|
5503ac565
|
586 587 |
n = p9_fd_poll(client, &m->pt); if (n & POLLIN) { |
5d3851530
|
588 589 |
p9_debug(P9_DEBUG_TRANS, "mux %p can read ", m); |
5503ac565
|
590 591 |
set_bit(Rpending, &m->wsched); } |
8a0dc95fd
|
592 |
|
5503ac565
|
593 |
if (n & POLLOUT) { |
5d3851530
|
594 595 |
p9_debug(P9_DEBUG_TRANS, "mux %p can write ", m); |
5503ac565
|
596 597 |
set_bit(Wpending, &m->wsched); } |
5503ac565
|
598 599 |
return m; } |
8a0dc95fd
|
600 |
|
5503ac565
|
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
/** * p9_poll_mux - polls a mux and schedules read or write works if necessary * @m: connection to poll * */ static void p9_poll_mux(struct p9_conn *m) { int n; if (m->err < 0) return; n = p9_fd_poll(m->client, NULL); if (n < 0 || n & (POLLERR | POLLHUP | POLLNVAL)) { |
5d3851530
|
616 617 |
p9_debug(P9_DEBUG_TRANS, "error mux %p err %d ", m, n); |
5503ac565
|
618 619 620 621 622 623 624 |
if (n >= 0) n = -ECONNRESET; p9_conn_cancel(m, n); } if (n & POLLIN) { set_bit(Rpending, &m->wsched); |
5d3851530
|
625 626 |
p9_debug(P9_DEBUG_TRANS, "mux %p can read ", m); |
5503ac565
|
627 |
if (!test_and_set_bit(Rworksched, &m->wsched)) { |
5d3851530
|
628 629 |
p9_debug(P9_DEBUG_TRANS, "sched read work %p ", m); |
61edeeed9
|
630 |
schedule_work(&m->rq); |
5503ac565
|
631 632 |
} } |
8a0dc95fd
|
633 |
|
5503ac565
|
634 635 |
if (n & POLLOUT) { set_bit(Wpending, &m->wsched); |
5d3851530
|
636 637 |
p9_debug(P9_DEBUG_TRANS, "mux %p can write ", m); |
f64f9e719
|
638 639 |
if ((m->wsize || !list_empty(&m->unsent_req_list)) && !test_and_set_bit(Wworksched, &m->wsched)) { |
5d3851530
|
640 641 |
p9_debug(P9_DEBUG_TRANS, "sched write work %p ", m); |
61edeeed9
|
642 |
schedule_work(&m->wq); |
5503ac565
|
643 644 |
} } |
8a0dc95fd
|
645 646 647 |
} /** |
91b8534fa
|
648 |
* p9_fd_request - send 9P request |
8a0dc95fd
|
649 650 |
* The function can sleep until the request is scheduled for sending. * The function can be interrupted. Return from the function is not |
91b8534fa
|
651 |
* a guarantee that the request is sent successfully. |
8a0dc95fd
|
652 |
* |
91b8534fa
|
653 654 |
* @client: client instance * @req: request to be sent |
ee443996a
|
655 |
* |
8a0dc95fd
|
656 |
*/ |
ee443996a
|
657 |
|
91b8534fa
|
658 |
static int p9_fd_request(struct p9_client *client, struct p9_req_t *req) |
8a0dc95fd
|
659 660 |
{ int n; |
91b8534fa
|
661 662 |
struct p9_trans_fd *ts = client->trans; struct p9_conn *m = ts->conn; |
8a0dc95fd
|
663 |
|
5d3851530
|
664 665 666 |
p9_debug(P9_DEBUG_TRANS, "mux %p task %p tcall %p id %d ", m, current, req->tc, req->tc->id); |
8a0dc95fd
|
667 |
if (m->err < 0) |
91b8534fa
|
668 |
return m->err; |
8a0dc95fd
|
669 |
|
91b8534fa
|
670 |
spin_lock(&client->lock); |
7eb923b80
|
671 |
req->status = REQ_STATUS_UNSENT; |
8a0dc95fd
|
672 |
list_add_tail(&req->req_list, &m->unsent_req_list); |
91b8534fa
|
673 |
spin_unlock(&client->lock); |
8a0dc95fd
|
674 675 676 677 |
if (test_and_clear_bit(Wpending, &m->wsched)) n = POLLOUT; else |
8b81ef589
|
678 |
n = p9_fd_poll(m->client, NULL); |
8a0dc95fd
|
679 680 |
if (n & POLLOUT && !test_and_set_bit(Wworksched, &m->wsched)) |
61edeeed9
|
681 |
schedule_work(&m->wq); |
8a0dc95fd
|
682 |
|
91b8534fa
|
683 |
return 0; |
8a0dc95fd
|
684 |
} |
91b8534fa
|
685 |
static int p9_fd_cancel(struct p9_client *client, struct p9_req_t *req) |
8a0dc95fd
|
686 |
{ |
7eb923b80
|
687 |
int ret = 1; |
8a0dc95fd
|
688 |
|
5d3851530
|
689 690 |
p9_debug(P9_DEBUG_TRANS, "client %p req %p ", client, req); |
8a0dc95fd
|
691 |
|
91b8534fa
|
692 |
spin_lock(&client->lock); |
91b8534fa
|
693 |
|
91b8534fa
|
694 |
if (req->status == REQ_STATUS_UNSENT) { |
1bab88b23
|
695 |
list_del(&req->req_list); |
91b8534fa
|
696 |
req->status = REQ_STATUS_FLSHD; |
7eb923b80
|
697 |
ret = 0; |
1bab88b23
|
698 699 |
} else if (req->status == REQ_STATUS_SENT) req->status = REQ_STATUS_FLSH; |
8a0dc95fd
|
700 |
|
7eb923b80
|
701 702 703 |
spin_unlock(&client->lock); return ret; |
8a0dc95fd
|
704 |
} |
8a0dc95fd
|
705 |
/** |
0e15597eb
|
706 707 708 |
* parse_opts - parse mount options into p9_fd_opts structure * @params: options string passed from mount * @opts: fd transport-specific structure to parse options into |
a80d923e1
|
709 |
* |
bb8ffdfc3
|
710 |
* Returns 0 upon success, -ERRNO upon failure |
a80d923e1
|
711 |
*/ |
bd238fb43
|
712 |
|
bb8ffdfc3
|
713 |
static int parse_opts(char *params, struct p9_fd_opts *opts) |
bd238fb43
|
714 |
{ |
a80d923e1
|
715 716 717 |
char *p; substring_t args[MAX_OPT_ARGS]; int option; |
d8c8a9e36
|
718 |
char *options, *tmp_options; |
bd238fb43
|
719 |
|
a80d923e1
|
720 721 722 |
opts->port = P9_PORT; opts->rfd = ~0; opts->wfd = ~0; |
bd238fb43
|
723 |
|
bb8ffdfc3
|
724 725 |
if (!params) return 0; |
d8c8a9e36
|
726 727 |
tmp_options = kstrdup(params, GFP_KERNEL); if (!tmp_options) { |
5d3851530
|
728 729 730 |
p9_debug(P9_DEBUG_ERROR, "failed to allocate copy of option string "); |
bb8ffdfc3
|
731 732 |
return -ENOMEM; } |
d8c8a9e36
|
733 |
options = tmp_options; |
bd238fb43
|
734 |
|
a80d923e1
|
735 736 |
while ((p = strsep(&options, ",")) != NULL) { int token; |
bb8ffdfc3
|
737 |
int r; |
a80d923e1
|
738 739 740 |
if (!*p) continue; token = match_token(p, tokens, args); |
15da4b161
|
741 742 743 |
if (token != Opt_err) { r = match_int(&args[0], &option); if (r < 0) { |
5d3851530
|
744 745 746 |
p9_debug(P9_DEBUG_ERROR, "integer field, but no integer? "); |
15da4b161
|
747 748 |
continue; } |
a80d923e1
|
749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
} switch (token) { case Opt_port: opts->port = option; break; case Opt_rfdno: opts->rfd = option; break; case Opt_wfdno: opts->wfd = option; break; default: continue; } |
bd238fb43
|
763 |
} |
d8c8a9e36
|
764 765 |
kfree(tmp_options); |
bb8ffdfc3
|
766 |
return 0; |
bd238fb43
|
767 |
} |
bd238fb43
|
768 |
|
8b81ef589
|
769 |
static int p9_fd_open(struct p9_client *client, int rfd, int wfd) |
bd238fb43
|
770 |
{ |
a80d923e1
|
771 772 773 774 |
struct p9_trans_fd *ts = kmalloc(sizeof(struct p9_trans_fd), GFP_KERNEL); if (!ts) return -ENOMEM; |
bd238fb43
|
775 |
|
a80d923e1
|
776 777 778 779 780 781 782 783 784 |
ts->rd = fget(rfd); ts->wr = fget(wfd); if (!ts->rd || !ts->wr) { if (ts->rd) fput(ts->rd); if (ts->wr) fput(ts->wr); kfree(ts); return -EIO; |
bd238fb43
|
785 |
} |
8b81ef589
|
786 787 |
client->trans = ts; client->status = Connected; |
bd238fb43
|
788 |
|
a80d923e1
|
789 |
return 0; |
bd238fb43
|
790 |
} |
bd238fb43
|
791 |
|
8b81ef589
|
792 |
static int p9_socket_open(struct p9_client *client, struct socket *csocket) |
bd238fb43
|
793 |
{ |
6b18662e2
|
794 |
struct p9_trans_fd *p; |
56b31d1c9
|
795 796 |
struct file *file; int ret; |
6b18662e2
|
797 798 799 800 |
p = kmalloc(sizeof(struct p9_trans_fd), GFP_KERNEL); if (!p) return -ENOMEM; |
bd238fb43
|
801 802 |
csocket->sk->sk_allocation = GFP_NOIO; |
aab174f0d
|
803 |
file = sock_alloc_file(csocket, 0, NULL); |
56b31d1c9
|
804 |
if (IS_ERR(file)) { |
5d3851530
|
805 806 807 |
pr_err("%s (%d): failed to map fd ", __func__, task_pid_nr(current)); |
6b18662e2
|
808 809 |
sock_release(csocket); kfree(p); |
56b31d1c9
|
810 |
return PTR_ERR(file); |
bd238fb43
|
811 |
} |
56b31d1c9
|
812 813 |
get_file(file); p->wr = p->rd = file; |
6b18662e2
|
814 815 |
client->trans = p; client->status = Connected; |
6b18662e2
|
816 817 818 819 820 821 822 823 |
p->rd->f_flags |= O_NONBLOCK; p->conn = p9_conn_create(client); if (IS_ERR(p->conn)) { ret = PTR_ERR(p->conn); p->conn = NULL; kfree(p); sockfd_put(csocket); |
bd238fb43
|
824 825 826 |
sockfd_put(csocket); return ret; } |
bd238fb43
|
827 828 |
return 0; } |
bd238fb43
|
829 |
/** |
5503ac565
|
830 831 |
* p9_mux_destroy - cancels all pending requests and frees mux resources * @m: mux to destroy |
bd238fb43
|
832 833 |
* */ |
ee443996a
|
834 |
|
5503ac565
|
835 |
static void p9_conn_destroy(struct p9_conn *m) |
bd238fb43
|
836 |
{ |
5d3851530
|
837 838 839 |
p9_debug(P9_DEBUG_TRANS, "mux %p prev %p next %p ", m, m->mux_list.prev, m->mux_list.next); |
bd238fb43
|
840 |
|
5503ac565
|
841 842 843 |
p9_mux_poll_stop(m); cancel_work_sync(&m->rq); cancel_work_sync(&m->wq); |
bd238fb43
|
844 |
|
5503ac565
|
845 |
p9_conn_cancel(m, -ECONNRESET); |
bd238fb43
|
846 |
|
5503ac565
|
847 |
m->client = NULL; |
5503ac565
|
848 |
kfree(m); |
bd238fb43
|
849 850 851 |
} /** |
8b81ef589
|
852 853 |
* p9_fd_close - shutdown file descriptor transport * @client: client instance |
bd238fb43
|
854 855 |
* */ |
ee443996a
|
856 |
|
8b81ef589
|
857 |
static void p9_fd_close(struct p9_client *client) |
bd238fb43
|
858 859 |
{ struct p9_trans_fd *ts; |
8b81ef589
|
860 |
if (!client) |
bd238fb43
|
861 |
return; |
8b81ef589
|
862 |
ts = client->trans; |
bd238fb43
|
863 864 |
if (!ts) return; |
8b81ef589
|
865 |
client->status = Disconnected; |
8a0dc95fd
|
866 |
p9_conn_destroy(ts->conn); |
bd238fb43
|
867 868 869 870 |
if (ts->rd) fput(ts->rd); if (ts->wr) fput(ts->wr); |
8b81ef589
|
871 |
|
bd238fb43
|
872 873 |
kfree(ts); } |
887b3ece6
|
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 |
/* * stolen from NFS - maybe should be made a generic function? */ static inline int valid_ipaddr4(const char *buf) { int rc, count, in[4]; rc = sscanf(buf, "%d.%d.%d.%d", &in[0], &in[1], &in[2], &in[3]); if (rc != 4) return -EINVAL; for (count = 0; count < 4; count++) { if (in[count] > 255) return -EINVAL; } return 0; } |
8b81ef589
|
890 891 |
static int p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args) |
a80d923e1
|
892 893 |
{ int err; |
a80d923e1
|
894 895 896 |
struct socket *csocket; struct sockaddr_in sin_server; struct p9_fd_opts opts; |
bb8ffdfc3
|
897 898 |
err = parse_opts(args, &opts); if (err < 0) |
8b81ef589
|
899 |
return err; |
a80d923e1
|
900 |
|
887b3ece6
|
901 |
if (valid_ipaddr4(addr) < 0) |
8b81ef589
|
902 |
return -EINVAL; |
887b3ece6
|
903 |
|
a80d923e1
|
904 |
csocket = NULL; |
a80d923e1
|
905 906 907 908 |
sin_server.sin_family = AF_INET; sin_server.sin_addr.s_addr = in_aton(addr); sin_server.sin_port = htons(opts.port); |
e75762fdc
|
909 910 |
err = __sock_create(read_pnet(¤t->nsproxy->net_ns), PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket, 1); |
6b18662e2
|
911 |
if (err) { |
5d3851530
|
912 913 914 |
pr_err("%s (%d): problem creating socket ", __func__, task_pid_nr(current)); |
6b18662e2
|
915 |
return err; |
a80d923e1
|
916 917 918 919 920 921 |
} err = csocket->ops->connect(csocket, (struct sockaddr *)&sin_server, sizeof(struct sockaddr_in), 0); if (err < 0) { |
5d3851530
|
922 923 924 |
pr_err("%s (%d): problem connecting socket to %s ", __func__, task_pid_nr(current), addr); |
a80d923e1
|
925 |
sock_release(csocket); |
6b18662e2
|
926 927 |
return err; } |
a80d923e1
|
928 |
|
6b18662e2
|
929 |
return p9_socket_open(client, csocket); |
a80d923e1
|
930 |
} |
8b81ef589
|
931 932 |
static int p9_fd_create_unix(struct p9_client *client, const char *addr, char *args) |
a80d923e1
|
933 934 935 936 |
{ int err; struct socket *csocket; struct sockaddr_un sun_server; |
a80d923e1
|
937 938 |
csocket = NULL; |
a80d923e1
|
939 |
|
cff6b8a9b
|
940 |
if (strlen(addr) >= UNIX_PATH_MAX) { |
5d3851530
|
941 942 943 |
pr_err("%s (%d): address too long: %s ", __func__, task_pid_nr(current), addr); |
6b18662e2
|
944 |
return -ENAMETOOLONG; |
a80d923e1
|
945 946 947 948 |
} sun_server.sun_family = PF_UNIX; strcpy(sun_server.sun_path, addr); |
e75762fdc
|
949 950 |
err = __sock_create(read_pnet(¤t->nsproxy->net_ns), PF_UNIX, SOCK_STREAM, 0, &csocket, 1); |
6b18662e2
|
951 |
if (err < 0) { |
5d3851530
|
952 953 954 |
pr_err("%s (%d): problem creating socket ", __func__, task_pid_nr(current)); |
6b18662e2
|
955 956 |
return err; } |
a80d923e1
|
957 958 959 |
err = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server, sizeof(struct sockaddr_un) - 1, 0); if (err < 0) { |
5d3851530
|
960 961 962 |
pr_err("%s (%d): problem connecting socket: %s: %d ", __func__, task_pid_nr(current), addr, err); |
a80d923e1
|
963 |
sock_release(csocket); |
6b18662e2
|
964 965 |
return err; } |
a80d923e1
|
966 |
|
6b18662e2
|
967 |
return p9_socket_open(client, csocket); |
a80d923e1
|
968 |
} |
8b81ef589
|
969 970 |
static int p9_fd_create(struct p9_client *client, const char *addr, char *args) |
a80d923e1
|
971 972 |
{ int err; |
a80d923e1
|
973 |
struct p9_fd_opts opts; |
6b18662e2
|
974 |
struct p9_trans_fd *p; |
a80d923e1
|
975 976 977 978 |
parse_opts(args, &opts); if (opts.rfd == ~0 || opts.wfd == ~0) { |
5d3851530
|
979 980 |
pr_err("Insufficient options for proto=fd "); |
8b81ef589
|
981 |
return -ENOPROTOOPT; |
a80d923e1
|
982 |
} |
8b81ef589
|
983 |
err = p9_fd_open(client, opts.rfd, opts.wfd); |
a80d923e1
|
984 |
if (err < 0) |
6b18662e2
|
985 |
return err; |
a80d923e1
|
986 |
|
8b81ef589
|
987 988 |
p = (struct p9_trans_fd *) client->trans; p->conn = p9_conn_create(client); |
8a0dc95fd
|
989 990 991 |
if (IS_ERR(p->conn)) { err = PTR_ERR(p->conn); p->conn = NULL; |
6b18662e2
|
992 993 994 |
fput(p->rd); fput(p->wr); return err; |
8a0dc95fd
|
995 |
} |
8b81ef589
|
996 |
return 0; |
a80d923e1
|
997 998 999 1000 1001 1002 |
} static struct p9_trans_module p9_tcp_trans = { .name = "tcp", .maxsize = MAX_SOCK_BUF, .def = 1, |
8b81ef589
|
1003 1004 |
.create = p9_fd_create_tcp, .close = p9_fd_close, |
91b8534fa
|
1005 1006 |
.request = p9_fd_request, .cancel = p9_fd_cancel, |
72029fe85
|
1007 |
.owner = THIS_MODULE, |
a80d923e1
|
1008 1009 1010 1011 1012 1013 |
}; static struct p9_trans_module p9_unix_trans = { .name = "unix", .maxsize = MAX_SOCK_BUF, .def = 0, |
8b81ef589
|
1014 1015 |
.create = p9_fd_create_unix, .close = p9_fd_close, |
91b8534fa
|
1016 1017 |
.request = p9_fd_request, .cancel = p9_fd_cancel, |
72029fe85
|
1018 |
.owner = THIS_MODULE, |
a80d923e1
|
1019 1020 1021 1022 1023 1024 |
}; static struct p9_trans_module p9_fd_trans = { .name = "fd", .maxsize = MAX_SOCK_BUF, .def = 0, |
8b81ef589
|
1025 1026 |
.create = p9_fd_create, .close = p9_fd_close, |
91b8534fa
|
1027 1028 |
.request = p9_fd_request, .cancel = p9_fd_cancel, |
72029fe85
|
1029 |
.owner = THIS_MODULE, |
a80d923e1
|
1030 |
}; |
5503ac565
|
1031 1032 1033 1034 1035 1036 1037 1038 |
/** * p9_poll_proc - poll worker thread * @a: thread state and arguments * * polls all v9fs transports for new events and queues the appropriate * work to the work queue * */ |
aa70c585b
|
1039 |
static void p9_poll_workfn(struct work_struct *work) |
5503ac565
|
1040 1041 |
{ unsigned long flags; |
5d3851530
|
1042 1043 |
p9_debug(P9_DEBUG_TRANS, "start %p ", current); |
aa70c585b
|
1044 |
|
5503ac565
|
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 |
spin_lock_irqsave(&p9_poll_lock, flags); while (!list_empty(&p9_poll_pending_list)) { struct p9_conn *conn = list_first_entry(&p9_poll_pending_list, struct p9_conn, poll_pending_link); list_del_init(&conn->poll_pending_link); spin_unlock_irqrestore(&p9_poll_lock, flags); p9_poll_mux(conn); spin_lock_irqsave(&p9_poll_lock, flags); } spin_unlock_irqrestore(&p9_poll_lock, flags); |
5d3851530
|
1058 1059 |
p9_debug(P9_DEBUG_TRANS, "finish "); |
5503ac565
|
1060 |
} |
887b3ece6
|
1061 |
int p9_trans_fd_init(void) |
a80d923e1
|
1062 1063 1064 1065 |
{ v9fs_register_trans(&p9_tcp_trans); v9fs_register_trans(&p9_unix_trans); v9fs_register_trans(&p9_fd_trans); |
3387b804d
|
1066 |
return 0; |
a80d923e1
|
1067 |
} |
72029fe85
|
1068 1069 1070 |
void p9_trans_fd_exit(void) { |
43829731d
|
1071 |
flush_work(&p9_poll_work); |
72029fe85
|
1072 1073 1074 1075 |
v9fs_unregister_trans(&p9_tcp_trans); v9fs_unregister_trans(&p9_unix_trans); v9fs_unregister_trans(&p9_fd_trans); } |