Skip to content

Commit 13927b3

Browse files
teknoraveraxboe
authored andcommitted
block: export diskseq in sysfs
Add a new sysfs handle to export the new diskseq value. Place it in <sysfs>/block/<disk>/diskseq and document it. $ grep . /sys/class/block/*/diskseq /sys/class/block/loop0/diskseq:13 /sys/class/block/loop1/diskseq:14 /sys/class/block/loop2/diskseq:5 /sys/class/block/loop3/diskseq:6 /sys/class/block/ram0/diskseq:1 /sys/class/block/ram1/diskseq:2 /sys/class/block/vda/diskseq:7 Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Matteo Croce <[email protected]> Tested-by: Luca Boccassi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 7957d93 commit 13927b3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Documentation/ABI/testing/sysfs-block

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ Description:
2828
For more details refer Documentation/admin-guide/iostats.rst
2929

3030

31+
What: /sys/block/<disk>/diskseq
32+
Date: February 2021
33+
Contact: Matteo Croce <[email protected]>
34+
Description:
35+
The /sys/block/<disk>/diskseq files reports the disk
36+
sequence number, which is a monotonically increasing
37+
number assigned to every drive.
38+
Some devices, like the loop device, refresh such number
39+
every time the backing file is changed.
40+
The value type is 64 bit unsigned.
41+
42+
3143
What: /sys/block/<disk>/<part>/stat
3244
Date: February 2008
3345
Contact: Jerome Marchand <[email protected]>

block/genhd.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,14 @@ static ssize_t disk_discard_alignment_show(struct device *dev,
977977
return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue));
978978
}
979979

980+
static ssize_t diskseq_show(struct device *dev,
981+
struct device_attribute *attr, char *buf)
982+
{
983+
struct gendisk *disk = dev_to_disk(dev);
984+
985+
return sprintf(buf, "%llu\n", disk->diskseq);
986+
}
987+
980988
static DEVICE_ATTR(range, 0444, disk_range_show, NULL);
981989
static DEVICE_ATTR(ext_range, 0444, disk_ext_range_show, NULL);
982990
static DEVICE_ATTR(removable, 0444, disk_removable_show, NULL);
@@ -989,6 +997,7 @@ static DEVICE_ATTR(capability, 0444, disk_capability_show, NULL);
989997
static DEVICE_ATTR(stat, 0444, part_stat_show, NULL);
990998
static DEVICE_ATTR(inflight, 0444, part_inflight_show, NULL);
991999
static DEVICE_ATTR(badblocks, 0644, disk_badblocks_show, disk_badblocks_store);
1000+
static DEVICE_ATTR(diskseq, 0444, diskseq_show, NULL);
9921001

9931002
#ifdef CONFIG_FAIL_MAKE_REQUEST
9941003
ssize_t part_fail_show(struct device *dev,
@@ -1034,6 +1043,7 @@ static struct attribute *disk_attrs[] = {
10341043
&dev_attr_events.attr,
10351044
&dev_attr_events_async.attr,
10361045
&dev_attr_events_poll_msecs.attr,
1046+
&dev_attr_diskseq.attr,
10371047
#ifdef CONFIG_FAIL_MAKE_REQUEST
10381048
&dev_attr_fail.attr,
10391049
#endif

0 commit comments

Comments
 (0)