Lines Matching refs:disk
129 state->disk = hd; in check_partition()
299 static struct block_device *add_partition(struct gendisk *disk, int partno, in add_partition() argument
304 struct device *ddev = disk_to_dev(disk); in add_partition()
310 lockdep_assert_held(&disk->open_mutex); in add_partition()
319 switch (disk->queue->limits.zoned) { in add_partition()
322 disk->disk_name); in add_partition()
326 disk->disk_name); in add_partition()
327 disk_set_zoned(disk, BLK_ZONED_NONE); in add_partition()
333 if (xa_load(&disk->part_tbl, partno)) in add_partition()
337 get_device(disk_to_dev(disk)); in add_partition()
340 bdev = bdev_alloc(disk, partno); in add_partition()
360 if (bdev->bd_partno < disk->minors) { in add_partition()
361 devt = MKDEV(disk->major, disk->first_minor + bdev->bd_partno); in add_partition()
396 err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL); in add_partition()
413 put_disk(disk); in add_partition()
417 static bool partition_overlaps(struct gendisk *disk, sector_t start, in partition_overlaps() argument
425 xa_for_each_start(&disk->part_tbl, idx, part, 1) { in partition_overlaps()
438 int bdev_add_partition(struct gendisk *disk, int partno, sector_t start, in bdev_add_partition() argument
441 sector_t capacity = get_capacity(disk), end; in bdev_add_partition()
445 mutex_lock(&disk->open_mutex); in bdev_add_partition()
456 if (!disk_live(disk)) { in bdev_add_partition()
461 if (disk->flags & GENHD_FL_NO_PART) { in bdev_add_partition()
466 if (partition_overlaps(disk, start, length, -1)) { in bdev_add_partition()
471 part = add_partition(disk, partno, start, length, in bdev_add_partition()
475 mutex_unlock(&disk->open_mutex); in bdev_add_partition()
479 int bdev_del_partition(struct gendisk *disk, int partno) in bdev_del_partition() argument
484 mutex_lock(&disk->open_mutex); in bdev_del_partition()
485 part = xa_load(&disk->part_tbl, partno); in bdev_del_partition()
496 mutex_unlock(&disk->open_mutex); in bdev_del_partition()
500 int bdev_resize_partition(struct gendisk *disk, int partno, sector_t start, in bdev_resize_partition() argument
506 mutex_lock(&disk->open_mutex); in bdev_resize_partition()
507 part = xa_load(&disk->part_tbl, partno); in bdev_resize_partition()
516 if (partition_overlaps(disk, start, length, partno)) in bdev_resize_partition()
523 mutex_unlock(&disk->open_mutex); in bdev_resize_partition()
527 static bool disk_unlock_native_capacity(struct gendisk *disk) in disk_unlock_native_capacity() argument
529 if (!disk->fops->unlock_native_capacity || in disk_unlock_native_capacity()
530 test_and_set_bit(GD_NATIVE_CAPACITY, &disk->state)) { in disk_unlock_native_capacity()
536 disk->fops->unlock_native_capacity(disk); in disk_unlock_native_capacity()
540 static bool blk_add_partition(struct gendisk *disk, in blk_add_partition() argument
550 if (from >= get_capacity(disk)) { in blk_add_partition()
553 disk->disk_name, p, (unsigned long long) from); in blk_add_partition()
554 if (disk_unlock_native_capacity(disk)) in blk_add_partition()
559 if (from + size > get_capacity(disk)) { in blk_add_partition()
562 disk->disk_name, p, (unsigned long long) size); in blk_add_partition()
564 if (disk_unlock_native_capacity(disk)) in blk_add_partition()
572 size = get_capacity(disk) - from; in blk_add_partition()
575 part = add_partition(disk, p, from, size, state->parts[p].flags, in blk_add_partition()
579 disk->disk_name, p, -PTR_ERR(part)); in blk_add_partition()
590 static int blk_add_partitions(struct gendisk *disk) in blk_add_partitions() argument
595 if (disk->flags & GENHD_FL_NO_PART) in blk_add_partitions()
598 if (test_bit(GD_SUPPRESS_PART_SCAN, &disk->state)) in blk_add_partitions()
601 state = check_partition(disk); in blk_add_partitions()
611 disk->disk_name); in blk_add_partitions()
612 if (disk_unlock_native_capacity(disk)) in blk_add_partitions()
621 if (disk->queue->limits.zoned == BLK_ZONED_HM) { in blk_add_partitions()
623 disk->disk_name); in blk_add_partitions()
636 disk->disk_name); in blk_add_partitions()
637 if (disk_unlock_native_capacity(disk)) in blk_add_partitions()
642 kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); in blk_add_partitions()
645 if (!blk_add_partition(disk, state, p)) in blk_add_partitions()
654 int bdev_disk_changed(struct gendisk *disk, bool invalidate) in bdev_disk_changed() argument
660 lockdep_assert_held(&disk->open_mutex); in bdev_disk_changed()
662 if (!disk_live(disk)) in bdev_disk_changed()
666 if (disk->open_partitions) in bdev_disk_changed()
668 sync_blockdev(disk->part0); in bdev_disk_changed()
669 invalidate_bdev(disk->part0); in bdev_disk_changed()
671 xa_for_each_start(&disk->part_tbl, idx, part, 1) in bdev_disk_changed()
673 clear_bit(GD_NEED_PART_SCAN, &disk->state); in bdev_disk_changed()
684 if (!(disk->flags & GENHD_FL_NO_PART) || in bdev_disk_changed()
685 !(disk->flags & GENHD_FL_REMOVABLE)) in bdev_disk_changed()
686 set_capacity(disk, 0); in bdev_disk_changed()
689 if (get_capacity(disk)) { in bdev_disk_changed()
690 ret = blk_add_partitions(disk); in bdev_disk_changed()
698 kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); in bdev_disk_changed()
711 struct address_space *mapping = state->disk->part0->bd_inode->i_mapping; in read_part_sector()
714 if (n >= get_capacity(state->disk)) { in read_part_sector()