block: move del_gendisk() from fs/partitions/check.c to block/genhd.c
PATCH 1/1 block: move del_gendisk() from fs/partitions/check.c to block/genhd.c
From: Kay Sievers <[email protected]>
Subject: block: move del_gendisk() from fs/partitions/check.c to block/genhd.c
Disk code belongs into genhd, not into the partition scanner code.
--- block/genhd.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/partitions/check.c | 51 ------------------------------------------------- 2 files changed, 52 insertions(+), 51 deletions(-)
block/genhd.c +52 -0
@@ -1344,3 +1344,55 @@ int invalidate_partition(struct gendisk }EXPORT_SYMBOL (invalidate_partition); + +void del_gendisk (struct gendisk *disk) +{ +struct disk_part_iter piter; +struct hd_struct *part; + +/* invalidate stuff */ +disk_part_iter_init (&piter, disk, +DISK_PITER_INCL_EMPTY |DISK_PITER_REVERSE ); +while ((part =disk_part_iter_next (&piter))) { +invalidate_partition (disk, part->partno); +delete_partition (disk, part->partno); + } +disk_part_iter_exit (&piter); + +invalidate_partition (disk,0 ); +blk_free_devt (disk_to_dev (disk)->devt); +set_capacity (disk,0 ); + disk->flags &= ~GENHD_FL_UP ; +unlink_gendisk (disk); +part_stat_set_all (&disk->part0,0 ); + disk->part0.stamp =0 ; + +kobject_put (disk->part0.holder_dir); +kobject_put (disk->slave_dir); + disk->driverfs_dev =NULL ; +#ifndef CONFIG_SYSFS_DEPRECATED +sysfs_remove_link (block_depr,dev_name (disk_to_dev (disk))); +#endif +device_del (disk_to_dev (disk)); +} + +unsigned char *read_dev_sector (struct block_device *bdev,sector_t n,Sector *p) +{ +struct address_space *mapping = bdev->bd_inode->i_mapping; +struct page *page; + + page =read_mapping_page (mapping, (pgoff_t)(n >> (PAGE_CACHE_SHIFT -9 )), +NULL ); +if (!IS_ERR (page)) { +if (PageError (page)) + goto fail; + p->v = page; +return (unsigned char *)page_address (page) + ((n & ((1 << (PAGE_CACHE_SHIFT -9 )) -1 )) <<9 ); +fail: +page_cache_release (page); + } + p->v =NULL ; +return NULL ; +} + +EXPORT_SYMBOL (read_dev_sector);
fs/partitions/check.c +0 -51
54 lines not on this page · raw message
Quoted 4 lines · Kay Sievers
From: Kay Sievers <[email protected]>
Subject: block: movedel_gendisk()fromfs/partitions/check.ctoblock/genhd.cDisk code belongs into genhd, not into the partition scanner code.
Sounds fine for del_gendisk, but read_dev_sector which isn't mentioned here really is for partitioning.
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Kay Sievers
From: Kay Sievers <[email protected]>
Subject: block: movedel_gendisk()fromfs/partitions/check.ctoblock/genhd.cDisk code belongs into genhd, not into the partition scanner code.
Sounds fine for
del_gendisk, butread_dev_sectorwhich isn't mentioned here really is for partitioning.
Right, the next patch moves it to /block/partition.c, because all the sysfs and driver core code really should not be below fs/.
If you want me to re reshuffle that, let me know. I was just annoyed again, and after all these years I though it's time to move that stuff around. :)
Thanks,
Kay
Quoted 9 lines · Kay Sievers
Quoted 2 lines
Sounds fine for
del_gendisk, butread_dev_sectorwhich isn't mentioned here really is for partitioning.Right, the next patch moves it to /block/partition.c, because all the sysfs and driver core code really should not be below
fs/.If you want me to re reshuffle that, let me know. I was just annoyed again, and after all these years I though it's time to move that stuff around. :)
So then please keep read_dev_sector in the file where it is right now, and just move the whole directory from fs/partitions/ to block/partitions. While you're at it fs/bio.c and fs/block_dev.c really belong into block/, too. The latter could also need some split up.
Quoted 11 lines · Christoph Hellwig
Quoted 9 lines · Kay Sievers
Quoted 2 lines
Sounds fine for
del_gendisk, butread_dev_sectorwhich isn't mentioned here really is for partitioning.Right, the next patch moves it to /block/partition.c, because all the sysfs and driver core code really should not be below
fs/.If you want me to re reshuffle that, let me know. I was just annoyed again, and after all these years I though it's time to move that stuff around. :)
Quoted 5 lines
So then please keep
read_dev_sectorin the file where it is right now, and just move the whole directory fromfs/partitions/to block/partitions. While you're at itfs/bio.candfs/block_dev.creally belong intoblock/, too. The latter could also need some split up.
Hehe, the usual thing: "If you want that, fix all of it." :)
Are you sure, that partition formats don't belong in fs/? It's kinda specific on-disk-layout like a fs, and I would have no problem with that staying in fs/.
Kay
Quoted 3 lines · Kay Sievers
Are you sure, that partition formats don't belong in
fs/? It's kinda specific on-disk-layout like a fs, and I would have no problem with that staying infs/.
It's on disk formats, but it's not related to filesystems at all.