md: Delete gendisk before cleaning up the request queue
authorBart Van Assche <bart.vanassche@wdc.com>
Wed, 28 Feb 2018 18:15:29 +0000 (10:15 -0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 28 Feb 2018 19:23:35 +0000 (12:23 -0700)
Remove the disk, partition and bdi sysfs attributes before cleaning up
the request queue associated with the disk.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Cc: Shaohua Li <shli@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/md.c

index bc67ab6844f02d540cf4ae3725ebdad13ee568b8..eba7fa2f0abbf89a00d7cf4952802d01e9a8ecba 100644 (file)
@@ -5203,12 +5203,12 @@ static void md_free(struct kobject *ko)
        if (mddev->sysfs_state)
                sysfs_put(mddev->sysfs_state);
 
+       if (mddev->gendisk)
+               del_gendisk(mddev->gendisk);
        if (mddev->queue)
                blk_cleanup_queue(mddev->queue);
-       if (mddev->gendisk) {
-               del_gendisk(mddev->gendisk);
+       if (mddev->gendisk)
                put_disk(mddev->gendisk);
-       }
        percpu_ref_exit(&mddev->writes_pending);
 
        kfree(mddev);