diff options
author | Tejun Heo <tj@kernel.org> | 2008-11-26 06:03:55 -0500 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2008-11-26 06:03:55 -0500 |
commit | 0d179aa59285ceef529c125e181cbb79ff5245c2 (patch) | |
tree | c044a2df496b362eee7dec5b176a14b0937b0725 /fs/fuse | |
parent | b93f858ab2a4bee779c360002f313ad6c3504cdc (diff) |
fuse: separate out fuse_conn_init() from new_conn()
Separate out fuse_conn_init() from new_conn() and while at it
initialize fuse_conn->entry during conn initialization.
This will be used by CUSE.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/fuse_i.h | 5 | ||||
-rw-r--r-- | fs/fuse/inode.c | 119 |
2 files changed, 67 insertions, 57 deletions
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index c08e7e890923..eb488d48b833 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -650,6 +650,11 @@ void fuse_invalidate_entry_cache(struct dentry *entry); | |||
650 | struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); | 650 | struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); |
651 | 651 | ||
652 | /** | 652 | /** |
653 | * Initialize fuse_conn | ||
654 | */ | ||
655 | int fuse_conn_init(struct fuse_conn *fc, struct super_block *sb); | ||
656 | |||
657 | /** | ||
653 | * Release reference to fuse_conn | 658 | * Release reference to fuse_conn |
654 | */ | 659 | */ |
655 | void fuse_conn_put(struct fuse_conn *fc); | 660 | void fuse_conn_put(struct fuse_conn *fc); |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index ee91639c6d35..6c9fa03aa367 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -462,70 +462,69 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
462 | return 0; | 462 | return 0; |
463 | } | 463 | } |
464 | 464 | ||
465 | static struct fuse_conn *new_conn(struct super_block *sb) | 465 | int fuse_conn_init(struct fuse_conn *fc, struct super_block *sb) |
466 | { | 466 | { |
467 | struct fuse_conn *fc; | ||
468 | int err; | 467 | int err; |
469 | 468 | ||
470 | fc = kzalloc(sizeof(*fc), GFP_KERNEL); | 469 | memset(fc, 0, sizeof(*fc)); |
471 | if (fc) { | 470 | spin_lock_init(&fc->lock); |
472 | spin_lock_init(&fc->lock); | 471 | mutex_init(&fc->inst_mutex); |
473 | mutex_init(&fc->inst_mutex); | 472 | atomic_set(&fc->count, 1); |
474 | atomic_set(&fc->count, 1); | 473 | init_waitqueue_head(&fc->waitq); |
475 | init_waitqueue_head(&fc->waitq); | 474 | init_waitqueue_head(&fc->blocked_waitq); |
476 | init_waitqueue_head(&fc->blocked_waitq); | 475 | init_waitqueue_head(&fc->reserved_req_waitq); |
477 | init_waitqueue_head(&fc->reserved_req_waitq); | 476 | INIT_LIST_HEAD(&fc->pending); |
478 | INIT_LIST_HEAD(&fc->pending); | 477 | INIT_LIST_HEAD(&fc->processing); |
479 | INIT_LIST_HEAD(&fc->processing); | 478 | INIT_LIST_HEAD(&fc->io); |
480 | INIT_LIST_HEAD(&fc->io); | 479 | INIT_LIST_HEAD(&fc->interrupts); |
481 | INIT_LIST_HEAD(&fc->interrupts); | 480 | INIT_LIST_HEAD(&fc->bg_queue); |
482 | INIT_LIST_HEAD(&fc->bg_queue); | 481 | INIT_LIST_HEAD(&fc->entry); |
483 | atomic_set(&fc->num_waiting, 0); | 482 | atomic_set(&fc->num_waiting, 0); |
484 | fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; | 483 | fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; |
485 | fc->bdi.unplug_io_fn = default_unplug_io_fn; | 484 | fc->bdi.unplug_io_fn = default_unplug_io_fn; |
486 | /* fuse does it's own writeback accounting */ | 485 | /* fuse does it's own writeback accounting */ |
487 | fc->bdi.capabilities = BDI_CAP_NO_ACCT_WB; | 486 | fc->bdi.capabilities = BDI_CAP_NO_ACCT_WB; |
488 | fc->khctr = 0; | 487 | fc->khctr = 0; |
489 | fc->polled_files = RB_ROOT; | 488 | fc->polled_files = RB_ROOT; |
490 | fc->dev = sb->s_dev; | 489 | fc->dev = sb->s_dev; |
491 | err = bdi_init(&fc->bdi); | 490 | err = bdi_init(&fc->bdi); |
492 | if (err) | 491 | if (err) |
493 | goto error_kfree; | 492 | goto error_mutex_destroy; |
494 | if (sb->s_bdev) { | 493 | if (sb->s_bdev) { |
495 | err = bdi_register(&fc->bdi, NULL, "%u:%u-fuseblk", | 494 | err = bdi_register(&fc->bdi, NULL, "%u:%u-fuseblk", |
496 | MAJOR(fc->dev), MINOR(fc->dev)); | 495 | MAJOR(fc->dev), MINOR(fc->dev)); |
497 | } else { | 496 | } else { |
498 | err = bdi_register_dev(&fc->bdi, fc->dev); | 497 | err = bdi_register_dev(&fc->bdi, fc->dev); |
499 | } | ||
500 | if (err) | ||
501 | goto error_bdi_destroy; | ||
502 | /* | ||
503 | * For a single fuse filesystem use max 1% of dirty + | ||
504 | * writeback threshold. | ||
505 | * | ||
506 | * This gives about 1M of write buffer for memory maps on a | ||
507 | * machine with 1G and 10% dirty_ratio, which should be more | ||
508 | * than enough. | ||
509 | * | ||
510 | * Privileged users can raise it by writing to | ||
511 | * | ||
512 | * /sys/class/bdi/<bdi>/max_ratio | ||
513 | */ | ||
514 | bdi_set_max_ratio(&fc->bdi, 1); | ||
515 | fc->reqctr = 0; | ||
516 | fc->blocked = 1; | ||
517 | fc->attr_version = 1; | ||
518 | get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); | ||
519 | } | 498 | } |
520 | return fc; | 499 | if (err) |
500 | goto error_bdi_destroy; | ||
501 | /* | ||
502 | * For a single fuse filesystem use max 1% of dirty + | ||
503 | * writeback threshold. | ||
504 | * | ||
505 | * This gives about 1M of write buffer for memory maps on a | ||
506 | * machine with 1G and 10% dirty_ratio, which should be more | ||
507 | * than enough. | ||
508 | * | ||
509 | * Privileged users can raise it by writing to | ||
510 | * | ||
511 | * /sys/class/bdi/<bdi>/max_ratio | ||
512 | */ | ||
513 | bdi_set_max_ratio(&fc->bdi, 1); | ||
514 | fc->reqctr = 0; | ||
515 | fc->blocked = 1; | ||
516 | fc->attr_version = 1; | ||
517 | get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); | ||
518 | |||
519 | return 0; | ||
521 | 520 | ||
522 | error_bdi_destroy: | 521 | error_bdi_destroy: |
523 | bdi_destroy(&fc->bdi); | 522 | bdi_destroy(&fc->bdi); |
524 | error_kfree: | 523 | error_mutex_destroy: |
525 | mutex_destroy(&fc->inst_mutex); | 524 | mutex_destroy(&fc->inst_mutex); |
526 | kfree(fc); | 525 | return err; |
527 | return NULL; | ||
528 | } | 526 | } |
527 | EXPORT_SYMBOL_GPL(fuse_conn_init); | ||
529 | 528 | ||
530 | void fuse_conn_put(struct fuse_conn *fc) | 529 | void fuse_conn_put(struct fuse_conn *fc) |
531 | { | 530 | { |
@@ -828,10 +827,16 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
828 | if (file->f_op != &fuse_dev_operations) | 827 | if (file->f_op != &fuse_dev_operations) |
829 | return -EINVAL; | 828 | return -EINVAL; |
830 | 829 | ||
831 | fc = new_conn(sb); | 830 | fc = kmalloc(sizeof(*fc), GFP_KERNEL); |
832 | if (!fc) | 831 | if (!fc) |
833 | return -ENOMEM; | 832 | return -ENOMEM; |
834 | 833 | ||
834 | err = fuse_conn_init(fc, sb); | ||
835 | if (err) { | ||
836 | kfree(fc); | ||
837 | return err; | ||
838 | } | ||
839 | |||
835 | fc->flags = d.flags; | 840 | fc->flags = d.flags; |
836 | fc->user_id = d.user_id; | 841 | fc->user_id = d.user_id; |
837 | fc->group_id = d.group_id; | 842 | fc->group_id = d.group_id; |