diff options
author | Christoph Hellwig <hch@lst.de> | 2015-10-03 09:32:58 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-10-14 01:17:55 -0400 |
commit | 45b997737a8025be2825e464e9e9dd5d07160dc3 (patch) | |
tree | b50ae2e25fd9d8727a097520ad655a9b2e521715 /fs | |
parent | 13a83fc9096dfaf2a7f4671b5777780bbe1d4a30 (diff) |
ocfs2/cluster: use per-attribute show and store methods
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/cluster/heartbeat.c | 205 | ||||
-rw-r--r-- | fs/ocfs2/cluster/nodemanager.c | 241 |
2 files changed, 100 insertions, 346 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index fa15debcc02b..e404386bd93e 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
@@ -1473,16 +1473,17 @@ static int o2hb_read_block_input(struct o2hb_region *reg, | |||
1473 | return 0; | 1473 | return 0; |
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | static ssize_t o2hb_region_block_bytes_read(struct o2hb_region *reg, | 1476 | static ssize_t o2hb_region_block_bytes_show(struct config_item *item, |
1477 | char *page) | 1477 | char *page) |
1478 | { | 1478 | { |
1479 | return sprintf(page, "%u\n", reg->hr_block_bytes); | 1479 | return sprintf(page, "%u\n", to_o2hb_region(item)->hr_block_bytes); |
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg, | 1482 | static ssize_t o2hb_region_block_bytes_store(struct config_item *item, |
1483 | const char *page, | 1483 | const char *page, |
1484 | size_t count) | 1484 | size_t count) |
1485 | { | 1485 | { |
1486 | struct o2hb_region *reg = to_o2hb_region(item); | ||
1486 | int status; | 1487 | int status; |
1487 | unsigned long block_bytes; | 1488 | unsigned long block_bytes; |
1488 | unsigned int block_bits; | 1489 | unsigned int block_bits; |
@@ -1501,16 +1502,17 @@ static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg, | |||
1501 | return count; | 1502 | return count; |
1502 | } | 1503 | } |
1503 | 1504 | ||
1504 | static ssize_t o2hb_region_start_block_read(struct o2hb_region *reg, | 1505 | static ssize_t o2hb_region_start_block_show(struct config_item *item, |
1505 | char *page) | 1506 | char *page) |
1506 | { | 1507 | { |
1507 | return sprintf(page, "%llu\n", reg->hr_start_block); | 1508 | return sprintf(page, "%llu\n", to_o2hb_region(item)->hr_start_block); |
1508 | } | 1509 | } |
1509 | 1510 | ||
1510 | static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg, | 1511 | static ssize_t o2hb_region_start_block_store(struct config_item *item, |
1511 | const char *page, | 1512 | const char *page, |
1512 | size_t count) | 1513 | size_t count) |
1513 | { | 1514 | { |
1515 | struct o2hb_region *reg = to_o2hb_region(item); | ||
1514 | unsigned long long tmp; | 1516 | unsigned long long tmp; |
1515 | char *p = (char *)page; | 1517 | char *p = (char *)page; |
1516 | 1518 | ||
@@ -1526,16 +1528,16 @@ static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg, | |||
1526 | return count; | 1528 | return count; |
1527 | } | 1529 | } |
1528 | 1530 | ||
1529 | static ssize_t o2hb_region_blocks_read(struct o2hb_region *reg, | 1531 | static ssize_t o2hb_region_blocks_show(struct config_item *item, char *page) |
1530 | char *page) | ||
1531 | { | 1532 | { |
1532 | return sprintf(page, "%d\n", reg->hr_blocks); | 1533 | return sprintf(page, "%d\n", to_o2hb_region(item)->hr_blocks); |
1533 | } | 1534 | } |
1534 | 1535 | ||
1535 | static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg, | 1536 | static ssize_t o2hb_region_blocks_store(struct config_item *item, |
1536 | const char *page, | 1537 | const char *page, |
1537 | size_t count) | 1538 | size_t count) |
1538 | { | 1539 | { |
1540 | struct o2hb_region *reg = to_o2hb_region(item); | ||
1539 | unsigned long tmp; | 1541 | unsigned long tmp; |
1540 | char *p = (char *)page; | 1542 | char *p = (char *)page; |
1541 | 1543 | ||
@@ -1554,13 +1556,12 @@ static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg, | |||
1554 | return count; | 1556 | return count; |
1555 | } | 1557 | } |
1556 | 1558 | ||
1557 | static ssize_t o2hb_region_dev_read(struct o2hb_region *reg, | 1559 | static ssize_t o2hb_region_dev_show(struct config_item *item, char *page) |
1558 | char *page) | ||
1559 | { | 1560 | { |
1560 | unsigned int ret = 0; | 1561 | unsigned int ret = 0; |
1561 | 1562 | ||
1562 | if (reg->hr_bdev) | 1563 | if (to_o2hb_region(item)->hr_bdev) |
1563 | ret = sprintf(page, "%s\n", reg->hr_dev_name); | 1564 | ret = sprintf(page, "%s\n", to_o2hb_region(item)->hr_dev_name); |
1564 | 1565 | ||
1565 | return ret; | 1566 | return ret; |
1566 | } | 1567 | } |
@@ -1670,10 +1671,11 @@ out: | |||
1670 | } | 1671 | } |
1671 | 1672 | ||
1672 | /* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */ | 1673 | /* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */ |
1673 | static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, | 1674 | static ssize_t o2hb_region_dev_store(struct config_item *item, |
1674 | const char *page, | 1675 | const char *page, |
1675 | size_t count) | 1676 | size_t count) |
1676 | { | 1677 | { |
1678 | struct o2hb_region *reg = to_o2hb_region(item); | ||
1677 | struct task_struct *hb_task; | 1679 | struct task_struct *hb_task; |
1678 | long fd; | 1680 | long fd; |
1679 | int sectsize; | 1681 | int sectsize; |
@@ -1828,9 +1830,9 @@ out: | |||
1828 | return ret; | 1830 | return ret; |
1829 | } | 1831 | } |
1830 | 1832 | ||
1831 | static ssize_t o2hb_region_pid_read(struct o2hb_region *reg, | 1833 | static ssize_t o2hb_region_pid_show(struct config_item *item, char *page) |
1832 | char *page) | ||
1833 | { | 1834 | { |
1835 | struct o2hb_region *reg = to_o2hb_region(item); | ||
1834 | pid_t pid = 0; | 1836 | pid_t pid = 0; |
1835 | 1837 | ||
1836 | spin_lock(&o2hb_live_lock); | 1838 | spin_lock(&o2hb_live_lock); |
@@ -1844,92 +1846,23 @@ static ssize_t o2hb_region_pid_read(struct o2hb_region *reg, | |||
1844 | return sprintf(page, "%u\n", pid); | 1846 | return sprintf(page, "%u\n", pid); |
1845 | } | 1847 | } |
1846 | 1848 | ||
1847 | struct o2hb_region_attribute { | 1849 | CONFIGFS_ATTR(o2hb_region_, block_bytes); |
1848 | struct configfs_attribute attr; | 1850 | CONFIGFS_ATTR(o2hb_region_, start_block); |
1849 | ssize_t (*show)(struct o2hb_region *, char *); | 1851 | CONFIGFS_ATTR(o2hb_region_, blocks); |
1850 | ssize_t (*store)(struct o2hb_region *, const char *, size_t); | 1852 | CONFIGFS_ATTR(o2hb_region_, dev); |
1851 | }; | 1853 | CONFIGFS_ATTR_RO(o2hb_region_, pid); |
1852 | |||
1853 | static struct o2hb_region_attribute o2hb_region_attr_block_bytes = { | ||
1854 | .attr = { .ca_owner = THIS_MODULE, | ||
1855 | .ca_name = "block_bytes", | ||
1856 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
1857 | .show = o2hb_region_block_bytes_read, | ||
1858 | .store = o2hb_region_block_bytes_write, | ||
1859 | }; | ||
1860 | |||
1861 | static struct o2hb_region_attribute o2hb_region_attr_start_block = { | ||
1862 | .attr = { .ca_owner = THIS_MODULE, | ||
1863 | .ca_name = "start_block", | ||
1864 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
1865 | .show = o2hb_region_start_block_read, | ||
1866 | .store = o2hb_region_start_block_write, | ||
1867 | }; | ||
1868 | |||
1869 | static struct o2hb_region_attribute o2hb_region_attr_blocks = { | ||
1870 | .attr = { .ca_owner = THIS_MODULE, | ||
1871 | .ca_name = "blocks", | ||
1872 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
1873 | .show = o2hb_region_blocks_read, | ||
1874 | .store = o2hb_region_blocks_write, | ||
1875 | }; | ||
1876 | |||
1877 | static struct o2hb_region_attribute o2hb_region_attr_dev = { | ||
1878 | .attr = { .ca_owner = THIS_MODULE, | ||
1879 | .ca_name = "dev", | ||
1880 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
1881 | .show = o2hb_region_dev_read, | ||
1882 | .store = o2hb_region_dev_write, | ||
1883 | }; | ||
1884 | |||
1885 | static struct o2hb_region_attribute o2hb_region_attr_pid = { | ||
1886 | .attr = { .ca_owner = THIS_MODULE, | ||
1887 | .ca_name = "pid", | ||
1888 | .ca_mode = S_IRUGO | S_IRUSR }, | ||
1889 | .show = o2hb_region_pid_read, | ||
1890 | }; | ||
1891 | 1854 | ||
1892 | static struct configfs_attribute *o2hb_region_attrs[] = { | 1855 | static struct configfs_attribute *o2hb_region_attrs[] = { |
1893 | &o2hb_region_attr_block_bytes.attr, | 1856 | &o2hb_region_attr_block_bytes, |
1894 | &o2hb_region_attr_start_block.attr, | 1857 | &o2hb_region_attr_start_block, |
1895 | &o2hb_region_attr_blocks.attr, | 1858 | &o2hb_region_attr_blocks, |
1896 | &o2hb_region_attr_dev.attr, | 1859 | &o2hb_region_attr_dev, |
1897 | &o2hb_region_attr_pid.attr, | 1860 | &o2hb_region_attr_pid, |
1898 | NULL, | 1861 | NULL, |
1899 | }; | 1862 | }; |
1900 | 1863 | ||
1901 | static ssize_t o2hb_region_show(struct config_item *item, | ||
1902 | struct configfs_attribute *attr, | ||
1903 | char *page) | ||
1904 | { | ||
1905 | struct o2hb_region *reg = to_o2hb_region(item); | ||
1906 | struct o2hb_region_attribute *o2hb_region_attr = | ||
1907 | container_of(attr, struct o2hb_region_attribute, attr); | ||
1908 | ssize_t ret = 0; | ||
1909 | |||
1910 | if (o2hb_region_attr->show) | ||
1911 | ret = o2hb_region_attr->show(reg, page); | ||
1912 | return ret; | ||
1913 | } | ||
1914 | |||
1915 | static ssize_t o2hb_region_store(struct config_item *item, | ||
1916 | struct configfs_attribute *attr, | ||
1917 | const char *page, size_t count) | ||
1918 | { | ||
1919 | struct o2hb_region *reg = to_o2hb_region(item); | ||
1920 | struct o2hb_region_attribute *o2hb_region_attr = | ||
1921 | container_of(attr, struct o2hb_region_attribute, attr); | ||
1922 | ssize_t ret = -EINVAL; | ||
1923 | |||
1924 | if (o2hb_region_attr->store) | ||
1925 | ret = o2hb_region_attr->store(reg, page, count); | ||
1926 | return ret; | ||
1927 | } | ||
1928 | |||
1929 | static struct configfs_item_operations o2hb_region_item_ops = { | 1864 | static struct configfs_item_operations o2hb_region_item_ops = { |
1930 | .release = o2hb_region_release, | 1865 | .release = o2hb_region_release, |
1931 | .show_attribute = o2hb_region_show, | ||
1932 | .store_attribute = o2hb_region_store, | ||
1933 | }; | 1866 | }; |
1934 | 1867 | ||
1935 | static struct config_item_type o2hb_region_type = { | 1868 | static struct config_item_type o2hb_region_type = { |
@@ -2124,49 +2057,14 @@ unlock: | |||
2124 | spin_unlock(&o2hb_live_lock); | 2057 | spin_unlock(&o2hb_live_lock); |
2125 | } | 2058 | } |
2126 | 2059 | ||
2127 | struct o2hb_heartbeat_group_attribute { | 2060 | static ssize_t o2hb_heartbeat_group_threshold_show(struct config_item *item, |
2128 | struct configfs_attribute attr; | 2061 | char *page) |
2129 | ssize_t (*show)(struct o2hb_heartbeat_group *, char *); | ||
2130 | ssize_t (*store)(struct o2hb_heartbeat_group *, const char *, size_t); | ||
2131 | }; | ||
2132 | |||
2133 | static ssize_t o2hb_heartbeat_group_show(struct config_item *item, | ||
2134 | struct configfs_attribute *attr, | ||
2135 | char *page) | ||
2136 | { | ||
2137 | struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item)); | ||
2138 | struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr = | ||
2139 | container_of(attr, struct o2hb_heartbeat_group_attribute, attr); | ||
2140 | ssize_t ret = 0; | ||
2141 | |||
2142 | if (o2hb_heartbeat_group_attr->show) | ||
2143 | ret = o2hb_heartbeat_group_attr->show(reg, page); | ||
2144 | return ret; | ||
2145 | } | ||
2146 | |||
2147 | static ssize_t o2hb_heartbeat_group_store(struct config_item *item, | ||
2148 | struct configfs_attribute *attr, | ||
2149 | const char *page, size_t count) | ||
2150 | { | ||
2151 | struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item)); | ||
2152 | struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr = | ||
2153 | container_of(attr, struct o2hb_heartbeat_group_attribute, attr); | ||
2154 | ssize_t ret = -EINVAL; | ||
2155 | |||
2156 | if (o2hb_heartbeat_group_attr->store) | ||
2157 | ret = o2hb_heartbeat_group_attr->store(reg, page, count); | ||
2158 | return ret; | ||
2159 | } | ||
2160 | |||
2161 | static ssize_t o2hb_heartbeat_group_threshold_show(struct o2hb_heartbeat_group *group, | ||
2162 | char *page) | ||
2163 | { | 2062 | { |
2164 | return sprintf(page, "%u\n", o2hb_dead_threshold); | 2063 | return sprintf(page, "%u\n", o2hb_dead_threshold); |
2165 | } | 2064 | } |
2166 | 2065 | ||
2167 | static ssize_t o2hb_heartbeat_group_threshold_store(struct o2hb_heartbeat_group *group, | 2066 | static ssize_t o2hb_heartbeat_group_threshold_store(struct config_item *item, |
2168 | const char *page, | 2067 | const char *page, size_t count) |
2169 | size_t count) | ||
2170 | { | 2068 | { |
2171 | unsigned long tmp; | 2069 | unsigned long tmp; |
2172 | char *p = (char *)page; | 2070 | char *p = (char *)page; |
@@ -2181,17 +2079,15 @@ static ssize_t o2hb_heartbeat_group_threshold_store(struct o2hb_heartbeat_group | |||
2181 | return count; | 2079 | return count; |
2182 | } | 2080 | } |
2183 | 2081 | ||
2184 | static | 2082 | static ssize_t o2hb_heartbeat_group_mode_show(struct config_item *item, |
2185 | ssize_t o2hb_heartbeat_group_mode_show(struct o2hb_heartbeat_group *group, | 2083 | char *page) |
2186 | char *page) | ||
2187 | { | 2084 | { |
2188 | return sprintf(page, "%s\n", | 2085 | return sprintf(page, "%s\n", |
2189 | o2hb_heartbeat_mode_desc[o2hb_heartbeat_mode]); | 2086 | o2hb_heartbeat_mode_desc[o2hb_heartbeat_mode]); |
2190 | } | 2087 | } |
2191 | 2088 | ||
2192 | static | 2089 | static ssize_t o2hb_heartbeat_group_mode_store(struct config_item *item, |
2193 | ssize_t o2hb_heartbeat_group_mode_store(struct o2hb_heartbeat_group *group, | 2090 | const char *page, size_t count) |
2194 | const char *page, size_t count) | ||
2195 | { | 2091 | { |
2196 | unsigned int i; | 2092 | unsigned int i; |
2197 | int ret; | 2093 | int ret; |
@@ -2216,33 +2112,15 @@ ssize_t o2hb_heartbeat_group_mode_store(struct o2hb_heartbeat_group *group, | |||
2216 | 2112 | ||
2217 | } | 2113 | } |
2218 | 2114 | ||
2219 | static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold = { | 2115 | CONFIGFS_ATTR(o2hb_heartbeat_group_, threshold); |
2220 | .attr = { .ca_owner = THIS_MODULE, | 2116 | CONFIGFS_ATTR(o2hb_heartbeat_group_, mode); |
2221 | .ca_name = "dead_threshold", | ||
2222 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
2223 | .show = o2hb_heartbeat_group_threshold_show, | ||
2224 | .store = o2hb_heartbeat_group_threshold_store, | ||
2225 | }; | ||
2226 | |||
2227 | static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_mode = { | ||
2228 | .attr = { .ca_owner = THIS_MODULE, | ||
2229 | .ca_name = "mode", | ||
2230 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
2231 | .show = o2hb_heartbeat_group_mode_show, | ||
2232 | .store = o2hb_heartbeat_group_mode_store, | ||
2233 | }; | ||
2234 | 2117 | ||
2235 | static struct configfs_attribute *o2hb_heartbeat_group_attrs[] = { | 2118 | static struct configfs_attribute *o2hb_heartbeat_group_attrs[] = { |
2236 | &o2hb_heartbeat_group_attr_threshold.attr, | 2119 | &o2hb_heartbeat_group_attr_threshold, |
2237 | &o2hb_heartbeat_group_attr_mode.attr, | 2120 | &o2hb_heartbeat_group_attr_mode, |
2238 | NULL, | 2121 | NULL, |
2239 | }; | 2122 | }; |
2240 | 2123 | ||
2241 | static struct configfs_item_operations o2hb_heartbeat_group_item_ops = { | ||
2242 | .show_attribute = o2hb_heartbeat_group_show, | ||
2243 | .store_attribute = o2hb_heartbeat_group_store, | ||
2244 | }; | ||
2245 | |||
2246 | static struct configfs_group_operations o2hb_heartbeat_group_group_ops = { | 2124 | static struct configfs_group_operations o2hb_heartbeat_group_group_ops = { |
2247 | .make_item = o2hb_heartbeat_group_make_item, | 2125 | .make_item = o2hb_heartbeat_group_make_item, |
2248 | .drop_item = o2hb_heartbeat_group_drop_item, | 2126 | .drop_item = o2hb_heartbeat_group_drop_item, |
@@ -2250,7 +2128,6 @@ static struct configfs_group_operations o2hb_heartbeat_group_group_ops = { | |||
2250 | 2128 | ||
2251 | static struct config_item_type o2hb_heartbeat_group_type = { | 2129 | static struct config_item_type o2hb_heartbeat_group_type = { |
2252 | .ct_group_ops = &o2hb_heartbeat_group_group_ops, | 2130 | .ct_group_ops = &o2hb_heartbeat_group_group_ops, |
2253 | .ct_item_ops = &o2hb_heartbeat_group_item_ops, | ||
2254 | .ct_attrs = o2hb_heartbeat_group_attrs, | 2131 | .ct_attrs = o2hb_heartbeat_group_attrs, |
2255 | .ct_owner = THIS_MODULE, | 2132 | .ct_owner = THIS_MODULE, |
2256 | }; | 2133 | }; |
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index 7a398f6346ed..72afdca3cea7 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c | |||
@@ -172,9 +172,9 @@ static void o2nm_node_release(struct config_item *item) | |||
172 | kfree(node); | 172 | kfree(node); |
173 | } | 173 | } |
174 | 174 | ||
175 | static ssize_t o2nm_node_num_read(struct o2nm_node *node, char *page) | 175 | static ssize_t o2nm_node_num_show(struct config_item *item, char *page) |
176 | { | 176 | { |
177 | return sprintf(page, "%d\n", node->nd_num); | 177 | return sprintf(page, "%d\n", to_o2nm_node(item)->nd_num); |
178 | } | 178 | } |
179 | 179 | ||
180 | static struct o2nm_cluster *to_o2nm_cluster_from_node(struct o2nm_node *node) | 180 | static struct o2nm_cluster *to_o2nm_cluster_from_node(struct o2nm_node *node) |
@@ -190,9 +190,10 @@ enum { | |||
190 | O2NM_NODE_ATTR_ADDRESS, | 190 | O2NM_NODE_ATTR_ADDRESS, |
191 | }; | 191 | }; |
192 | 192 | ||
193 | static ssize_t o2nm_node_num_write(struct o2nm_node *node, const char *page, | 193 | static ssize_t o2nm_node_num_store(struct config_item *item, const char *page, |
194 | size_t count) | 194 | size_t count) |
195 | { | 195 | { |
196 | struct o2nm_node *node = to_o2nm_node(item); | ||
196 | struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); | 197 | struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); |
197 | unsigned long tmp; | 198 | unsigned long tmp; |
198 | char *p = (char *)page; | 199 | char *p = (char *)page; |
@@ -230,14 +231,15 @@ static ssize_t o2nm_node_num_write(struct o2nm_node *node, const char *page, | |||
230 | 231 | ||
231 | return count; | 232 | return count; |
232 | } | 233 | } |
233 | static ssize_t o2nm_node_ipv4_port_read(struct o2nm_node *node, char *page) | 234 | static ssize_t o2nm_node_ipv4_port_show(struct config_item *item, char *page) |
234 | { | 235 | { |
235 | return sprintf(page, "%u\n", ntohs(node->nd_ipv4_port)); | 236 | return sprintf(page, "%u\n", ntohs(to_o2nm_node(item)->nd_ipv4_port)); |
236 | } | 237 | } |
237 | 238 | ||
238 | static ssize_t o2nm_node_ipv4_port_write(struct o2nm_node *node, | 239 | static ssize_t o2nm_node_ipv4_port_store(struct config_item *item, |
239 | const char *page, size_t count) | 240 | const char *page, size_t count) |
240 | { | 241 | { |
242 | struct o2nm_node *node = to_o2nm_node(item); | ||
241 | unsigned long tmp; | 243 | unsigned long tmp; |
242 | char *p = (char *)page; | 244 | char *p = (char *)page; |
243 | 245 | ||
@@ -257,15 +259,16 @@ static ssize_t o2nm_node_ipv4_port_write(struct o2nm_node *node, | |||
257 | return count; | 259 | return count; |
258 | } | 260 | } |
259 | 261 | ||
260 | static ssize_t o2nm_node_ipv4_address_read(struct o2nm_node *node, char *page) | 262 | static ssize_t o2nm_node_ipv4_address_show(struct config_item *item, char *page) |
261 | { | 263 | { |
262 | return sprintf(page, "%pI4\n", &node->nd_ipv4_address); | 264 | return sprintf(page, "%pI4\n", &to_o2nm_node(item)->nd_ipv4_address); |
263 | } | 265 | } |
264 | 266 | ||
265 | static ssize_t o2nm_node_ipv4_address_write(struct o2nm_node *node, | 267 | static ssize_t o2nm_node_ipv4_address_store(struct config_item *item, |
266 | const char *page, | 268 | const char *page, |
267 | size_t count) | 269 | size_t count) |
268 | { | 270 | { |
271 | struct o2nm_node *node = to_o2nm_node(item); | ||
269 | struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); | 272 | struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); |
270 | int ret, i; | 273 | int ret, i; |
271 | struct rb_node **p, *parent; | 274 | struct rb_node **p, *parent; |
@@ -303,14 +306,15 @@ static ssize_t o2nm_node_ipv4_address_write(struct o2nm_node *node, | |||
303 | return count; | 306 | return count; |
304 | } | 307 | } |
305 | 308 | ||
306 | static ssize_t o2nm_node_local_read(struct o2nm_node *node, char *page) | 309 | static ssize_t o2nm_node_local_show(struct config_item *item, char *page) |
307 | { | 310 | { |
308 | return sprintf(page, "%d\n", node->nd_local); | 311 | return sprintf(page, "%d\n", to_o2nm_node(item)->nd_local); |
309 | } | 312 | } |
310 | 313 | ||
311 | static ssize_t o2nm_node_local_write(struct o2nm_node *node, const char *page, | 314 | static ssize_t o2nm_node_local_store(struct config_item *item, const char *page, |
312 | size_t count) | 315 | size_t count) |
313 | { | 316 | { |
317 | struct o2nm_node *node = to_o2nm_node(item); | ||
314 | struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); | 318 | struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); |
315 | unsigned long tmp; | 319 | unsigned long tmp; |
316 | char *p = (char *)page; | 320 | char *p = (char *)page; |
@@ -357,84 +361,21 @@ static ssize_t o2nm_node_local_write(struct o2nm_node *node, const char *page, | |||
357 | return count; | 361 | return count; |
358 | } | 362 | } |
359 | 363 | ||
360 | struct o2nm_node_attribute { | 364 | CONFIGFS_ATTR(o2nm_node_, num); |
361 | struct configfs_attribute attr; | 365 | CONFIGFS_ATTR(o2nm_node_, ipv4_port); |
362 | ssize_t (*show)(struct o2nm_node *, char *); | 366 | CONFIGFS_ATTR(o2nm_node_, ipv4_address); |
363 | ssize_t (*store)(struct o2nm_node *, const char *, size_t); | 367 | CONFIGFS_ATTR(o2nm_node_, local); |
364 | }; | ||
365 | |||
366 | static struct o2nm_node_attribute o2nm_node_attr_num = { | ||
367 | .attr = { .ca_owner = THIS_MODULE, | ||
368 | .ca_name = "num", | ||
369 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
370 | .show = o2nm_node_num_read, | ||
371 | .store = o2nm_node_num_write, | ||
372 | }; | ||
373 | |||
374 | static struct o2nm_node_attribute o2nm_node_attr_ipv4_port = { | ||
375 | .attr = { .ca_owner = THIS_MODULE, | ||
376 | .ca_name = "ipv4_port", | ||
377 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
378 | .show = o2nm_node_ipv4_port_read, | ||
379 | .store = o2nm_node_ipv4_port_write, | ||
380 | }; | ||
381 | |||
382 | static struct o2nm_node_attribute o2nm_node_attr_ipv4_address = { | ||
383 | .attr = { .ca_owner = THIS_MODULE, | ||
384 | .ca_name = "ipv4_address", | ||
385 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
386 | .show = o2nm_node_ipv4_address_read, | ||
387 | .store = o2nm_node_ipv4_address_write, | ||
388 | }; | ||
389 | |||
390 | static struct o2nm_node_attribute o2nm_node_attr_local = { | ||
391 | .attr = { .ca_owner = THIS_MODULE, | ||
392 | .ca_name = "local", | ||
393 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
394 | .show = o2nm_node_local_read, | ||
395 | .store = o2nm_node_local_write, | ||
396 | }; | ||
397 | 368 | ||
398 | static struct configfs_attribute *o2nm_node_attrs[] = { | 369 | static struct configfs_attribute *o2nm_node_attrs[] = { |
399 | &o2nm_node_attr_num.attr, | 370 | &o2nm_node_attr_num, |
400 | &o2nm_node_attr_ipv4_port.attr, | 371 | &o2nm_node_attr_ipv4_port, |
401 | &o2nm_node_attr_ipv4_address.attr, | 372 | &o2nm_node_attr_ipv4_address, |
402 | &o2nm_node_attr_local.attr, | 373 | &o2nm_node_attr_local, |
403 | NULL, | 374 | NULL, |
404 | }; | 375 | }; |
405 | 376 | ||
406 | static ssize_t o2nm_node_show(struct config_item *item, | ||
407 | struct configfs_attribute *attr, | ||
408 | char *page) | ||
409 | { | ||
410 | struct o2nm_node *node = to_o2nm_node(item); | ||
411 | struct o2nm_node_attribute *o2nm_node_attr = | ||
412 | container_of(attr, struct o2nm_node_attribute, attr); | ||
413 | ssize_t ret = 0; | ||
414 | |||
415 | if (o2nm_node_attr->show) | ||
416 | ret = o2nm_node_attr->show(node, page); | ||
417 | return ret; | ||
418 | } | ||
419 | |||
420 | static ssize_t o2nm_node_store(struct config_item *item, | ||
421 | struct configfs_attribute *attr, | ||
422 | const char *page, size_t count) | ||
423 | { | ||
424 | struct o2nm_node *node = to_o2nm_node(item); | ||
425 | struct o2nm_node_attribute *o2nm_node_attr = | ||
426 | container_of(attr, struct o2nm_node_attribute, attr); | ||
427 | |||
428 | if (o2nm_node_attr->store == NULL) | ||
429 | return -EINVAL; | ||
430 | |||
431 | return o2nm_node_attr->store(node, page, count); | ||
432 | } | ||
433 | |||
434 | static struct configfs_item_operations o2nm_node_item_ops = { | 377 | static struct configfs_item_operations o2nm_node_item_ops = { |
435 | .release = o2nm_node_release, | 378 | .release = o2nm_node_release, |
436 | .show_attribute = o2nm_node_show, | ||
437 | .store_attribute = o2nm_node_store, | ||
438 | }; | 379 | }; |
439 | 380 | ||
440 | static struct config_item_type o2nm_node_type = { | 381 | static struct config_item_type o2nm_node_type = { |
@@ -459,12 +400,6 @@ static struct o2nm_node_group *to_o2nm_node_group(struct config_group *group) | |||
459 | } | 400 | } |
460 | #endif | 401 | #endif |
461 | 402 | ||
462 | struct o2nm_cluster_attribute { | ||
463 | struct configfs_attribute attr; | ||
464 | ssize_t (*show)(struct o2nm_cluster *, char *); | ||
465 | ssize_t (*store)(struct o2nm_cluster *, const char *, size_t); | ||
466 | }; | ||
467 | |||
468 | static ssize_t o2nm_cluster_attr_write(const char *page, ssize_t count, | 403 | static ssize_t o2nm_cluster_attr_write(const char *page, ssize_t count, |
469 | unsigned int *val) | 404 | unsigned int *val) |
470 | { | 405 | { |
@@ -485,15 +420,16 @@ static ssize_t o2nm_cluster_attr_write(const char *page, ssize_t count, | |||
485 | return count; | 420 | return count; |
486 | } | 421 | } |
487 | 422 | ||
488 | static ssize_t o2nm_cluster_attr_idle_timeout_ms_read( | 423 | static ssize_t o2nm_cluster_idle_timeout_ms_show(struct config_item *item, |
489 | struct o2nm_cluster *cluster, char *page) | 424 | char *page) |
490 | { | 425 | { |
491 | return sprintf(page, "%u\n", cluster->cl_idle_timeout_ms); | 426 | return sprintf(page, "%u\n", to_o2nm_cluster(item)->cl_idle_timeout_ms); |
492 | } | 427 | } |
493 | 428 | ||
494 | static ssize_t o2nm_cluster_attr_idle_timeout_ms_write( | 429 | static ssize_t o2nm_cluster_idle_timeout_ms_store(struct config_item *item, |
495 | struct o2nm_cluster *cluster, const char *page, size_t count) | 430 | const char *page, size_t count) |
496 | { | 431 | { |
432 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); | ||
497 | ssize_t ret; | 433 | ssize_t ret; |
498 | unsigned int val; | 434 | unsigned int val; |
499 | 435 | ||
@@ -520,15 +456,17 @@ static ssize_t o2nm_cluster_attr_idle_timeout_ms_write( | |||
520 | return ret; | 456 | return ret; |
521 | } | 457 | } |
522 | 458 | ||
523 | static ssize_t o2nm_cluster_attr_keepalive_delay_ms_read( | 459 | static ssize_t o2nm_cluster_keepalive_delay_ms_show( |
524 | struct o2nm_cluster *cluster, char *page) | 460 | struct config_item *item, char *page) |
525 | { | 461 | { |
526 | return sprintf(page, "%u\n", cluster->cl_keepalive_delay_ms); | 462 | return sprintf(page, "%u\n", |
463 | to_o2nm_cluster(item)->cl_keepalive_delay_ms); | ||
527 | } | 464 | } |
528 | 465 | ||
529 | static ssize_t o2nm_cluster_attr_keepalive_delay_ms_write( | 466 | static ssize_t o2nm_cluster_keepalive_delay_ms_store( |
530 | struct o2nm_cluster *cluster, const char *page, size_t count) | 467 | struct config_item *item, const char *page, size_t count) |
531 | { | 468 | { |
469 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); | ||
532 | ssize_t ret; | 470 | ssize_t ret; |
533 | unsigned int val; | 471 | unsigned int val; |
534 | 472 | ||
@@ -555,22 +493,24 @@ static ssize_t o2nm_cluster_attr_keepalive_delay_ms_write( | |||
555 | return ret; | 493 | return ret; |
556 | } | 494 | } |
557 | 495 | ||
558 | static ssize_t o2nm_cluster_attr_reconnect_delay_ms_read( | 496 | static ssize_t o2nm_cluster_reconnect_delay_ms_show( |
559 | struct o2nm_cluster *cluster, char *page) | 497 | struct config_item *item, char *page) |
560 | { | 498 | { |
561 | return sprintf(page, "%u\n", cluster->cl_reconnect_delay_ms); | 499 | return sprintf(page, "%u\n", |
500 | to_o2nm_cluster(item)->cl_reconnect_delay_ms); | ||
562 | } | 501 | } |
563 | 502 | ||
564 | static ssize_t o2nm_cluster_attr_reconnect_delay_ms_write( | 503 | static ssize_t o2nm_cluster_reconnect_delay_ms_store( |
565 | struct o2nm_cluster *cluster, const char *page, size_t count) | 504 | struct config_item *item, const char *page, size_t count) |
566 | { | 505 | { |
567 | return o2nm_cluster_attr_write(page, count, | 506 | return o2nm_cluster_attr_write(page, count, |
568 | &cluster->cl_reconnect_delay_ms); | 507 | &to_o2nm_cluster(item)->cl_reconnect_delay_ms); |
569 | } | 508 | } |
570 | 509 | ||
571 | static ssize_t o2nm_cluster_attr_fence_method_read( | 510 | static ssize_t o2nm_cluster_fence_method_show( |
572 | struct o2nm_cluster *cluster, char *page) | 511 | struct config_item *item, char *page) |
573 | { | 512 | { |
513 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); | ||
574 | ssize_t ret = 0; | 514 | ssize_t ret = 0; |
575 | 515 | ||
576 | if (cluster) | 516 | if (cluster) |
@@ -579,8 +519,8 @@ static ssize_t o2nm_cluster_attr_fence_method_read( | |||
579 | return ret; | 519 | return ret; |
580 | } | 520 | } |
581 | 521 | ||
582 | static ssize_t o2nm_cluster_attr_fence_method_write( | 522 | static ssize_t o2nm_cluster_fence_method_store( |
583 | struct o2nm_cluster *cluster, const char *page, size_t count) | 523 | struct config_item *item, const char *page, size_t count) |
584 | { | 524 | { |
585 | unsigned int i; | 525 | unsigned int i; |
586 | 526 | ||
@@ -592,10 +532,10 @@ static ssize_t o2nm_cluster_attr_fence_method_write( | |||
592 | continue; | 532 | continue; |
593 | if (strncasecmp(page, o2nm_fence_method_desc[i], count - 1)) | 533 | if (strncasecmp(page, o2nm_fence_method_desc[i], count - 1)) |
594 | continue; | 534 | continue; |
595 | if (cluster->cl_fence_method != i) { | 535 | if (to_o2nm_cluster(item)->cl_fence_method != i) { |
596 | printk(KERN_INFO "ocfs2: Changing fence method to %s\n", | 536 | printk(KERN_INFO "ocfs2: Changing fence method to %s\n", |
597 | o2nm_fence_method_desc[i]); | 537 | o2nm_fence_method_desc[i]); |
598 | cluster->cl_fence_method = i; | 538 | to_o2nm_cluster(item)->cl_fence_method = i; |
599 | } | 539 | } |
600 | return count; | 540 | return count; |
601 | } | 541 | } |
@@ -604,79 +544,18 @@ bail: | |||
604 | return -EINVAL; | 544 | return -EINVAL; |
605 | } | 545 | } |
606 | 546 | ||
607 | static struct o2nm_cluster_attribute o2nm_cluster_attr_idle_timeout_ms = { | 547 | CONFIGFS_ATTR(o2nm_cluster_, idle_timeout_ms); |
608 | .attr = { .ca_owner = THIS_MODULE, | 548 | CONFIGFS_ATTR(o2nm_cluster_, keepalive_delay_ms); |
609 | .ca_name = "idle_timeout_ms", | 549 | CONFIGFS_ATTR(o2nm_cluster_, reconnect_delay_ms); |
610 | .ca_mode = S_IRUGO | S_IWUSR }, | 550 | CONFIGFS_ATTR(o2nm_cluster_, fence_method); |
611 | .show = o2nm_cluster_attr_idle_timeout_ms_read, | ||
612 | .store = o2nm_cluster_attr_idle_timeout_ms_write, | ||
613 | }; | ||
614 | |||
615 | static struct o2nm_cluster_attribute o2nm_cluster_attr_keepalive_delay_ms = { | ||
616 | .attr = { .ca_owner = THIS_MODULE, | ||
617 | .ca_name = "keepalive_delay_ms", | ||
618 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
619 | .show = o2nm_cluster_attr_keepalive_delay_ms_read, | ||
620 | .store = o2nm_cluster_attr_keepalive_delay_ms_write, | ||
621 | }; | ||
622 | |||
623 | static struct o2nm_cluster_attribute o2nm_cluster_attr_reconnect_delay_ms = { | ||
624 | .attr = { .ca_owner = THIS_MODULE, | ||
625 | .ca_name = "reconnect_delay_ms", | ||
626 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
627 | .show = o2nm_cluster_attr_reconnect_delay_ms_read, | ||
628 | .store = o2nm_cluster_attr_reconnect_delay_ms_write, | ||
629 | }; | ||
630 | |||
631 | static struct o2nm_cluster_attribute o2nm_cluster_attr_fence_method = { | ||
632 | .attr = { .ca_owner = THIS_MODULE, | ||
633 | .ca_name = "fence_method", | ||
634 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
635 | .show = o2nm_cluster_attr_fence_method_read, | ||
636 | .store = o2nm_cluster_attr_fence_method_write, | ||
637 | }; | ||
638 | 551 | ||
639 | static struct configfs_attribute *o2nm_cluster_attrs[] = { | 552 | static struct configfs_attribute *o2nm_cluster_attrs[] = { |
640 | &o2nm_cluster_attr_idle_timeout_ms.attr, | 553 | &o2nm_cluster_attr_idle_timeout_ms, |
641 | &o2nm_cluster_attr_keepalive_delay_ms.attr, | 554 | &o2nm_cluster_attr_keepalive_delay_ms, |
642 | &o2nm_cluster_attr_reconnect_delay_ms.attr, | 555 | &o2nm_cluster_attr_reconnect_delay_ms, |
643 | &o2nm_cluster_attr_fence_method.attr, | 556 | &o2nm_cluster_attr_fence_method, |
644 | NULL, | 557 | NULL, |
645 | }; | 558 | }; |
646 | static ssize_t o2nm_cluster_show(struct config_item *item, | ||
647 | struct configfs_attribute *attr, | ||
648 | char *page) | ||
649 | { | ||
650 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); | ||
651 | struct o2nm_cluster_attribute *o2nm_cluster_attr = | ||
652 | container_of(attr, struct o2nm_cluster_attribute, attr); | ||
653 | ssize_t ret = 0; | ||
654 | |||
655 | if (o2nm_cluster_attr->show) | ||
656 | ret = o2nm_cluster_attr->show(cluster, page); | ||
657 | return ret; | ||
658 | } | ||
659 | |||
660 | static ssize_t o2nm_cluster_store(struct config_item *item, | ||
661 | struct configfs_attribute *attr, | ||
662 | const char *page, size_t count) | ||
663 | { | ||
664 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); | ||
665 | struct o2nm_cluster_attribute *o2nm_cluster_attr = | ||
666 | container_of(attr, struct o2nm_cluster_attribute, attr); | ||
667 | ssize_t ret; | ||
668 | |||
669 | if (o2nm_cluster_attr->store == NULL) { | ||
670 | ret = -EINVAL; | ||
671 | goto out; | ||
672 | } | ||
673 | |||
674 | ret = o2nm_cluster_attr->store(cluster, page, count); | ||
675 | if (ret < count) | ||
676 | goto out; | ||
677 | out: | ||
678 | return ret; | ||
679 | } | ||
680 | 559 | ||
681 | static struct config_item *o2nm_node_group_make_item(struct config_group *group, | 560 | static struct config_item *o2nm_node_group_make_item(struct config_group *group, |
682 | const char *name) | 561 | const char *name) |
@@ -757,8 +636,6 @@ static void o2nm_cluster_release(struct config_item *item) | |||
757 | 636 | ||
758 | static struct configfs_item_operations o2nm_cluster_item_ops = { | 637 | static struct configfs_item_operations o2nm_cluster_item_ops = { |
759 | .release = o2nm_cluster_release, | 638 | .release = o2nm_cluster_release, |
760 | .show_attribute = o2nm_cluster_show, | ||
761 | .store_attribute = o2nm_cluster_store, | ||
762 | }; | 639 | }; |
763 | 640 | ||
764 | static struct config_item_type o2nm_cluster_type = { | 641 | static struct config_item_type o2nm_cluster_type = { |