aboutsummaryrefslogtreecommitdiffstats
path: root/block/as-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/as-iosched.c
parent1cc9be68ebcc1de9904bf225441613878da9c0d8 (diff)
[PATCH] elevator_t lifetime rules and sysfs fixes
Diffstat (limited to 'block/as-iosched.c')
-rw-r--r--block/as-iosched.c69
1 files changed, 15 insertions, 54 deletions
diff --git a/block/as-iosched.c b/block/as-iosched.c
index 55a997fc4bb4..3fb60eb7093b 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -1709,11 +1709,6 @@ static int as_init_queue(request_queue_t *q, elevator_t *e)
1709/* 1709/*
1710 * sysfs parts below 1710 * sysfs parts below
1711 */ 1711 */
1712struct as_fs_entry {
1713 struct attribute attr;
1714 ssize_t (*show)(struct as_data *, char *);
1715 ssize_t (*store)(struct as_data *, const char *, size_t);
1716};
1717 1712
1718static ssize_t 1713static ssize_t
1719as_var_show(unsigned int var, char *page) 1714as_var_show(unsigned int var, char *page)
@@ -1730,8 +1725,9 @@ as_var_store(unsigned long *var, const char *page, size_t count)
1730 return count; 1725 return count;
1731} 1726}
1732 1727
1733static ssize_t as_est_show(struct as_data *ad, char *page) 1728static ssize_t as_est_show(elevator_t *e, char *page)
1734{ 1729{
1730 struct as_data *ad = e->elevator_data;
1735 int pos = 0; 1731 int pos = 0;
1736 1732
1737 pos += sprintf(page+pos, "%lu %% exit probability\n", 1733 pos += sprintf(page+pos, "%lu %% exit probability\n",
@@ -1747,8 +1743,9 @@ static ssize_t as_est_show(struct as_data *ad, char *page)
1747} 1743}
1748 1744
1749#define SHOW_FUNCTION(__FUNC, __VAR) \ 1745#define SHOW_FUNCTION(__FUNC, __VAR) \
1750static ssize_t __FUNC(struct as_data *ad, char *page) \ 1746static ssize_t __FUNC(elevator_t *e, char *page) \
1751{ \ 1747{ \
1748 struct as_data *ad = e->elevator_data; \
1752 return as_var_show(jiffies_to_msecs((__VAR)), (page)); \ 1749 return as_var_show(jiffies_to_msecs((__VAR)), (page)); \
1753} 1750}
1754SHOW_FUNCTION(as_readexpire_show, ad->fifo_expire[REQ_SYNC]); 1751SHOW_FUNCTION(as_readexpire_show, ad->fifo_expire[REQ_SYNC]);
@@ -1759,9 +1756,10 @@ SHOW_FUNCTION(as_write_batchexpire_show, ad->batch_expire[REQ_ASYNC]);
1759#undef SHOW_FUNCTION 1756#undef SHOW_FUNCTION
1760 1757
1761#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX) \ 1758#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX) \
1762static ssize_t __FUNC(struct as_data *ad, const char *page, size_t count) \ 1759static ssize_t __FUNC(elevator_t *e, const char *page, size_t count) \
1763{ \ 1760{ \
1764 int ret = as_var_store(__PTR, (page), count); \ 1761 struct as_data *ad = e->elevator_data; \
1762 int ret = as_var_store(__PTR, (page), count); \
1765 if (*(__PTR) < (MIN)) \ 1763 if (*(__PTR) < (MIN)) \
1766 *(__PTR) = (MIN); \ 1764 *(__PTR) = (MIN); \
1767 else if (*(__PTR) > (MAX)) \ 1765 else if (*(__PTR) > (MAX)) \
@@ -1778,37 +1776,37 @@ STORE_FUNCTION(as_write_batchexpire_store,
1778 &ad->batch_expire[REQ_ASYNC], 0, INT_MAX); 1776 &ad->batch_expire[REQ_ASYNC], 0, INT_MAX);
1779#undef STORE_FUNCTION 1777#undef STORE_FUNCTION
1780 1778
1781static struct as_fs_entry as_est_entry = { 1779static struct elv_fs_entry as_est_entry = {
1782 .attr = {.name = "est_time", .mode = S_IRUGO }, 1780 .attr = {.name = "est_time", .mode = S_IRUGO },
1783 .show = as_est_show, 1781 .show = as_est_show,
1784}; 1782};
1785static struct as_fs_entry as_readexpire_entry = { 1783static struct elv_fs_entry as_readexpire_entry = {
1786 .attr = {.name = "read_expire", .mode = S_IRUGO | S_IWUSR }, 1784 .attr = {.name = "read_expire", .mode = S_IRUGO | S_IWUSR },
1787 .show = as_readexpire_show, 1785 .show = as_readexpire_show,
1788 .store = as_readexpire_store, 1786 .store = as_readexpire_store,
1789}; 1787};
1790static struct as_fs_entry as_writeexpire_entry = { 1788static struct elv_fs_entry as_writeexpire_entry = {
1791 .attr = {.name = "write_expire", .mode = S_IRUGO | S_IWUSR }, 1789 .attr = {.name = "write_expire", .mode = S_IRUGO | S_IWUSR },
1792 .show = as_writeexpire_show, 1790 .show = as_writeexpire_show,
1793 .store = as_writeexpire_store, 1791 .store = as_writeexpire_store,
1794}; 1792};
1795static struct as_fs_entry as_anticexpire_entry = { 1793static struct elv_fs_entry as_anticexpire_entry = {
1796 .attr = {.name = "antic_expire", .mode = S_IRUGO | S_IWUSR }, 1794 .attr = {.name = "antic_expire", .mode = S_IRUGO | S_IWUSR },
1797 .show = as_anticexpire_show, 1795 .show = as_anticexpire_show,
1798 .store = as_anticexpire_store, 1796 .store = as_anticexpire_store,
1799}; 1797};
1800static struct as_fs_entry as_read_batchexpire_entry = { 1798static struct elv_fs_entry as_read_batchexpire_entry = {
1801 .attr = {.name = "read_batch_expire", .mode = S_IRUGO | S_IWUSR }, 1799 .attr = {.name = "read_batch_expire", .mode = S_IRUGO | S_IWUSR },
1802 .show = as_read_batchexpire_show, 1800 .show = as_read_batchexpire_show,
1803 .store = as_read_batchexpire_store, 1801 .store = as_read_batchexpire_store,
1804}; 1802};
1805static struct as_fs_entry as_write_batchexpire_entry = { 1803static struct elv_fs_entry as_write_batchexpire_entry = {
1806 .attr = {.name = "write_batch_expire", .mode = S_IRUGO | S_IWUSR }, 1804 .attr = {.name = "write_batch_expire", .mode = S_IRUGO | S_IWUSR },
1807 .show = as_write_batchexpire_show, 1805 .show = as_write_batchexpire_show,
1808 .store = as_write_batchexpire_store, 1806 .store = as_write_batchexpire_store,
1809}; 1807};
1810 1808
1811static struct attribute *default_attrs[] = { 1809static struct attribute *as_attrs[] = {
1812 &as_est_entry.attr, 1810 &as_est_entry.attr,
1813 &as_readexpire_entry.attr, 1811 &as_readexpire_entry.attr,
1814 &as_writeexpire_entry.attr, 1812 &as_writeexpire_entry.attr,
@@ -1818,43 +1816,6 @@ static struct attribute *default_attrs[] = {
1818 NULL, 1816 NULL,
1819}; 1817};
1820 1818
1821#define to_as(atr) container_of((atr), struct as_fs_entry, attr)
1822
1823static ssize_t
1824as_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
1825{
1826 elevator_t *e = container_of(kobj, elevator_t, kobj);
1827 struct as_fs_entry *entry = to_as(attr);
1828
1829 if (!entry->show)
1830 return -EIO;
1831
1832 return entry->show(e->elevator_data, page);
1833}
1834
1835static ssize_t
1836as_attr_store(struct kobject *kobj, struct attribute *attr,
1837 const char *page, size_t length)
1838{
1839 elevator_t *e = container_of(kobj, elevator_t, kobj);
1840 struct as_fs_entry *entry = to_as(attr);
1841
1842 if (!entry->store)
1843 return -EIO;
1844
1845 return entry->store(e->elevator_data, page, length);
1846}
1847
1848static struct sysfs_ops as_sysfs_ops = {
1849 .show = as_attr_show,
1850 .store = as_attr_store,
1851};
1852
1853static struct kobj_type as_ktype = {
1854 .sysfs_ops = &as_sysfs_ops,
1855 .default_attrs = default_attrs,
1856};
1857
1858static struct elevator_type iosched_as = { 1819static struct elevator_type iosched_as = {
1859 .ops = { 1820 .ops = {
1860 .elevator_merge_fn = as_merge, 1821 .elevator_merge_fn = as_merge,
@@ -1876,7 +1837,7 @@ static struct elevator_type iosched_as = {
1876 .trim = as_trim, 1837 .trim = as_trim,
1877 }, 1838 },
1878 1839
1879 .elevator_ktype = &as_ktype, 1840 .elevator_attrs = as_attrs,
1880 .elevator_name = "anticipatory", 1841 .elevator_name = "anticipatory",
1881 .elevator_owner = THIS_MODULE, 1842 .elevator_owner = THIS_MODULE,
1882}; 1843};