linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
	Chuck Lever <chuck.lever@oracle.com>,
	linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
	target-devel@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: [PATCH 1/7] block: add a ->get_unique_id method
Date: Thu, 21 Oct 2021 08:06:01 +0200	[thread overview]
Message-ID: <20211021060607.264371-2-hch@lst.de> (raw)
In-Reply-To: <20211021060607.264371-1-hch@lst.de>

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(+)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index fd9771a1da096..af61fb3e1502c 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_unique_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_unique_id id_type);
 	struct module *owner;
 	const struct pr_ops *pr_ops;
 
-- 
2.30.2


  reply	other threads:[~2021-10-21  6:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21  6:06 remove QUEUE_FLAG_SCSI_PASSTHROUGH v3 Christoph Hellwig
2021-10-21  6:06 ` Christoph Hellwig [this message]
2021-10-21 13:34   ` [PATCH 1/7] block: add a ->get_unique_id method Hannes Reinecke
2021-10-21  6:06 ` [PATCH 2/7] sd: implement ->get_unique_id Christoph Hellwig
2021-10-21 13:34   ` Hannes Reinecke
2021-10-21  6:06 ` [PATCH 3/7] nfsd/blocklayout: use ->get_unique_id instead of sending SCSI commands Christoph Hellwig
2021-10-21  6:06 ` [PATCH 4/7] bsg-lib: initialize the bsg_job in bsg_transport_sg_io_fn Christoph Hellwig
2021-10-21  6:06 ` [PATCH 5/7] scsi: add a scsi_alloc_request helper Christoph Hellwig
2021-10-21  6:06 ` [PATCH 6/7] block: remove the initialize_rq_fn blk_mq_ops method Christoph Hellwig
2021-10-21  6:06 ` [PATCH 7/7] block: remove QUEUE_FLAG_SCSI_PASSTHROUGH Christoph Hellwig
2021-10-22 14:34 ` remove QUEUE_FLAG_SCSI_PASSTHROUGH v3 Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2021-10-19  7:54 remove QUEUE_FLAG_SCSI_PASSTHROUGH v2 Christoph Hellwig
2021-10-19  7:54 ` [PATCH 1/7] block: add a ->get_unique_id method Christoph Hellwig
2021-10-20  3:47   ` Martin K. Petersen
2021-10-12 12:04 remove QUEUE_FLAG_SCSI_PASSTHROUGH Christoph Hellwig
2021-10-12 12:04 ` [PATCH 1/7] block: add a ->get_unique_id method Christoph Hellwig
2021-10-12 17:03   ` Bart Van Assche
2021-10-14  7:31   ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211021060607.264371-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).