mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Direct io on block device has performance regression on 2.6.x kernel - pseudo disk driver
@ 2005-03-09  1:51 Chen, Kenneth W
  0 siblings, 0 replies; only message in thread
From: Chen, Kenneth W @ 2005-03-09  1:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: 'Andrew Morton', 'Jens Axboe'

The pseudo disk driver that I used to stress the kernel I/O stack
(anything above block layer, AIO/DIO/BIO).

- Ken



diff -Nur zero/blknull.c blknull/blknull.c
--- zero/blknull.c	1969-12-31 16:00:00.000000000 -0800
+++ blknull/blknull.c	2005-03-03 19:04:07.000000000 -0800
@@ -0,0 +1,97 @@
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/major.h>
+#include <linux/fs.h>
+#include <linux/bio.h>
+#include <linux/blkpg.h>
+#include <linux/spinlock.h>
+
+#include <linux/blkdev.h>
+#include <linux/genhd.h>
+
+#define BLK_NULL_MAJOR	60
+#define BLK_NULL_NAME	"blknull"
+
+
+MODULE_AUTHOR("Ken Chen");
+MODULE_DESCRIPTION("null block driver");
+MODULE_LICENSE("GPL");
+
+
+spinlock_t driver_lock;
+struct request_queue *q;
+struct gendisk *disk;
+
+
+static int null_open(struct inode *inode, struct file *filp)
+{
+	return 0;
+}
+
+static int null_release(struct inode *inode, struct file *filp)
+{
+	return 0;
+}
+
+static struct block_device_operations null_fops = {
+	.owner		= THIS_MODULE,
+	.open		= null_open,
+	.release	= null_release,
+};
+
+static void do_null_request(request_queue_t *q)
+{
+	struct request *req;
+
+	while (!blk_queue_plugged(q)) {
+		req = elv_next_request(q);
+		if (!req)
+			break;
+
+		blkdev_dequeue_request(req);
+
+		end_that_request_first(req, 1, req->nr_sectors);
+		end_that_request_last(req);
+	}
+}
+
+static int __init init_blk_null_module(void)
+{
+
+	if (register_blkdev(BLK_NULL_MAJOR, BLK_NULL_NAME)) {
+		printk(KERN_ERR "Unable to register null blk device\n");
+		return 0;
+	}
+
+	spin_lock_init(&driver_lock);
+	q = blk_init_queue(do_null_request, &driver_lock);
+	if (q) {
+		disk = alloc_disk(1);
+
+		if (disk) {
+			disk->major = BLK_NULL_MAJOR;
+			disk->first_minor = 0;
+			disk->fops = &null_fops;
+			disk->capacity = 1<<30;
+			disk->queue = q;
+			memcpy(disk->disk_name, BLK_NULL_NAME, sizeof(BLK_NULL_NAME));
+			add_disk(disk);
+			return 1;
+		}
+
+		blk_cleanup_queue(q);
+	}
+	unregister_blkdev(BLK_NULL_MAJOR, BLK_NULL_NAME);
+	return 0;
+}
+
+static void __exit exit_blk_null_module(void)
+{
+	del_gendisk(disk);
+	blk_cleanup_queue(q);
+	unregister_blkdev(BLK_NULL_MAJOR, BLK_NULL_NAME);
+}
+
+module_init(init_blk_null_module);
+module_exit(exit_blk_null_module);
diff -Nur zero/Makefile blknull/Makefile
--- zero/Makefile	1969-12-31 16:00:00.000000000 -0800
+++ blknull/Makefile	2005-03-03 18:42:55.000000000 -0800
@@ -0,0 +1 @@
+obj-m := blknull.o




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-03-09  2:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-09  1:51 Direct io on block device has performance regression on 2.6.x kernel - pseudo disk driver Chen, Kenneth W

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®