aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bitmap.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-05-21 23:55:07 -0400
committerNeilBrown <neilb@suse.de>2012-05-21 23:55:07 -0400
commit6409bb05a9831f6af36a20b97cda13059c2ef1b6 (patch)
treec997526bd60d3fb5cafea604e5b240c2479e20d9 /drivers/md/bitmap.c
parentbf07bb7d5be813630d3530be274b3324f85e310c (diff)
md/bitmap: add new 'space' attribute for bitmaps.
If we are to allow bitmaps to be resized when the array is resized, we need to know how much space there is. So create an attribute to store this information and set appropriate defaults. It can be set more precisely via sysfs, or future metadata extensions may allow it to be recorded. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r--drivers/md/bitmap.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index c7784a985676..ac688fb54e1d 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1934,6 +1934,44 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
1934static struct md_sysfs_entry bitmap_location = 1934static struct md_sysfs_entry bitmap_location =
1935__ATTR(location, S_IRUGO|S_IWUSR, location_show, location_store); 1935__ATTR(location, S_IRUGO|S_IWUSR, location_show, location_store);
1936 1936
1937/* 'bitmap/space' is the space available at 'location' for the
1938 * bitmap. This allows the kernel to know when it is safe to
1939 * resize the bitmap to match a resized array.
1940 */
1941static ssize_t
1942space_show(struct mddev *mddev, char *page)
1943{
1944 return sprintf(page, "%lu\n", mddev->bitmap_info.space);
1945}
1946
1947static ssize_t
1948space_store(struct mddev *mddev, const char *buf, size_t len)
1949{
1950 unsigned long sectors;
1951 int rv;
1952
1953 rv = kstrtoul(buf, 10, &sectors);
1954 if (rv)
1955 return rv;
1956
1957 if (sectors == 0)
1958 return -EINVAL;
1959
1960 if (mddev->bitmap &&
1961 sectors < ((mddev->bitmap->file_pages - 1) * PAGE_SIZE
1962 + mddev->bitmap->last_page_size + 511) >> 9)
1963 return -EFBIG; /* Bitmap is too big for this small space */
1964
1965 /* could make sure it isn't too big, but that isn't really
1966 * needed - user-space should be careful.
1967 */
1968 mddev->bitmap_info.space = sectors;
1969 return len;
1970}
1971
1972static struct md_sysfs_entry bitmap_space =
1973__ATTR(space, S_IRUGO|S_IWUSR, space_show, space_store);
1974
1937static ssize_t 1975static ssize_t
1938timeout_show(struct mddev *mddev, char *page) 1976timeout_show(struct mddev *mddev, char *page)
1939{ 1977{
@@ -2109,6 +2147,7 @@ __ATTR(max_backlog_used, S_IRUGO | S_IWUSR,
2109 2147
2110static struct attribute *md_bitmap_attrs[] = { 2148static struct attribute *md_bitmap_attrs[] = {
2111 &bitmap_location.attr, 2149 &bitmap_location.attr,
2150 &bitmap_space.attr,
2112 &bitmap_timeout.attr, 2151 &bitmap_timeout.attr,
2113 &bitmap_backlog.attr, 2152 &bitmap_backlog.attr,
2114 &bitmap_chunksize.attr, 2153 &bitmap_chunksize.attr,