Commit 0d179aa5 authored by Tejun Heo's avatar Tejun Heo Committed by Miklos Szeredi
Browse files

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: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
parent b93f858a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -649,6 +649,11 @@ void fuse_invalidate_entry_cache(struct dentry *entry);
 */
struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);

/**
 * Initialize fuse_conn
 */
int fuse_conn_init(struct fuse_conn *fc, struct super_block *sb);

/**
 * Release reference to fuse_conn
 */
+62 −57
Original line number Diff line number Diff line
@@ -462,13 +462,11 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt)
	return 0;
}

static struct fuse_conn *new_conn(struct super_block *sb)
int fuse_conn_init(struct fuse_conn *fc, struct super_block *sb)
{
	struct fuse_conn *fc;
	int err;

	fc = kzalloc(sizeof(*fc), GFP_KERNEL);
	if (fc) {
	memset(fc, 0, sizeof(*fc));
	spin_lock_init(&fc->lock);
	mutex_init(&fc->inst_mutex);
	atomic_set(&fc->count, 1);
@@ -480,6 +478,7 @@ static struct fuse_conn *new_conn(struct super_block *sb)
	INIT_LIST_HEAD(&fc->io);
	INIT_LIST_HEAD(&fc->interrupts);
	INIT_LIST_HEAD(&fc->bg_queue);
	INIT_LIST_HEAD(&fc->entry);
	atomic_set(&fc->num_waiting, 0);
	fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
	fc->bdi.unplug_io_fn = default_unplug_io_fn;
@@ -490,7 +489,7 @@ static struct fuse_conn *new_conn(struct super_block *sb)
	fc->dev = sb->s_dev;
	err = bdi_init(&fc->bdi);
	if (err)
			goto error_kfree;
		goto error_mutex_destroy;
	if (sb->s_bdev) {
		err = bdi_register(&fc->bdi, NULL, "%u:%u-fuseblk",
				   MAJOR(fc->dev), MINOR(fc->dev));
@@ -516,16 +515,16 @@ static struct fuse_conn *new_conn(struct super_block *sb)
	fc->blocked = 1;
	fc->attr_version = 1;
	get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key));
	}
	return fc;

	return 0;

 error_bdi_destroy:
	bdi_destroy(&fc->bdi);
error_kfree:
 error_mutex_destroy:
	mutex_destroy(&fc->inst_mutex);
	kfree(fc);
	return NULL;
	return err;
}
EXPORT_SYMBOL_GPL(fuse_conn_init);

void fuse_conn_put(struct fuse_conn *fc)
{
@@ -828,10 +827,16 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
	if (file->f_op != &fuse_dev_operations)
		return -EINVAL;

	fc = new_conn(sb);
	fc = kmalloc(sizeof(*fc), GFP_KERNEL);
	if (!fc)
		return -ENOMEM;

	err = fuse_conn_init(fc, sb);
	if (err) {
		kfree(fc);
		return err;
	}

	fc->flags = d.flags;
	fc->user_id = d.user_id;
	fc->group_id = d.group_id;