md: add bitmap_abort label in md_run
authorGuoqing Jiang <gqjiang@suse.com>
Fri, 14 Jun 2019 09:10:39 +0000 (17:10 +0800)
committerSong Liu <songliubraving@fb.com>
Thu, 20 Jun 2019 23:36:00 +0000 (16:36 -0700)
Now, there are two places need to consider about
the failure of destroy bitmap, so move the common
part between bitmap_abort and abort label.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
drivers/md/md.c

index b43207a..692fc36 100644 (file)
@@ -5666,15 +5666,8 @@ int md_run(struct mddev *mddev)
                        mddev->bitmap = bitmap;
 
        }
-       if (err) {
-               mddev_detach(mddev);
-               if (mddev->private)
-                       pers->free(mddev, mddev->private);
-               mddev->private = NULL;
-               module_put(pers->owner);
-               md_bitmap_destroy(mddev);
-               goto abort;
-       }
+       if (err)
+               goto bitmap_abort;
 
        if (mddev->bitmap_info.max_write_behind > 0) {
                bool creat_pool = false;
@@ -5690,13 +5683,7 @@ int md_run(struct mddev *mddev)
                                                    sizeof(struct wb_info));
                        if (!mddev->wb_info_pool) {
                                err = -ENOMEM;
-                               mddev_detach(mddev);
-                               if (mddev->private)
-                                       pers->free(mddev, mddev->private);
-                               mddev->private = NULL;
-                               module_put(pers->owner);
-                               md_bitmap_destroy(mddev);
-                               goto abort;
+                               goto bitmap_abort;
                        }
                }
        }
@@ -5761,6 +5748,13 @@ int md_run(struct mddev *mddev)
        sysfs_notify(&mddev->kobj, NULL, "degraded");
        return 0;
 
+bitmap_abort:
+       mddev_detach(mddev);
+       if (mddev->private)
+               pers->free(mddev, mddev->private);
+       mddev->private = NULL;
+       module_put(pers->owner);
+       md_bitmap_destroy(mddev);
 abort:
        bioset_exit(&mddev->bio_set);
        bioset_exit(&mddev->sync_set);