[stgt] RFC [PATCH] Implement PERSISTENT RESERVE IN/OUT
Arne Redlich
agr at powerkom-dd.de
Wed Aug 20 22:08:02 CEST 2008
[dropping stgt-devel at berlios]
Am Mittwoch, den 20.08.2008, 15:01 +1000 schrieb Mark Harvey:
> Apologies for sending as an attachment... gmail and all.
>
> This is an initial attempt to implement PERSISTENT RESERVE IN and
> PERSISTENT RESERVE OUT.
>
> Currently only READ KEY service action will actually return anything.
> It returns a hard-coded 'ABC1234'.
>
> This post is a request for comment before I get too far into coding effort.
>
> # lsscsi -g
> [3:0:0:0] disk USB-HS HTS726060M9AT00 0.01 /dev/sda /dev/sg0
> [7:0:0:0] storage IET Controller 0001 - /dev/sg1
> [7:0:0:1] disk QUANTUM HD100 0010 /dev/sdb /dev/sg2
> [7:0:0:2] tape QUANTUM DLT6000 0010 /dev/st0 /dev/sg3
> [7:0:0:3] tape QUANTUM DLT6000 0010 /dev/st1 /dev/sg4
> [7:0:0:4] tape QUANTUM DLT6000 0010 /dev/st2 /dev/sg5
> [7:0:0:5] mediumx STK L700 0010 - /dev/sg6
>
> # sg_persist -i /dev/sg3
> >> No service action given; assume Persistent Reservations In command
> >> with Read Keys service action
> QUANTUM DLT6000 0010
> Peripheral device type: tape
> PR generation=0x0, 4 registered reservation keys follow:
> 0x4142433132333400
> 0x0
> 0x0
> 0x0
>
>
> I'll include in-line for viewing pleasure :)
>
> [PATCH 1/2]
> From 11ad9ee209708f51bd2884598d309b1e7079cdce Mon Sep 17 00:00:00 2001
> From: Mark Harvey <markh794 at gmail.com>
> Date: Wed, 20 Aug 2008 14:42:27 +1000
> Subject: RFC - Implement PERSISTENT RESERVE IN/OUT
>
> Implement service action 'READ KEY' which returns
> a hard-coded string 'ABC1234'
>
> Signed-off-by: Mark Harvey <markh794 at gmail.com>
> ---
> usr/scsi.h | 5 ++
> usr/spc.c | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> usr/spc.h | 2 +
> usr/tgtd.h | 13 ++++
> 4 files changed, 251 insertions(+), 0 deletions(-)
>
> diff --git a/usr/scsi.h b/usr/scsi.h
> index 84fadff..a9481a1 100644
> --- a/usr/scsi.h
> +++ b/usr/scsi.h
> @@ -208,6 +208,11 @@
> #define ASC_POSITION_PAST_BOM 0x3b0c
> #define ASC_MEDIUM_REMOVAL_PREVENTED 0x5302
> #define ASC_BAD_MICROCODE_DETECTED 0x8283
> +#define ASC_INSUFFICENT_RESERVE_RESOURCE 0x5502
> +#define ASC_INSUFFICENT_RESOURCE 0x5503
> +#define ASC_INSUFFICENT_REGISTRAT_RESOURCE 0x5504
> +#define ASC_INSUFFICENT_AC_RESOURCE 0x5505
> +#define ASC_AUX_MEMORY_OUT_OF_SPACE 0x5506
>
> /* Key 6: Unit Attention */
> #define ASC_NOT_READY_TO_TRANSITION 0x2800
> diff --git a/usr/spc.c b/usr/spc.c
> index bd2c975..cc088bf 100644
> --- a/usr/spc.c
> +++ b/usr/spc.c
> @@ -880,6 +880,237 @@ void dump_cdb(struct scsi_cmd *cmd)
> }
> }
>
> +/**
> + * SCSI Persistent Reservation
> + *
> + * Reference: spc4r16 Ch 5.7
Though I'm not sure it will differ at all in this area, but SPC-3 should
be used as reference when implementing it - cf. spc_inquiry().
[snip]
> +struct scsi_pr {
> + /* Persistent Reservation Generation */
> + uint32_t PRgeneration;
> + uint8_t pr_key[PR_RESERVATION_SZ][PR_KEY_SZ];
> +};
> +
Too bad the most interesting part is missing - an efficient way to
lookup the registered keys. I could imagine using a hashtable, but then
again finding a good hash function is not easy - (u64)key % tablesize
possibly? So:
struct scsi_pr_key {
struct list_head entry;
uint8_t key[8];
struct it_nexus *itn;
};
> struct scsi_lu {
> int fd;
> uint64_t addr; /* persistent mapped address */
> @@ -150,6 +161,8 @@ struct scsi_lu {
> uint8_t mode_block_descriptor[BLOCK_DESCRIPTOR_LEN];
> struct mode_pg *mode_pgs[0x3f];
>
> + struct scsi_pr pr;
> +
struct list_head pr_keys[PR_HT_SIZE];
> struct lu_phy_attr attrs;
>
> /* A pointer for each modules private use.
Cheers,
Arne
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list