Skip to content

Commit 9208d41

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: add a ->get_unique_id method
Add a method to query unique IDs from block devices. It will be used to remove code that deeply pokes into SCSI internals in the NFS server. The implementation in the sd driver itself is also much nicer as it can use the cached VPD page instead of always sending a command as the current NFS code does. For now the interface is kept very minimal but could be easily extended when other users like a block-layer sysfs interface for uniquue IDs shows up. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20211021060607.264371-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8e9f666 commit 9208d41

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/linux/blkdev.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,14 @@ static inline void blk_crypto_unregister(struct request_queue *q) { }
11581158

11591159
#endif /* CONFIG_BLK_INLINE_ENCRYPTION */
11601160

1161+
enum blk_unique_id {
1162+
/* these match the Designator Types specified in SPC */
1163+
BLK_UID_T10 = 1,
1164+
BLK_UID_EUI64 = 2,
1165+
BLK_UID_NAA = 3,
1166+
};
1167+
1168+
#define NFL4_UFLG_MASK 0x0000003F
11611169

11621170
struct block_device_operations {
11631171
void (*submit_bio)(struct bio *bio);
@@ -1176,6 +1184,9 @@ struct block_device_operations {
11761184
int (*report_zones)(struct gendisk *, sector_t sector,
11771185
unsigned int nr_zones, report_zones_cb cb, void *data);
11781186
char *(*devnode)(struct gendisk *disk, umode_t *mode);
1187+
/* returns the length of the identifier or a negative errno: */
1188+
int (*get_unique_id)(struct gendisk *disk, u8 id[16],
1189+
enum blk_unique_id id_type);
11791190
struct module *owner;
11801191
const struct pr_ops *pr_ops;
11811192

0 commit comments

Comments
 (0)