aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/md.txt8
-rw-r--r--drivers/md/md.c26
2 files changed, 34 insertions, 0 deletions
diff --git a/Documentation/md.txt b/Documentation/md.txt
index 1dd0fb6021cf..9710138d101a 100644
--- a/Documentation/md.txt
+++ b/Documentation/md.txt
@@ -166,6 +166,14 @@ All md devices contain:
166 will be empty. If an array is being resized (not currently 166 will be empty. If an array is being resized (not currently
167 possible) this will contain the larger of the old and new sizes. 167 possible) this will contain the larger of the old and new sizes.
168 168
169 chunk_size
170 This is the size if bytes for 'chunks' and is only relevant to
171 raid levels that involve striping (1,4,5,6,10). The address space
172 of the array is conceptually divided into chunks and consecutive
173 chunks are striped onto neighbouring devices.
174 The size should be atleast PAGE_SIZE (4k) and should be a power
175 of 2. This can only be set while assembling an array
176
169As component devices are added to an md array, they appear in the 'md' 177As component devices are added to an md array, they appear in the 'md'
170directory as new directories named 178directory as new directories named
171 dev-XXX 179 dev-XXX
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0b3081aa4d63..9e57e97bd530 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1795,6 +1795,31 @@ raid_disks_show(mddev_t *mddev, char *page)
1795static struct md_sysfs_entry md_raid_disks = __ATTR_RO(raid_disks); 1795static struct md_sysfs_entry md_raid_disks = __ATTR_RO(raid_disks);
1796 1796
1797static ssize_t 1797static ssize_t
1798chunk_size_show(mddev_t *mddev, char *page)
1799{
1800 return sprintf(page, "%d\n", mddev->chunk_size);
1801}
1802
1803static ssize_t
1804chunk_size_store(mddev_t *mddev, const char *buf, size_t len)
1805{
1806 /* can only set chunk_size if array is not yet active */
1807 char *e;
1808 unsigned long n = simple_strtoul(buf, &e, 10);
1809
1810 if (mddev->pers)
1811 return -EBUSY;
1812 if (!*buf || (*e && *e != '\n'))
1813 return -EINVAL;
1814
1815 mddev->chunk_size = n;
1816 return len;
1817}
1818static struct md_sysfs_entry md_chunk_size =
1819__ATTR(chunk_size, 0644, chunk_size_show, chunk_size_store);
1820
1821
1822static ssize_t
1798action_show(mddev_t *mddev, char *page) 1823action_show(mddev_t *mddev, char *page)
1799{ 1824{
1800 char *type = "idle"; 1825 char *type = "idle";
@@ -1861,6 +1886,7 @@ md_mismatches = __ATTR_RO(mismatch_cnt);
1861static struct attribute *md_default_attrs[] = { 1886static struct attribute *md_default_attrs[] = {
1862 &md_level.attr, 1887 &md_level.attr,
1863 &md_raid_disks.attr, 1888 &md_raid_disks.attr,
1889 &md_chunk_size.attr,
1864 NULL, 1890 NULL,
1865}; 1891};
1866 1892