Skip to contentSkip to conversation

md/bitmap: use mddev_suspend/resume instead of ->quiesce()

PATCH In review Jack Wang 3 participants 3 messages Sep 27, 2018 – Oct 8, 2018 MD RAID

lore
Share & tools
lore

Jack Wang

author
#0 lore raw

PATCH 1/1 md/bitmap: use mddev_suspend/resume instead of ->quiesce()

From: Jack Wang <[email protected]>

After 9e1cc0a54556 ("md: use mddev_suspend/resume instead of ->quiesce()") We still have similar left in bitmap functions.

Replace quiesce() with mddev_suspend/resume.

Also move md_bitmap_create out of mddev_suspend. and move mddev_resume after md_bitmap_destroy. as we did in set_bitmap_file.

---
v2->v1: add reviewed-by.

---
 drivers/md/md-bitmap.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/md/md-bitmap.c +7 -6
index 2fc8c113977f..c369f1753ea6 100644
@@ -2123,7 +2123,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 	}
 
 	if (!init)
-		bitmap->mddev->pers->quiesce(bitmap->mddev, 1);
+		mddev_suspend(bitmap->mddev);
 
 	store.file = bitmap->storage.file;
 	bitmap->storage.file = NULL;
@@ -2239,7 +2239,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 
 	if (!init) {
 		md_bitmap_unplug(bitmap);
-		bitmap->mddev->pers->quiesce(bitmap->mddev, 0);
+		mddev_resume(bitmap->mddev);
 	}
 	ret = 0;
 err:
@@ -2288,9 +2288,9 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 			goto out;
 		}
 		if (mddev->pers) {
-			mddev->pers->quiesce(mddev, 1);
+			mddev_suspend(mddev);
 			md_bitmap_destroy(mddev);
-			mddev->pers->quiesce(mddev, 0);
+			mddev_resume(mddev);
 		}
 		mddev->bitmap_info.offset = 0;
 		if (mddev->bitmap_info.file) {
@@ -2327,8 +2327,8 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 			mddev->bitmap_info.offset = offset;
 			if (mddev->pers) {
 				struct bitmap *bitmap;
-				mddev->pers->quiesce(mddev, 1);
 				bitmap = md_bitmap_create(mddev, -1);
+				mddev_suspend(mddev);
 				if (IS_ERR(bitmap))
 					rv = PTR_ERR(bitmap);
 				else {
@@ -2337,11 +2337,12 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 					if (rv)
 						mddev->bitmap_info.offset = 0;
 				}
-				mddev->pers->quiesce(mddev, 0);
 				if (rv) {
 					md_bitmap_destroy(mddev);
+					mddev_resume(mddev);
 					goto out;
 				}
+				mddev_resume(mddev);
 			}
 		}
 	}
Signature · 1 line
2.7.4
#1 lore raw
Quoted 24 lines · Jack Wang

From: Jack Wang <[email protected]>

After 9e1cc0a54556 ("md: use mddev_suspend/resume instead of ->quiesce()") We still have similar left in bitmap functions.

Replace quiesce() with mddev_suspend/resume.

Also move md_bitmap_create out of mddev_suspend. and move mddev_resume after md_bitmap_destroy. as we did in set_bitmap_file.

---
v2->v1: add reviewed-by.

---
 drivers/md/md-bitmap.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/md/md-bitmap.c +0 -0
index 2fc8c113977f..c369f1753ea6 100644

drivers/md/md-bitmap.c int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks, · line 2126

Quoted 5 lines
drivers/md/md-bitmap.c +1 -1
@@ -2123,7 +2123,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 	}
 
 	if (!init)
-		bitmap->mddev->pers->quiesce(bitmap->mddev, 1);
+		mddev_suspend(bitmap->mddev);

mddev_suspend is supposed to be called with reconfig_mutex hold. At least one place this isn't true with this change, for example, raid_preresume doesn't call md_bitmap_resize with the lock hold. Could you please double check the lock usage?

Quoted 50 lines
drivers/md/md-bitmap.c +6 -5
 	store.file = bitmap->storage.file;
 	bitmap->storage.file = NULL;
@@ -2239,7 +2239,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 
 	if (!init) {
 		md_bitmap_unplug(bitmap);
-		bitmap->mddev->pers->quiesce(bitmap->mddev, 0);
+		mddev_resume(bitmap->mddev);
 	}
 	ret = 0;
 err:
@@ -2288,9 +2288,9 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 			goto out;
 		}
 		if (mddev->pers) {
-			mddev->pers->quiesce(mddev, 1);
+			mddev_suspend(mddev);
 			md_bitmap_destroy(mddev);
-			mddev->pers->quiesce(mddev, 0);
+			mddev_resume(mddev);
 		}
 		mddev->bitmap_info.offset = 0;
 		if (mddev->bitmap_info.file) {
@@ -2327,8 +2327,8 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 			mddev->bitmap_info.offset = offset;
 			if (mddev->pers) {
 				struct bitmap *bitmap;
-				mddev->pers->quiesce(mddev, 1);
 				bitmap = md_bitmap_create(mddev, -1);
+				mddev_suspend(mddev);
 				if (IS_ERR(bitmap))
 					rv = PTR_ERR(bitmap);
 				else {
@@ -2337,11 +2337,12 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 					if (rv)
 						mddev->bitmap_info.offset = 0;
 				}
-				mddev->pers->quiesce(mddev, 0);
 				if (rv) {
 					md_bitmap_destroy(mddev);
+					mddev_resume(mddev);
 					goto out;
 				}
+				mddev_resume(mddev);
 			}
 		}
 	}
Signature · 1 line
2.7.4
#2 lore raw
Quoted 28 lines · Shaohua Li
Quoted 26 lines · Jack Wang

From: Jack Wang <[email protected]>

After 9e1cc0a54556 ("md: use mddev_suspend/resume instead of ->quiesce()") We still have similar left in bitmap functions.

Replace quiesce() with mddev_suspend/resume.

Also move md_bitmap_create out of mddev_suspend. and move mddev_resume after md_bitmap_destroy. as we did in set_bitmap_file.

---
v2->v1: add reviewed-by.

---
 drivers/md/md-bitmap.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/md/md-bitmap.c +0 -0
index 2fc8c113977f..c369f1753ea6 100644
@@ -2123,7 +2123,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
      }
 
Quoted 9 lines

drivers/md/md-bitmap.c int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks, · line 2126

Quoted 3 lines
drivers/md/md-bitmap.c +1 -1
      if (!init)
-             bitmap->mddev->pers->quiesce(bitmap->mddev, 1);
+             mddev_suspend(bitmap->mddev);

mddev_suspend is supposed to be called with reconfig_mutex hold. At least one place this isn't true with this change, for example, raid_preresume doesn't call md_bitmap_resize with the lock hold. Could you please double check the lock usage?

You're right, I missed this one, will double check.

Thanks for review!

Signature · 15 lines
Jack Wang
Linux Kernel Developer

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:       +49 30 577 008  042
Fax:      +49 30 577 008 299
Email:    [email protected]
URL:      https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss, Matthias Steinberg, Christoph Steffens