aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/mux.c
diff options
context:
space:
mode:
authorLatchesar Ionkov <lucho@ionkov.net>2006-01-08 04:05:02 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-08 23:14:06 -0500
commit1dac06b20dcc8078dab037bd70652c69c67ba672 (patch)
tree34436f474074aa2760604555e3aa9b02df18fce2 /fs/9p/mux.c
parent531b1094b74365dcc55fa464d28a9a2497ae825d (diff)
[PATCH] v9fs: handle kthread_create failure, minor bugfixes
- remove unnecessary -ENOMEM assignments - return correct value when buf_check_size for second time in a buffer - handle failures when create_workqueue and kthread_create are called - use kzalloc instead of kmalloc/memset 0 - v9fs_str_copy and v9fs_str_compare were buggy, were used only in one place, correct the logic and move it to the place it is used. Signed-off-by: Latchesar Ionkov <lucho@ionkov.net> Cc: Eric Van Hensbergen <ericvh@ericvh.myip.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/9p/mux.c')
-rw-r--r--fs/9p/mux.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/fs/9p/mux.c b/fs/9p/mux.c
index f21cf5083973..945cb368d451 100644
--- a/fs/9p/mux.c
+++ b/fs/9p/mux.c
@@ -102,8 +102,6 @@ struct v9fs_mux_rpc {
102 wait_queue_head_t wqueue; 102 wait_queue_head_t wqueue;
103}; 103};
104 104
105extern int v9fs_errstr2errno(char *str, int len);
106
107static int v9fs_poll_proc(void *); 105static int v9fs_poll_proc(void *);
108static void v9fs_read_work(void *); 106static void v9fs_read_work(void *);
109static void v9fs_write_work(void *); 107static void v9fs_write_work(void *);
@@ -119,7 +117,7 @@ static int v9fs_mux_num;
119static int v9fs_mux_poll_task_num; 117static int v9fs_mux_poll_task_num;
120static struct v9fs_mux_poll_task v9fs_mux_poll_tasks[100]; 118static struct v9fs_mux_poll_task v9fs_mux_poll_tasks[100];
121 119
122void v9fs_mux_global_init(void) 120int v9fs_mux_global_init(void)
123{ 121{
124 int i; 122 int i;
125 123
@@ -127,6 +125,10 @@ void v9fs_mux_global_init(void)
127 v9fs_mux_poll_tasks[i].task = NULL; 125 v9fs_mux_poll_tasks[i].task = NULL;
128 126
129 v9fs_mux_wq = create_workqueue("v9fs"); 127 v9fs_mux_wq = create_workqueue("v9fs");
128 if (!v9fs_mux_wq)
129 return -ENOMEM;
130
131 return 0;
130} 132}
131 133
132void v9fs_mux_global_exit(void) 134void v9fs_mux_global_exit(void)
@@ -156,10 +158,11 @@ inline int v9fs_mux_calc_poll_procs(int muxnum)
156 return n; 158 return n;
157} 159}
158 160
159static void v9fs_mux_poll_start(struct v9fs_mux_data *m) 161static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
160{ 162{
161 int i, n; 163 int i, n;
162 struct v9fs_mux_poll_task *vpt, *vptlast; 164 struct v9fs_mux_poll_task *vpt, *vptlast;
165 struct task_struct *pproc;
163 166
164 dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num, 167 dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num,
165 v9fs_mux_poll_task_num); 168 v9fs_mux_poll_task_num);
@@ -171,13 +174,16 @@ static void v9fs_mux_poll_start(struct v9fs_mux_data *m)
171 if (v9fs_mux_poll_tasks[i].task == NULL) { 174 if (v9fs_mux_poll_tasks[i].task == NULL) {
172 vpt = &v9fs_mux_poll_tasks[i]; 175 vpt = &v9fs_mux_poll_tasks[i];
173 dprintk(DEBUG_MUX, "create proc %p\n", vpt); 176 dprintk(DEBUG_MUX, "create proc %p\n", vpt);
174 vpt->task = 177 pproc = kthread_create(v9fs_poll_proc, vpt,
175 kthread_create(v9fs_poll_proc, vpt,
176 "v9fs-poll"); 178 "v9fs-poll");
177 INIT_LIST_HEAD(&vpt->mux_list); 179
178 vpt->muxnum = 0; 180 if (!IS_ERR(pproc)) {
179 v9fs_mux_poll_task_num++; 181 vpt->task = pproc;
180 wake_up_process(vpt->task); 182 INIT_LIST_HEAD(&vpt->mux_list);
183 vpt->muxnum = 0;
184 v9fs_mux_poll_task_num++;
185 wake_up_process(vpt->task);
186 }
181 break; 187 break;
182 } 188 }
183 } 189 }
@@ -207,16 +213,21 @@ static void v9fs_mux_poll_start(struct v9fs_mux_data *m)
207 } 213 }
208 214
209 if (i >= ARRAY_SIZE(v9fs_mux_poll_tasks)) { 215 if (i >= ARRAY_SIZE(v9fs_mux_poll_tasks)) {
216 if (vptlast == NULL)
217 return -ENOMEM;
218
210 dprintk(DEBUG_MUX, "put in proc %d\n", i); 219 dprintk(DEBUG_MUX, "put in proc %d\n", i);
211 list_add(&m->mux_list, &vptlast->mux_list); 220 list_add(&m->mux_list, &vptlast->mux_list);
212 vptlast->muxnum++; 221 vptlast->muxnum++;
213 m->poll_task = vpt; 222 m->poll_task = vptlast;
214 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); 223 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
215 init_poll_funcptr(&m->pt, v9fs_pollwait); 224 init_poll_funcptr(&m->pt, v9fs_pollwait);
216 } 225 }
217 226
218 v9fs_mux_num++; 227 v9fs_mux_num++;
219 down(&v9fs_mux_task_lock); 228 down(&v9fs_mux_task_lock);
229
230 return 0;
220} 231}
221 232
222static void v9fs_mux_poll_stop(struct v9fs_mux_data *m) 233static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
@@ -283,7 +294,10 @@ struct v9fs_mux_data *v9fs_mux_init(struct v9fs_transport *trans, int msize,
283 INIT_WORK(&m->wq, v9fs_write_work, m); 294 INIT_WORK(&m->wq, v9fs_write_work, m);
284 m->wsched = 0; 295 m->wsched = 0;
285 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); 296 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
286 v9fs_mux_poll_start(m); 297 m->poll_task = NULL;
298 n = v9fs_mux_poll_start(m);
299 if (n)
300 return ERR_PTR(n);
287 301
288 n = trans->poll(trans, &m->pt); 302 n = trans->poll(trans, &m->pt);
289 if (n & POLLIN) { 303 if (n & POLLIN) {