[PATCH] fuse: move INIT handling to inode.c

Now the INIT requests can be completely handled in inode.c and the
fuse_send_init() function need not be global any more.

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Miklos Szeredi and committed by Linus Torvalds 9b9a0469 64c6d8ed

+45 -50
-45
fs/fuse/dev.c
··· 154 154 spin_unlock(&fuse_lock); 155 155 } 156 156 157 - static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) 158 - { 159 - int i; 160 - struct fuse_init_out *arg = &req->misc.init_out; 161 - 162 - if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION) 163 - fc->conn_error = 1; 164 - else { 165 - fc->minor = arg->minor; 166 - fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; 167 - } 168 - 169 - /* After INIT reply is received other requests can go 170 - out. So do (FUSE_MAX_OUTSTANDING - 1) number of 171 - up()s on outstanding_sem. The last up() is done in 172 - fuse_putback_request() */ 173 - for (i = 1; i < FUSE_MAX_OUTSTANDING; i++) 174 - up(&fc->outstanding_sem); 175 - 176 - fuse_put_request(fc, req); 177 - } 178 - 179 157 /* 180 158 * This function is called when a request is finished. Either a reply 181 159 * has arrived or it was interrupted (and not yet sent) or some error ··· 342 364 background_request(fc, req); 343 365 spin_unlock(&fuse_lock); 344 366 request_send_nowait(fc, req); 345 - } 346 - 347 - void fuse_send_init(struct fuse_conn *fc) 348 - { 349 - /* This is called from fuse_read_super() so there's guaranteed 350 - to be exactly one request available */ 351 - struct fuse_req *req = fuse_get_request(fc); 352 - struct fuse_init_in *arg = &req->misc.init_in; 353 - arg->major = FUSE_KERNEL_VERSION; 354 - arg->minor = FUSE_KERNEL_MINOR_VERSION; 355 - req->in.h.opcode = FUSE_INIT; 356 - req->in.numargs = 1; 357 - req->in.args[0].size = sizeof(*arg); 358 - req->in.args[0].value = arg; 359 - req->out.numargs = 1; 360 - /* Variable length arguement used for backward compatibility 361 - with interface version < 7.5. Rest of init_out is zeroed 362 - by do_get_request(), so a short reply is not a problem */ 363 - req->out.argvar = 1; 364 - req->out.args[0].size = sizeof(struct fuse_init_out); 365 - req->out.args[0].value = &req->misc.init_out; 366 - req->end = process_init_reply; 367 - request_send_background(fc, req); 368 367 } 369 368 370 369 /*
-5
fs/fuse/fuse_i.h
··· 480 480 * Invalidate inode attributes 481 481 */ 482 482 void fuse_invalidate_attr(struct inode *inode); 483 - 484 - /** 485 - * Send the INIT message 486 - */ 487 - void fuse_send_init(struct fuse_conn *fc);
+45
fs/fuse/inode.c
··· 464 464 .show_options = fuse_show_options, 465 465 }; 466 466 467 + static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) 468 + { 469 + int i; 470 + struct fuse_init_out *arg = &req->misc.init_out; 471 + 472 + if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION) 473 + fc->conn_error = 1; 474 + else { 475 + fc->minor = arg->minor; 476 + fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; 477 + } 478 + 479 + /* After INIT reply is received other requests can go 480 + out. So do (FUSE_MAX_OUTSTANDING - 1) number of 481 + up()s on outstanding_sem. The last up() is done in 482 + fuse_putback_request() */ 483 + for (i = 1; i < FUSE_MAX_OUTSTANDING; i++) 484 + up(&fc->outstanding_sem); 485 + 486 + fuse_put_request(fc, req); 487 + } 488 + 489 + static void fuse_send_init(struct fuse_conn *fc) 490 + { 491 + /* This is called from fuse_read_super() so there's guaranteed 492 + to be exactly one request available */ 493 + struct fuse_req *req = fuse_get_request(fc); 494 + struct fuse_init_in *arg = &req->misc.init_in; 495 + arg->major = FUSE_KERNEL_VERSION; 496 + arg->minor = FUSE_KERNEL_MINOR_VERSION; 497 + req->in.h.opcode = FUSE_INIT; 498 + req->in.numargs = 1; 499 + req->in.args[0].size = sizeof(*arg); 500 + req->in.args[0].value = arg; 501 + req->out.numargs = 1; 502 + /* Variable length arguement used for backward compatibility 503 + with interface version < 7.5. Rest of init_out is zeroed 504 + by do_get_request(), so a short reply is not a problem */ 505 + req->out.argvar = 1; 506 + req->out.args[0].size = sizeof(struct fuse_init_out); 507 + req->out.args[0].value = &req->misc.init_out; 508 + req->end = process_init_reply; 509 + request_send_background(fc, req); 510 + } 511 + 467 512 static unsigned long long conn_id(void) 468 513 { 469 514 static unsigned long long ctr = 1;