aboutsummaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-03-18 18:35:43 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2006-03-18 18:35:43 -0500
commit3d1ab40f4c20767afbd361b258a531d73e3e6fc2 (patch)
tree2da79cc8b47a98b0496b6e762fa790a8d547977b /block/cfq-iosched.c
parent1cc9be68ebcc1de9904bf225441613878da9c0d8 (diff)
[PATCH] elevator_t lifetime rules and sysfs fixes
Diffstat (limited to 'block/cfq-iosched.c')
-rw-r--r--block/cfq-iosched.c74
1 files changed, 17 insertions, 57 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index d1f2ae1629f7..6dc156e1c29b 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -2275,11 +2275,6 @@ fail:
2275/* 2275/*
2276 * sysfs parts below --> 2276 * sysfs parts below -->
2277 */ 2277 */
2278struct cfq_fs_entry {
2279 struct attribute attr;
2280 ssize_t (*show)(struct cfq_data *, char *);
2281 ssize_t (*store)(struct cfq_data *, const char *, size_t);
2282};
2283 2278
2284static ssize_t 2279static ssize_t
2285cfq_var_show(unsigned int var, char *page) 2280cfq_var_show(unsigned int var, char *page)
@@ -2297,8 +2292,9 @@ cfq_var_store(unsigned int *var, const char *page, size_t count)
2297} 2292}
2298 2293
2299#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \ 2294#define SHOW_FUNCTION(__FUNC, __VAR, __CONV) \
2300static ssize_t __FUNC(struct cfq_data *cfqd, char *page) \ 2295static ssize_t __FUNC(elevator_t *e, char *page) \
2301{ \ 2296{ \
2297 struct cfq_data *cfqd = e->elevator_data; \
2302 unsigned int __data = __VAR; \ 2298 unsigned int __data = __VAR; \
2303 if (__CONV) \ 2299 if (__CONV) \
2304 __data = jiffies_to_msecs(__data); \ 2300 __data = jiffies_to_msecs(__data); \
@@ -2318,8 +2314,9 @@ SHOW_FUNCTION(cfq_max_depth_show, cfqd->cfq_max_depth, 0);
2318#undef SHOW_FUNCTION 2314#undef SHOW_FUNCTION
2319 2315
2320#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ 2316#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \
2321static ssize_t __FUNC(struct cfq_data *cfqd, const char *page, size_t count) \ 2317static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \
2322{ \ 2318{ \
2319 struct cfq_data *cfqd = e->elevator_data; \
2323 unsigned int __data; \ 2320 unsigned int __data; \
2324 int ret = cfq_var_store(&__data, (page), count); \ 2321 int ret = cfq_var_store(&__data, (page), count); \
2325 if (__data < (MIN)) \ 2322 if (__data < (MIN)) \
@@ -2345,63 +2342,63 @@ STORE_FUNCTION(cfq_slice_async_rq_store, &cfqd->cfq_slice_async_rq, 1, UINT_MAX,
2345STORE_FUNCTION(cfq_max_depth_store, &cfqd->cfq_max_depth, 1, UINT_MAX, 0); 2342STORE_FUNCTION(cfq_max_depth_store, &cfqd->cfq_max_depth, 1, UINT_MAX, 0);
2346#undef STORE_FUNCTION 2343#undef STORE_FUNCTION
2347 2344
2348static struct cfq_fs_entry cfq_quantum_entry = { 2345static struct elv_fs_entry cfq_quantum_entry = {
2349 .attr = {.name = "quantum", .mode = S_IRUGO | S_IWUSR }, 2346 .attr = {.name = "quantum", .mode = S_IRUGO | S_IWUSR },
2350 .show = cfq_quantum_show, 2347 .show = cfq_quantum_show,
2351 .store = cfq_quantum_store, 2348 .store = cfq_quantum_store,
2352}; 2349};
2353static struct cfq_fs_entry cfq_queued_entry = { 2350static struct elv_fs_entry cfq_queued_entry = {
2354 .attr = {.name = "queued", .mode = S_IRUGO | S_IWUSR }, 2351 .attr = {.name = "queued", .mode = S_IRUGO | S_IWUSR },
2355 .show = cfq_queued_show, 2352 .show = cfq_queued_show,
2356 .store = cfq_queued_store, 2353 .store = cfq_queued_store,
2357}; 2354};
2358static struct cfq_fs_entry cfq_fifo_expire_sync_entry = { 2355static struct elv_fs_entry cfq_fifo_expire_sync_entry = {
2359 .attr = {.name = "fifo_expire_sync", .mode = S_IRUGO | S_IWUSR }, 2356 .attr = {.name = "fifo_expire_sync", .mode = S_IRUGO | S_IWUSR },
2360 .show = cfq_fifo_expire_sync_show, 2357 .show = cfq_fifo_expire_sync_show,
2361 .store = cfq_fifo_expire_sync_store, 2358 .store = cfq_fifo_expire_sync_store,
2362}; 2359};
2363static struct cfq_fs_entry cfq_fifo_expire_async_entry = { 2360static struct elv_fs_entry cfq_fifo_expire_async_entry = {
2364 .attr = {.name = "fifo_expire_async", .mode = S_IRUGO | S_IWUSR }, 2361 .attr = {.name = "fifo_expire_async", .mode = S_IRUGO | S_IWUSR },
2365 .show = cfq_fifo_expire_async_show, 2362 .show = cfq_fifo_expire_async_show,
2366 .store = cfq_fifo_expire_async_store, 2363 .store = cfq_fifo_expire_async_store,
2367}; 2364};
2368static struct cfq_fs_entry cfq_back_max_entry = { 2365static struct elv_fs_entry cfq_back_max_entry = {
2369 .attr = {.name = "back_seek_max", .mode = S_IRUGO | S_IWUSR }, 2366 .attr = {.name = "back_seek_max", .mode = S_IRUGO | S_IWUSR },
2370 .show = cfq_back_max_show, 2367 .show = cfq_back_max_show,
2371 .store = cfq_back_max_store, 2368 .store = cfq_back_max_store,
2372}; 2369};
2373static struct cfq_fs_entry cfq_back_penalty_entry = { 2370static struct elv_fs_entry cfq_back_penalty_entry = {
2374 .attr = {.name = "back_seek_penalty", .mode = S_IRUGO | S_IWUSR }, 2371 .attr = {.name = "back_seek_penalty", .mode = S_IRUGO | S_IWUSR },
2375 .show = cfq_back_penalty_show, 2372 .show = cfq_back_penalty_show,
2376 .store = cfq_back_penalty_store, 2373 .store = cfq_back_penalty_store,
2377}; 2374};
2378static struct cfq_fs_entry cfq_slice_sync_entry = { 2375static struct elv_fs_entry cfq_slice_sync_entry = {
2379 .attr = {.name = "slice_sync", .mode = S_IRUGO | S_IWUSR }, 2376 .attr = {.name = "slice_sync", .mode = S_IRUGO | S_IWUSR },
2380 .show = cfq_slice_sync_show, 2377 .show = cfq_slice_sync_show,
2381 .store = cfq_slice_sync_store, 2378 .store = cfq_slice_sync_store,
2382}; 2379};
2383static struct cfq_fs_entry cfq_slice_async_entry = { 2380static struct elv_fs_entry cfq_slice_async_entry = {
2384 .attr = {.name = "slice_async", .mode = S_IRUGO | S_IWUSR }, 2381 .attr = {.name = "slice_async", .mode = S_IRUGO | S_IWUSR },
2385 .show = cfq_slice_async_show, 2382 .show = cfq_slice_async_show,
2386 .store = cfq_slice_async_store, 2383 .store = cfq_slice_async_store,
2387}; 2384};
2388static struct cfq_fs_entry cfq_slice_async_rq_entry = { 2385static struct elv_fs_entry cfq_slice_async_rq_entry = {
2389 .attr = {.name = "slice_async_rq", .mode = S_IRUGO | S_IWUSR }, 2386 .attr = {.name = "slice_async_rq", .mode = S_IRUGO | S_IWUSR },
2390 .show = cfq_slice_async_rq_show, 2387 .show = cfq_slice_async_rq_show,
2391 .store = cfq_slice_async_rq_store, 2388 .store = cfq_slice_async_rq_store,
2392}; 2389};
2393static struct cfq_fs_entry cfq_slice_idle_entry = { 2390static struct elv_fs_entry cfq_slice_idle_entry = {
2394 .attr = {.name = "slice_idle", .mode = S_IRUGO | S_IWUSR }, 2391 .attr = {.name = "slice_idle", .mode = S_IRUGO | S_IWUSR },
2395 .show = cfq_slice_idle_show, 2392 .show = cfq_slice_idle_show,
2396 .store = cfq_slice_idle_store, 2393 .store = cfq_slice_idle_store,
2397}; 2394};
2398static struct cfq_fs_entry cfq_max_depth_entry = { 2395static struct elv_fs_entry cfq_max_depth_entry = {
2399 .attr = {.name = "max_depth", .mode = S_IRUGO | S_IWUSR }, 2396 .attr = {.name = "max_depth", .mode = S_IRUGO | S_IWUSR },
2400 .show = cfq_max_depth_show, 2397 .show = cfq_max_depth_show,
2401 .store = cfq_max_depth_store, 2398 .store = cfq_max_depth_store,
2402}; 2399};
2403 2400
2404static struct attribute *default_attrs[] = { 2401static struct attribute *cfq_attrs[] = {
2405 &cfq_quantum_entry.attr, 2402 &cfq_quantum_entry.attr,
2406 &cfq_queued_entry.attr, 2403 &cfq_queued_entry.attr,
2407 &cfq_fifo_expire_sync_entry.attr, 2404 &cfq_fifo_expire_sync_entry.attr,
@@ -2416,43 +2413,6 @@ static struct attribute *default_attrs[] = {
2416 NULL, 2413 NULL,
2417}; 2414};
2418 2415
2419#define to_cfq(atr) container_of((atr), struct cfq_fs_entry, attr)
2420
2421static ssize_t
2422cfq_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
2423{
2424 elevator_t *e = container_of(kobj, elevator_t, kobj);
2425 struct cfq_fs_entry *entry = to_cfq(attr);
2426
2427 if (!entry->show)
2428 return -EIO;
2429
2430 return entry->show(e->elevator_data, page);
2431}
2432
2433static ssize_t
2434cfq_attr_store(struct kobject *kobj, struct attribute *attr,
2435 const char *page, size_t length)
2436{
2437 elevator_t *e = container_of(kobj, elevator_t, kobj);
2438 struct cfq_fs_entry *entry = to_cfq(attr);
2439
2440 if (!entry->store)
2441 return -EIO;
2442
2443 return entry->store(e->elevator_data, page, length);
2444}
2445
2446static struct sysfs_ops cfq_sysfs_ops = {
2447 .show = cfq_attr_show,
2448 .store = cfq_attr_store,
2449};
2450
2451static struct kobj_type cfq_ktype = {
2452 .sysfs_ops = &cfq_sysfs_ops,
2453 .default_attrs = default_attrs,
2454};
2455
2456static struct elevator_type iosched_cfq = { 2416static struct elevator_type iosched_cfq = {
2457 .ops = { 2417 .ops = {
2458 .elevator_merge_fn = cfq_merge, 2418 .elevator_merge_fn = cfq_merge,
@@ -2473,7 +2433,7 @@ static struct elevator_type iosched_cfq = {
2473 .elevator_exit_fn = cfq_exit_queue, 2433 .elevator_exit_fn = cfq_exit_queue,
2474 .trim = cfq_trim, 2434 .trim = cfq_trim,
2475 }, 2435 },
2476 .elevator_ktype = &cfq_ktype, 2436 .elevator_attrs = cfq_attrs,
2477 .elevator_name = "cfq", 2437 .elevator_name = "cfq",
2478 .elevator_owner = THIS_MODULE, 2438 .elevator_owner = THIS_MODULE,
2479}; 2439};