From: "Jan Beulich" Subject: [PATCH] linux-2.6.18/blktap2: fix synchronization in blktap_device_run_queue() Date: Thu, 18 Nov 2010 12:28:39 +0000 Message-ID: <4CE52A070200007800023048@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3D1099E7.1__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" Cc: jake.wires@citrix.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part3D1099E7.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline c/s 896 (use of blk_rq_map_sg()) made the problem worse, but from what I can tell there had been races (ring and stats updates) before. If that's not a correct observation, a perhaps better solution might be to move the struct scatterlist array out of struct blktap (and make it e.g. an on-stack variable, the problem being that blktap_device_process_request() has a pretty large stack frame already - shrinking this might be possible by moving e.g. the struct blktap_grant_table and struct blkif_request blkif_req instances the other way if the locking change here is the right thing to do). Signed-off-by: Jan Beulich --- a/drivers/xen/blktap2/device.c +++ b/drivers/xen/blktap2/device.c @@ -887,7 +887,7 @@ blktap_device_run_queue(struct blktap *t blkdev_dequeue_request(req); =20 spin_unlock_irq(&dev->lock); - down_read(&tap->tap_sem); + down_write(&tap->tap_sem); =20 err =3D blktap_device_process_request(tap, request, req); if (!err) @@ -897,7 +897,7 @@ blktap_device_run_queue(struct blktap *t blktap_request_free(tap, request); } =20 - up_read(&tap->tap_sem); + up_write(&tap->tap_sem); spin_lock_irq(&dev->lock); } =20 --=__Part3D1099E7.1__= Content-Type: text/plain; name="xen-blktap2-run-queue-sem.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-blktap2-run-queue-sem.patch" c/s 896 (use of blk_rq_map_sg()) made the problem worse, but from what=0AI = can tell there had been races (ring and stats updates) before. If=0Athat's = not a correct observation, a perhaps better solution might be=0Ato move = the struct scatterlist array out of struct blktap (and make it=0Ae.g. an = on-stack variable, the problem being that=0Ablktap_device_process_request()= has a pretty large stack frame=0Aalready - shrinking this might be = possible by moving e.g. the=0Astruct blktap_grant_table and struct = blkif_request blkif_req instances=0Athe other way if the locking change = here is the right thing to do).=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/drivers/xen/blktap2/device.c=0A+++ b/drivers/xen/blkt= ap2/device.c=0A@@ -887,7 +887,7 @@ blktap_device_run_queue(struct blktap = *t=0A blkdev_dequeue_request(req);=0A =0A spin_unlock= _irq(&dev->lock);=0A- down_read(&tap->tap_sem);=0A+ = down_write(&tap->tap_sem);=0A =0A err =3D blktap_device_proce= ss_request(tap, request, req);=0A if (!err)=0A@@ -897,7 = +897,7 @@ blktap_device_run_queue(struct blktap *t=0A = blktap_request_free(tap, request);=0A }=0A =0A- = up_read(&tap->tap_sem);=0A+ up_write(&tap->tap_sem);=0A = spin_lock_irq(&dev->lock);=0A }=0A =0A --=__Part3D1099E7.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part3D1099E7.1__=--