1 --- a/include/linux/blkdev.h
2 +++ b/include/linux/blkdev.h
3 @@ -1299,6 +1299,8 @@ struct block_device_operations {
5 int (*revalidate_disk) (struct gendisk *);
6 int (*getgeo)(struct block_device *, struct hd_geometry *);
7 + /* this callback is with swap_lock and sometimes page table lock held */
8 + void (*swap_slot_free_notify) (struct block_device *, unsigned long);
14 @@ -574,6 +574,7 @@ static unsigned char swap_entry_free(str
16 /* free if no reference */
18 + struct gendisk *disk = p->bdev->bd_disk;
19 if (offset < p->lowest_bit)
20 p->lowest_bit = offset;
21 if (offset > p->highest_bit)
22 @@ -583,6 +584,8 @@ static unsigned char swap_entry_free(str
23 swap_list.next = p->type;
26 + if (disk->fops->swap_slot_free_notify)
27 + disk->fops->swap_slot_free_notify(p->bdev, offset);