diff options
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 39 |
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) | |||
1934 | static struct md_sysfs_entry bitmap_location = | 1934 | static 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 | */ | ||
1941 | static ssize_t | ||
1942 | space_show(struct mddev *mddev, char *page) | ||
1943 | { | ||
1944 | return sprintf(page, "%lu\n", mddev->bitmap_info.space); | ||
1945 | } | ||
1946 | |||
1947 | static ssize_t | ||
1948 | space_store(struct mddev *mddev, const char *buf, size_t len) | ||
1949 | { | ||
1950 | unsigned long sectors; | ||
1951 | int rv; | ||
1952 | |||
1953 | rv = kstrtoul(buf, 10, §ors); | ||
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 | |||
1972 | static struct md_sysfs_entry bitmap_space = | ||
1973 | __ATTR(space, S_IRUGO|S_IWUSR, space_show, space_store); | ||
1974 | |||
1937 | static ssize_t | 1975 | static ssize_t |
1938 | timeout_show(struct mddev *mddev, char *page) | 1976 | timeout_show(struct mddev *mddev, char *page) |
1939 | { | 1977 | { |
@@ -2109,6 +2147,7 @@ __ATTR(max_backlog_used, S_IRUGO | S_IWUSR, | |||
2109 | 2147 | ||
2110 | static struct attribute *md_bitmap_attrs[] = { | 2148 | static 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, |