aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorPaul Clements <paul.clements@steeleye.com>2006-10-03 04:15:49 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-03 11:04:17 -0400
commit9b1d1dac181d8c1b9492e05cee660a985d035a06 (patch)
treeaf12b1eaac4e0f7f3528ec26a223faeabed35845 /drivers/md/md.c
parent76186dd8b73d2b7b9b4c8629b89c845e97009801 (diff)
[PATCH] md: new sysfs interface for setting bits in the write-intent-bitmap
Add a new sysfs interface that allows the bitmap of an array to be dirtied. The interface is write-only, and is used as follows: echo "1000" > /sys/block/md2/md/bitmap (dirty the bit for chunk 1000 [offset 0] in the in-memory and on-disk bitmaps of array md2) echo "1000-2000" > /sys/block/md1/md/bitmap (dirty the bits for chunks 1000-2000 in md1's bitmap) This is useful, for example, in cluster environments where you may need to combine two disjoint bitmaps into one (following a server failure, after a secondary server has taken over the array). By combining the bitmaps on the two servers, a full resync can be avoided (This was discussed on the list back on March 18, 2005, "[PATCH 1/2] md bitmap bug fixes" thread). Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c31
1 files changed, 31 insertions, 0 deletions
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 = {