]> www.infradead.org Git - users/hch/block.git/commitdiff
block: move more syncing and invalidation to delete_partition
authorChristoph Hellwig <hch@lst.de>
Fri, 26 Mar 2021 13:27:22 +0000 (14:27 +0100)
committerChristoph Hellwig <hch@lst.de>
Tue, 30 Mar 2021 05:44:40 +0000 (07:44 +0200)
Move the calls to fsync_bdev and __invalidate_device from del_gendisk to
delete_partition.  For the other two callers that check that there are
no openers for the delete partitions(s) the callouts are a no-op as no
file system can be mounted, but this keeps all the cleanup in one
place.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/genhd.c
block/partitions/core.c

index 9b121b1f79982fd9210c66228c925e6c28597d9e..15f99da4543f6d220d4d45d2e8ebe801e72f97bd 100644 (file)
@@ -686,11 +686,8 @@ void del_gendisk(struct gendisk *disk)
 
        /* invalidate stuff */
        disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
-       while ((part = disk_part_iter_next(&piter))) {
-               fsync_bdev(part);
-               __invalidate_device(part, true);
+       while ((part = disk_part_iter_next(&piter)))
                delete_partition(part);
-       }
        disk_part_iter_exit(&piter);
 
        fsync_bdev(disk->part0);
index 90e3bd2804c4fad9f417bea9dac86a11489d6cc9..b3cfda1e87143127efddf9818ae1ae96c5fdf401 100644 (file)
@@ -287,6 +287,9 @@ struct device_type part_type = {
  */
 void delete_partition(struct block_device *part)
 {
+       fsync_bdev(part);
+       __invalidate_device(part, true);
+
        xa_erase(&part->bd_disk->part_tbl, part->bd_partno);
        kobject_put(part->bd_holder_dir);
        device_del(&part->bd_device);
@@ -468,9 +471,6 @@ int bdev_del_partition(struct block_device *bdev, int partno)
        if (part->bd_openers)
                goto out_unlock;
 
-       sync_blockdev(part);
-       invalidate_bdev(part);
-
        delete_partition(part);
        ret = 0;
 out_unlock: