Lines Matching full:disk
17 * Probe partition formats with tables at disk address 0
32 * disk address 0xdc0. Since these may also have stale
137 state->disk = hd; in check_partition()
302 * Must be called either with open_mutex held, before a disk can be opened or
303 * after all disk users are gone.
305 static struct block_device *add_partition(struct gendisk *disk, int partno, in add_partition() argument
310 struct device *ddev = disk_to_dev(disk); in add_partition()
316 lockdep_assert_held(&disk->open_mutex); in add_partition()
325 switch (disk->queue->limits.zoned) { in add_partition()
328 disk->disk_name); in add_partition()
332 disk->disk_name); in add_partition()
333 disk_set_zoned(disk, BLK_ZONED_NONE); in add_partition()
339 if (xa_load(&disk->part_tbl, partno)) in add_partition()
342 /* ensure we always have a reference to the whole disk */ in add_partition()
343 get_device(disk_to_dev(disk)); in add_partition()
346 bdev = bdev_alloc(disk, partno); in add_partition()
366 if (bdev->bd_partno < disk->minors) { in add_partition()
367 devt = MKDEV(disk->major, disk->first_minor + bdev->bd_partno); in add_partition()
402 err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL); in add_partition()
407 /* suppress uevent if the disk suppresses it */ in add_partition()
419 put_disk(disk); in add_partition()
423 static bool partition_overlaps(struct gendisk *disk, sector_t start, in partition_overlaps() argument
431 xa_for_each_start(&disk->part_tbl, idx, part, 1) { in partition_overlaps()
444 int bdev_add_partition(struct gendisk *disk, int partno, sector_t start, in bdev_add_partition() argument
450 mutex_lock(&disk->open_mutex); in bdev_add_partition()
451 if (!disk_live(disk)) { in bdev_add_partition()
456 if (partition_overlaps(disk, start, length, -1)) { in bdev_add_partition()
461 part = add_partition(disk, partno, start, length, in bdev_add_partition()
465 mutex_unlock(&disk->open_mutex); in bdev_add_partition()
469 int bdev_del_partition(struct gendisk *disk, int partno) in bdev_del_partition() argument
474 mutex_lock(&disk->open_mutex); in bdev_del_partition()
475 part = xa_load(&disk->part_tbl, partno); in bdev_del_partition()
486 mutex_unlock(&disk->open_mutex); in bdev_del_partition()
490 int bdev_resize_partition(struct gendisk *disk, int partno, sector_t start, in bdev_resize_partition() argument
496 mutex_lock(&disk->open_mutex); in bdev_resize_partition()
497 part = xa_load(&disk->part_tbl, partno); in bdev_resize_partition()
506 if (partition_overlaps(disk, start, length, partno)) in bdev_resize_partition()
513 mutex_unlock(&disk->open_mutex); in bdev_resize_partition()
517 static bool disk_unlock_native_capacity(struct gendisk *disk) in disk_unlock_native_capacity() argument
519 if (!disk->fops->unlock_native_capacity || in disk_unlock_native_capacity()
520 test_and_set_bit(GD_NATIVE_CAPACITY, &disk->state)) { in disk_unlock_native_capacity()
526 disk->fops->unlock_native_capacity(disk); in disk_unlock_native_capacity()
530 void blk_drop_partitions(struct gendisk *disk) in blk_drop_partitions() argument
535 lockdep_assert_held(&disk->open_mutex); in blk_drop_partitions()
537 xa_for_each_start(&disk->part_tbl, idx, part, 1) in blk_drop_partitions()
541 static bool blk_add_partition(struct gendisk *disk, in blk_add_partition() argument
551 if (from >= get_capacity(disk)) { in blk_add_partition()
554 disk->disk_name, p, (unsigned long long) from); in blk_add_partition()
555 if (disk_unlock_native_capacity(disk)) in blk_add_partition()
560 if (from + size > get_capacity(disk)) { in blk_add_partition()
563 disk->disk_name, p, (unsigned long long) size); in blk_add_partition()
565 if (disk_unlock_native_capacity(disk)) in blk_add_partition()
571 * disk to avoid creating invalid block devices. in blk_add_partition()
573 size = get_capacity(disk) - from; in blk_add_partition()
576 part = add_partition(disk, p, from, size, state->parts[p].flags, in blk_add_partition()
580 disk->disk_name, p, -PTR_ERR(part)); in blk_add_partition()
591 static int blk_add_partitions(struct gendisk *disk) in blk_add_partitions() argument
596 if (disk->flags & GENHD_FL_NO_PART) in blk_add_partitions()
599 if (test_bit(GD_SUPPRESS_PART_SCAN, &disk->state)) in blk_add_partitions()
602 state = check_partition(disk); in blk_add_partitions()
612 disk->disk_name); in blk_add_partitions()
613 if (disk_unlock_native_capacity(disk)) in blk_add_partitions()
622 if (disk->queue->limits.zoned == BLK_ZONED_HM) { in blk_add_partitions()
624 disk->disk_name); in blk_add_partitions()
637 disk->disk_name); in blk_add_partitions()
638 if (disk_unlock_native_capacity(disk)) in blk_add_partitions()
643 kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); in blk_add_partitions()
646 if (!blk_add_partition(disk, state, p)) in blk_add_partitions()
655 int bdev_disk_changed(struct gendisk *disk, bool invalidate) in bdev_disk_changed() argument
659 lockdep_assert_held(&disk->open_mutex); in bdev_disk_changed()
661 if (!disk_live(disk)) in bdev_disk_changed()
665 if (disk->open_partitions) in bdev_disk_changed()
667 sync_blockdev(disk->part0); in bdev_disk_changed()
668 invalidate_bdev(disk->part0); in bdev_disk_changed()
669 blk_drop_partitions(disk); in bdev_disk_changed()
671 clear_bit(GD_NEED_PART_SCAN, &disk->state); in bdev_disk_changed()
682 if (!(disk->flags & GENHD_FL_NO_PART) || in bdev_disk_changed()
683 !(disk->flags & GENHD_FL_REMOVABLE)) in bdev_disk_changed()
684 set_capacity(disk, 0); in bdev_disk_changed()
687 if (get_capacity(disk)) { in bdev_disk_changed()
688 ret = blk_add_partitions(disk); in bdev_disk_changed()
696 kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); in bdev_disk_changed()
709 struct address_space *mapping = state->disk->part0->bd_inode->i_mapping; in read_part_sector()
712 if (n >= get_capacity(state->disk)) { in read_part_sector()