PATCH for a little bug in deadline-iosched.c

From: Juergen Quade
Date: Tue Dec 28 2004 - 10:58:33 EST


There is some (obvious) mess with "unsigned int" and "int" in
the deadline-io-scheduler (sysfs-section). Try to change
the attribute "writes_starved":

root@ezs-mobil:/sys/block/hda/queue# cat scheduler
noop anticipatory [deadline]
root@ezs-mobil:/sys/block/hda/queue# cd iosched/
root@ezs-mobil:/sys/block/hda/queue/iosched# ls
fifo_batch front_merges read_expire write_expire writes_starved
root@ezs-mobil:/sys/block/hda/queue/iosched# cat writes_starved
2
root@ezs-mobil:/sys/block/hda/queue/iosched# echo 4 >writes_starved
root@ezs-mobil:/sys/block/hda/queue/iosched# cat writes_starved
-2147483648
root@ezs-mobil:/sys/block/hda/queue/iosched#

Because all attribute-variables are defined as "int", the patch
below changes them to "int". Now it works as expected...

Juergen.

P.S.: Does it really make sense to allow a negative "writes_starved"?

==========================================================================
Signed-off-by: Juergen Quade <quade@xxxxxxx>

--- linux-2.6.10/drivers/block/deadline-iosched.c.org 2004-12-28 16:19:46.000000000 +0100
+++ linux-2.6.10/drivers/block/deadline-iosched.c 2004-12-28 16:36:59.000000000 +0100
@@ -791,24 +791,24 @@
};

static ssize_t
-deadline_var_show(unsigned int var, char *page)
+deadline_var_show(int var, char *page)
{
return sprintf(page, "%d\n", var);
}

static ssize_t
-deadline_var_store(unsigned int *var, const char *page, size_t count)
+deadline_var_store(int *var, const char *page, size_t count)
{
char *p = (char *) page;

- *var = simple_strtoul(p, &p, 10);
+ *var = (int)simple_strtol(p, &p, 10);
return count;
}

#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
static ssize_t __FUNC(struct deadline_data *dd, char *page) \
{ \
- unsigned int __data = __VAR; \
+ int __data = __VAR; \
if (__CONV) \
__data = jiffies_to_msecs(__data); \
return deadline_var_show(__data, (page)); \
@@ -823,7 +823,7 @@
#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
static ssize_t __FUNC(struct deadline_data *dd, const char *page, size_t count) \
{ \
- unsigned int __data; \
+ int __data; \
int ret = deadline_var_store(&__data, (page), count); \
if (__data < (MIN)) \
__data = (MIN); \
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/