Minor synchronisation quibble in scsifront
I've been having a look through scsifront again, and I saw this bit:
ring_req->timeout_per_command = (sc->timeout_per_command / HZ); ring_req->nr_segments = 0; spin_unlock_irq(host->host_lock); scsifront_do_request(info); wait_event_interruptible(info->shadow[ring_req->rqid].wq_reset, info->shadow[ring_req->rqid].wait_reset);
in scsifront_dev_reset_handler(). Looking at scsifront_do_request():
static void scsifront_do_request(struct vscsifrnt_info *info)
{
struct vscsiif_front_ring *ring = &(info->ring);
unsigned int irq = info->irq;
int notify;
RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(ring, notify);
if (notify)
notify_remote_via_irq(irq);
}scsifront_do_request() is also called from scsifront_queuecommand(), where it's under the host lock. I can't see any other relevant synchronisation, so I think that you might be able to end up with several processors pushing requests at the same time. I'm not sure what'll happen then, but I doubt it's a good idea.
The issue could be avoided if you just swapped two lines in scsifront_dev_reset_handler():
ring_req->timeout_per_command = (sc->timeout_per_command / HZ); ring_req->nr_segments = 0; scsifront_do_request(info); spin_unlock_irq(host->host_lock); wait_event_interruptible(info->shadow[ring_req->rqid].wq_reset, info->shadow[ring_req->rqid].wait_reset);
Does that sound sane?
On the plus side, that's the only strange bit I could see in current scsifront. :)
Steven.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PATCH 1/1 : pvSCSI (Re: Minor synchronisation quibble in scsifront)
Hi Steven-san,
Thank you for your advice.
I will attach a patch to solve the lock problem. And also, the patch contains few modifications about SCSI Reset, which you pointed out in the past.
Best regards,
Quoted 40 lines · On Thu, 10 Jul 2008 16:26:56 +0100 Steven Smith <[email protected]> wrote:
I've been having a look through scsifront again, and I saw this bit:
ring_req->timeout_per_command = (sc->timeout_per_command / HZ); ring_req->nr_segments = 0; spin_unlock_irq(host->host_lock); scsifront_do_request(info); wait_event_interruptible(info->shadow[ring_req->rqid].wq_reset, info->shadow[ring_req->rqid].wait_reset);in
scsifront_dev_reset_handler(). Looking atscsifront_do_request():static void
scsifront_do_request(struct vscsifrnt_info *info){ struct vscsiif_front_ring *ring = &(info->ring); unsigned int irq = info->irq; int notify; RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(ring, notify); if (notify) notify_remote_via_irq(irq); }
scsifront_do_request()is also called fromscsifront_queuecommand(), where it's under the host lock. I can't see any other relevant synchronisation, so I think that you might be able to end up with several processors pushing requests at the same time. I'm not sure what'll happen then, but I doubt it's a good idea.The issue could be avoided if you just swapped two lines in
scsifront_dev_reset_handler():ring_req->timeout_per_command = (sc->timeout_per_command / HZ); ring_req->nr_segments = 0; scsifront_do_request(info); spin_unlock_irq(host->host_lock); wait_event_interruptible(info->shadow[ring_req->rqid].wq_reset, info->shadow[ring_req->rqid].wait_reset);
Quoted 6 lines
Does that sound sane?
On the plus side, that's the only strange bit I could see in current scsifront. :)
Steven.
-----
Jun Kamada
# HG changeset patch
# User [email protected]
# Date 1216020893 -32400
# Node ID 840c90710f293e1fd5be110ac350b148c733fd51 # Parent 29228a5f9fea2cf5b30645c4bb23852b1fb3802f Fix Minor synchronisation quibble
drivers/xen/scsifront/common.h +0 -3
@@ -112,9 +112,6 @@ struct vscsifrnt_info {struct task_struct *kthread;wait_queue_head_t wq;unsigned int waiting_resp; - -/* abort reset condition bit*/ -atomic_t abort_reset_cond; };
drivers/xen/scsifront/scsifront.c +11 -20
@@ -146,12 +146,7 @@ static void scsifront_cdb_cmd_done(strucscsifront_gnttab_done (&info->shadow[id], id);add_id_to_freelist (info, id); -if (atomic_read (&info->abort_reset_cond) ==VSCSI_IN_RESET ) { - sc->result = (DID_RESET <<16 ); - }else { - sc->result = ring_res->rslt; - } - + sc->result = ring_res->rslt; sc->resid =0 ;if (ring_res->sense_len >VSCSIIF_SENSE_BUFFERSIZE )
@@ -432,22 +427,18 @@ static int scsifront_dev_reset_handler(s (struct vscsifrnt_info *) sc->device->host->hostdata;vscsiif_request_t *ring_req; +uint16_t rqid;int err;#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 )spin_lock_irq (host->host_lock);#endif -atomic_set (&info->abort_reset_cond,VSCSI_IN_RESET ); -while (RING_HAS_UNCONSUMED_RESPONSES (&info->ring)) { -if (!scsifront_cmd_done (info)) -break ; - } - ring_req =scsifront_pre_request (info); ring_req->act =VSCSIIF_ACT_SCSI_RESET ; - info->shadow[ring_req->rqid].act =VSCSIIF_ACT_SCSI_RESET ; + rqid = ring_req->rqid; + info->shadow[rqid].act =VSCSIIF_ACT_SCSI_RESET ; ring_req->channel = sc->device->channel; ring_req->id = sc->device->id;
@@ -463,20 +454,20 @@ static int scsifront_dev_reset_handler(s ring_req->timeout_per_command = (sc->timeout_per_command /HZ ); ring_req->nr_segments =0 ; +scsifront_do_request (info); +spin_unlock_irq (host->host_lock); -scsifront_do_request (info); -wait_event_interruptible (info->shadow[ring_req->rqid].wq_reset, - info->shadow[ring_req->rqid].wait_reset); - +wait_event_interruptible (info->shadow[rqid].wq_reset, + info->shadow[rqid].wait_reset);spin_lock_irq (host->host_lock); - err = info->shadow[ring_req->rqid].rslt_reset; -atomic_set (&info->abort_reset_cond,0 ); + err = info->shadow[rqid].rslt_reset; + +add_id_to_freelist (info, rqid);#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 )spin_unlock_irq (host->host_lock);#endif -return (err); }
drivers/xen/scsifront/xenbus.c +0 -2
@@ -195,8 +195,6 @@ static int scsifront_probe(struct xenbus } info->shadow[VSCSIIF_MAX_REQS -1 ].next_free =0x0fff ; -atomic_set (&info->abort_reset_cond,0 ); - err =scsifront_init_ring (info);if (err) {scsi_host_put (host);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Re: [Patch]: pvSCSI (Re: Minor synchronisation quibble in scsifront)
Quoted 4 lines
Thank you for your advice.
I will attach a patch to solve the lock problem. And also, the patch contains few modifications about SCSI Reset, which you pointed out in the past.
Thanks, that looks better.
Steven.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel