2.6.18-mm3 pktcdvd: packet buffer control
PATCH 9/11 2.6.18-mm3 pktcdvd: packet buffer control
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<[email protected]>
-Thomas Maier
Documentation/ABI/testing/sysfs-class-pktcdvd +4 -0
@@ -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
drivers/block/pktcdvd.c +34 -1
@@ -90,6 +90,7 @@ static struct pktcdvd_device *pkt_devs[Mstatic 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 pktcdvdelse msg ="Unknown" ;"\tblock mode:\t\t%s\n" , msg); +"\tconcurrent packets:\t%d\n" , packet_buffers);"\nStatistics:\n" );"\tpackets started:\t%lu\n" , pd->stats.pkt_started);
@@ -465,6 +475,7 @@ static void pkt_sysfs_dev_remove(structadd 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(streturn 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_removreturn -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);
include/linux/pktcdvd.h +7 -0
@@ -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