* [md PATCH 1/3] md: improve errno return when setting array_size
[not found] <20090525042538.3758.7928.stgit@notabene.brown>
@ 2009-05-25 4:33 ` NeilBrown
2009-05-25 4:33 ` [md PATCH 2/3] md: bitmap: improve bitmap maintenance code NeilBrown
2009-05-25 4:33 ` [md PATCH 3/3] md: export 'frozen' resync state through sysfs NeilBrown
2 siblings, 0 replies; 3+ messages in thread
From: NeilBrown @ 2009-05-25 4:33 UTC (permalink / raw)
To: linux-raid; +Cc: NeilBrown
Instead of always returns EINVAL if anything goes wrong
when setting the array size, add the option of
E2BIG
if the size requested is too large. This makes it easier
for user-space to be sure what went wrong.
Signed-off-by: NeilBrown <neilb@suse.de>
---
drivers/md/md.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index fccc834..cc46c11 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3680,7 +3680,7 @@ array_size_store(mddev_t *mddev, const char *buf, size_t len)
if (strict_blocks_to_sectors(buf, §ors) < 0)
return -EINVAL;
if (mddev->pers && mddev->pers->size(mddev, 0, 0) < sectors)
- return -EINVAL;
+ return -E2BIG;
mddev->external_size = 1;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [md PATCH 2/3] md: bitmap: improve bitmap maintenance code.
[not found] <20090525042538.3758.7928.stgit@notabene.brown>
2009-05-25 4:33 ` [md PATCH 1/3] md: improve errno return when setting array_size NeilBrown
@ 2009-05-25 4:33 ` NeilBrown
2009-05-25 4:33 ` [md PATCH 3/3] md: export 'frozen' resync state through sysfs NeilBrown
2 siblings, 0 replies; 3+ messages in thread
From: NeilBrown @ 2009-05-25 4:33 UTC (permalink / raw)
To: linux-raid; +Cc: NeilBrown
The code for checking which bits in the bitmap can be cleared
has 2 problems:
1/ it repeatedly takes and drops a spinlock, where it would make
more sense to just hold on to it most of the time.
2/ it doesn't make use of some opportunities to skip large sections
of the bitmap
This patch fixes those. It will only affect CPU consumption, not
correctness.
Signed-off-by: NeilBrown <neilb@suse.de>
---
drivers/md/bitmap.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 47c68bc..56df1ce 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1097,14 +1097,12 @@ void bitmap_daemon_work(struct bitmap *bitmap)
}
bitmap->allclean = 1;
+ spin_lock_irqsave(&bitmap->lock, flags);
for (j = 0; j < bitmap->chunks; j++) {
bitmap_counter_t *bmc;
- spin_lock_irqsave(&bitmap->lock, flags);
- if (!bitmap->filemap) {
+ if (!bitmap->filemap)
/* error or shutdown */
- spin_unlock_irqrestore(&bitmap->lock, flags);
break;
- }
page = filemap_get_page(bitmap, j);
@@ -1121,6 +1119,8 @@ void bitmap_daemon_work(struct bitmap *bitmap)
write_page(bitmap, page, 0);
bitmap->allclean = 0;
}
+ spin_lock_irqsave(&bitmap->lock, flags);
+ j |= (PAGE_BITS - 1);
continue;
}
@@ -1181,9 +1181,10 @@ void bitmap_daemon_work(struct bitmap *bitmap)
ext2_clear_bit(file_page_offset(j), paddr);
kunmap_atomic(paddr, KM_USER0);
}
- }
- spin_unlock_irqrestore(&bitmap->lock, flags);
+ } else
+ j |= PAGE_COUNTER_MASK;
}
+ spin_unlock_irqrestore(&bitmap->lock, flags);
/* now sync the final page */
if (lastpage != NULL) {
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [md PATCH 3/3] md: export 'frozen' resync state through sysfs
[not found] <20090525042538.3758.7928.stgit@notabene.brown>
2009-05-25 4:33 ` [md PATCH 1/3] md: improve errno return when setting array_size NeilBrown
2009-05-25 4:33 ` [md PATCH 2/3] md: bitmap: improve bitmap maintenance code NeilBrown
@ 2009-05-25 4:33 ` NeilBrown
2 siblings, 0 replies; 3+ messages in thread
From: NeilBrown @ 2009-05-25 4:33 UTC (permalink / raw)
To: linux-raid; +Cc: NeilBrown
The md resync engine has a 'frozen' state which ensures that
no resync/recovery. This is used to avoid races.
Export this state through the 'sync_action' sysfs attribute
so that user-space can benefit and also avoid some races.
Signed-off-by: NeilBrown <neilb@suse.de>
---
drivers/md/md.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index cc46c11..6683b9a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3303,7 +3303,9 @@ static ssize_t
action_show(mddev_t *mddev, char *page)
{
char *type = "idle";
- if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
+ if (test_bit(MD_RECOVERY_FROZEN, &mddev->recovery))
+ type = "frozen";
+ else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
(!mddev->ro && test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))) {
if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery))
type = "reshape";
@@ -3326,7 +3328,12 @@ action_store(mddev_t *mddev, const char *page, size_t len)
if (!mddev->pers || !mddev->pers->sync_request)
return -EINVAL;
- if (cmd_match(page, "idle")) {
+ if (cmd_match(page, "frozen"))
+ set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
+ else
+ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
+
+ if (cmd_match(page, "idle") || cmd_match(page, "frozen")) {
if (mddev->sync_thread) {
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
md_unregister_thread(mddev->sync_thread);
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-25 4:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20090525042538.3758.7928.stgit@notabene.brown>
2009-05-25 4:33 ` [md PATCH 1/3] md: improve errno return when setting array_size NeilBrown
2009-05-25 4:33 ` [md PATCH 2/3] md: bitmap: improve bitmap maintenance code NeilBrown
2009-05-25 4:33 ` [md PATCH 3/3] md: export 'frozen' resync state through sysfs NeilBrown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).