support suspend/resume in pvscsi drivers
Juergen Gross
maintainerPATCH 1/1 support suspend/resume in pvscsi drivers
Up to now the pvscsi drivers haven't supported domain suspend and resume. When a domain with an assigned pvscsi device was suspended and resumed again, it was not able to use the device any more: trying to do so resulted in hanging processes.
Support suspend and resume of pvscsi devices.
drivers/xen/scsiback/xenbus.c +39 -24
@@ -167,33 +167,48 @@ static void scsiback_do_lun_hotplug(struswitch (op) {case VSCSIBACK_OP_ADD_OR_DEL_LUN : -if (device_state == XenbusStateInitialising) { +switch (device_state) { +case XenbusStateInitialising: +case XenbusStateConnected: sdev =scsiback_get_scsi_device (&phy); -if (!sdev) -xenbus_printf (XBT_NIL , dev->nodename, state_str, -"%d" , XenbusStateClosed); -else { - err =scsiback_add_translation_entry (be->info, sdev, &vir); -if (!err) { -if (xenbus_printf (XBT_NIL , dev->nodename, state_str, -"%d" , XenbusStateInitialised)) { -printk (KERN_ERR "scsiback: xenbus_printf error %s\n" , state_str); -scsiback_del_translation_entry (be->info, &vir); - } - }else { -scsi_device_put (sdev); -xenbus_printf (XBT_NIL , dev->nodename, state_str, -"%d" , XenbusStateClosed); - } +if (!sdev) { +xenbus_printf (XBT_NIL , dev->nodename, + state_str, +"%d" , XenbusStateClosed); +break ; } - } +if (scsiback_add_translation_entry (be->info, + sdev, &vir)) { +scsi_device_put (sdev); +if (device_state == XenbusStateConnected) +break ; +xenbus_printf (XBT_NIL , dev->nodename, + state_str, +"%d" , XenbusStateClosed); +break ; + } +if (!xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateInitialised)) +break ; +printk (KERN_ERR "scsiback: xenbus_printf error %s\n" , + state_str); +scsiback_del_translation_entry (be->info, &vir); +break ; -if (device_state == XenbusStateClosing) { -if (!scsiback_del_translation_entry (be->info, &vir)) { -if (xenbus_printf (XBT_NIL , dev->nodename, state_str, -"%d" , XenbusStateClosed)) -printk (KERN_ERR "scsiback: xenbus_printf error %s\n" , state_str); - } +case XenbusStateClosing: +if (scsiback_del_translation_entry (be->info, + &vir)) +break ; +if (xenbus_printf (XBT_NIL , dev->nodename, + state_str,"%d" , + XenbusStateClosed)) +printk (KERN_ERR "scsiback: xenbus_printf error %s\n" , + state_str); +break ; + +default : +break ; }break ;
drivers/xen/scsifront/common.h +8 -1
@@ -75,7 +75,9 @@struct vscsifrnt_shadow {uint16_t next_free; - +#define VSCSIIF_IN_USE 0x0fff +#define VSCSIIF_NONE 0x0ffe +/* command between backend and frontend * VSCSIIF_ACT_SCSI_CDB or VSCSIIF_ACT_SCSI_RESET */ unsigned char act;
@@ -113,8 +115,12 @@ struct vscsifrnt_info {struct task_struct *kthread;wait_queue_head_t wq;wait_queue_head_t wq_sync; +wait_queue_head_t wq_pause;unsigned char waiting_resp;unsigned char waiting_sync; +unsigned char waiting_pause; +unsigned char pause; +unsigned callers; }; #define DPRINTK(_f, _a...) \
@@ -124,6 +130,7 @@ struct vscsifrnt_info {int scsifront_xenbus_init (void );void scsifront_xenbus_unregister (void );int scsifront_schedule (void *data); +void scsifront_finish_all (struct vscsifrnt_info *info);irqreturn_t scsifront_intr (int irq,void *dev_id,struct pt_regs *ptregs);
drivers/xen/scsifront/scsifront.c +74 -14
168 lines not on this page · raw message
drivers/xen/scsifront/xenbus.c +97 -12
162 lines not on this page · raw message
drivers/xen/scsifront/scsifront.c static int scsifront_cmd_done(struct vsc · line 250
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 14:52, <"[email protected]".non-mime.internet> wrote:
drivers/xen/scsifront/scsifront.c +5
-0@@ -231,8 +242,23 @@ static int scsifront_cmd_done(struct vscreturn more_to_do; } +void scsifront_finish_all (struct vscsifrnt_info *info) +{ +unsigned i; +struct vscsiif_response resp; +scsifront_ring_drain (info);
Shouldn't you at least issue some kind of warning when this returns non-zero?
Jan
A message that is not in the archive (sent off-list or not yet received): [email protected]
Juergen Gross
maintainerQuoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 14:52, <"[email protected]".non-mime.internet> wrote:
drivers/xen/scsifront/scsifront.c +4
-0@@ -231,8 +242,23 @@ static int scsifront_cmd_done(struct vscreturn more_to_do; } +void scsifront_finish_all (struct vscsifrnt_info *info) +{ +unsigned i; +struct vscsiif_response resp;
Quoted 4 lines
drivers/xen/scsifront/scsifront.c static int scsifront_cmd_done(struct vsc · line 250
Quoted 1 line
drivers/xen/scsifront/scsifront.c +1
-0+scsifront_ring_drain (info);Shouldn't you at least issue some kind of warning when this returns non-zero?
If a warning should be issued, then this should be done after the following loop in case of at least one request terminated there.
I'm really not sure, whether a warning is required here. If you like, I can add one.
Juergen
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 15:54, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 14:52, <"[email protected]".non-mime.internet> wrote:
drivers/xen/scsifront/scsifront.c +4
-0@@ -231,8 +242,23 @@ static int scsifront_cmd_done(struct vscreturn more_to_do; } +void scsifront_finish_all (struct vscsifrnt_info *info) +{ +unsigned i; +struct vscsiif_response resp;Quoted 4 lines
drivers/xen/scsifront/scsifront.c static int scsifront_cmd_done(struct vsc · line 250
Quoted 1 line
drivers/xen/scsifront/scsifront.c +1
-0+scsifront_ring_drain (info);Shouldn't you at least issue some kind of warning when this returns non-zero?
Quoted 5 lines
If a warning should be issued, then this should be done after the following loop in case of at least one request terminated there.
I'm really not sure, whether a warning is required here. If you like, I can add one.
I'm not sure, I'm merely asking because I saw the function return value being ignored here.
Jan
A message that is not in the archive (sent off-list or not yet received): [email protected]
Juergen Gross
maintainerQuoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 15:54, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
drivers/xen/scsifront/scsifront.c static int scsifront_cmd_done(struct vsc · line 250
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 14:52, <"[email protected]".non-mime.internet> wrote:
drivers/xen/scsifront/scsifront.c +5
-0@@ -231,8 +242,23 @@ static int scsifront_cmd_done(struct vscreturn more_to_do; } +void scsifront_finish_all (struct vscsifrnt_info *info) +{ +unsigned i; +struct vscsiif_response resp; +scsifront_ring_drain (info);Shouldn't you at least issue some kind of warning when this returns non-zero?
Quoted 8 lines
Quoted 5 lines
If a warning should be issued, then this should be done after the following loop in case of at least one request terminated there.
I'm really not sure, whether a warning is required here. If you like, I can add one.
I'm not sure, I'm merely asking because I saw the function return value being ignored here.
I think it can be 0 only. We are handling resume, so the ring which is being drained will no longer be filled by the backend.
Juergen