]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: add ioctl to read the disk sequence number
authorMatteo Croce <mcroce@microsoft.com>
Mon, 12 Jul 2021 23:05:27 +0000 (01:05 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 2 Aug 2021 19:37:28 +0000 (13:37 -0600)
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 <hch@lst.de>
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Tested-by: Luca Boccassi <bluca@debian.org>
Link: https://lore.kernel.org/r/20210712230530.29323-4-mcroce@linux.microsoft.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/ioctl.c
include/uapi/linux/fs.h

index 24beec9ca9c95b776c6976bb5e6d5f129420c326..0c3a4a53fa11822e160cd107376471b02bf5d901 100644 (file)
@@ -469,6 +469,8 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
                                BLKDEV_DISCARD_SECURE);
        case BLKZEROOUT:
                return blk_ioctl_zeroout(bdev, mode, arg);
+       case BLKGETDISKSEQ:
+               return put_u64(argp, bdev->bd_disk->diskseq);
        case BLKREPORTZONE:
                return blkdev_report_zones_ioctl(bdev, mode, cmd, arg);
        case BLKRESETZONE:
index 4c32e97dcdf00a22ebbcfc3c03f849ea90b2d9f5..bdf7b404b3e723e2def3acad8354f6f32e02a3e7 100644 (file)
@@ -184,6 +184,7 @@ struct fsxattr {
 #define BLKSECDISCARD _IO(0x12,125)
 #define BLKROTATIONAL _IO(0x12,126)
 #define BLKZEROOUT _IO(0x12,127)
+#define BLKGETDISKSEQ _IOR(0x12,128,__u64)
 /*
  * A jump here: 130-136 are reserved for zoned block devices
  * (see uapi/linux/blkzoned.h)