diff mbox series

[1/7] block: add a ->get_unique_id method

Message ID 20211019075418.2332481-2-hch@lst.de (mailing list archive)
State Superseded
Headers show
Series [1/7] block: add a ->get_unique_id method | expand

Commit Message

Christoph Hellwig Oct. 19, 2021, 7:54 a.m. UTC
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>
---
 include/linux/blkdev.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Martin K. Petersen Oct. 20, 2021, 3:47 a.m. UTC | #1
Christoph,

> +enum blk_uniqueue_id {

uniqueue as opposed to unique?

> +	/* these match the Designator Types specified in SPC */
> +	BLK_UID_T10	= 1,
> +	BLK_UID_EUI64	= 2,
> +	BLK_UID_NAA	= 3,
> +};
> +
> +#define NFL4_UFLG_MASK			0x0000003F
>  
>  struct block_device_operations {
>  	void (*submit_bio)(struct bio *bio);
> @@ -1195,6 +1203,9 @@ struct block_device_operations {
>  	int (*report_zones)(struct gendisk *, sector_t sector,
>  			unsigned int nr_zones, report_zones_cb cb, void *data);
>  	char *(*devnode)(struct gendisk *disk, umode_t *mode);
> +	/* returns the length of the identifier or a negative errno: */
> +	int (*get_unique_id)(struct gendisk *disk, u8 id[16],
> +			enum blk_uniqueue_id id_type);
>  	struct module *owner;
>  	const struct pr_ops *pr_ops;
diff mbox series

Patch

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index fd9771a1da096..6e1c6fbdee0b5 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1177,6 +1177,14 @@  static inline void blk_ksm_unregister(struct request_queue *q) { }
 
 #endif /* CONFIG_BLK_INLINE_ENCRYPTION */
 
+enum blk_uniqueue_id {
+	/* these match the Designator Types specified in SPC */
+	BLK_UID_T10	= 1,
+	BLK_UID_EUI64	= 2,
+	BLK_UID_NAA	= 3,
+};
+
+#define NFL4_UFLG_MASK			0x0000003F
 
 struct block_device_operations {
 	void (*submit_bio)(struct bio *bio);
@@ -1195,6 +1203,9 @@  struct block_device_operations {
 	int (*report_zones)(struct gendisk *, sector_t sector,
 			unsigned int nr_zones, report_zones_cb cb, void *data);
 	char *(*devnode)(struct gendisk *disk, umode_t *mode);
+	/* returns the length of the identifier or a negative errno: */
+	int (*get_unique_id)(struct gendisk *disk, u8 id[16],
+			enum blk_uniqueue_id id_type);
 	struct module *owner;
 	const struct pr_ops *pr_ops;