From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D66F6C41514 for ; Wed, 7 Aug 2019 11:43:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B806321BF6 for ; Wed, 7 Aug 2019 11:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729745AbfHGLnA (ORCPT ); Wed, 7 Aug 2019 07:43:00 -0400 Received: from smtp.infotech.no ([82.134.31.41]:45261 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729625AbfHGLm6 (ORCPT ); Wed, 7 Aug 2019 07:42:58 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 52939204272; Wed, 7 Aug 2019 13:42:54 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t+GbFHINGWL1; Wed, 7 Aug 2019 13:42:54 +0200 (CEST) Received: from xtwo70.infotech.no (unknown [82.134.31.183]) by smtp.infotech.no (Postfix) with ESMTPA id E6246204255; Wed, 7 Aug 2019 13:42:53 +0200 (CEST) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, bvanassche@acm.org Subject: [PATCH v3 15/20] sg: add 8 byte SCSI LUN to sg_scsi_id Date: Wed, 7 Aug 2019 13:42:47 +0200 Message-Id: <20190807114252.2565-16-dgilbert@interlog.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190807114252.2565-1-dgilbert@interlog.com> References: <20190807114252.2565-1-dgilbert@interlog.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The existing ioctl(SG_GET_SCSI_ID) fills a object of type struct sg_scsi_id whose last field is int unused[2]. Add an anonymous union with u8 scsi_lun[8] sharing those last 8 bytes. This patch will place the current device's full LUN in the scsi_lun array using T10's preferred LUN format (i.e. an array of 8 bytes) when ioctl(SG_GET_SCSI_ID) is called. Note that structure already contains a 'lun' field but that is a 32 bit integer. Users of this upgrade should choose the scsi_lun array field henceforth but existing code can remain as it is and will get the same 'lun' value with the version 3 or version 4 driver. Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 5 +++-- include/uapi/scsi/sg.h | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 694a2f50063b..fb7eeafff801 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1684,6 +1684,7 @@ static int sg_ctl_scsi_id(struct scsi_device *sdev, struct sg_fd *sfp, void __user *p) { struct sg_scsi_id __user *sg_idp = p; + struct scsi_lun lun8b; SG_LOG(3, sfp, "%s: SG_GET_SCSI_ID\n", __func__); if (!access_ok(p, sizeof(struct sg_scsi_id))) @@ -1701,8 +1702,8 @@ sg_ctl_scsi_id(struct scsi_device *sdev, struct sg_fd *sfp, void __user *p) &sg_idp->h_cmd_per_lun); __put_user((short)sdev->queue_depth, &sg_idp->d_queue_depth); - __put_user(0, &sg_idp->unused[0]); - __put_user(0, &sg_idp->unused[1]); + int_to_scsilun(sdev->lun, &lun8b); + __copy_to_user(sg_idp->scsi_lun, lun8b.scsi_lun, 8); return 0; } diff --git a/include/uapi/scsi/sg.h b/include/uapi/scsi/sg.h index 47eefe731a84..0d6fbf976e5c 100644 --- a/include/uapi/scsi/sg.h +++ b/include/uapi/scsi/sg.h @@ -135,7 +135,10 @@ typedef struct sg_scsi_id { int scsi_type; /* TYPE_... defined in scsi/scsi.h */ short h_cmd_per_lun;/* host (adapter) maximum commands per lun */ short d_queue_depth;/* device (or adapter) maximum queue length */ - int unused[2]; + union { + int unused[2]; /* as per version 3 driver */ + __u8 scsi_lun[8]; /* full 8 byte SCSI LUN [in v4 driver] */ + }; } sg_scsi_id_t; /* For backward compatibility v4 driver yields at most SG_MAX_QUEUE of these */ -- 2.22.0