md: switch to ->check_events for media change notifications
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. Signed-off-by: Christoph Hellwig <hch@lst.de> [axboe: remove unused 'bdops' variable in disk_clear_events()] Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:

committed by
Jens Axboe

parent
568f270065
commit
a564e23f0f
@@ -467,7 +467,6 @@ prototypes::
|
|||||||
int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
|
int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
|
||||||
int (*direct_access) (struct block_device *, sector_t, void **,
|
int (*direct_access) (struct block_device *, sector_t, void **,
|
||||||
unsigned long *);
|
unsigned long *);
|
||||||
int (*media_changed) (struct gendisk *);
|
|
||||||
void (*unlock_native_capacity) (struct gendisk *);
|
void (*unlock_native_capacity) (struct gendisk *);
|
||||||
int (*revalidate_disk) (struct gendisk *);
|
int (*revalidate_disk) (struct gendisk *);
|
||||||
int (*getgeo)(struct block_device *, struct hd_geometry *);
|
int (*getgeo)(struct block_device *, struct hd_geometry *);
|
||||||
@@ -483,14 +482,13 @@ release: yes
|
|||||||
ioctl: no
|
ioctl: no
|
||||||
compat_ioctl: no
|
compat_ioctl: no
|
||||||
direct_access: no
|
direct_access: no
|
||||||
media_changed: no
|
|
||||||
unlock_native_capacity: no
|
unlock_native_capacity: no
|
||||||
revalidate_disk: no
|
revalidate_disk: no
|
||||||
getgeo: no
|
getgeo: no
|
||||||
swap_slot_free_notify: no (see below)
|
swap_slot_free_notify: no (see below)
|
||||||
======================= ===================
|
======================= ===================
|
||||||
|
|
||||||
media_changed, unlock_native_capacity and revalidate_disk are called only from
|
unlock_native_capacity and revalidate_disk are called only from
|
||||||
check_disk_change().
|
check_disk_change().
|
||||||
|
|
||||||
swap_slot_free_notify is called with swap_lock and sometimes the page lock
|
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)
|
|||||||
*/
|
*/
|
||||||
unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)
|
unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)
|
||||||
{
|
{
|
||||||
const struct block_device_operations *bdops = disk->fops;
|
|
||||||
struct disk_events *ev = disk->ev;
|
struct disk_events *ev = disk->ev;
|
||||||
unsigned int pending;
|
unsigned int pending;
|
||||||
unsigned int clearing = mask;
|
unsigned int clearing = mask;
|
||||||
|
|
||||||
if (!ev) {
|
if (!ev)
|
||||||
/* for drivers still using the old ->media_changed method */
|
|
||||||
if ((mask & DISK_EVENT_MEDIA_CHANGE) &&
|
|
||||||
bdops->media_changed && bdops->media_changed(disk))
|
|
||||||
return DISK_EVENT_MEDIA_CHANGE;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
disk_block_events(disk);
|
disk_block_events(disk);
|
||||||
|
|
||||||
|
@@ -5670,6 +5670,7 @@ static int md_alloc(dev_t dev, char *name)
|
|||||||
* remove it now.
|
* remove it now.
|
||||||
*/
|
*/
|
||||||
disk->flags |= GENHD_FL_EXT_DEVT;
|
disk->flags |= GENHD_FL_EXT_DEVT;
|
||||||
|
disk->events |= DISK_EVENT_MEDIA_CHANGE;
|
||||||
mddev->gendisk = disk;
|
mddev->gendisk = disk;
|
||||||
/* As soon as we call add_disk(), another thread could get
|
/* As soon as we call add_disk(), another thread could get
|
||||||
* through to md_open, so make sure it doesn't get too far
|
* 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)
|
|||||||
mddev_put(mddev);
|
mddev_put(mddev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int md_media_changed(struct gendisk *disk)
|
static unsigned int md_check_events(struct gendisk *disk, unsigned int clearing)
|
||||||
{
|
|
||||||
struct mddev *mddev = disk->private_data;
|
|
||||||
|
|
||||||
return mddev->changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int md_revalidate(struct gendisk *disk)
|
|
||||||
{
|
{
|
||||||
struct mddev *mddev = disk->private_data;
|
struct mddev *mddev = disk->private_data;
|
||||||
|
unsigned int ret = 0;
|
||||||
|
|
||||||
|
if (mddev->changed)
|
||||||
|
ret = DISK_EVENT_MEDIA_CHANGE;
|
||||||
mddev->changed = 0;
|
mddev->changed = 0;
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct block_device_operations md_fops =
|
static const struct block_device_operations md_fops =
|
||||||
{
|
{
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
@@ -7831,8 +7829,7 @@ static const struct block_device_operations md_fops =
|
|||||||
.compat_ioctl = md_compat_ioctl,
|
.compat_ioctl = md_compat_ioctl,
|
||||||
#endif
|
#endif
|
||||||
.getgeo = md_getgeo,
|
.getgeo = md_getgeo,
|
||||||
.media_changed = md_media_changed,
|
.check_events = md_check_events,
|
||||||
.revalidate_disk= md_revalidate,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int md_thread(void *arg)
|
static int md_thread(void *arg)
|
||||||
|
@@ -1781,8 +1781,6 @@ struct block_device_operations {
|
|||||||
int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
|
int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
|
||||||
unsigned int (*check_events) (struct gendisk *disk,
|
unsigned int (*check_events) (struct gendisk *disk,
|
||||||
unsigned int clearing);
|
unsigned int clearing);
|
||||||
/* ->media_changed() is DEPRECATED, use ->check_events() instead */
|
|
||||||
int (*media_changed) (struct gendisk *);
|
|
||||||
void (*unlock_native_capacity) (struct gendisk *);
|
void (*unlock_native_capacity) (struct gendisk *);
|
||||||
int (*revalidate_disk) (struct gendisk *);
|
int (*revalidate_disk) (struct gendisk *);
|
||||||
int (*getgeo)(struct block_device *, struct hd_geometry *);
|
int (*getgeo)(struct block_device *, struct hd_geometry *);
|
||||||
|
Reference in New Issue
Block a user