Commit 3b34380ae8c5df6debd85183c7fa1ac05f79b7d2

Authored by NeilBrown
Committed by Linus Torvalds
1 parent 03c902e17f

[PATCH] md: allow chunk_size to be settable through sysfs

... only before array is started of course.

Signed-off-by: Neil Brown <neilb@suse.de>
Acked-by: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 2 changed files with 34 additions and 0 deletions Side-by-side Diff

Documentation/md.txt
... ... @@ -166,6 +166,14 @@
166 166 will be empty. If an array is being resized (not currently
167 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 +
169 177 As component devices are added to an md array, they appear in the 'md'
170 178 directory as new directories named
171 179 dev-XXX
... ... @@ -1795,6 +1795,31 @@
1795 1795 static struct md_sysfs_entry md_raid_disks = __ATTR_RO(raid_disks);
1796 1796  
1797 1797 static ssize_t
  1798 +chunk_size_show(mddev_t *mddev, char *page)
  1799 +{
  1800 + return sprintf(page, "%d\n", mddev->chunk_size);
  1801 +}
  1802 +
  1803 +static ssize_t
  1804 +chunk_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 +}
  1818 +static struct md_sysfs_entry md_chunk_size =
  1819 +__ATTR(chunk_size, 0644, chunk_size_show, chunk_size_store);
  1820 +
  1821 +
  1822 +static ssize_t
1798 1823 action_show(mddev_t *mddev, char *page)
1799 1824 {
1800 1825 char *type = "idle";
... ... @@ -1861,6 +1886,7 @@
1861 1886 static struct attribute *md_default_attrs[] = {
1862 1887 &md_level.attr,
1863 1888 &md_raid_disks.attr,
  1889 + &md_chunk_size.attr,
1864 1890 NULL,
1865 1891 };
1866 1892