aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/bitmap.c14
-rw-r--r--drivers/md/md.c31
2 files changed, 45 insertions, 0 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index ecc56765d949..0a44298fb353 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -613,6 +613,7 @@ static inline unsigned long file_page_offset(unsigned long chunk)
613static inline struct page *filemap_get_page(struct bitmap *bitmap, 613static inline struct page *filemap_get_page(struct bitmap *bitmap,
614 unsigned long chunk) 614 unsigned long chunk)
615{ 615{
616 if (file_page_index(chunk) >= bitmap->file_pages) return NULL;
616 return bitmap->filemap[file_page_index(chunk) - file_page_index(0)]; 617 return bitmap->filemap[file_page_index(chunk) - file_page_index(0)];
617} 618}
618 619
@@ -739,6 +740,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
739 } 740 }
740 741
741 page = filemap_get_page(bitmap, chunk); 742 page = filemap_get_page(bitmap, chunk);
743 if (!page) return;
742 bit = file_page_offset(chunk); 744 bit = file_page_offset(chunk);
743 745
744 /* set the bit */ 746 /* set the bit */
@@ -1322,6 +1324,18 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n
1322 1324
1323} 1325}
1324 1326
1327/* dirty the memory and file bits for bitmap chunks "s" to "e" */
1328void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
1329{
1330 unsigned long chunk;
1331
1332 for (chunk = s; chunk <= e; chunk++) {
1333 sector_t sec = chunk << CHUNK_BLOCK_SHIFT(bitmap);
1334 bitmap_set_memory_bits(bitmap, sec, 1);
1335 bitmap_file_set_bit(bitmap, sec);
1336 }
1337}
1338
1325/* 1339/*
1326 * flush out any pending updates 1340 * flush out any pending updates
1327 */ 1341 */
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 8b08043f07ef..b95dd8a183ec 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2524,6 +2524,36 @@ static struct md_sysfs_entry md_new_device =
2524__ATTR(new_dev, S_IWUSR, null_show, new_dev_store); 2524__ATTR(new_dev, S_IWUSR, null_show, new_dev_store);
2525 2525
2526static ssize_t 2526static ssize_t
2527bitmap_store(mddev_t *mddev, const char *buf, size_t len)
2528{
2529 char *end;
2530 unsigned long chunk, end_chunk;
2531
2532 if (!mddev->bitmap)
2533 goto out;
2534 /* buf should be <chunk> <chunk> ... or <chunk>-<chunk> ... (range) */
2535 while (*buf) {
2536 chunk = end_chunk = simple_strtoul(buf, &end, 0);
2537 if (buf == end) break;
2538 if (*end == '-') { /* range */
2539 buf = end + 1;
2540 end_chunk = simple_strtoul(buf, &end, 0);
2541 if (buf == end) break;
2542 }
2543 if (*end && !isspace(*end)) break;
2544 bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk);
2545 buf = end;
2546 while (isspace(*buf)) buf++;
2547 }
2548 bitmap_unplug(mddev->bitmap); /* flush the bits to disk */
2549out:
2550 return len;
2551}
2552
2553static struct md_sysfs_entry md_bitmap =
2554__ATTR(bitmap_set_bits, S_IWUSR, null_show, bitmap_store);
2555
2556static ssize_t
2527size_show(mddev_t *mddev, char *page) 2557size_show(mddev_t *mddev, char *page)
2528{ 2558{
2529 return sprintf(page, "%llu\n", (unsigned long long)mddev->size); 2559 return sprintf(page, "%llu\n", (unsigned long long)mddev->size);
@@ -2843,6 +2873,7 @@ static struct attribute *md_redundancy_attrs[] = {
2843 &md_sync_completed.attr, 2873 &md_sync_completed.attr,
2844 &md_suspend_lo.attr, 2874 &md_suspend_lo.attr,
2845 &md_suspend_hi.attr, 2875 &md_suspend_hi.attr,
2876 &md_bitmap.attr,
2846 NULL, 2877 NULL,
2847}; 2878};
2848static struct attribute_group md_redundancy_group = { 2879static struct attribute_group md_redundancy_group = {