diff mbox series

[v2,5/6] block: increment sequence number

Message ID 20210520135622.44625-6-mcroce@linux.microsoft.com (mailing list archive)
State New, archived
Headers show
Series block: add a sequence number to disks | expand

Commit Message

Matteo Croce May 20, 2021, 1:56 p.m. UTC
From: Matteo Croce <mcroce@microsoft.com>

Increment the disk sequence number when the media has changed,
i.e. on DISK_EVENT_MEDIA_CHANGE event.

    $ cat /sys/class/block/sr0/diskseq
    12
    $ eject
    $ cat /sys/class/block/sr0/diskseq
    22

Signed-off-by: Matteo Croce <mcroce@microsoft.com>
---
 block/genhd.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/block/genhd.c b/block/genhd.c
index 67519c034f9f..5bc6b6c248c4 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1666,6 +1666,9 @@  static void disk_check_events(struct disk_events *ev,
 
 	spin_unlock_irq(&ev->lock);
 
+	if (events & DISK_EVENT_MEDIA_CHANGE)
+		inc_diskseq(disk);
+
 	/*
 	 * Tell userland about new events.  Only the events listed in
 	 * @disk->events are reported, and only if DISK_EVENT_FLAG_UEVENT