Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38116
b: refs/heads/master
c: 9b1d1da
h: refs/heads/master
v: v3
  • Loading branch information
Paul Clements authored and Linus Torvalds committed Oct 3, 2006
1 parent f5b6534 commit 8e5ac50
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 76186dd8b73d2b7b9b4c8629b89c845e97009801
refs/heads/master: 9b1d1dac181d8c1b9492e05cee660a985d035a06
9 changes: 9 additions & 0 deletions trunk/Documentation/md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,15 @@ also have
than sectors, this my be larger than the number of actual errors
by a factor of the number of sectors in a page.

bitmap_set_bits
If the array has a write-intent bitmap, then writing to this
attribute can set bits in the bitmap, indicating that a resync
would need to check the corresponding blocks. Either individual
numbers or start-end pairs can be written. Multiple numbers
can be separated by a space.
Note that the numbers are 'bit' numbers, not 'block' numbers.
They should be scaled by the bitmap_chunksize.

Each active md device may also have attributes specific to the
personality module that manages it.
These are specific to the implementation of the module and could
Expand Down
14 changes: 14 additions & 0 deletions trunk/drivers/md/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ static inline unsigned long file_page_offset(unsigned long chunk)
static inline struct page *filemap_get_page(struct bitmap *bitmap,
unsigned long chunk)
{
if (file_page_index(chunk) >= bitmap->file_pages) return NULL;
return bitmap->filemap[file_page_index(chunk) - file_page_index(0)];
}

Expand Down Expand Up @@ -739,6 +740,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
}

page = filemap_get_page(bitmap, chunk);
if (!page) return;
bit = file_page_offset(chunk);

/* set the bit */
Expand Down Expand Up @@ -1322,6 +1324,18 @@ static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int n

}

/* dirty the memory and file bits for bitmap chunks "s" to "e" */
void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
{
unsigned long chunk;

for (chunk = s; chunk <= e; chunk++) {
sector_t sec = chunk << CHUNK_BLOCK_SHIFT(bitmap);
bitmap_set_memory_bits(bitmap, sec, 1);
bitmap_file_set_bit(bitmap, sec);
}
}

/*
* flush out any pending updates
*/
Expand Down
31 changes: 31 additions & 0 deletions trunk/drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,36 @@ new_dev_store(mddev_t *mddev, const char *buf, size_t len)
static struct md_sysfs_entry md_new_device =
__ATTR(new_dev, S_IWUSR, null_show, new_dev_store);

static ssize_t
bitmap_store(mddev_t *mddev, const char *buf, size_t len)
{
char *end;
unsigned long chunk, end_chunk;

if (!mddev->bitmap)
goto out;
/* buf should be <chunk> <chunk> ... or <chunk>-<chunk> ... (range) */
while (*buf) {
chunk = end_chunk = simple_strtoul(buf, &end, 0);
if (buf == end) break;
if (*end == '-') { /* range */
buf = end + 1;
end_chunk = simple_strtoul(buf, &end, 0);
if (buf == end) break;
}
if (*end && !isspace(*end)) break;
bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk);
buf = end;
while (isspace(*buf)) buf++;
}
bitmap_unplug(mddev->bitmap); /* flush the bits to disk */
out:
return len;
}

static struct md_sysfs_entry md_bitmap =
__ATTR(bitmap_set_bits, S_IWUSR, null_show, bitmap_store);

static ssize_t
size_show(mddev_t *mddev, char *page)
{
Expand Down Expand Up @@ -2843,6 +2873,7 @@ static struct attribute *md_redundancy_attrs[] = {
&md_sync_completed.attr,
&md_suspend_lo.attr,
&md_suspend_hi.attr,
&md_bitmap.attr,
NULL,
};
static struct attribute_group md_redundancy_group = {
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/raid/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ int bitmap_update_sb(struct bitmap *bitmap);
int bitmap_setallbits(struct bitmap *bitmap);
void bitmap_write_all(struct bitmap *bitmap);

void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e);

/* these are exported */
int bitmap_startwrite(struct bitmap *bitmap, sector_t offset,
unsigned long sectors, int behind);
Expand Down

0 comments on commit 8e5ac50

Please sign in to comment.