md is the last driver using the legacy media_changed method. Switch it over to (not so) new ->clear_events approach, which also removes the need for the ->revalidate_disk method.
Unified · Split
| @@ -467,7 +467,6 @@ prototypes:: · 466 unmodified lines | |||
| 467 | int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); | 467 | int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); |
| 468 | int (*direct_access) (struct block_device *, sector_t, void **, | 468 | int (*direct_access) (struct block_device *, sector_t, void **, |
| 469 | unsigned long *); | 469 | unsigned long *); |
| 470 | int (*media_changed) (struct gendisk *); | ||
| 471 | void (*unlock_native_capacity) (struct gendisk *); | 470 | void (*unlock_native_capacity) (struct gendisk *); |
| 472 | int (*revalidate_disk) (struct gendisk *); | 471 | int (*revalidate_disk) (struct gendisk *); |
| 473 | int (*getgeo)(struct block_device *, struct hd_geometry *); | 472 | int (*getgeo)(struct block_device *, struct hd_geometry *); |
| @@ -483,14 +482,13 @@ release: yes · 9 unmodified lines | |||
| 483 | ioctl: no | 482 | ioctl: no |
| 484 | compat_ioctl: no | 483 | compat_ioctl: no |
| 485 | direct_access: no | 484 | direct_access: no |
| 486 | media_changed: no | ||
| 487 | unlock_native_capacity: no | 485 | unlock_native_capacity: no |
| 488 | revalidate_disk: no | 486 | revalidate_disk: no |
| 489 | getgeo: no | 487 | getgeo: no |
| 490 | swap_slot_free_notify: no (see below) | 488 | swap_slot_free_notify: no (see below) |
| 491 | ======================= =================== | 489 | ======================= =================== |
| 492 | 490 | ||
| 493 | media_changed, unlock_native_capacity and revalidate_disk are called only from | 491 | unlock_native_capacity and revalidate_disk are called only from |
| 494 | check_disk_change(). | 492 | check_disk_change(). |
| 495 | 493 | ||
| 496 | swap_slot_free_notify is called with swap_lock and sometimes the page lock | 494 | swap_slot_free_notify is called with swap_lock and sometimes the page lock |
| @@ -2056,18 +2056,12 @@ void disk_flush_events(struct gendisk *disk, unsigned int mask) · 2055 unmodified lines | |||
| 2056 | */ | 2056 | */ |
| 2057 | unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask) | 2057 | unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask) |
| 2058 | { | 2058 | { |
| 2059 | const struct block_device_operations *bdops = disk->fops; | ||
| 2060 | struct disk_events *ev = disk->ev; | 2059 | struct disk_events *ev = disk->ev; |
| 2061 | unsigned int pending; | 2060 | unsigned int pending; |
| 2062 | unsigned int clearing = mask; | 2061 | unsigned int clearing = mask; |
| 2063 | 2062 | ||
| 2064 | if (!ev) { | 2063 | if (!ev) |
| 2065 | /* for drivers still using the old ->media_changed method */ | ||
| 2066 | if ((mask & DISK_EVENT_MEDIA_CHANGE) && | ||
| 2067 | bdops->media_changed && bdops->media_changed(disk)) | ||
| 2068 | return DISK_EVENT_MEDIA_CHANGE; | ||
| 2069 | return 0; | 2064 | return 0; |
| 2070 | } | ||
| 2071 | 2065 | ||
| 2072 | disk_block_events(disk); | 2066 | disk_block_events(disk); |
| 2073 | 2067 | ||
| @@ -5670,6 +5670,7 @@ static int md_alloc(dev_t dev, char *name) · 5669 unmodified lines | |||
| 5670 | * remove it now. | 5670 | * remove it now. |
| 5671 | */ | 5671 | */ |
| 5672 | disk->flags |= GENHD_FL_EXT_DEVT; | 5672 | disk->flags |= GENHD_FL_EXT_DEVT; |
| 5673 | disk->events |= DISK_EVENT_MEDIA_CHANGE; | ||
| 5673 | mddev->gendisk = disk; | 5674 | mddev->gendisk = disk; |
| 5674 | /* As soon as we call add_disk(), another thread could get | 5675 | /* As soon as we call add_disk(), another thread could get |
| 5675 | * through to md_open, so make sure it doesn't get too far | 5676 | * through to md_open, so make sure it doesn't get too far |
| @@ -7806,20 +7807,17 @@ static void md_release(struct gendisk *disk, fmode_t mode) · 2130 unmodified lines | |||
| 7806 | mddev_put(mddev); | 7807 | mddev_put(mddev); |
| 7807 | } | 7808 | } |
| 7808 | 7809 | ||
| 7809 | static int md_media_changed(struct gendisk *disk) | 7810 | static unsigned int md_check_events(struct gendisk *disk, unsigned int clearing) |
| 7810 | { | ||
| 7811 | struct mddev *mddev = disk->private_data; | ||
| 7812 | |||
| 7813 | return mddev->changed; | ||
| 7814 | } | ||
| 7815 | |||
| 7816 | static int md_revalidate(struct gendisk *disk) | ||
| 7817 | { | 7811 | { |
| 7818 | struct mddev *mddev = disk->private_data; | 7812 | struct mddev *mddev = disk->private_data; |
| 7813 | unsigned int ret = 0; | ||
| 7819 | 7814 | ||
| 7815 | if (mddev->changed) | ||
| 7816 | ret = DISK_EVENT_MEDIA_CHANGE; | ||
| 7820 | mddev->changed = 0; | 7817 | mddev->changed = 0; |
| 7821 | return 0; | 7818 | return ret; |
| 7822 | } | 7819 | } |
| 7820 | |||
| 7823 | static const struct block_device_operations md_fops = | 7821 | static const struct block_device_operations md_fops = |
| 7824 | { | 7822 | { |
| 7825 | .owner = THIS_MODULE, | 7823 | .owner = THIS_MODULE, |
| @@ -7831,8 +7829,7 @@ static const struct block_device_operations md_fops = · 5 unmodified lines | |||
| 7831 | .compat_ioctl = md_compat_ioctl, | 7829 | .compat_ioctl = md_compat_ioctl, |
| 7832 | #endif | 7830 | #endif |
| 7833 | .getgeo = md_getgeo, | 7831 | .getgeo = md_getgeo, |
| 7834 | .media_changed = md_media_changed, | 7832 | .check_events = md_check_events, |
| 7835 | .revalidate_disk= md_revalidate, | ||
| 7836 | }; | 7833 | }; |
| 7837 | 7834 | ||
| 7838 | static int md_thread(void *arg) | 7835 | static int md_thread(void *arg) |
| @@ -1781,8 +1781,6 @@ struct block_device_operations { · 1780 unmodified lines | |||
| 1781 | int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); | 1781 | int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); |
| 1782 | unsigned int (*check_events) (struct gendisk *disk, | 1782 | unsigned int (*check_events) (struct gendisk *disk, |
| 1783 | unsigned int clearing); | 1783 | unsigned int clearing); |
| 1784 | /* ->media_changed() is DEPRECATED, use ->check_events() instead */ | ||
| 1785 | int (*media_changed) (struct gendisk *); | ||
| 1786 | void (*unlock_native_capacity) (struct gendisk *); | 1784 | void (*unlock_native_capacity) (struct gendisk *); |
| 1787 | int (*revalidate_disk) (struct gendisk *); | 1785 | int (*revalidate_disk) (struct gendisk *); |
| 1788 | int (*getgeo)(struct block_device *, struct hd_geometry *); | 1786 | int (*getgeo)(struct block_device *, struct hd_geometry *); |