Commit e572ec7e authored by Al Viro's avatar Al Viro

[PATCH] fix rmmod problems with elevator attributes, clean them up

parent 3d1ab40f
...@@ -1725,7 +1725,7 @@ as_var_store(unsigned long *var, const char *page, size_t count) ...@@ -1725,7 +1725,7 @@ as_var_store(unsigned long *var, const char *page, size_t count)
return count; return count;
} }
static ssize_t as_est_show(elevator_t *e, char *page) static ssize_t est_time_show(elevator_t *e, char *page)
{ {
struct as_data *ad = e->elevator_data; struct as_data *ad = e->elevator_data;
int pos = 0; int pos = 0;
...@@ -1748,11 +1748,11 @@ static ssize_t __FUNC(elevator_t *e, char *page) \ ...@@ -1748,11 +1748,11 @@ static ssize_t __FUNC(elevator_t *e, char *page) \
struct as_data *ad = e->elevator_data; \ struct as_data *ad = e->elevator_data; \
return as_var_show(jiffies_to_msecs((__VAR)), (page)); \ return as_var_show(jiffies_to_msecs((__VAR)), (page)); \
} }
SHOW_FUNCTION(as_readexpire_show, ad->fifo_expire[REQ_SYNC]); SHOW_FUNCTION(as_read_expire_show, ad->fifo_expire[REQ_SYNC]);
SHOW_FUNCTION(as_writeexpire_show, ad->fifo_expire[REQ_ASYNC]); SHOW_FUNCTION(as_write_expire_show, ad->fifo_expire[REQ_ASYNC]);
SHOW_FUNCTION(as_anticexpire_show, ad->antic_expire); SHOW_FUNCTION(as_antic_expire_show, ad->antic_expire);
SHOW_FUNCTION(as_read_batchexpire_show, ad->batch_expire[REQ_SYNC]); SHOW_FUNCTION(as_read_batch_expire_show, ad->batch_expire[REQ_SYNC]);
SHOW_FUNCTION(as_write_batchexpire_show, ad->batch_expire[REQ_ASYNC]); SHOW_FUNCTION(as_write_batch_expire_show, ad->batch_expire[REQ_ASYNC]);
#undef SHOW_FUNCTION #undef SHOW_FUNCTION
#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX) \ #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX) \
...@@ -1767,53 +1767,26 @@ static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \ ...@@ -1767,53 +1767,26 @@ static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \
*(__PTR) = msecs_to_jiffies(*(__PTR)); \ *(__PTR) = msecs_to_jiffies(*(__PTR)); \
return ret; \ return ret; \
} }
STORE_FUNCTION(as_readexpire_store, &ad->fifo_expire[REQ_SYNC], 0, INT_MAX); STORE_FUNCTION(as_read_expire_store, &ad->fifo_expire[REQ_SYNC], 0, INT_MAX);
STORE_FUNCTION(as_writeexpire_store, &ad->fifo_expire[REQ_ASYNC], 0, INT_MAX); STORE_FUNCTION(as_write_expire_store, &ad->fifo_expire[REQ_ASYNC], 0, INT_MAX);
STORE_FUNCTION(as_anticexpire_store, &ad->antic_expire, 0, INT_MAX); STORE_FUNCTION(as_antic_expire_store, &ad->antic_expire, 0, INT_MAX);
STORE_FUNCTION(as_read_batchexpire_store, STORE_FUNCTION(as_read_batch_expire_store,
&ad->batch_expire[REQ_SYNC], 0, INT_MAX); &ad->batch_expire[REQ_SYNC], 0, INT_MAX);
STORE_FUNCTION(as_write_batchexpire_store, STORE_FUNCTION(as_write_batch_expire_store,
&ad->batch_expire[REQ_ASYNC], 0, INT_MAX); &ad->batch_expire[REQ_ASYNC], 0, INT_MAX);
#undef STORE_FUNCTION #undef STORE_FUNCTION
static struct elv_fs_entry as_est_entry = { #define AS_ATTR(name) \
.attr = {.name = "est_time", .mode = S_IRUGO }, __ATTR(name, S_IRUGO|S_IWUSR, as_##name##_show, as_##name##_store)
.show = as_est_show,
}; static struct elv_fs_entry as_attrs[] = {
static struct elv_fs_entry as_readexpire_entry = { __ATTR_RO(est_time),
.attr = {.name = "read_expire", .mode = S_IRUGO | S_IWUSR }, AS_ATTR(read_expire),
.show = as_readexpire_show, AS_ATTR(write_expire),
.store = as_readexpire_store, AS_ATTR(antic_expire),
}; AS_ATTR(read_batch_expire),
static struct elv_fs_entry as_writeexpire_entry = { AS_ATTR(write_batch_expire),
.attr = {.name = "write_expire", .mode = S_IRUGO | S_IWUSR }, __ATTR_NULL
.show = as_writeexpire_show,
.store = as_writeexpire_store,
};
static struct elv_fs_entry as_anticexpire_entry = {
.attr = {.name = "antic_expire", .mode = S_IRUGO | S_IWUSR },
.show = as_anticexpire_show,
.store = as_anticexpire_store,
};
static struct elv_fs_entry as_read_batchexpire_entry = {
.attr = {.name = "read_batch_expire", .mode = S_IRUGO | S_IWUSR },
.show = as_read_batchexpire_show,
.store = as_read_batchexpire_store,
};
static struct elv_fs_entry as_write_batchexpire_entry = {
.attr = {.name = "write_batch_expire", .mode = S_IRUGO | S_IWUSR },
.show = as_write_batchexpire_show,
.store = as_write_batchexpire_store,
};
static struct attribute *as_attrs[] = {
&as_est_entry.attr,
&as_readexpire_entry.attr,
&as_writeexpire_entry.attr,
&as_anticexpire_entry.attr,
&as_read_batchexpire_entry.attr,
&as_write_batchexpire_entry.attr,
NULL,
}; };
static struct elevator_type iosched_as = { static struct elevator_type iosched_as = {
......
...@@ -2304,8 +2304,8 @@ SHOW_FUNCTION(cfq_quantum_show, cfqd->cfq_quantum, 0); ...@@ -2304,8 +2304,8 @@ SHOW_FUNCTION(cfq_quantum_show, cfqd->cfq_quantum, 0);
SHOW_FUNCTION(cfq_queued_show, cfqd->cfq_queued, 0); SHOW_FUNCTION(cfq_queued_show, cfqd->cfq_queued, 0);
SHOW_FUNCTION(cfq_fifo_expire_sync_show, cfqd->cfq_fifo_expire[1], 1); SHOW_FUNCTION(cfq_fifo_expire_sync_show, cfqd->cfq_fifo_expire[1], 1);
SHOW_FUNCTION(cfq_fifo_expire_async_show, cfqd->cfq_fifo_expire[0], 1); SHOW_FUNCTION(cfq_fifo_expire_async_show, cfqd->cfq_fifo_expire[0], 1);
SHOW_FUNCTION(cfq_back_max_show, cfqd->cfq_back_max, 0); SHOW_FUNCTION(cfq_back_seek_max_show, cfqd->cfq_back_max, 0);
SHOW_FUNCTION(cfq_back_penalty_show, cfqd->cfq_back_penalty, 0); SHOW_FUNCTION(cfq_back_seek_penalty_show, cfqd->cfq_back_penalty, 0);
SHOW_FUNCTION(cfq_slice_idle_show, cfqd->cfq_slice_idle, 1); SHOW_FUNCTION(cfq_slice_idle_show, cfqd->cfq_slice_idle, 1);
SHOW_FUNCTION(cfq_slice_sync_show, cfqd->cfq_slice[1], 1); SHOW_FUNCTION(cfq_slice_sync_show, cfqd->cfq_slice[1], 1);
SHOW_FUNCTION(cfq_slice_async_show, cfqd->cfq_slice[0], 1); SHOW_FUNCTION(cfq_slice_async_show, cfqd->cfq_slice[0], 1);
...@@ -2333,8 +2333,8 @@ STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0); ...@@ -2333,8 +2333,8 @@ STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0);
STORE_FUNCTION(cfq_queued_store, &cfqd->cfq_queued, 1, UINT_MAX, 0); STORE_FUNCTION(cfq_queued_store, &cfqd->cfq_queued, 1, UINT_MAX, 0);
STORE_FUNCTION(cfq_fifo_expire_sync_store, &cfqd->cfq_fifo_expire[1], 1, UINT_MAX, 1); STORE_FUNCTION(cfq_fifo_expire_sync_store, &cfqd->cfq_fifo_expire[1], 1, UINT_MAX, 1);
STORE_FUNCTION(cfq_fifo_expire_async_store, &cfqd->cfq_fifo_expire[0], 1, UINT_MAX, 1); STORE_FUNCTION(cfq_fifo_expire_async_store, &cfqd->cfq_fifo_expire[0], 1, UINT_MAX, 1);
STORE_FUNCTION(cfq_back_max_store, &cfqd->cfq_back_max, 0, UINT_MAX, 0); STORE_FUNCTION(cfq_back_seek_max_store, &cfqd->cfq_back_max, 0, UINT_MAX, 0);
STORE_FUNCTION(cfq_back_penalty_store, &cfqd->cfq_back_penalty, 1, UINT_MAX, 0); STORE_FUNCTION(cfq_back_seek_penalty_store, &cfqd->cfq_back_penalty, 1, UINT_MAX, 0);
STORE_FUNCTION(cfq_slice_idle_store, &cfqd->cfq_slice_idle, 0, UINT_MAX, 1); STORE_FUNCTION(cfq_slice_idle_store, &cfqd->cfq_slice_idle, 0, UINT_MAX, 1);
STORE_FUNCTION(cfq_slice_sync_store, &cfqd->cfq_slice[1], 1, UINT_MAX, 1); STORE_FUNCTION(cfq_slice_sync_store, &cfqd->cfq_slice[1], 1, UINT_MAX, 1);
STORE_FUNCTION(cfq_slice_async_store, &cfqd->cfq_slice[0], 1, UINT_MAX, 1); STORE_FUNCTION(cfq_slice_async_store, &cfqd->cfq_slice[0], 1, UINT_MAX, 1);
...@@ -2342,75 +2342,22 @@ STORE_FUNCTION(cfq_slice_async_rq_store, &cfqd->cfq_slice_async_rq, 1, UINT_MAX, ...@@ -2342,75 +2342,22 @@ STORE_FUNCTION(cfq_slice_async_rq_store, &cfqd->cfq_slice_async_rq, 1, UINT_MAX,
STORE_FUNCTION(cfq_max_depth_store, &cfqd->cfq_max_depth, 1, UINT_MAX, 0); STORE_FUNCTION(cfq_max_depth_store, &cfqd->cfq_max_depth, 1, UINT_MAX, 0);
#undef STORE_FUNCTION #undef STORE_FUNCTION
static struct elv_fs_entry cfq_quantum_entry = { #define CFQ_ATTR(name) \
.attr = {.name = "quantum", .mode = S_IRUGO | S_IWUSR }, __ATTR(name, S_IRUGO|S_IWUSR, cfq_##name##_show, cfq_##name##_store)
.show = cfq_quantum_show,
.store = cfq_quantum_store, static struct elv_fs_entry cfq_attrs[] = {
}; CFQ_ATTR(quantum),
static struct elv_fs_entry cfq_queued_entry = { CFQ_ATTR(queued),
.attr = {.name = "queued", .mode = S_IRUGO | S_IWUSR }, CFQ_ATTR(fifo_expire_sync),
.show = cfq_queued_show, CFQ_ATTR(fifo_expire_async),
.store = cfq_queued_store, CFQ_ATTR(back_seek_max),
}; CFQ_ATTR(back_seek_penalty),
static struct elv_fs_entry cfq_fifo_expire_sync_entry = { CFQ_ATTR(slice_sync),
.attr = {.name = "fifo_expire_sync", .mode = S_IRUGO | S_IWUSR }, CFQ_ATTR(slice_async),
.show = cfq_fifo_expire_sync_show, CFQ_ATTR(slice_async_rq),
.store = cfq_fifo_expire_sync_store, CFQ_ATTR(slice_idle),
}; CFQ_ATTR(max_depth),
static struct elv_fs_entry cfq_fifo_expire_async_entry = { __ATTR_NULL
.attr = {.name = "fifo_expire_async", .mode = S_IRUGO | S_IWUSR },
.show = cfq_fifo_expire_async_show,
.store = cfq_fifo_expire_async_store,
};
static struct elv_fs_entry cfq_back_max_entry = {
.attr = {.name = "back_seek_max", .mode = S_IRUGO | S_IWUSR },
.show = cfq_back_max_show,
.store = cfq_back_max_store,
};
static struct elv_fs_entry cfq_back_penalty_entry = {
.attr = {.name = "back_seek_penalty", .mode = S_IRUGO | S_IWUSR },
.show = cfq_back_penalty_show,
.store = cfq_back_penalty_store,
};
static struct elv_fs_entry cfq_slice_sync_entry = {
.attr = {.name = "slice_sync", .mode = S_IRUGO | S_IWUSR },
.show = cfq_slice_sync_show,
.store = cfq_slice_sync_store,
};
static struct elv_fs_entry cfq_slice_async_entry = {
.attr = {.name = "slice_async", .mode = S_IRUGO | S_IWUSR },
.show = cfq_slice_async_show,
.store = cfq_slice_async_store,
};
static struct elv_fs_entry cfq_slice_async_rq_entry = {
.attr = {.name = "slice_async_rq", .mode = S_IRUGO | S_IWUSR },
.show = cfq_slice_async_rq_show,
.store = cfq_slice_async_rq_store,
};
static struct elv_fs_entry cfq_slice_idle_entry = {
.attr = {.name = "slice_idle", .mode = S_IRUGO | S_IWUSR },
.show = cfq_slice_idle_show,
.store = cfq_slice_idle_store,
};
static struct elv_fs_entry cfq_max_depth_entry = {
.attr = {.name = "max_depth", .mode = S_IRUGO | S_IWUSR },
.show = cfq_max_depth_show,
.store = cfq_max_depth_store,
};
static struct attribute *cfq_attrs[] = {
&cfq_quantum_entry.attr,
&cfq_queued_entry.attr,
&cfq_fifo_expire_sync_entry.attr,
&cfq_fifo_expire_async_entry.attr,
&cfq_back_max_entry.attr,
&cfq_back_penalty_entry.attr,
&cfq_slice_sync_entry.attr,
&cfq_slice_async_entry.attr,
&cfq_slice_async_rq_entry.attr,
&cfq_slice_idle_entry.attr,
&cfq_max_depth_entry.attr,
NULL,
}; };
static struct elevator_type iosched_cfq = { static struct elevator_type iosched_cfq = {
......
...@@ -719,11 +719,11 @@ static ssize_t __FUNC(elevator_t *e, char *page) \ ...@@ -719,11 +719,11 @@ static ssize_t __FUNC(elevator_t *e, char *page) \
__data = jiffies_to_msecs(__data); \ __data = jiffies_to_msecs(__data); \
return deadline_var_show(__data, (page)); \ return deadline_var_show(__data, (page)); \
} }
SHOW_FUNCTION(deadline_readexpire_show, dd->fifo_expire[READ], 1); SHOW_FUNCTION(deadline_read_expire_show, dd->fifo_expire[READ], 1);
SHOW_FUNCTION(deadline_writeexpire_show, dd->fifo_expire[WRITE], 1); SHOW_FUNCTION(deadline_write_expire_show, dd->fifo_expire[WRITE], 1);
SHOW_FUNCTION(deadline_writesstarved_show, dd->writes_starved, 0); SHOW_FUNCTION(deadline_writes_starved_show, dd->writes_starved, 0);
SHOW_FUNCTION(deadline_frontmerges_show, dd->front_merges, 0); SHOW_FUNCTION(deadline_front_merges_show, dd->front_merges, 0);
SHOW_FUNCTION(deadline_fifobatch_show, dd->fifo_batch, 0); SHOW_FUNCTION(deadline_fifo_batch_show, dd->fifo_batch, 0);
#undef SHOW_FUNCTION #undef SHOW_FUNCTION
#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
...@@ -742,46 +742,24 @@ static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \ ...@@ -742,46 +742,24 @@ static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \
*(__PTR) = __data; \ *(__PTR) = __data; \
return ret; \ return ret; \
} }
STORE_FUNCTION(deadline_readexpire_store, &dd->fifo_expire[READ], 0, INT_MAX, 1); STORE_FUNCTION(deadline_read_expire_store, &dd->fifo_expire[READ], 0, INT_MAX, 1);
STORE_FUNCTION(deadline_writeexpire_store, &dd->fifo_expire[WRITE], 0, INT_MAX, 1); STORE_FUNCTION(deadline_write_expire_store, &dd->fifo_expire[WRITE], 0, INT_MAX, 1);
STORE_FUNCTION(deadline_writesstarved_store, &dd->writes_starved, INT_MIN, INT_MAX, 0); STORE_FUNCTION(deadline_writes_starved_store, &dd->writes_starved, INT_MIN, INT_MAX, 0);
STORE_FUNCTION(deadline_frontmerges_store, &dd->front_merges, 0, 1, 0); STORE_FUNCTION(deadline_front_merges_store, &dd->front_merges, 0, 1, 0);
STORE_FUNCTION(deadline_fifobatch_store, &dd->fifo_batch, 0, INT_MAX, 0); STORE_FUNCTION(deadline_fifo_batch_store, &dd->fifo_batch, 0, INT_MAX, 0);
#undef STORE_FUNCTION #undef STORE_FUNCTION
static struct elv_fs_entry deadline_readexpire_entry = { #define DD_ATTR(name) \
.attr = {.name = "read_expire", .mode = S_IRUGO | S_IWUSR }, __ATTR(name, S_IRUGO|S_IWUSR, deadline_##name##_show, \
.show = deadline_readexpire_show, deadline_##name##_store)
.store = deadline_readexpire_store,
}; static struct elv_fs_entry deadline_attrs[] = {
static struct elv_fs_entry deadline_writeexpire_entry = { DD_ATTR(read_expire),
.attr = {.name = "write_expire", .mode = S_IRUGO | S_IWUSR }, DD_ATTR(write_expire),
.show = deadline_writeexpire_show, DD_ATTR(writes_starved),
.store = deadline_writeexpire_store, DD_ATTR(front_merges),
}; DD_ATTR(fifo_batch),
static struct elv_fs_entry deadline_writesstarved_entry = { __ATTR_NULL
.attr = {.name = "writes_starved", .mode = S_IRUGO | S_IWUSR },
.show = deadline_writesstarved_show,
.store = deadline_writesstarved_store,
};
static struct elv_fs_entry deadline_frontmerges_entry = {
.attr = {.name = "front_merges", .mode = S_IRUGO | S_IWUSR },
.show = deadline_frontmerges_show,
.store = deadline_frontmerges_store,
};
static struct elv_fs_entry deadline_fifobatch_entry = {
.attr = {.name = "fifo_batch", .mode = S_IRUGO | S_IWUSR },
.show = deadline_fifobatch_show,
.store = deadline_fifobatch_store,
};
static struct attribute *deadline_attrs[] = {
&deadline_readexpire_entry.attr,
&deadline_writeexpire_entry.attr,
&deadline_writesstarved_entry.attr,
&deadline_frontmerges_entry.attr,
&deadline_fifobatch_entry.attr,
NULL,
}; };
static struct elevator_type iosched_deadline = { static struct elevator_type iosched_deadline = {
......
...@@ -699,11 +699,12 @@ int elv_register_queue(struct request_queue *q) ...@@ -699,11 +699,12 @@ int elv_register_queue(struct request_queue *q)
error = kobject_add(&e->kobj); error = kobject_add(&e->kobj);
if (!error) { if (!error) {
struct attribute **attr = e->elevator_type->elevator_attrs; struct elv_fs_entry *attr = e->elevator_type->elevator_attrs;
if (attr) { if (attr) {
while (*attr) { while (attr->attr.name) {
if (sysfs_create_file(&e->kobj,*attr++)) if (sysfs_create_file(&e->kobj, &attr->attr))
break; break;
attr++;
} }
} }
kobject_uevent(&e->kobj, KOBJ_ADD); kobject_uevent(&e->kobj, KOBJ_ADD);
......
...@@ -53,6 +53,12 @@ struct elevator_ops ...@@ -53,6 +53,12 @@ struct elevator_ops
#define ELV_NAME_MAX (16) #define ELV_NAME_MAX (16)
struct elv_fs_entry {
struct attribute attr;
ssize_t (*show)(elevator_t *, char *);
ssize_t (*store)(elevator_t *, const char *, size_t);
};
/* /*
* identifies an elevator type, such as AS or deadline * identifies an elevator type, such as AS or deadline
*/ */
...@@ -61,7 +67,7 @@ struct elevator_type ...@@ -61,7 +67,7 @@ struct elevator_type
struct list_head list; struct list_head list;
struct elevator_ops ops; struct elevator_ops ops;
struct elevator_type *elevator_type; struct elevator_type *elevator_type;
struct attribute **elevator_attrs; struct elv_fs_entry *elevator_attrs;
char elevator_name[ELV_NAME_MAX]; char elevator_name[ELV_NAME_MAX];
struct module *elevator_owner; struct module *elevator_owner;
}; };
...@@ -142,12 +148,6 @@ enum { ...@@ -142,12 +148,6 @@ enum {
ELV_MQUEUE_MUST, ELV_MQUEUE_MUST,
}; };
struct elv_fs_entry {
struct attribute attr;
ssize_t (*show)(elevator_t *, char *);
ssize_t (*store)(elevator_t *, const char *, size_t);
};
#define rq_end_sector(rq) ((rq)->sector + (rq)->nr_sectors) #define rq_end_sector(rq) ((rq)->sector + (rq)->nr_sectors)
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment