public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 9/11] 2.6.18-mm3 pktcdvd: packet buffer control
@ 2006-10-03 15:26 Thomas Maier
  0 siblings, 0 replies; only message in thread
From: Thomas Maier @ 2006-10-03 15:26 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org; +Cc: petero2@telia.com, akpm@osdl.org

[-- Attachment #1: Type: text/plain, Size: 284 bytes --]

Hello,

this patch allows to control the amount of packet buffers per
device.
See the Documentation/* files in the patch for further infos.

http://people.freenet.de/BalaGi/download/pktcdvd-9-packet-buffers_2.6.18.patch

Signed-off-by: Thomas Maier<balagi@justmail.de>

-Thomas Maier

[-- Attachment #2: pktcdvd-9-packet-buffers_2.6.18.patch --]
[-- Type: application/octet-stream, Size: 4645 bytes --]

diff -urpN 8-wqueue-congestion/Documentation/ABI/testing/sysfs-class-pktcdvd 9-packet-buffers/Documentation/ABI/testing/sysfs-class-pktcdvd
--- 8-wqueue-congestion/Documentation/ABI/testing/sysfs-class-pktcdvd	2006-10-03 15:46:49.000000000 +0200
+++ 9-packet-buffers/Documentation/ABI/testing/sysfs-class-pktcdvd	2006-10-03 13:48:22.000000000 +0200
@@ -22,6 +22,10 @@ these files in the sysfs:
 
     device_map     (0444)  Shows the device mapping in format:
                              pktcdvd[0-7] <pktdevid> <blkdevid>
+
+    packet_buffers (0644)  Number of concurrent packets per
+                           pktcdvd device. Used for new created
+                           devices.
 	
 /sys/class/pktcdvd/pktcdvd[0-7]/
     dev                   (0444) Device id
diff -urpN 8-wqueue-congestion/drivers/block/pktcdvd.c 9-packet-buffers/drivers/block/pktcdvd.c
--- 8-wqueue-congestion/drivers/block/pktcdvd.c	2006-10-03 13:54:43.000000000 +0200
+++ 9-packet-buffers/drivers/block/pktcdvd.c	2006-10-03 13:54:54.000000000 +0200
@@ -90,6 +90,7 @@ static struct pktcdvd_device *pkt_devs[M
 static int pktdev_major = 0; /* default: dynamic major number */
 static int write_congestion_on  = PKT_WRITE_CONGESTION_ON;
 static int write_congestion_off = PKT_WRITE_CONGESTION_OFF;
+static int packet_buffers = PKT_BUFFERS_DEFAULT;
 static struct mutex ctl_mutex;	/* Serialize open/close/setup/teardown */
 static mempool_t *psd_pool;
 
@@ -152,6 +153,14 @@ static void init_write_congestion_marks(
 	}
 }
 
+static void init_packet_buffers(int *n)
+{
+	if (*n < 1)
+		*n = 1;
+	else if (*n > 128)
+		*n = 128;
+}
+
 static void pkt_count_states(struct pktcdvd_device *pd, int *states)
 {
 	struct packet_data *pkt;
@@ -201,6 +210,7 @@ static int pkt_print_info(struct pktcdvd
 	else
 		msg = "Unknown";
 	PRINT("\tblock mode:\t\t%s\n", msg);
+	PRINT("\tconcurrent packets:\t%d\n", packet_buffers);
 
 	PRINT("\nStatistics:\n");
 	PRINT("\tpackets started:\t%lu\n", pd->stats.pkt_started);
@@ -465,6 +475,7 @@ static void pkt_sysfs_dev_remove(struct 
                      add            map block device
                      remove         unmap packet dev
                      device_map     show mappings
+                     packet_buffers number of packet buffers per dev
  *******************************************************************/
 
 static void class_pktcdvd_release(struct class *cls)
@@ -491,6 +502,11 @@ static ssize_t class_pktcdvd_show_map(st
 	return n;
 }
 
+static ssize_t class_pktcdvd_show_pb(struct class *c, char *data)
+{
+	return sprintf(data, "%d\n", packet_buffers);
+}
+
 static ssize_t class_pktcdvd_store_add(struct class *c, const char *buf,
 					size_t count)
 {
@@ -515,10 +531,26 @@ static ssize_t class_pktcdvd_store_remov
 	return -EINVAL;
 }
 
+static ssize_t class_pktcdvd_store_pb(struct class *c, const char *buf,
+					size_t count)
+{
+	int val;
+	DECLARE_BUF_AS_STRING(dbuf, buf, count);
+	if (sscanf(dbuf, "%d", &val) == 1) {
+		mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
+		init_packet_buffers(&val);
+		packet_buffers = val;
+		mutex_unlock(&ctl_mutex);
+		return count;
+	}
+	return -EINVAL;
+}
+
 static struct class_attribute class_pktcdvd_attrs[] = {
  __ATTR(add,            0200, NULL, class_pktcdvd_store_add),
  __ATTR(remove,         0200, NULL, class_pktcdvd_store_remove),
  __ATTR(device_map,     0444, class_pktcdvd_show_map, NULL),
+ __ATTR(packet_buffers, 0644, class_pktcdvd_show_pb, class_pktcdvd_store_pb),
  __ATTR_NULL
 };
 
@@ -2603,7 +2635,7 @@ static int pkt_open_dev(struct pktcdvd_d
 		goto out_unclaim;
 
 	if (write) {
-		if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) {
+		if (!pkt_grow_pktlist(pd, packet_buffers)) {
 			printk(DRIVER_NAME": not enough memory for buffers\n");
 			ret = -ENOMEM;
 			goto out_unclaim;
@@ -3180,6 +3212,7 @@ static int __init pkt_init(void)
 
 	init_write_congestion_marks(&write_congestion_off,
 				&write_congestion_on);
+	init_packet_buffers(&packet_buffers);
 
 	mutex_init(&ctl_mutex);
 
diff -urpN 8-wqueue-congestion/include/linux/pktcdvd.h 9-packet-buffers/include/linux/pktcdvd.h
--- 8-wqueue-congestion/include/linux/pktcdvd.h	2006-10-03 13:37:01.000000000 +0200
+++ 9-packet-buffers/include/linux/pktcdvd.h	2006-10-03 13:47:56.000000000 +0200
@@ -122,6 +122,13 @@ struct pkt_ctrl_command {
 #define PKT_USE_PROCFS  0
 #endif
 
+/* use concurrent packets per device */
+#ifdef CONFIG_CDROM_PKTCDVD_BUFFERS
+#define PKT_BUFFERS_DEFAULT CONFIG_CDROM_PKTCDVD_BUFFERS
+#else
+#define PKT_BUFFERS_DEFAULT 8
+#endif
+
 
 /* default bio write queue congestion marks */
 #define PKT_WRITE_CONGESTION_ON 5000

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

only message in thread, other threads:[~2006-10-03 15:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-03 15:26 [PATCH 9/11] 2.6.18-mm3 pktcdvd: packet buffer control Thomas Maier

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