lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 14 Apr 2009 10:54:52 +0900
From:	Tejun Heo <tj@...nel.org>
To:	linux-kernel@...r.kernel.org, fuse-devel@...ts.sourceforge.net,
	miklos@...redi.hu
Cc:	Tejun Heo <tj@...nel.org>
Subject: [PATCH 4/6] FUSE: update fuse_conn_init() and separate out fuse_conn_kill()

Update fuse_conn_init() such that it takes @devt and @bdev instead of
@sb and skip bdi registration if device number is not available.
Also, separate out fuse_conn_kill() from fuse_put_super() and export
it.

These will be used to implement cuse.

Signed-off-by: Tejun Heo <tj@...nel.org>
---
 fs/fuse/fuse_i.h |    7 ++++++-
 fs/fuse/inode.c  |   49 +++++++++++++++++++++++++++++--------------------
 2 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 016a745..d2643df 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -679,7 +679,12 @@ 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);
+int fuse_conn_init(struct fuse_conn *fc, dev_t devt, struct block_device *bdev);
+
+/**
+ * Destroy fuse_conn
+ */
+void fuse_conn_kill(struct fuse_conn *fc);
 
 /**
  * Release reference to fuse_conn
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 459b73d..699b228 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -279,20 +279,7 @@ static void fuse_put_super(struct super_block *sb)
 	struct fuse_conn *fc = get_fuse_conn_super(sb);
 
 	fuse_send_destroy(fc);
-	spin_lock(&fc->lock);
-	fc->connected = 0;
-	fc->blocked = 0;
-	spin_unlock(&fc->lock);
-	/* Flush all readers on this fs */
-	kill_fasync(&fc->fasync, SIGIO, POLL_IN);
-	wake_up_all(&fc->waitq);
-	wake_up_all(&fc->blocked_waitq);
-	wake_up_all(&fc->reserved_req_waitq);
-	mutex_lock(&fuse_mutex);
-	list_del(&fc->entry);
-	fuse_ctl_remove_conn(fc);
-	mutex_unlock(&fuse_mutex);
-	bdi_destroy(&fc->bdi);
+	fuse_conn_kill(fc);
 	fuse_conn_put(fc);
 }
 
@@ -463,7 +450,7 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt)
 	return 0;
 }
 
-int fuse_conn_init(struct fuse_conn *fc, struct super_block *sb)
+int fuse_conn_init(struct fuse_conn *fc, dev_t devt, struct block_device *bdev)
 {
 	int err;
 
@@ -487,18 +474,21 @@ int fuse_conn_init(struct fuse_conn *fc, struct super_block *sb)
 	fc->bdi.capabilities = BDI_CAP_NO_ACCT_WB;
 	fc->khctr = 0;
 	fc->polled_files = RB_ROOT;
-	fc->dev = sb->s_dev;
+	fc->dev = devt;
 	err = bdi_init(&fc->bdi);
+
 	if (err)
 		goto error_mutex_destroy;
-	if (sb->s_bdev) {
+
+	if (bdev)
 		err = bdi_register(&fc->bdi, NULL, "%u:%u-fuseblk",
 				   MAJOR(fc->dev), MINOR(fc->dev));
-	} else {
+	else if (fc->dev)
 		err = bdi_register_dev(&fc->bdi, fc->dev);
-	}
+
 	if (err)
 		goto error_bdi_destroy;
+
 	/*
 	 * For a single fuse filesystem use max 1% of dirty +
 	 * writeback threshold.
@@ -527,6 +517,25 @@ int fuse_conn_init(struct fuse_conn *fc, struct super_block *sb)
 }
 EXPORT_SYMBOL_GPL(fuse_conn_init);
 
+void fuse_conn_kill(struct fuse_conn *fc)
+{
+	spin_lock(&fc->lock);
+	fc->connected = 0;
+	fc->blocked = 0;
+	spin_unlock(&fc->lock);
+	/* Flush all readers on this fs */
+	kill_fasync(&fc->fasync, SIGIO, POLL_IN);
+	wake_up_all(&fc->waitq);
+	wake_up_all(&fc->blocked_waitq);
+	wake_up_all(&fc->reserved_req_waitq);
+	mutex_lock(&fuse_mutex);
+	list_del(&fc->entry);
+	fuse_ctl_remove_conn(fc);
+	mutex_unlock(&fuse_mutex);
+	bdi_destroy(&fc->bdi);
+}
+EXPORT_SYMBOL_GPL(fuse_conn_kill);
+
 void fuse_conn_put(struct fuse_conn *fc)
 {
 	if (atomic_dec_and_test(&fc->count)) {
@@ -840,7 +849,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
 	if (!fc)
 		goto err_fput;
 
-	err = fuse_conn_init(fc, sb);
+	err = fuse_conn_init(fc, sb->s_dev, sb->s_bdev);
 	if (err) {
 		kfree(fc);
 		goto err_fput;
-- 
1.6.0.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ