Commit 7957d93b authored by Matteo Croce's avatar Matteo Croce Committed by Jens Axboe

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMatteo Croce <mcroce@microsoft.com>
Tested-by: default avatarLuca Boccassi <bluca@debian.org>
Link: https://lore.kernel.org/r/20210712230530.29323-4-mcroce@linux.microsoft.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 87eb7107
...@@ -469,6 +469,8 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -469,6 +469,8 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
BLKDEV_DISCARD_SECURE); BLKDEV_DISCARD_SECURE);
case BLKZEROOUT: case BLKZEROOUT:
return blk_ioctl_zeroout(bdev, mode, arg); return blk_ioctl_zeroout(bdev, mode, arg);
case BLKGETDISKSEQ:
return put_u64(argp, bdev->bd_disk->diskseq);
case BLKREPORTZONE: case BLKREPORTZONE:
return blkdev_report_zones_ioctl(bdev, mode, cmd, arg); return blkdev_report_zones_ioctl(bdev, mode, cmd, arg);
case BLKRESETZONE: case BLKRESETZONE:
......
...@@ -184,6 +184,7 @@ struct fsxattr { ...@@ -184,6 +184,7 @@ struct fsxattr {
#define BLKSECDISCARD _IO(0x12,125) #define BLKSECDISCARD _IO(0x12,125)
#define BLKROTATIONAL _IO(0x12,126) #define BLKROTATIONAL _IO(0x12,126)
#define BLKZEROOUT _IO(0x12,127) #define BLKZEROOUT _IO(0x12,127)
#define BLKGETDISKSEQ _IOR(0x12,128,__u64)
/* /*
* A jump here: 130-136 are reserved for zoned block devices * A jump here: 130-136 are reserved for zoned block devices
* (see uapi/linux/blkzoned.h) * (see uapi/linux/blkzoned.h)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment