Skip to content

Commit 7957d93

Browse files
teknoraveraxboe
authored andcommitted
block: add ioctl to read the disk sequence number
Add a new BLKGETDISKSEQ ioctl which retrieves the disk sequence number from the genhd structure. # ./getdiskseq /dev/loop* /dev/loop0: 13 /dev/loop0p1: 13 /dev/loop0p2: 13 /dev/loop0p3: 13 /dev/loop1: 14 /dev/loop1p1: 14 /dev/loop1p2: 14 /dev/loop2: 5 /dev/loop3: 6 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 87eb710 commit 7957d93

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

block/ioctl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,8 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
469469
BLKDEV_DISCARD_SECURE);
470470
case BLKZEROOUT:
471471
return blk_ioctl_zeroout(bdev, mode, arg);
472+
case BLKGETDISKSEQ:
473+
return put_u64(argp, bdev->bd_disk->diskseq);
472474
case BLKREPORTZONE:
473475
return blkdev_report_zones_ioctl(bdev, mode, cmd, arg);
474476
case BLKRESETZONE:

include/uapi/linux/fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ struct fsxattr {
184184
#define BLKSECDISCARD _IO(0x12,125)
185185
#define BLKROTATIONAL _IO(0x12,126)
186186
#define BLKZEROOUT _IO(0x12,127)
187+
#define BLKGETDISKSEQ _IOR(0x12,128,__u64)
187188
/*
188189
* A jump here: 130-136 are reserved for zoned block devices
189190
* (see uapi/linux/blkzoned.h)

0 commit comments

Comments
 (0)