Add XEN pvSCSI support
Subsystems (3)
[email protected]
maintainerv2 cover Add XEN pvSCSI support
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V2 1/4] Add XEN pvSCSI protocol description [PATCH V2 2/4] Introduce xen-scsifront module [PATCH V2 3/4] Introduce XEN scsiback module [PATCH V2 4/4] add xen pvscsi maintainer
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability
[email protected]
maintainerPATCH v2 1/4 Add XEN pvSCSI protocol description
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitions
--- include/xen/interface/io/vscsiif.h | 102 +++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 include/xen/interface/io/vscsiif.h
include/xen/interface/io/vscsiif.h new file +102 -0
@@ -0,0 +1,102 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* commands between backend and frontend */ +#define VSCSIIF_ACT_SCSI_CDB 1/* SCSI CDB command */ +#define VSCSIIF_ACT_SCSI_ABORT 2/* SCSI Device(Lun) Abort*/ +#define VSCSIIF_ACT_SCSI_RESET 3/* SCSI Device(Lun) Reset*/ + +/* +* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18 +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure +* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +}; + +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len; + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ]; +uint16_t timeout_per_command;/* The command is issued by twice +the value in Backend. */ +uint16_t channel, id, lun; +uint16_t padding; +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements +usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ]; +}; + +struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/
Signature · 1 line
1.8.4.5
Re: [PATCH V2 1/4] Add XEN pvSCSI protocol description
Quoted 11 lines · On 25/07/14 12:37, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitions
This is a protocol extension and needs to be reviewed separately, and the Xen header needs updating as well.
The documentation for this protocol is rather lacking. In particular it is missing the connection states.
David
Re: [Xen-devel] [PATCH V2 1/4] Add XEN pvSCSI protocol description
In reply to [email protected]Quoted 11 lines · On 25/07/14 12:37, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitions
This is a protocol extension and needs to be reviewed separately, and the Xen header needs updating as well.
The documentation for this protocol is rather lacking. In particular it is missing the connection states.
David
Juergen Gross
maintainerRe: [PATCH V2 1/4] Add XEN pvSCSI protocol description
Quoted 13 lines · David Vrabel
Quoted 11 lines · On 25/07/14 12:37, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitions
Quoted 2 lines
This is a protocol extension and needs to be reviewed separately, and the Xen header needs updating as well.
Sure. The review can start right now. Updating the Xen header will be done as soon as the drivers are accepted in Linux.
Quoted 2 lines
The documentation for this protocol is rather lacking. In particular it is missing the connection states.
Regarding documentation: I'll add some.
Regarding the connection states: I'd rather move the description in blkif.h to xenbus.h than duplicating it in vscsiif.h. What do you think?
Juergen
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V2 1/4] Add XEN pvSCSI protocol description
In reply to David VrabelQuoted 13 lines · David Vrabel
Quoted 11 lines · On 25/07/14 12:37, [email protected] wrote:
From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitions
Quoted 2 lines
This is a protocol extension and needs to be reviewed separately, and the Xen header needs updating as well.
Sure. The review can start right now. Updating the Xen header will be done as soon as the drivers are accepted in Linux.
Quoted 2 lines
The documentation for this protocol is rather lacking. In particular it is missing the connection states.
Regarding documentation: I'll add some.
Regarding the connection states: I'd rather move the description in blkif.h to xenbus.h than duplicating it in vscsiif.h. What do you think?
Juergen
[email protected]
maintainerPATCH v2 1/4 Add XEN pvSCSI protocol description
In reply to [email protected]From: Juergen Gross <[email protected]>
Add the definition of pvSCSI protocol used between the pvSCSI frontend in a XEN domU and the pvSCSI backend in a XEN driver domain (usually Dom0).
This header was originally provided by Fujitsu for XEN based on Linux 2.6.18. Changes are:
- added comment
- adapt to Linux style guide
- add support for larger SG-lists by putting them in an own granted page
- remove stale definitions
--- include/xen/interface/io/vscsiif.h | 102 +++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 include/xen/interface/io/vscsiif.h
include/xen/interface/io/vscsiif.h new file +102 -0
@@ -0,0 +1,102 @@ +/****************************************************************************** +* vscsiif.h +* +* Based on the blkif.h code. +* +* This interface is to be regarded as a stable API between XEN domains +* running potentially different Linux kernel versions. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright(c) FUJITSU Limited 2008. +*/ + +#ifndef __XEN__PUBLIC_IO_SCSI_H__ +#define __XEN__PUBLIC_IO_SCSI_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* commands between backend and frontend */ +#define VSCSIIF_ACT_SCSI_CDB 1/* SCSI CDB command */ +#define VSCSIIF_ACT_SCSI_ABORT 2/* SCSI Device(Lun) Abort*/ +#define VSCSIIF_ACT_SCSI_RESET 3/* SCSI Device(Lun) Reset*/ + +/* +* Maximum scatter/gather segments per request. +* +* Considering balance between allocating at least 16 "vscsiif_request" +* structures on one page (4096 bytes) and the number of scatter/gather +* elements needed, we decided to use 26 as a magic number. +*/ +#define VSCSIIF_SG_TABLESIZE 26 + +/* +* based on Linux kernel 2.6.18 +* Changing these values requires support of multiple protocols via the rings +* as "old clients" will blindly use these values and the resulting structure +* sizes. +*/ +#define VSCSIIF_MAX_COMMAND_SIZE 16 +#define VSCSIIF_SENSE_BUFFERSIZE 96 + +struct scsiif_request_segment { +grant_ref_t gref; +uint16_t offset; +uint16_t length; +}; + +/* Size of one request is 252 bytes */ +struct vscsiif_request { +uint16_t rqid;/* private guest value, echoed in resp */ +uint8_t act;/* command between backend and frontend */ +uint8_t cmd_len; + +uint8_t cmnd[VSCSIIF_MAX_COMMAND_SIZE ]; +uint16_t timeout_per_command;/* The command is issued by twice +the value in Backend. */ +uint16_t channel, id, lun; +uint16_t padding; +uint8_t sc_data_direction;/* for DMA_TO_DEVICE(1) +DMA_FROM_DEVICE(2) +DMA_NONE(3) requests */ +uint8_t nr_segments;/* Number of pieces of scatter-gather */ +#define VSCSIIF_SG_GRANT 0x80/* flag: SG elements via grant page */ +/* nr_segments counts grant pages with +SG elements +usable if "feature-sg-grant" set */ + +struct scsiif_request_segment seg[VSCSIIF_SG_TABLESIZE ]; +uint32_t reserved[3 ]; +}; + +struct vscsiif_response { +uint16_t rqid;/* identifies request */ +uint8_t padding; +uint8_t sense_len; +uint8_t sense_buffer[VSCSIIF_SENSE_BUFFERSIZE ]; +int32_t rslt; +uint32_t residual_len;/* request bufflen - +return the value from physical device */ +uint32_t reserved[36 ]; +}; + +DEFINE_RING_TYPES(vscsiif, struct vscsiif_request, struct vscsiif_response); + +#endif /*__XEN__PUBLIC_IO_SCSI_H__*/
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v2 2/4 Introduce xen-scsifront module
In reply to [email protected]From: Juergen Gross <[email protected]>
Introduces the XEN pvSCSI frontend. With pvSCSI it is possible for a XEN domU to issue SCSI commands to a SCSI LUN assigned to that domU. The SCSI commands are passed to the pvSCSI backend in a driver domain (usually Dom0) which is owner of the physical device. This allows e.g. to use SCSI tape drives in a XEN domU.
The code is taken from the pvSCSI implementation in XEN done by Fujitsu based on Linux kernel 2.6.18.
Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- move module to appropriate location in kernel tree
- adapt to Linux style guide
- some minor code simplifications
- replace constants with defines
- remove not used defines
- add support for larger SG lists by putting them in a granted page
--- drivers/scsi/Kconfig | 9 + drivers/scsi/Makefile | 1 + drivers/scsi/xen-scsifront.c | 1006 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1016 insertions(+) create mode 100644 drivers/scsi/xen-scsifront.c
drivers/scsi/Kconfig +9 -0
@@ -611,6 +611,15 @@ config VMWARE_PVSCSI To compile this driver as a module, choose M here: the module will be called vmw_pvscsi. +config XEN_SCSI_FRONTEND + tristate "XEN SCSI frontend driver" + depends on SCSI && XEN + help + The XEN SCSI frontend driver allows the kernel to access SCSI Devices + within another guest OS (usually Dom0). + Only needed if the kernel is running in a XEN guest and generic + SCSI access to a device is needed. + config HYPERV_STORAGE tristate "Microsoft Hyper-V virtual storage driver" depends on SCSI && HYPERV
drivers/scsi/Makefile +1 -0
@@ -144,6 +144,7 @@ obj-$(CONFIG_SCSI_ESAS2R) += esas2r/ obj-$(CONFIG_SCSI_PMCRAID) += pmcraid.o obj-$(CONFIG_SCSI_VIRTIO) += virtio_scsi.o obj-$(CONFIG_VMWARE_PVSCSI) += vmw_pvscsi.o +obj-$(CONFIG_XEN_SCSI_FRONTEND) += xen-scsifront.o obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o obj-$(CONFIG_ARM) += arm/
drivers/scsi/xen-scsifront.c new file +1006 -0
1,006 lines not on this page · raw message
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v2 2/4 Introduce xen-scsifront module
In reply to [email protected]From: Juergen Gross <[email protected]>
Introduces the XEN pvSCSI frontend. With pvSCSI it is possible for a XEN domU to issue SCSI commands to a SCSI LUN assigned to that domU. The SCSI commands are passed to the pvSCSI backend in a driver domain (usually Dom0) which is owner of the physical device. This allows e.g. to use SCSI tape drives in a XEN domU.
The code is taken from the pvSCSI implementation in XEN done by Fujitsu based on Linux kernel 2.6.18.
Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- move module to appropriate location in kernel tree
- adapt to Linux style guide
- some minor code simplifications
- replace constants with defines
- remove not used defines
- add support for larger SG lists by putting them in a granted page
--- drivers/scsi/Kconfig | 9 + drivers/scsi/Makefile | 1 + drivers/scsi/xen-scsifront.c | 1006 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1016 insertions(+) create mode 100644 drivers/scsi/xen-scsifront.c
drivers/scsi/Kconfig +9 -0
@@ -611,6 +611,15 @@ config VMWARE_PVSCSI To compile this driver as a module, choose M here: the module will be called vmw_pvscsi. +config XEN_SCSI_FRONTEND + tristate "XEN SCSI frontend driver" + depends on SCSI && XEN + help + The XEN SCSI frontend driver allows the kernel to access SCSI Devices + within another guest OS (usually Dom0). + Only needed if the kernel is running in a XEN guest and generic + SCSI access to a device is needed. + config HYPERV_STORAGE tristate "Microsoft Hyper-V virtual storage driver" depends on SCSI && HYPERV
drivers/scsi/Makefile +1 -0
@@ -144,6 +144,7 @@ obj-$(CONFIG_SCSI_ESAS2R) += esas2r/ obj-$(CONFIG_SCSI_PMCRAID) += pmcraid.o obj-$(CONFIG_SCSI_VIRTIO) += virtio_scsi.o obj-$(CONFIG_VMWARE_PVSCSI) += vmw_pvscsi.o +obj-$(CONFIG_XEN_SCSI_FRONTEND) += xen-scsifront.o obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o obj-$(CONFIG_ARM) += arm/
drivers/scsi/xen-scsifront.c new file +1006 -0
1,006 lines not on this page · raw message
Signature · 1 line
1.8.4.5
Re: [PATCH V2 2/4] Introduce xen-scsifront module
Quoted 3 lines
+ * Patched to support >2TB drives
+ * 2010, Samuel Kvasnica, IMS Nanofabrication AG
+ */
This doesn't really belong into the top of the file comment and should be moved to the patch description.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#include <linux/version.h>
not needed.
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+static int get_id_from_freelist (struct vscsifrnt_info *info) +{ +unsigned long flags; +uint32_t free; + +spin_lock_irqsave (&info->shadow_lock, flags);
drivers/scsi/xen-scsifront.c line 149
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ + free = info->shadow_free; +BUG_ON (free >=VSCSIIF_MAX_REQS ); + info->shadow_free = info->shadow[free].next_free; + info->shadow[free].next_free =VSCSIIF_MAX_REQS ; + info->shadow[free].wait_reset =0 ; + +spin_unlock_irqrestore (&info->shadow_lock, flags); + +return free;
Is the shadow array exposed to the hypervisor? If not it might be a better idea to just allocate the driver private data with the command by setting the cmd_size field in the host template. Take a look at the virtio_scsi driver in recent kernels for an example.
drivers/scsi/xen-scsifront.c line 203
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+static irqreturn_t scsifront_intr (int irq,void *dev_id) +{ +scsifront_notify_work ((struct vscsifrnt_info *)dev_id); +return IRQ_HANDLED ;
Seems like you should simply use threaded interrupt handlers. If that doesn't work for you at least this should use a workqueue instead of manually reimplementing it using a kthread.
drivers/scsi/xen-scsifront.c line 496
Quoted 7 lines
drivers/scsi/xen-scsifront.c new file +7
-0+/* debug printk to identify more missing scsi commands +shost_printk(KERN_INFO "scsicmd: ", sc->device->host, +"len=%u %#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x\n", +sc->cmd_len, sc->cmnd[0], sc->cmnd[1], +sc->cmnd[2], sc->cmnd[3], sc->cmnd[4], sc->cmnd[5], +sc->cmnd[6], sc->cmnd[7], sc->cmnd[8], sc->cmnd[9]); +*/
We already have pretty good ways to debug this in the midlayer, I don't think this is needed.
drivers/scsi/xen-scsifront.c line 497
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+spin_lock_irqsave (shost->host_lock, flags);
What's actually protected by the host lock in this driver? It has ample of driver-local locking, so avoiding to touch the host lock would be a clear win.
drivers/scsi/xen-scsifront.c line 498
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+scsi_cmd_get_serial (shost, sc);
What do you need the serial number for? Generally only legacy drivers use it.
drivers/scsi/xen-scsifront.c line 586
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+static int scsifront_eh_abort_handler (struct scsi_cmnd *sc) +{ +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_ABORT ); +}
The amount of waiting that your command abort handler does inside scsifront_action_handler looks wrong to me. Can you explain the theory of operation for error handling in this driver? How much of error recovery is supposed to be handled by the hypervisor, and much is supposed to be handle in the intiator side driver?
drivers/scsi/xen-scsifront.c line 612
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+static void scsifront_free (struct vscsifrnt_info *info) +{ +struct Scsi_Host *host = info->host; + +if (host->shost_state !=SHOST_DEL ) +scsi_remove_host (info->host);
A driver really shouldn't look at shost_state like this. Is there some SCM history explaining where this comes from?
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +11
-0+switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) { + sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +dev_err (&dev->dev, +"Device already in use.\n" ); +scsi_device_put (sdev); + xenbus_printf(XBT_NIL, dev->nodename, + state_str, "%d",
drivers/scsi/xen-scsifront.c line 890
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ XenbusStateClosed); + }else { +scsi_add_device (info->host, chn, tgt, + lun); +xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateConnected); + } + } +break ;
scsi_add_device handles an already existing device just fine, and unlike this construct isn't racy.
Re: [PATCH V2 2/4] Introduce xen-scsifront module
In reply to [email protected]Quoted 3 lines
+ * Patched to support >2TB drives
+ * 2010, Samuel Kvasnica, IMS Nanofabrication AG
+ */
This doesn't really belong into the top of the file comment and should be moved to the patch description.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#include <linux/version.h>
not needed.
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+static int get_id_from_freelist (struct vscsifrnt_info *info) +{ +unsigned long flags; +uint32_t free; + +spin_lock_irqsave (&info->shadow_lock, flags);
drivers/scsi/xen-scsifront.c line 149
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ + free = info->shadow_free; +BUG_ON (free >=VSCSIIF_MAX_REQS ); + info->shadow_free = info->shadow[free].next_free; + info->shadow[free].next_free =VSCSIIF_MAX_REQS ; + info->shadow[free].wait_reset =0 ; + +spin_unlock_irqrestore (&info->shadow_lock, flags); + +return free;
Is the shadow array exposed to the hypervisor? If not it might be a better idea to just allocate the driver private data with the command by setting the cmd_size field in the host template. Take a look at the virtio_scsi driver in recent kernels for an example.
drivers/scsi/xen-scsifront.c line 203
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+static irqreturn_t scsifront_intr (int irq,void *dev_id) +{ +scsifront_notify_work ((struct vscsifrnt_info *)dev_id); +return IRQ_HANDLED ;
Seems like you should simply use threaded interrupt handlers. If that doesn't work for you at least this should use a workqueue instead of manually reimplementing it using a kthread.
drivers/scsi/xen-scsifront.c line 496
Quoted 7 lines
drivers/scsi/xen-scsifront.c new file +7
-0+/* debug printk to identify more missing scsi commands +shost_printk(KERN_INFO "scsicmd: ", sc->device->host, +"len=%u %#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x\n", +sc->cmd_len, sc->cmnd[0], sc->cmnd[1], +sc->cmnd[2], sc->cmnd[3], sc->cmnd[4], sc->cmnd[5], +sc->cmnd[6], sc->cmnd[7], sc->cmnd[8], sc->cmnd[9]); +*/
We already have pretty good ways to debug this in the midlayer, I don't think this is needed.
drivers/scsi/xen-scsifront.c line 497
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+spin_lock_irqsave (shost->host_lock, flags);
What's actually protected by the host lock in this driver? It has ample of driver-local locking, so avoiding to touch the host lock would be a clear win.
drivers/scsi/xen-scsifront.c line 498
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+scsi_cmd_get_serial (shost, sc);
What do you need the serial number for? Generally only legacy drivers use it.
drivers/scsi/xen-scsifront.c line 586
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+static int scsifront_eh_abort_handler (struct scsi_cmnd *sc) +{ +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_ABORT ); +}
The amount of waiting that your command abort handler does inside scsifront_action_handler looks wrong to me. Can you explain the theory of operation for error handling in this driver? How much of error recovery is supposed to be handled by the hypervisor, and much is supposed to be handle in the intiator side driver?
drivers/scsi/xen-scsifront.c line 612
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+static void scsifront_free (struct vscsifrnt_info *info) +{ +struct Scsi_Host *host = info->host; + +if (host->shost_state !=SHOST_DEL ) +scsi_remove_host (info->host);
A driver really shouldn't look at shost_state like this. Is there some SCM history explaining where this comes from?
Quoted 11 lines
drivers/scsi/xen-scsifront.c new file +11
-0+switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) { + sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +dev_err (&dev->dev, +"Device already in use.\n" ); +scsi_device_put (sdev); + xenbus_printf(XBT_NIL, dev->nodename, + state_str, "%d",
drivers/scsi/xen-scsifront.c line 890
Quoted 10 lines
drivers/scsi/xen-scsifront.c new file +10
-0+ XenbusStateClosed); + }else { +scsi_add_device (info->host, chn, tgt, + lun); +xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateConnected); + } + } +break ;
scsi_add_device handles an already existing device just fine, and unlike this construct isn't racy.
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V2 2/4] Introduce xen-scsifront module
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines
+ * Patched to support >2TB drives
+ * 2010, Samuel Kvasnica, IMS Nanofabrication AG
+ */This doesn't really belong into the top of the file comment and should be moved to the patch description.
Okay.
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#include <linux/version.h>not needed.
Okay.
Quoted 13 lines
Quoted 13 lines
drivers/scsi/xen-scsifront.c new file +13
-0+static int get_id_from_freelist (struct vscsifrnt_info *info) +{ +unsigned long flags; +uint32_t free; + +spin_lock_irqsave (&info->shadow_lock, flags); + + free = info->shadow_free; +BUG_ON (free >=VSCSIIF_MAX_REQS ); + info->shadow_free = info->shadow[free].next_free; + info->shadow[free].next_free =VSCSIIF_MAX_REQS ; + info->shadow[free].wait_reset =0 ; +
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 149
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +3
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); + +return free;Is the shadow array exposed to the hypervisor? If not it might be a better idea to just allocate the driver private data with the command by setting the
cmd_sizefield in the host template. Take a look at thevirtio_scsidriver in recent kernels for an example.
Ah, okay. I'll still need an array for managing the request ids, but this will be much smaller...
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 203
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+static irqreturn_t scsifront_intr (int irq,void *dev_id) +{ +scsifront_notify_work ((struct vscsifrnt_info *)dev_id); +return IRQ_HANDLED ;Seems like you should simply use threaded interrupt handlers. If that doesn't work for you at least this should use a workqueue instead of manually reimplementing it using a kthread.
A threaded interrupt handler seems to be a good idea. I'll check if it is working.
Quoted 10 lines
drivers/scsi/xen-scsifront.c line 496
Quoted 7 lines
drivers/scsi/xen-scsifront.c new file +7
-0+/* debug printk to identify more missing scsi commands +shost_printk(KERN_INFO "scsicmd: ", sc->device->host, +"len=%u %#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x\n", +sc->cmd_len, sc->cmnd[0], sc->cmnd[1], +sc->cmnd[2], sc->cmnd[3], sc->cmnd[4], sc->cmnd[5], +sc->cmnd[6], sc->cmnd[7], sc->cmnd[8], sc->cmnd[9]); +*/ We already have pretty good ways to debug this in the midlayer, I don't think this is needed.
Okay, I'll remove it.
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 497
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+spin_lock_irqsave (shost->host_lock, flags);What's actually protected by the host lock in this driver? It has ample of driver-local locking, so avoiding to touch the host lock would be a clear win.
The host_lock protects the ring buffers used to communicate with Dom0. I think this is the correct lock for this operation, as there is exactly one such ring buffer pair for each host structure allocated in scsifront_probe().
Quoted 4 lines
drivers/scsi/xen-scsifront.c line 498
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+scsi_cmd_get_serial (shost, sc);What do you need the serial number for? Generally only legacy drivers use it.
Historical reasons :-)
I'll remove it.
Quoted 10 lines
drivers/scsi/xen-scsifront.c line 586
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+static int scsifront_eh_abort_handler (struct scsi_cmnd *sc) +{ +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_ABORT ); +}The amount of waiting that your command abort handler does inside
scsifront_action_handlerlooks wrong to me. Can you explain the theory of operation for error handling in this driver? How much of error recovery is supposed to be handled by the hypervisor, and much is supposed to be handle in the intiator side driver?
The initiator side just forwards the abort/reset request to Dom0 and waits for an answer (okay or error).
Quoted 9 lines
drivers/scsi/xen-scsifront.c line 612
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+static void scsifront_free (struct vscsifrnt_info *info) +{ +struct Scsi_Host *host = info->host; + +if (host->shost_state !=SHOST_DEL ) +scsi_remove_host (info->host);A driver really shouldn't look at
shost_statelike this. Is there some SCM history explaining where this comes from?
I'll investigate it. It was added soon after the first version was available, but I haven't found a reason yet.
Quoted 16 lines
Quoted 16 lines
drivers/scsi/xen-scsifront.c new file +16
-0+switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) { + sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +dev_err (&dev->dev, +"Device already in use.\n" ); +scsi_device_put (sdev); +xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateClosed); + }else { +scsi_add_device (info->host, chn, tgt, + lun); + xenbus_printf(XBT_NIL, dev->nodename,
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 890
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +5
-0+ state_str,"%d" , + XenbusStateConnected); + } + } +break ;
scsi_add_devicehandles an already existing device just fine, and unlike this construct isn't racy.
Okay. I'll change it.
Juergen
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V2 2/4] Introduce xen-scsifront module
Quoted 24 lines · Juergen Gross
Quoted 22 lines · Christoph Hellwig
Quoted 21 lines
drivers/scsi/xen-scsifront.c new file +21
-0+switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) { + sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +dev_err (&dev->dev, +"Device already in use.\n" ); +scsi_device_put (sdev); +xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateClosed); + }else { +scsi_add_device (info->host, chn, tgt, + lun); +xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateConnected); + } + } +break ;
Quoted 4 lines
Quoted 2 lines
scsi_add_devicehandles an already existing device just fine, and unlike this construct isn't racy.Okay. I'll change it.
Hmm, I looked into scsi_add_device(). It seems as if the caller can't distinguish between a new created and an already existing device. Am I missing something?
The race is not existing: scsi_add_device() (and scsi_remove_device() as well) for this scsi_host is called in scsifront_do_lun_hotplug() only, and this function is always called in the same thread (xenbus watch). A comment seems to be a good idea.
Juergen
Re: [Xen-devel] [PATCH V2 2/4] Introduce xen-scsifront module
Quoted 3 lines · Juergen Gross
Hmm, I looked into
scsi_add_device(). It seems as if the caller can't distinguish between a new created and an already existing device. Am I missing something?
That's right. If you need that I still think it's better to add a variant of scsi_add_device helping you with that.
Quoted 4 lines
The race is not existing:
scsi_add_device()(andscsi_remove_device()as well) for thisscsi_hostis called inscsifront_do_lun_hotplug()only, and this function is always called in the same thread (xenbus watch). A comment seems to be a good idea.
Do you disable scanning through procfs and sysfs as well?
Juergen Gross
maintainerRe: [Xen-devel] [PATCH V2 2/4] Introduce xen-scsifront module
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Juergen Gross
Hmm, I looked into
scsi_add_device(). It seems as if the caller can't distinguish between a new created and an already existing device. Am I missing something?That's right. If you need that I still think it's better to add a variant of
scsi_add_devicehelping you with that.
I'm open to that solution.
Do you have preferences how to do it (IOW: can you give me a hint)?
Quoted 6 lines
Quoted 4 lines
The race is not existing:
scsi_add_device()(andscsi_remove_device()as well) for thisscsi_hostis called inscsifront_do_lun_hotplug()only, and this function is always called in the same thread (xenbus watch). A comment seems to be a good idea.Do you disable scanning through procfs and sysfs as well?
No, I don't.
OTOH I don't think I see the problem. What could go wrong? Either scsi_device_lookup() does find an existing device, then I refuse to add it again. If I don't find it, it will be added. I can't see how any harm would be done in either case when the device is added/removed between the check and the action. What am I missing?
Juergen
Re: [Xen-devel] [PATCH V2 2/4] Introduce xen-scsifront module
Quoted 6 lines · Juergen Gross
Quoted 2 lines
That's right. If you need that I still think it's better to add a variant of
scsi_add_devicehelping you with that.I'm open to that solution.
Do you have preferences how to do it (IOW: can you give me a hint)?
I thought about it a bit more and came to the conclusion that we shouldn't bother. Why do you care if the scsi_add_device actually added the device? Any per-device setup should be done in ->slave_configure anyway.
Re: [PATCH V2 2/4] Introduce xen-scsifront module
In reply to Juergen GrossQuoted 6 lines · Juergen Gross
Quoted 2 lines
That's right. If you need that I still think it's better to add a variant of
scsi_add_devicehelping you with that.I'm open to that solution.
Do you have preferences how to do it (IOW: can you give me a hint)?
I thought about it a bit more and came to the conclusion that we shouldn't bother. Why do you care if the scsi_add_device actually added the device? Any per-device setup should be done in ->slave_configure anyway.
Juergen Gross
maintainerRe: [PATCH V2 2/4] Introduce xen-scsifront module
In reply to Christoph HellwigQuoted 7 lines · Christoph Hellwig
Quoted 3 lines · Juergen Gross
Hmm, I looked into
scsi_add_device(). It seems as if the caller can't distinguish between a new created and an already existing device. Am I missing something?That's right. If you need that I still think it's better to add a variant of
scsi_add_devicehelping you with that.
I'm open to that solution.
Do you have preferences how to do it (IOW: can you give me a hint)?
Quoted 6 lines
Quoted 4 lines
The race is not existing:
scsi_add_device()(andscsi_remove_device()as well) for thisscsi_hostis called inscsifront_do_lun_hotplug()only, and this function is always called in the same thread (xenbus watch). A comment seems to be a good idea.Do you disable scanning through procfs and sysfs as well?
No, I don't.
OTOH I don't think I see the problem. What could go wrong? Either scsi_device_lookup() does find an existing device, then I refuse to add it again. If I don't find it, it will be added. I can't see how any harm would be done in either case when the device is added/removed between the check and the action. What am I missing?
Juergen
Re: [PATCH V2 2/4] Introduce xen-scsifront module
In reply to Juergen GrossQuoted 3 lines · Juergen Gross
Hmm, I looked into
scsi_add_device(). It seems as if the caller can't distinguish between a new created and an already existing device. Am I missing something?
That's right. If you need that I still think it's better to add a variant of scsi_add_device helping you with that.
Quoted 4 lines
The race is not existing:
scsi_add_device()(andscsi_remove_device()as well) for thisscsi_hostis called inscsifront_do_lun_hotplug()only, and this function is always called in the same thread (xenbus watch). A comment seems to be a good idea.
Do you disable scanning through procfs and sysfs as well?
Juergen Gross
maintainerRe: [PATCH V2 2/4] Introduce xen-scsifront module
In reply to Juergen GrossQuoted 24 lines · Juergen Gross
Quoted 22 lines · Christoph Hellwig
Quoted 21 lines
drivers/scsi/xen-scsifront.c new file +21
-0+switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) { + sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +dev_err (&dev->dev, +"Device already in use.\n" ); +scsi_device_put (sdev); +xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateClosed); + }else { +scsi_add_device (info->host, chn, tgt, + lun); +xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateConnected); + } + } +break ;
Quoted 4 lines
Quoted 2 lines
scsi_add_devicehandles an already existing device just fine, and unlike this construct isn't racy.Okay. I'll change it.
Hmm, I looked into scsi_add_device(). It seems as if the caller can't distinguish between a new created and an already existing device. Am I missing something?
The race is not existing: scsi_add_device() (and scsi_remove_device() as well) for this scsi_host is called in scsifront_do_lun_hotplug() only, and this function is always called in the same thread (xenbus watch). A comment seems to be a good idea.
Juergen
Juergen Gross
maintainerRe: [PATCH V2 2/4] Introduce xen-scsifront module
In reply to Christoph HellwigQuoted 6 lines · Christoph Hellwig
Quoted 3 lines
+ * Patched to support >2TB drives
+ * 2010, Samuel Kvasnica, IMS Nanofabrication AG
+ */This doesn't really belong into the top of the file comment and should be moved to the patch description.
Okay.
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#include <linux/version.h>not needed.
Okay.
Quoted 13 lines
Quoted 13 lines
drivers/scsi/xen-scsifront.c new file +13
-0+static int get_id_from_freelist (struct vscsifrnt_info *info) +{ +unsigned long flags; +uint32_t free; + +spin_lock_irqsave (&info->shadow_lock, flags); + + free = info->shadow_free; +BUG_ON (free >=VSCSIIF_MAX_REQS ); + info->shadow_free = info->shadow[free].next_free; + info->shadow[free].next_free =VSCSIIF_MAX_REQS ; + info->shadow[free].wait_reset =0 ; +
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 149
Quoted 3 lines
drivers/scsi/xen-scsifront.c new file +3
-0+spin_unlock_irqrestore (&info->shadow_lock, flags); + +return free;Is the shadow array exposed to the hypervisor? If not it might be a better idea to just allocate the driver private data with the command by setting the
cmd_sizefield in the host template. Take a look at thevirtio_scsidriver in recent kernels for an example.
Ah, okay. I'll still need an array for managing the request ids, but this will be much smaller...
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 203
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+static irqreturn_t scsifront_intr (int irq,void *dev_id) +{ +scsifront_notify_work ((struct vscsifrnt_info *)dev_id); +return IRQ_HANDLED ;Seems like you should simply use threaded interrupt handlers. If that doesn't work for you at least this should use a workqueue instead of manually reimplementing it using a kthread.
A threaded interrupt handler seems to be a good idea. I'll check if it is working.
Quoted 10 lines
drivers/scsi/xen-scsifront.c line 496
Quoted 7 lines
drivers/scsi/xen-scsifront.c new file +7
-0+/* debug printk to identify more missing scsi commands +shost_printk(KERN_INFO "scsicmd: ", sc->device->host, +"len=%u %#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x,%#x\n", +sc->cmd_len, sc->cmnd[0], sc->cmnd[1], +sc->cmnd[2], sc->cmnd[3], sc->cmnd[4], sc->cmnd[5], +sc->cmnd[6], sc->cmnd[7], sc->cmnd[8], sc->cmnd[9]); +*/ We already have pretty good ways to debug this in the midlayer, I don't think this is needed.
Okay, I'll remove it.
Quoted 5 lines
drivers/scsi/xen-scsifront.c line 497
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+spin_lock_irqsave (shost->host_lock, flags);What's actually protected by the host lock in this driver? It has ample of driver-local locking, so avoiding to touch the host lock would be a clear win.
The host_lock protects the ring buffers used to communicate with Dom0. I think this is the correct lock for this operation, as there is exactly one such ring buffer pair for each host structure allocated in scsifront_probe().
Quoted 4 lines
drivers/scsi/xen-scsifront.c line 498
Quoted 1 line
drivers/scsi/xen-scsifront.c new file +1
-0+scsi_cmd_get_serial (shost, sc);What do you need the serial number for? Generally only legacy drivers use it.
Historical reasons :-)
I'll remove it.
Quoted 10 lines
drivers/scsi/xen-scsifront.c line 586
Quoted 4 lines
drivers/scsi/xen-scsifront.c new file +4
-0+static int scsifront_eh_abort_handler (struct scsi_cmnd *sc) +{ +return scsifront_action_handler (sc,VSCSIIF_ACT_SCSI_ABORT ); +}The amount of waiting that your command abort handler does inside
scsifront_action_handlerlooks wrong to me. Can you explain the theory of operation for error handling in this driver? How much of error recovery is supposed to be handled by the hypervisor, and much is supposed to be handle in the intiator side driver?
The initiator side just forwards the abort/reset request to Dom0 and waits for an answer (okay or error).
Quoted 9 lines
drivers/scsi/xen-scsifront.c line 612
Quoted 6 lines
drivers/scsi/xen-scsifront.c new file +6
-0+static void scsifront_free (struct vscsifrnt_info *info) +{ +struct Scsi_Host *host = info->host; + +if (host->shost_state !=SHOST_DEL ) +scsi_remove_host (info->host);A driver really shouldn't look at
shost_statelike this. Is there some SCM history explaining where this comes from?
I'll investigate it. It was added soon after the first version was available, but I haven't found a reason yet.
Quoted 16 lines
Quoted 16 lines
drivers/scsi/xen-scsifront.c new file +16
-0+switch (op) { +case VSCSIFRONT_OP_ADD_LUN : +if (device_state == XenbusStateInitialised) { + sdev =scsi_device_lookup (info->host, chn, tgt, + lun); +if (sdev) { +dev_err (&dev->dev, +"Device already in use.\n" ); +scsi_device_put (sdev); +xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateClosed); + }else { +scsi_add_device (info->host, chn, tgt, + lun); + xenbus_printf(XBT_NIL, dev->nodename,
Quoted 8 lines
drivers/scsi/xen-scsifront.c line 890
Quoted 5 lines
drivers/scsi/xen-scsifront.c new file +5
-0+ state_str,"%d" , + XenbusStateConnected); + } + } +break ;
scsi_add_devicehandles an already existing device just fine, and unlike this construct isn't racy.
Okay. I'll change it.
Juergen
[email protected]
maintainerPATCH v2 3/4 Introduce XEN scsiback module
In reply to [email protected]From: Juergen Gross <[email protected]>
Introduces the XEN pvSCSI backend. With pvSCSI it is possible for a XEN domU to issue SCSI commands to a SCSI LUN assigned to that domU. The SCSI commands are passed to the pvSCSI backend in a driver domain (usually Dom0) which is owner of the physical device. This allows e.g. to use SCSI tape drives in a XEN domU.
The code is taken from the pvSCSI implementation in XEN done by Fujitsu based on Linux kernel 2.6.18.
Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- adapt to Linux style guide
- use target core infrastructure instead doing pure pass-through
- enable module unloading
- support SG-list in grant page(s)
- support task abort
- remove redundant struct backend
- allocate resources dynamically
- correct minor error in scsiback_fast_flush_area
- free allocated resources in case of error during I/O preparation
- initialize SCSI emulation table statically
- fix emulation of "report LUNs" to not needing retry
--- drivers/xen/Kconfig | 9 + drivers/xen/Makefile | 1 + drivers/xen/xen-scsiback.c | 2655 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2665 insertions(+) create mode 100644 drivers/xen/xen-scsiback.c
drivers/xen/Kconfig +9 -0
@@ -172,6 +172,15 @@ config XEN_PCIDEV_BACKEND If in doubt, say m. +config XEN_SCSI_BACKEND + tristate "XEN SCSI backend driver" + depends on SCSI && XEN && XEN_BACKEND && TARGET_CORE + help + The SCSI backend driver allows the kernel to export its SCSI Devices + to other guests via a high-performance shared-memory interface. + Only needed for systems running as XEN driver domains (e.g. Dom0) and + if guests need generic access to SCSI devices. + config XEN_PRIVCMD tristate depends on XEN
drivers/xen/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_XEN_STUB) += xen-stub.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o +obj-$(CONFIG_XEN_SCSI_BACKEND) += xen-scsiback.o xen-evtchn-y := evtchn.o xen-gntdev-y := gntdev.o xen-gntalloc-y := gntalloc.o
drivers/xen/xen-scsiback.c new file +2655 -0
2,655 lines not on this page · raw message
Signature · 1 line
1.8.4.5
Re: [PATCH V2 3/4] Introduce XEN scsiback module
Just a quick glance:
a) this should move to drivers/target with the other target code
b) you're still having your own CDB emulation in there, the target code should be taking care of all that.
Jürgen Groß
maintainerRe: [Xen-devel] [PATCH V2 3/4] Introduce XEN scsiback module
Quoted 3 lines · Christoph Hellwig
Just a quick glance:
a) this should move to
drivers/targetwith the other target code
I don't mind. I just followed the example of drivers/vhost/vhost.c and thought the similar xen module should be located under drivers/xen.
Quoted 2 lines
b) you're still having your own CDB emulation in there, the target code should be taking care of all that.
Okay, I'll remove the CDB emulation.
Juergen
Re: [Xen-devel] [PATCH V2 3/4] Introduce XEN scsiback module
Quoted 7 lines · J?rgen Gro?
Quoted 3 lines · Christoph Hellwig
Just a quick glance:
a) this should move to
drivers/targetwith the other target codeI don't mind. I just followed the example of
drivers/vhost/vhost.cand thought the similar xen module should be located underdrivers/xen.
Oh sorry, I overlooked that you moved it to drivers/xen from drivers/scsi in the initial submission. That's fine with me.
Quoted 4 lines
Quoted 2 lines
b) you're still having your own CDB emulation in there, the target code should be taking care of all that.
Okay, I'll remove the CDB emulation.
Thanks. If there's anything missing that Xen except feel free to adopt the target core to it.
Re: [PATCH V2 3/4] Introduce XEN scsiback module
In reply to Jürgen GroßQuoted 7 lines · J?rgen Gro?
Quoted 3 lines · Christoph Hellwig
Just a quick glance:
a) this should move to
drivers/targetwith the other target codeI don't mind. I just followed the example of
drivers/vhost/vhost.cand thought the similar xen module should be located underdrivers/xen.
Oh sorry, I overlooked that you moved it to drivers/xen from drivers/scsi in the initial submission. That's fine with me.
Quoted 4 lines
Quoted 2 lines
b) you're still having your own CDB emulation in there, the target code should be taking care of all that.
Okay, I'll remove the CDB emulation.
Thanks. If there's anything missing that Xen except feel free to adopt the target core to it.
Jürgen Groß
maintainerRe: [PATCH V2 3/4] Introduce XEN scsiback module
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
Just a quick glance:
a) this should move to
drivers/targetwith the other target code
I don't mind. I just followed the example of drivers/vhost/vhost.c and thought the similar xen module should be located under drivers/xen.
Quoted 2 lines
b) you're still having your own CDB emulation in there, the target code should be taking care of all that.
Okay, I'll remove the CDB emulation.
Juergen
Re: [PATCH V2 3/4] Introduce XEN scsiback module
In reply to [email protected]Just a quick glance:
a) this should move to drivers/target with the other target code
b) you're still having your own CDB emulation in there, the target code should be taking care of all that.
[email protected]
maintainerPATCH v2 3/4 Introduce XEN scsiback module
In reply to [email protected]From: Juergen Gross <[email protected]>
Introduces the XEN pvSCSI backend. With pvSCSI it is possible for a XEN domU to issue SCSI commands to a SCSI LUN assigned to that domU. The SCSI commands are passed to the pvSCSI backend in a driver domain (usually Dom0) which is owner of the physical device. This allows e.g. to use SCSI tape drives in a XEN domU.
The code is taken from the pvSCSI implementation in XEN done by Fujitsu based on Linux kernel 2.6.18.
Changes from the original version are:
- port to upstream kernel
- put all code in just one source file
- adapt to Linux style guide
- use target core infrastructure instead doing pure pass-through
- enable module unloading
- support SG-list in grant page(s)
- support task abort
- remove redundant struct backend
- allocate resources dynamically
- correct minor error in scsiback_fast_flush_area
- free allocated resources in case of error during I/O preparation
- initialize SCSI emulation table statically
- fix emulation of "report LUNs" to not needing retry
--- drivers/xen/Kconfig | 9 + drivers/xen/Makefile | 1 + drivers/xen/xen-scsiback.c | 2655 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2665 insertions(+) create mode 100644 drivers/xen/xen-scsiback.c
drivers/xen/Kconfig +9 -0
@@ -172,6 +172,15 @@ config XEN_PCIDEV_BACKEND If in doubt, say m. +config XEN_SCSI_BACKEND + tristate "XEN SCSI backend driver" + depends on SCSI && XEN && XEN_BACKEND && TARGET_CORE + help + The SCSI backend driver allows the kernel to export its SCSI Devices + to other guests via a high-performance shared-memory interface. + Only needed for systems running as XEN driver domains (e.g. Dom0) and + if guests need generic access to SCSI devices. + config XEN_PRIVCMD tristate depends on XEN
drivers/xen/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_XEN_STUB) += xen-stub.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o +obj-$(CONFIG_XEN_SCSI_BACKEND) += xen-scsiback.o xen-evtchn-y := evtchn.o xen-gntdev-y := gntdev.o xen-gntalloc-y := gntalloc.o
drivers/xen/xen-scsiback.c new file +2655 -0
2,655 lines not on this page · raw message
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v2 4/4 add xen pvscsi maintainer
In reply to [email protected]From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -10046,6 +10046,14 @@ S: Supported F: arch/x86/pci/*xen* F: drivers/pci/*xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h + XEN SWIOTLB SUBSYSTEM M: Konrad Rzeszutek Wilk <[email protected]> L: [email protected] (moderated for non-subscribers)
Signature · 1 line
1.8.4.5
[email protected]
maintainerPATCH v2 4/4 add xen pvscsi maintainer
In reply to [email protected]From: Juergen Gross <[email protected]>
Add myself as maintainer for the Xen pvSCSI stuff.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -10046,6 +10046,14 @@ S: Supported F: arch/x86/pci/*xen* F: drivers/pci/*xen* +XEN PVSCSI DRIVERS +M: Juergen Gross <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Supported +F: drivers/scsi/xen-scsifront.c +F: drivers/xen/xen-scsiback.c +F: include/xen/interface/io/vscsiif.h + XEN SWIOTLB SUBSYSTEM M: Konrad Rzeszutek Wilk <[email protected]> L: [email protected] (moderated for non-subscribers)
Signature · 1 line
1.8.4.5
Quoted 6 lines · On Fri, Jul 25, 2014 at 01:37:29PM +0200, [email protected] wrote:
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
About the question that Christopher Hellwig asked - was that ever answered?
Quoted 12 lines
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V2 1/4] Add XEN pvSCSI protocol description [PATCH V2 2/4] Introduce xen-scsifront module [PATCH V2 3/4] Introduce XEN scsiback module [PATCH V2 4/4] add xen pvscsi maintainer
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability
Juergen Gross
maintainerQuoted 9 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · On Fri, Jul 25, 2014 at 01:37:29PM +0200, [email protected] wrote:
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
About the question that Christopher Hellwig asked - was that ever answered?
Sure. That's the first item under "Changes in V2".
Quoted 14 lines
Quoted 13 lines
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V2 1/4] Add XEN pvSCSI protocol description [PATCH V2 2/4] Introduce xen-scsifront module [PATCH V2 3/4] Introduce XEN scsiback module [PATCH V2 4/4] add xen pvscsi maintainer
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability
Juergen Gross
maintainerQuoted 9 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · On Fri, Jul 25, 2014 at 01:37:29PM +0200, [email protected] wrote:
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
About the question that Christopher Hellwig asked - was that ever answered?
Sure. That's the first item under "Changes in V2".
Quoted 14 lines
Quoted 13 lines
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V2 1/4] Add XEN pvSCSI protocol description [PATCH V2 2/4] Introduce xen-scsifront module [PATCH V2 3/4] Introduce XEN scsiback module [PATCH V2 4/4] add xen pvscsi maintainer
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability
Quoted 6 lines · On Fri, Jul 25, 2014 at 01:37:29PM +0200, [email protected] wrote:
This series adds XEN pvSCSI support. With pvSCSI it is possible to use physical SCSI devices from a XEN domain.
The support consists of a backend in the privileged Domain-0 doing the real I/O and a frontend in the unprivileged domU passing I/O-requests to the backend.
About the question that Christopher Hellwig asked - was that ever answered?
Quoted 12 lines
The code is taken (and adapted) from the original pvSCSI implementation done for Linux 2.6 in 2008 by Fujitsu.
[PATCH V2 1/4] Add XEN pvSCSI protocol description [PATCH V2 2/4] Introduce xen-scsifront module [PATCH V2 3/4] Introduce XEN scsiback module [PATCH V2 4/4] add xen pvscsi maintainer
Changes in V2:
- use core target infrastructure by backend instead of pure SCSI passthrough
- add support for larger SG lists by putting them in grant page(s)
- add command abort capability