Skip to contentSkip to conversation

mdadm -Db switches array to write-pending?!

DISCUSSION Martin Wilck 2 participants 5 messages Jul 10, 2013 – Jul 26, 2013 MD RAID

lore
Share & tools
lore
#0 lore raw

Hi Neil, hi all,

I discovered a weird behavior of mdadm -Db - it will switch a RAID array from read-auto state to write-pending. For DDF (and possibly other formats) this will cause metadata writes.

If I read the code correctly, the reason is that mdadm -Db will use the GET_BITMAP_FILE ioctl, which calls md_allow_write(). I saw this on a CentOS 6.3 kernel but comparing the code I didn't see a difference in recent kernels.

I am wondering if this is intentional, and if no, if anything could be done about it. It is certainly surprising behavior.

Regards
Martin

#1 lore raw
Quoted 11 lines · On Wed, 10 Jul 2013 19:54:09 +0200 Martin Wilck <[email protected]> wrote:

Hi Neil, hi all,

I discovered a weird behavior of mdadm -Db - it will switch a RAID array from read-auto state to write-pending. For DDF (and possibly other formats) this will cause metadata writes.

If I read the code correctly, the reason is that mdadm -Db will use the GET_BITMAP_FILE ioctl, which calls md_allow_write(). I saw this on a CentOS 6.3 kernel but comparing the code I didn't see a difference in recent kernels.

Quoted 5 lines

I am wondering if this is intentional, and if no, if anything could be done about it. It is certainly surprising behavior.

Regards
Martin

I hadn't thought of that consequence.
Probably the best thing to do is:

drivers/md/md.c +1 -4
index d059af5..b19a1c8 100644
@@ -5629,10 +5629,7 @@ static int get_bitmap_file(struct mddev * mddev, void __user * arg)
 	char *ptr, *buf = NULL;
 	int err = -ENOMEM;
 
-	if (md_allow_write(mddev))
-		file = kmalloc(sizeof(*file), GFP_NOIO);
-	else
-		file = kmalloc(sizeof(*file), GFP_KERNEL);
+	file = kmalloc(sizeof(*file), GFP_NOIO);
 
 	if (!file)
 		goto out;

A failure here is not likely and not catastrophic.

Does it fix the situation for you?

NeilBrown

#2 lore raw
Quoted 20 lines · NeilBrown

Probably the best thing to do is:

drivers/md/md.c +1 -4
index d059af5..b19a1c8 100644
@@ -5629,10 +5629,7 @@ static int get_bitmap_file(struct mddev * mddev, void __user * arg)
 	char *ptr, *buf = NULL;
 	int err = -ENOMEM;
 
-	if (md_allow_write(mddev))
-		file = kmalloc(sizeof(*file), GFP_NOIO);
-	else
-		file = kmalloc(sizeof(*file), GFP_KERNEL);
+	file = kmalloc(sizeof(*file), GFP_NOIO);
 
 	if (!file)
 		goto out;
Quoted 3 lines

A failure here is not likely and not catastrophic.

Does it fix the situation for you?

Yes it does.
Martin

#3 lore raw

Hi Neil,

Quoted 24 lines · Martin Wilck
Quoted 22 lines · NeilBrown

Probably the best thing to do is:

drivers/md/md.c +1 -4
index d059af5..b19a1c8 100644
@@ -5629,10 +5629,7 @@ static int get_bitmap_file(struct mddev * mddev, void __user * arg)
 	char *ptr, *buf = NULL;
 	int err = -ENOMEM;
 
-	if (md_allow_write(mddev))
-		file = kmalloc(sizeof(*file), GFP_NOIO);
-	else
-		file = kmalloc(sizeof(*file), GFP_KERNEL);
+	file = kmalloc(sizeof(*file), GFP_NOIO);
 
 	if (!file)
 		goto out;

A failure here is not likely and not catastrophic.

Quoted 9 lines
Quoted 1 line

Does it fix the situation for you?

Yes it does.
Martin
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Any particular reason why you haven't applied this patch in your git tree http://git.neil.brown.name/?p=md.git;a=summary yet?

Martin

#4 lore raw
Quoted 37 lines · On Fri, 26 Jul 2013 20:01:54 +0200 Martin Wilck <[email protected]> wrote:

Hi Neil,

Quoted 24 lines · Martin Wilck
Quoted 22 lines · NeilBrown

Probably the best thing to do is:

drivers/md/md.c +1 -4
index d059af5..b19a1c8 100644
@@ -5629,10 +5629,7 @@ static int get_bitmap_file(struct mddev * mddev, void __user * arg)
 	char *ptr, *buf = NULL;
 	int err = -ENOMEM;
 
-	if (md_allow_write(mddev))
-		file = kmalloc(sizeof(*file), GFP_NOIO);
-	else
-		file = kmalloc(sizeof(*file), GFP_KERNEL);
+	file = kmalloc(sizeof(*file), GFP_NOIO);
 
 	if (!file)
 		goto out;

A failure here is not likely and not catastrophic.

Quoted 9 lines
Quoted 1 line

Does it fix the situation for you?

Yes it does.
Martin
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 2 lines

Any particular reason why you haven't applied this patch in your git tree http://git.neil.brown.name/?p=md.git;a=summary yet?

Hi Martin,
you need to look in the for-next branch.
http://git.neil.brown.name/?p=md.git;a=shortlog;h=refs/heads/for-next

NeilBrown