5 #include <linux/module.h>
7 #include <linux/genhd.h>
8 #include <linux/kdev_t.h>
9 #include <linux/kernel.h>
10 #include <linux/blkdev.h>
11 #include <linux/init.h>
12 #include <linux/spinlock.h>
13 #include <linux/seq_file.h>
14 #include <linux/slab.h>
15 #include <linux/kmod.h>
16 #include <linux/kobj_map.h>
17 #include <linux/buffer_head.h>
18 #include <linux/mutex.h>
22 static DEFINE_MUTEX(block_class_lock);
23 #ifndef CONFIG_SYSFS_DEPRECATED
24 struct kobject *block_depr;
27 static struct device_type disk_type;
30 * disk_get_part - get partition
31 * @disk: disk to look partition from
32 * @partno: partition number
34 * Look for partition @partno from @disk. If found, increment
35 * reference count and return it.
41 * Pointer to the found partition on success, NULL if not found.
43 struct hd_struct *disk_get_part(struct gendisk *disk, int partno)
45 struct hd_struct *part;
47 if (unlikely(partno < 1 || partno > disk_max_parts(disk)))
50 part = rcu_dereference(disk->__part[partno - 1]);
52 get_device(&part->dev);
57 EXPORT_SYMBOL_GPL(disk_get_part);
60 * disk_part_iter_init - initialize partition iterator
61 * @piter: iterator to initialize
62 * @disk: disk to iterate over
63 * @flags: DISK_PITER_* flags
65 * Initialize @piter so that it iterates over partitions of @disk.
70 void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
76 if (flags & DISK_PITER_REVERSE)
77 piter->idx = disk_max_parts(piter->disk) - 1;
83 EXPORT_SYMBOL_GPL(disk_part_iter_init);
86 * disk_part_iter_next - proceed iterator to the next partition and return it
87 * @piter: iterator of interest
89 * Proceed @piter to the next partition and return it.
94 struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter)
98 /* put the last partition */
99 disk_put_part(piter->part);
104 /* determine iteration parameters */
105 if (piter->flags & DISK_PITER_REVERSE) {
110 end = disk_max_parts(piter->disk);
113 /* iterate to the next partition */
114 for (; piter->idx != end; piter->idx += inc) {
115 struct hd_struct *part;
117 part = rcu_dereference(piter->disk->__part[piter->idx]);
120 if (!(piter->flags & DISK_PITER_INCL_EMPTY) && !part->nr_sects)
123 get_device(&part->dev);
133 EXPORT_SYMBOL_GPL(disk_part_iter_next);
136 * disk_part_iter_exit - finish up partition iteration
137 * @piter: iter of interest
139 * Called when iteration is over. Cleans up @piter.
144 void disk_part_iter_exit(struct disk_part_iter *piter)
146 disk_put_part(piter->part);
149 EXPORT_SYMBOL_GPL(disk_part_iter_exit);
152 * disk_map_sector_rcu - map sector to partition
153 * @disk: gendisk of interest
154 * @sector: sector to map
156 * Find out which partition @sector maps to on @disk. This is
157 * primarily used for stats accounting.
160 * RCU read locked. The returned partition pointer is valid only
161 * while preemption is disabled.
164 * Found partition on success, NULL if there's no matching partition.
166 struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector)
170 for (i = 0; i < disk_max_parts(disk); i++) {
171 struct hd_struct *part = rcu_dereference(disk->__part[i]);
173 if (part && part->start_sect <= sector &&
174 sector < part->start_sect + part->nr_sects)
179 EXPORT_SYMBOL_GPL(disk_map_sector_rcu);
182 * Can be deleted altogether. Later.
185 static struct blk_major_name {
186 struct blk_major_name *next;
189 } *major_names[BLKDEV_MAJOR_HASH_SIZE];
191 /* index in the above - for now: assume no multimajor ranges */
192 static inline int major_to_index(int major)
194 return major % BLKDEV_MAJOR_HASH_SIZE;
197 #ifdef CONFIG_PROC_FS
198 void blkdev_show(struct seq_file *seqf, off_t offset)
200 struct blk_major_name *dp;
202 if (offset < BLKDEV_MAJOR_HASH_SIZE) {
203 mutex_lock(&block_class_lock);
204 for (dp = major_names[offset]; dp; dp = dp->next)
205 seq_printf(seqf, "%3d %s\n", dp->major, dp->name);
206 mutex_unlock(&block_class_lock);
209 #endif /* CONFIG_PROC_FS */
211 int register_blkdev(unsigned int major, const char *name)
213 struct blk_major_name **n, *p;
216 mutex_lock(&block_class_lock);
220 for (index = ARRAY_SIZE(major_names)-1; index > 0; index--) {
221 if (major_names[index] == NULL)
226 printk("register_blkdev: failed to get major for %s\n",
235 p = kmalloc(sizeof(struct blk_major_name), GFP_KERNEL);
242 strlcpy(p->name, name, sizeof(p->name));
244 index = major_to_index(major);
246 for (n = &major_names[index]; *n; n = &(*n)->next) {
247 if ((*n)->major == major)
256 printk("register_blkdev: cannot get major %d for %s\n",
261 mutex_unlock(&block_class_lock);
265 EXPORT_SYMBOL(register_blkdev);
267 void unregister_blkdev(unsigned int major, const char *name)
269 struct blk_major_name **n;
270 struct blk_major_name *p = NULL;
271 int index = major_to_index(major);
273 mutex_lock(&block_class_lock);
274 for (n = &major_names[index]; *n; n = &(*n)->next)
275 if ((*n)->major == major)
277 if (!*n || strcmp((*n)->name, name)) {
283 mutex_unlock(&block_class_lock);
287 EXPORT_SYMBOL(unregister_blkdev);
289 static struct kobj_map *bdev_map;
292 * Register device numbers dev..(dev+range-1)
293 * range must be nonzero
294 * The hash chain is sorted on range, so that subranges can override.
296 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
297 struct kobject *(*probe)(dev_t, int *, void *),
298 int (*lock)(dev_t, void *), void *data)
300 kobj_map(bdev_map, devt, range, module, probe, lock, data);
303 EXPORT_SYMBOL(blk_register_region);
305 void blk_unregister_region(dev_t devt, unsigned long range)
307 kobj_unmap(bdev_map, devt, range);
310 EXPORT_SYMBOL(blk_unregister_region);
312 static struct kobject *exact_match(dev_t devt, int *partno, void *data)
314 struct gendisk *p = data;
319 static int exact_lock(dev_t devt, void *data)
321 struct gendisk *p = data;
329 * add_disk - add partitioning information to kernel list
330 * @disk: per-device partitioning information
332 * This function registers the partitioning information in @disk
335 void add_disk(struct gendisk *disk)
337 struct backing_dev_info *bdi;
340 disk->flags |= GENHD_FL_UP;
341 disk->dev.devt = MKDEV(disk->major, disk->first_minor);
342 blk_register_region(disk_devt(disk), disk->minors, NULL,
343 exact_match, exact_lock, disk);
345 blk_register_queue(disk);
347 bdi = &disk->queue->backing_dev_info;
348 bdi_register_dev(bdi, disk_devt(disk));
349 retval = sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
353 EXPORT_SYMBOL(add_disk);
354 EXPORT_SYMBOL(del_gendisk); /* in partitions/check.c */
356 void unlink_gendisk(struct gendisk *disk)
358 sysfs_remove_link(&disk->dev.kobj, "bdi");
359 bdi_unregister(&disk->queue->backing_dev_info);
360 blk_unregister_queue(disk);
361 blk_unregister_region(disk_devt(disk), disk->minors);
365 * get_gendisk - get partitioning information for a given device
366 * @devt: device to get partitioning information for
367 * @part: returned partition index
369 * This function gets the structure containing partitioning
370 * information for the given device @devt.
372 struct gendisk *get_gendisk(dev_t devt, int *partno)
374 struct kobject *kobj = kobj_lookup(bdev_map, devt, partno);
375 struct device *dev = kobj_to_dev(kobj);
377 return kobj ? dev_to_disk(dev) : NULL;
381 * bdget_disk - do bdget() by gendisk and partition number
382 * @disk: gendisk of interest
383 * @partno: partition number
385 * Find partition @partno from @disk, do bdget() on it.
391 * Resulting block_device on success, NULL on failure.
393 extern struct block_device *bdget_disk(struct gendisk *disk, int partno)
395 dev_t devt = MKDEV(0, 0);
398 devt = disk_devt(disk);
400 struct hd_struct *part;
402 part = disk_get_part(disk, partno);
403 if (part && part->nr_sects)
404 devt = part_devt(part);
408 if (likely(devt != MKDEV(0, 0)))
412 EXPORT_SYMBOL(bdget_disk);
415 * print a full list of all partitions - intended for places where the root
416 * filesystem can't be mounted and thus to give the victim some idea of what
419 void __init printk_all_partitions(void)
421 struct class_dev_iter iter;
424 class_dev_iter_init(&iter, &block_class, NULL, &disk_type);
425 while ((dev = class_dev_iter_next(&iter))) {
426 struct gendisk *disk = dev_to_disk(dev);
427 struct disk_part_iter piter;
428 struct hd_struct *part;
429 char buf[BDEVNAME_SIZE];
432 * Don't show empty devices or things that have been
435 if (get_capacity(disk) == 0 ||
436 (disk->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
440 * Note, unlike /proc/partitions, I am showing the
441 * numbers in hex - the same format as the root=
444 printk("%02x%02x %10llu %s",
445 MAJOR(disk_devt(disk)), MINOR(disk_devt(disk)),
446 (unsigned long long)get_capacity(disk) >> 1,
447 disk_name(disk, 0, buf));
448 if (disk->driverfs_dev != NULL &&
449 disk->driverfs_dev->driver != NULL)
450 printk(" driver: %s\n",
451 disk->driverfs_dev->driver->name);
453 printk(" (driver?)\n");
455 /* now show the partitions */
456 disk_part_iter_init(&piter, disk, 0);
457 while ((part = disk_part_iter_next(&piter)))
458 printk(" %02x%02x %10llu %s\n",
459 MAJOR(part_devt(part)), MINOR(part_devt(part)),
460 (unsigned long long)part->nr_sects >> 1,
461 disk_name(disk, part->partno, buf));
462 disk_part_iter_exit(&piter);
464 class_dev_iter_exit(&iter);
467 #ifdef CONFIG_PROC_FS
469 static void *disk_seqf_start(struct seq_file *seqf, loff_t *pos)
472 struct class_dev_iter *iter;
475 iter = kmalloc(GFP_KERNEL, sizeof(*iter));
477 return ERR_PTR(-ENOMEM);
479 seqf->private = iter;
480 class_dev_iter_init(iter, &block_class, NULL, &disk_type);
482 dev = class_dev_iter_next(iter);
487 return dev_to_disk(dev);
490 static void *disk_seqf_next(struct seq_file *seqf, void *v, loff_t *pos)
495 dev = class_dev_iter_next(seqf->private);
497 return dev_to_disk(dev);
502 static void disk_seqf_stop(struct seq_file *seqf, void *v)
504 struct class_dev_iter *iter = seqf->private;
506 /* stop is called even after start failed :-( */
508 class_dev_iter_exit(iter);
513 static void *show_partition_start(struct seq_file *seqf, loff_t *pos)
517 p = disk_seqf_start(seqf, pos);
519 seq_puts(seqf, "major minor #blocks name\n\n");
523 static int show_partition(struct seq_file *seqf, void *v)
525 struct gendisk *sgp = v;
526 struct disk_part_iter piter;
527 struct hd_struct *part;
528 char buf[BDEVNAME_SIZE];
530 /* Don't show non-partitionable removeable devices or empty devices */
531 if (!get_capacity(sgp) || (!disk_max_parts(sgp) &&
532 (sgp->flags & GENHD_FL_REMOVABLE)))
534 if (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO)
537 /* show the full disk and all non-0 size partitions of it */
538 seq_printf(seqf, "%4d %4d %10llu %s\n",
539 MAJOR(disk_devt(sgp)), MINOR(disk_devt(sgp)),
540 (unsigned long long)get_capacity(sgp) >> 1,
541 disk_name(sgp, 0, buf));
543 disk_part_iter_init(&piter, sgp, 0);
544 while ((part = disk_part_iter_next(&piter)))
545 seq_printf(seqf, "%4d %4d %10llu %s\n",
546 MAJOR(part_devt(part)), MINOR(part_devt(part)),
547 (unsigned long long)part->nr_sects >> 1,
548 disk_name(sgp, part->partno, buf));
549 disk_part_iter_exit(&piter);
554 const struct seq_operations partitions_op = {
555 .start = show_partition_start,
556 .next = disk_seqf_next,
557 .stop = disk_seqf_stop,
558 .show = show_partition
563 static struct kobject *base_probe(dev_t devt, int *partno, void *data)
565 if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
566 /* Make old-style 2.4 aliases work */
567 request_module("block-major-%d", MAJOR(devt));
571 static int __init genhd_device_init(void)
575 block_class.dev_kobj = sysfs_dev_block_kobj;
576 error = class_register(&block_class);
579 bdev_map = kobj_map_init(base_probe, &block_class_lock);
582 #ifndef CONFIG_SYSFS_DEPRECATED
583 /* create top-level block dir */
584 block_depr = kobject_create_and_add("block", NULL);
589 subsys_initcall(genhd_device_init);
591 static ssize_t disk_range_show(struct device *dev,
592 struct device_attribute *attr, char *buf)
594 struct gendisk *disk = dev_to_disk(dev);
596 return sprintf(buf, "%d\n", disk->minors);
599 static ssize_t disk_removable_show(struct device *dev,
600 struct device_attribute *attr, char *buf)
602 struct gendisk *disk = dev_to_disk(dev);
604 return sprintf(buf, "%d\n",
605 (disk->flags & GENHD_FL_REMOVABLE ? 1 : 0));
608 static ssize_t disk_ro_show(struct device *dev,
609 struct device_attribute *attr, char *buf)
611 struct gendisk *disk = dev_to_disk(dev);
613 return sprintf(buf, "%d\n", disk->policy ? 1 : 0);
616 static ssize_t disk_size_show(struct device *dev,
617 struct device_attribute *attr, char *buf)
619 struct gendisk *disk = dev_to_disk(dev);
621 return sprintf(buf, "%llu\n", (unsigned long long)get_capacity(disk));
624 static ssize_t disk_capability_show(struct device *dev,
625 struct device_attribute *attr, char *buf)
627 struct gendisk *disk = dev_to_disk(dev);
629 return sprintf(buf, "%x\n", disk->flags);
632 static ssize_t disk_stat_show(struct device *dev,
633 struct device_attribute *attr, char *buf)
635 struct gendisk *disk = dev_to_disk(dev);
638 disk_round_stats(disk);
641 "%8lu %8lu %8llu %8u "
642 "%8lu %8lu %8llu %8u "
645 disk_stat_read(disk, ios[READ]),
646 disk_stat_read(disk, merges[READ]),
647 (unsigned long long)disk_stat_read(disk, sectors[READ]),
648 jiffies_to_msecs(disk_stat_read(disk, ticks[READ])),
649 disk_stat_read(disk, ios[WRITE]),
650 disk_stat_read(disk, merges[WRITE]),
651 (unsigned long long)disk_stat_read(disk, sectors[WRITE]),
652 jiffies_to_msecs(disk_stat_read(disk, ticks[WRITE])),
654 jiffies_to_msecs(disk_stat_read(disk, io_ticks)),
655 jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
658 #ifdef CONFIG_FAIL_MAKE_REQUEST
659 static ssize_t disk_fail_show(struct device *dev,
660 struct device_attribute *attr, char *buf)
662 struct gendisk *disk = dev_to_disk(dev);
664 return sprintf(buf, "%d\n", disk->flags & GENHD_FL_FAIL ? 1 : 0);
667 static ssize_t disk_fail_store(struct device *dev,
668 struct device_attribute *attr,
669 const char *buf, size_t count)
671 struct gendisk *disk = dev_to_disk(dev);
674 if (count > 0 && sscanf(buf, "%d", &i) > 0) {
676 disk->flags &= ~GENHD_FL_FAIL;
678 disk->flags |= GENHD_FL_FAIL;
686 static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
687 static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
688 static DEVICE_ATTR(ro, S_IRUGO, disk_ro_show, NULL);
689 static DEVICE_ATTR(size, S_IRUGO, disk_size_show, NULL);
690 static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL);
691 static DEVICE_ATTR(stat, S_IRUGO, disk_stat_show, NULL);
692 #ifdef CONFIG_FAIL_MAKE_REQUEST
693 static struct device_attribute dev_attr_fail =
694 __ATTR(make-it-fail, S_IRUGO|S_IWUSR, disk_fail_show, disk_fail_store);
697 static struct attribute *disk_attrs[] = {
698 &dev_attr_range.attr,
699 &dev_attr_removable.attr,
702 &dev_attr_capability.attr,
704 #ifdef CONFIG_FAIL_MAKE_REQUEST
710 static struct attribute_group disk_attr_group = {
714 static struct attribute_group *disk_attr_groups[] = {
719 static void disk_release(struct device *dev)
721 struct gendisk *disk = dev_to_disk(dev);
725 free_disk_stats(disk);
728 struct class block_class = {
732 static struct device_type disk_type = {
734 .groups = disk_attr_groups,
735 .release = disk_release,
738 #ifdef CONFIG_PROC_FS
740 * aggregate disk stat collector. Uses the same stats that the sysfs
741 * entries do, above, but makes them available through one seq_file.
743 * The output looks suspiciously like /proc/partitions with a bunch of
746 static int diskstats_show(struct seq_file *seqf, void *v)
748 struct gendisk *gp = v;
749 struct disk_part_iter piter;
750 struct hd_struct *hd;
751 char buf[BDEVNAME_SIZE];
754 if (&gp->dev.kobj.entry == block_class.devices.next)
755 seq_puts(seqf, "major minor name"
756 " rio rmerge rsect ruse wio wmerge "
757 "wsect wuse running use aveq"
762 disk_round_stats(gp);
764 seq_printf(seqf, "%4d %4d %s %lu %lu %llu %u %lu %lu %llu %u %u %u %u\n",
765 MAJOR(disk_devt(gp)), MINOR(disk_devt(gp)),
766 disk_name(gp, 0, buf),
767 disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]),
768 (unsigned long long)disk_stat_read(gp, sectors[0]),
769 jiffies_to_msecs(disk_stat_read(gp, ticks[0])),
770 disk_stat_read(gp, ios[1]), disk_stat_read(gp, merges[1]),
771 (unsigned long long)disk_stat_read(gp, sectors[1]),
772 jiffies_to_msecs(disk_stat_read(gp, ticks[1])),
774 jiffies_to_msecs(disk_stat_read(gp, io_ticks)),
775 jiffies_to_msecs(disk_stat_read(gp, time_in_queue)));
777 /* now show all non-0 size partitions of it */
778 disk_part_iter_init(&piter, gp, 0);
779 while ((hd = disk_part_iter_next(&piter))) {
781 part_round_stats(hd);
783 seq_printf(seqf, "%4d %4d %s %lu %lu %llu "
784 "%u %lu %lu %llu %u %u %u %u\n",
785 MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
786 disk_name(gp, hd->partno, buf),
787 part_stat_read(hd, ios[0]),
788 part_stat_read(hd, merges[0]),
789 (unsigned long long)part_stat_read(hd, sectors[0]),
790 jiffies_to_msecs(part_stat_read(hd, ticks[0])),
791 part_stat_read(hd, ios[1]),
792 part_stat_read(hd, merges[1]),
793 (unsigned long long)part_stat_read(hd, sectors[1]),
794 jiffies_to_msecs(part_stat_read(hd, ticks[1])),
796 jiffies_to_msecs(part_stat_read(hd, io_ticks)),
797 jiffies_to_msecs(part_stat_read(hd, time_in_queue))
800 disk_part_iter_exit(&piter);
805 const struct seq_operations diskstats_op = {
806 .start = disk_seqf_start,
807 .next = disk_seqf_next,
808 .stop = disk_seqf_stop,
809 .show = diskstats_show
811 #endif /* CONFIG_PROC_FS */
813 static void media_change_notify_thread(struct work_struct *work)
815 struct gendisk *gd = container_of(work, struct gendisk, async_notify);
816 char event[] = "MEDIA_CHANGE=1";
817 char *envp[] = { event, NULL };
820 * set enviroment vars to indicate which event this is for
821 * so that user space will know to go check the media status.
823 kobject_uevent_env(&gd->dev.kobj, KOBJ_CHANGE, envp);
824 put_device(gd->driverfs_dev);
828 void genhd_media_change_notify(struct gendisk *disk)
830 get_device(disk->driverfs_dev);
831 schedule_work(&disk->async_notify);
833 EXPORT_SYMBOL_GPL(genhd_media_change_notify);
836 dev_t blk_lookup_devt(const char *name, int partno)
838 dev_t devt = MKDEV(0, 0);
839 struct class_dev_iter iter;
842 class_dev_iter_init(&iter, &block_class, NULL, &disk_type);
843 while ((dev = class_dev_iter_next(&iter))) {
844 struct gendisk *disk = dev_to_disk(dev);
846 if (strcmp(dev->bus_id, name))
848 if (partno < 0 || partno > disk_max_parts(disk))
852 devt = disk_devt(disk);
854 struct hd_struct *part;
856 part = disk_get_part(disk, partno);
857 if (!part || !part->nr_sects) {
862 devt = part_devt(part);
867 class_dev_iter_exit(&iter);
870 EXPORT_SYMBOL(blk_lookup_devt);
872 struct gendisk *alloc_disk(int minors)
874 return alloc_disk_node(minors, -1);
877 struct gendisk *alloc_disk_node(int minors, int node_id)
879 struct gendisk *disk;
881 disk = kmalloc_node(sizeof(struct gendisk),
882 GFP_KERNEL | __GFP_ZERO, node_id);
884 if (!init_disk_stats(disk)) {
889 int size = (minors - 1) * sizeof(struct hd_struct *);
890 disk->__part = kmalloc_node(size,
891 GFP_KERNEL | __GFP_ZERO, node_id);
893 free_disk_stats(disk);
898 disk->minors = minors;
899 rand_initialize_disk(disk);
900 disk->dev.class = &block_class;
901 disk->dev.type = &disk_type;
902 device_initialize(&disk->dev);
903 INIT_WORK(&disk->async_notify,
904 media_change_notify_thread);
909 EXPORT_SYMBOL(alloc_disk);
910 EXPORT_SYMBOL(alloc_disk_node);
912 struct kobject *get_disk(struct gendisk *disk)
914 struct module *owner;
915 struct kobject *kobj;
919 owner = disk->fops->owner;
920 if (owner && !try_module_get(owner))
922 kobj = kobject_get(&disk->dev.kobj);
931 EXPORT_SYMBOL(get_disk);
933 void put_disk(struct gendisk *disk)
936 kobject_put(&disk->dev.kobj);
939 EXPORT_SYMBOL(put_disk);
941 void set_device_ro(struct block_device *bdev, int flag)
943 if (bdev->bd_contains != bdev)
944 bdev->bd_part->policy = flag;
946 bdev->bd_disk->policy = flag;
949 EXPORT_SYMBOL(set_device_ro);
951 void set_disk_ro(struct gendisk *disk, int flag)
953 struct disk_part_iter piter;
954 struct hd_struct *part;
957 disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY);
958 while ((part = disk_part_iter_next(&piter)))
960 disk_part_iter_exit(&piter);
963 EXPORT_SYMBOL(set_disk_ro);
965 int bdev_read_only(struct block_device *bdev)
969 else if (bdev->bd_contains != bdev)
970 return bdev->bd_part->policy;
972 return bdev->bd_disk->policy;
975 EXPORT_SYMBOL(bdev_read_only);
977 int invalidate_partition(struct gendisk *disk, int partno)
980 struct block_device *bdev = bdget_disk(disk, partno);
983 res = __invalidate_device(bdev);
989 EXPORT_SYMBOL(invalidate_partition);