root / hw / 9pfs / virtio-9p-coth.h @ 737e150e
History | View | Annotate | Download (4.9 kB)
1 | 39c0564e | Venkateswararao Jujjuri (JV) | /*
|
---|---|---|---|
2 | 39c0564e | Venkateswararao Jujjuri (JV) | * Virtio 9p backend
|
3 | 39c0564e | Venkateswararao Jujjuri (JV) | *
|
4 | 39c0564e | Venkateswararao Jujjuri (JV) | * Copyright IBM, Corp. 2010
|
5 | 39c0564e | Venkateswararao Jujjuri (JV) | *
|
6 | 39c0564e | Venkateswararao Jujjuri (JV) | * Authors:
|
7 | 39c0564e | Venkateswararao Jujjuri (JV) | * Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
|
8 | 39c0564e | Venkateswararao Jujjuri (JV) | * Venkateswararao Jujjuri(JV) <jvrao@linux.vnet.ibm.com>
|
9 | 39c0564e | Venkateswararao Jujjuri (JV) | *
|
10 | 39c0564e | Venkateswararao Jujjuri (JV) | * This work is licensed under the terms of the GNU GPL, version 2. See
|
11 | 39c0564e | Venkateswararao Jujjuri (JV) | * the COPYING file in the top-level directory.
|
12 | 39c0564e | Venkateswararao Jujjuri (JV) | *
|
13 | 39c0564e | Venkateswararao Jujjuri (JV) | */
|
14 | 39c0564e | Venkateswararao Jujjuri (JV) | |
15 | 39c0564e | Venkateswararao Jujjuri (JV) | #ifndef _QEMU_VIRTIO_9P_COTH_H
|
16 | 39c0564e | Venkateswararao Jujjuri (JV) | #define _QEMU_VIRTIO_9P_COTH_H
|
17 | 39c0564e | Venkateswararao Jujjuri (JV) | |
18 | 39c0564e | Venkateswararao Jujjuri (JV) | #include "qemu-thread.h" |
19 | 737e150e | Paolo Bonzini | #include "block/coroutine.h" |
20 | ff06030f | Venkateswararao Jujjuri (JV) | #include "virtio-9p.h" |
21 | 39c0564e | Venkateswararao Jujjuri (JV) | #include <glib.h> |
22 | 39c0564e | Venkateswararao Jujjuri (JV) | |
23 | 39c0564e | Venkateswararao Jujjuri (JV) | typedef struct V9fsThPool { |
24 | 39c0564e | Venkateswararao Jujjuri (JV) | int rfd;
|
25 | 39c0564e | Venkateswararao Jujjuri (JV) | int wfd;
|
26 | 39c0564e | Venkateswararao Jujjuri (JV) | GThreadPool *pool; |
27 | 39c0564e | Venkateswararao Jujjuri (JV) | GAsyncQueue *completed; |
28 | 39c0564e | Venkateswararao Jujjuri (JV) | } V9fsThPool; |
29 | 39c0564e | Venkateswararao Jujjuri (JV) | |
30 | 39c0564e | Venkateswararao Jujjuri (JV) | /*
|
31 | 39c0564e | Venkateswararao Jujjuri (JV) | * we want to use bottom half because we want to make sure the below
|
32 | 39c0564e | Venkateswararao Jujjuri (JV) | * sequence of events.
|
33 | 39c0564e | Venkateswararao Jujjuri (JV) | *
|
34 | 39c0564e | Venkateswararao Jujjuri (JV) | * 1. Yield the coroutine in the QEMU thread.
|
35 | 39c0564e | Venkateswararao Jujjuri (JV) | * 2. Submit the coroutine to a worker thread.
|
36 | 39c0564e | Venkateswararao Jujjuri (JV) | * 3. Enter the coroutine in the worker thread.
|
37 | 39c0564e | Venkateswararao Jujjuri (JV) | * we cannot swap step 1 and 2, because that would imply worker thread
|
38 | 39c0564e | Venkateswararao Jujjuri (JV) | * can enter coroutine while step1 is still running
|
39 | 39c0564e | Venkateswararao Jujjuri (JV) | */
|
40 | 39c0564e | Venkateswararao Jujjuri (JV) | #define v9fs_co_run_in_worker(code_block) \
|
41 | 39c0564e | Venkateswararao Jujjuri (JV) | do { \
|
42 | 39c0564e | Venkateswararao Jujjuri (JV) | QEMUBH *co_bh; \ |
43 | 39c0564e | Venkateswararao Jujjuri (JV) | co_bh = qemu_bh_new(co_run_in_worker_bh, \ |
44 | 39c0564e | Venkateswararao Jujjuri (JV) | qemu_coroutine_self()); \ |
45 | 39c0564e | Venkateswararao Jujjuri (JV) | qemu_bh_schedule(co_bh); \ |
46 | 39c0564e | Venkateswararao Jujjuri (JV) | /* \
|
47 | 66a0a2cb | Dong Xu Wang | * yield in qemu thread and re-enter back \
|
48 | 39c0564e | Venkateswararao Jujjuri (JV) | * in glib worker thread \
|
49 | 39c0564e | Venkateswararao Jujjuri (JV) | */ \
|
50 | 39c0564e | Venkateswararao Jujjuri (JV) | qemu_coroutine_yield(); \ |
51 | 39c0564e | Venkateswararao Jujjuri (JV) | qemu_bh_delete(co_bh); \ |
52 | 39c0564e | Venkateswararao Jujjuri (JV) | code_block; \ |
53 | 39c0564e | Venkateswararao Jujjuri (JV) | /* re-enter back to qemu thread */ \
|
54 | 39c0564e | Venkateswararao Jujjuri (JV) | qemu_coroutine_yield(); \ |
55 | 39c0564e | Venkateswararao Jujjuri (JV) | } while (0) |
56 | 39c0564e | Venkateswararao Jujjuri (JV) | |
57 | 39c0564e | Venkateswararao Jujjuri (JV) | extern void co_run_in_worker_bh(void *); |
58 | 39c0564e | Venkateswararao Jujjuri (JV) | extern int v9fs_init_worker_threads(void); |
59 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_readlink(V9fsPDU *, V9fsPath *, V9fsString *); |
60 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_readdir_r(V9fsPDU *, V9fsFidState *, |
61 | 5f524c1e | Harsh Prateek Bora | struct dirent *, struct dirent **result); |
62 | bccacf6c | Aneesh Kumar K.V | extern off_t v9fs_co_telldir(V9fsPDU *, V9fsFidState *);
|
63 | bccacf6c | Aneesh Kumar K.V | extern void v9fs_co_seekdir(V9fsPDU *, V9fsFidState *, off_t); |
64 | bccacf6c | Aneesh Kumar K.V | extern void v9fs_co_rewinddir(V9fsPDU *, V9fsFidState *); |
65 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_statfs(V9fsPDU *, V9fsPath *, struct statfs *); |
66 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_lstat(V9fsPDU *, V9fsPath *, struct stat *); |
67 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_chmod(V9fsPDU *, V9fsPath *, mode_t); |
68 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_utimensat(V9fsPDU *, V9fsPath *, struct timespec [2]); |
69 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_chown(V9fsPDU *, V9fsPath *, uid_t, gid_t); |
70 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_truncate(V9fsPDU *, V9fsPath *, off_t); |
71 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_llistxattr(V9fsPDU *, V9fsPath *, void *, size_t); |
72 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_lgetxattr(V9fsPDU *, V9fsPath *, |
73 | 1ceffa54 | Aneesh Kumar K.V | V9fsString *, void *, size_t);
|
74 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_mknod(V9fsPDU *, V9fsFidState *, V9fsString *, uid_t, |
75 | 02cb7f3a | Aneesh Kumar K.V | gid_t, dev_t, mode_t, struct stat *);
|
76 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_mkdir(V9fsPDU *, V9fsFidState *, V9fsString *, |
77 | 02cb7f3a | Aneesh Kumar K.V | mode_t, uid_t, gid_t, struct stat *);
|
78 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_remove(V9fsPDU *, V9fsPath *); |
79 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_rename(V9fsPDU *, V9fsPath *, V9fsPath *); |
80 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_unlinkat(V9fsPDU *, V9fsPath *, V9fsString *, int flags); |
81 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_renameat(V9fsPDU *, V9fsPath *, V9fsString *, |
82 | 2289be19 | Aneesh Kumar K.V | V9fsPath *, V9fsString *); |
83 | cc720ddb | Aneesh Kumar K.V | extern int v9fs_co_fstat(V9fsPDU *, V9fsFidState *, struct stat *); |
84 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_opendir(V9fsPDU *, V9fsFidState *); |
85 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_open(V9fsPDU *, V9fsFidState *, int); |
86 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_open2(V9fsPDU *, V9fsFidState *, V9fsString *, |
87 | 02cb7f3a | Aneesh Kumar K.V | gid_t, int, int, struct stat *); |
88 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_lsetxattr(V9fsPDU *, V9fsPath *, V9fsString *, |
89 | bed4352c | Aneesh Kumar K.V | void *, size_t, int); |
90 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_lremovexattr(V9fsPDU *, V9fsPath *, V9fsString *); |
91 | cc720ddb | Aneesh Kumar K.V | extern int v9fs_co_closedir(V9fsPDU *, V9fsFidOpenState *); |
92 | cc720ddb | Aneesh Kumar K.V | extern int v9fs_co_close(V9fsPDU *, V9fsFidOpenState *); |
93 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_fsync(V9fsPDU *, V9fsFidState *, int); |
94 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_symlink(V9fsPDU *, V9fsFidState *, V9fsString *, |
95 | 02cb7f3a | Aneesh Kumar K.V | const char *, gid_t, struct stat *); |
96 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_link(V9fsPDU *, V9fsFidState *, |
97 | 2289be19 | Aneesh Kumar K.V | V9fsFidState *, V9fsString *); |
98 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_pwritev(V9fsPDU *, V9fsFidState *, |
99 | f6b3c976 | Aneesh Kumar K.V | struct iovec *, int, int64_t); |
100 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_preadv(V9fsPDU *, V9fsFidState *, |
101 | 7eafdcc9 | Aneesh Kumar K.V | struct iovec *, int, int64_t); |
102 | bccacf6c | Aneesh Kumar K.V | extern int v9fs_co_name_to_path(V9fsPDU *, V9fsPath *, |
103 | 2289be19 | Aneesh Kumar K.V | const char *, V9fsPath *); |
104 | e06a765e | Harsh Prateek Bora | extern int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t, |
105 | e06a765e | Harsh Prateek Bora | V9fsStatDotl *v9stat); |
106 | e06a765e | Harsh Prateek Bora | |
107 | 39c0564e | Venkateswararao Jujjuri (JV) | #endif |