[stgt] [PATCH 1/4] Add support for block limits VPD (0xb0) to tgtd
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Fri Jan 6 06:33:48 CET 2012
On Thu, 5 Jan 2012 16:53:53 -0800
Andy Grover <agrover at redhat.com> wrote:
> This is needed to support larger phys block sizes in direct-store
> backstores.
>
> Signed-off-by: Andy Grover <agrover at redhat.com>
> ---
> usr/spc.c | 31 +++++++++++++++++++++++++++++++
> usr/tgtd.h | 1 +
> 2 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/usr/spc.c b/usr/spc.c
> index 4824ac2..0490ed9 100644
> --- a/usr/spc.c
> +++ b/usr/spc.c
> @@ -139,6 +139,22 @@ static void update_vpd_83(struct scsi_lu *lu, void *id)
> strncpy((char *)data + 4, id, SCSI_ID_LEN);
> }
>
> +static void update_b0_opt_xfer_gran(struct scsi_lu *lu, int opt_xfer_gran)
> +{
> + struct vpd *vpd_pg = lu->attrs.lu_vpd[PCODE_OFFSET(0xb0)];
> + uint32_t *data = (uint32_t*) vpd_pg->data;
> +
> + data[1] = __cpu_to_be32(opt_xfer_gran & 0xffff);
Can you use put_unaligned_be16() instead?
> +}
> +
> +static void update_b0_opt_xfer_len(struct scsi_lu *lu, int opt_xfer_len)
> +{
> + struct vpd *vpd_pg = lu->attrs.lu_vpd[PCODE_OFFSET(0xb0)];
> + uint32_t *data = (uint32_t*) vpd_pg->data;
> +
> + data[3] = __cpu_to_be32(opt_xfer_len);
Can you use put_unaligned_be32() instead?
> +}
> +
> int spc_inquiry(int host_no, struct scsi_cmd *cmd)
> {
> int len = 0, ret = SAM_STAT_CHECK_CONDITION;
> @@ -1596,6 +1612,7 @@ enum {
> Opt_scsi_id, Opt_scsi_sn,
> Opt_vendor_id, Opt_product_id,
> Opt_product_rev, Opt_sense_format,
> + Opt_optimal_xfer_gran, Opt_optimal_xfer_len,
> Opt_removable, Opt_readonly, Opt_online,
> Opt_mode_page,
> Opt_path,
> @@ -1610,6 +1627,8 @@ static match_table_t tokens = {
> {Opt_product_id, "product_id=%s"},
> {Opt_product_rev, "product_rev=%s"},
> {Opt_sense_format, "sense_format=%s"},
> + {Opt_optimal_xfer_gran, "optimal_xfer_gran=%s"},
> + {Opt_optimal_xfer_len, "optimal_xfer_len=%s"},
> {Opt_removable, "removable=%s"},
> {Opt_readonly, "readonly=%s"},
> {Opt_online, "online=%s"},
> @@ -1679,6 +1698,14 @@ int lu_config(struct scsi_lu *lu, char *params, match_fn_t *fn)
> match_strncpy(buf, &args[0], sizeof(buf));
> attrs->sense_format = atoi(buf);
> break;
> + case Opt_optimal_xfer_gran:
> + match_strncpy(buf, &args[0], sizeof(buf));
> + update_b0_opt_xfer_gran(lu, atoi(buf));
> + break;
> + case Opt_optimal_xfer_len:
> + match_strncpy(buf, &args[0], sizeof(buf));
> + update_b0_opt_xfer_len(lu, atoi(buf));
> + break;
> case Opt_removable:
> match_strncpy(buf, &args[0], sizeof(buf));
> attrs->removable = atoi(buf);
> @@ -1744,6 +1771,10 @@ int spc_lu_init(struct scsi_lu *lu)
> lu_vpd[pg]->vpd_update = update_vpd_83;
> lu_vpd[pg]->vpd_update(lu, lu->attrs.scsi_id);
>
> + /* VPD page 0xb0 */
> + pg = PCODE_OFFSET(0xb0);
> + lu_vpd[pg] = alloc_vpd(BLOCK_LIMITS_VPD_LEN);
> +
> lu->attrs.removable = 0;
> lu->attrs.readonly = 0;
> lu->attrs.sense_format = 0;
> diff --git a/usr/tgtd.h b/usr/tgtd.h
> index dfddca1..c59f309 100644
> --- a/usr/tgtd.h
> +++ b/usr/tgtd.h
> @@ -10,6 +10,7 @@
> #define VENDOR_ID_LEN 8
> #define PRODUCT_ID_LEN 16
> #define PRODUCT_REV_LEN 4
> +#define BLOCK_LIMITS_VPD_LEN 64
>
> #define PCODE_SHIFT 7
> #define PCODE_OFFSET(x) (x & ((1 << PCODE_SHIFT) - 1))
> --
> 1.7.1
>
> --
> 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
--
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