Skip to content

Commit 52a0d49

Browse files
NeilBrownshligit
authored andcommitted
md: don't call bitmap_create() while array is quiesced.
bitmap_create() allocates memory with GFP_KERNEL and so can wait for IO. If called while the array is quiesced, it could wait indefinitely for write out to the array - deadlock. So call bitmap_create() before quiescing the array. Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Shaohua Li <[email protected]>
1 parent 4d5324f commit 52a0d49

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/md/md.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6621,22 +6621,26 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
66216621
return -ENOENT; /* cannot remove what isn't there */
66226622
err = 0;
66236623
if (mddev->pers) {
6624-
mddev->pers->quiesce(mddev, 1);
66256624
if (fd >= 0) {
66266625
struct bitmap *bitmap;
66276626

66286627
bitmap = bitmap_create(mddev, -1);
6628+
mddev->pers->quiesce(mddev, 1);
66296629
if (!IS_ERR(bitmap)) {
66306630
mddev->bitmap = bitmap;
66316631
err = bitmap_load(mddev);
66326632
} else
66336633
err = PTR_ERR(bitmap);
6634-
}
6635-
if (fd < 0 || err) {
6634+
if (err) {
6635+
bitmap_destroy(mddev);
6636+
fd = -1;
6637+
}
6638+
mddev->pers->quiesce(mddev, 0);
6639+
} else if (fd < 0) {
6640+
mddev->pers->quiesce(mddev, 1);
66366641
bitmap_destroy(mddev);
6637-
fd = -1; /* make sure to put the file */
6642+
mddev->pers->quiesce(mddev, 0);
66386643
}
6639-
mddev->pers->quiesce(mddev, 0);
66406644
}
66416645
if (fd < 0) {
66426646
struct file *f = mddev->bitmap_info.file;
@@ -6920,8 +6924,8 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
69206924
mddev->bitmap_info.default_offset;
69216925
mddev->bitmap_info.space =
69226926
mddev->bitmap_info.default_space;
6923-
mddev->pers->quiesce(mddev, 1);
69246927
bitmap = bitmap_create(mddev, -1);
6928+
mddev->pers->quiesce(mddev, 1);
69256929
if (!IS_ERR(bitmap)) {
69266930
mddev->bitmap = bitmap;
69276931
rv = bitmap_load(mddev);

0 commit comments

Comments
 (0)