scsifront: avoid aquiring same lock twice if ring is full
Juergen Gross
maintainerPATCH 1/1 scsifront: avoid aquiring same lock twice if ring is full
The locking in scsifront_dev_reset_handler() is obviously wrong. In case of a full ring the host lock is aquired twice.
Fixing this issue enables to get rid of the endless fo loop with an explicit break statement.
---
drivers/xen/scsifront/scsifront.c +2 -4
@@ -447,12 +447,10 @@ static int scsifront_dev_reset_handler(suint16_t rqid;int err =0 ; -for (;;) {#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 ) -spin_lock_irq (host->host_lock); +spin_lock_irq (host->host_lock);#endif -if (!RING_FULL (&info->ring)) -break ; +while (RING_FULL (&info->ring)) {if (err) {#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 )spin_unlock_irq (host->host_lock);
Hi,
Quoted 6 lines · Juergen Gross
The locking in
scsifront_dev_reset_handler()is obviously wrong. In case of a full ring the host lock is aquired twice.Fixing this issue enables to get rid of the endless fo loop with an explicit break statement.
Is this patch needed in upstream Linux kernel aswell, now that Xen PVSCSI drivers are in upstream Linux ?
Thanks,
-- Pasi
Quoted 26 lines
Signed-off-by Juergen Gross <[email protected]>---
diff -r
078f1bb69ea5drivers/xen/scsifront/scsifront.cdrivers/xen/scsifront/scsifront.c +2
-4@@ -447,12 +447,10 @@ static int scsifront_dev_reset_handler(suint16_t rqid;int err =0 ; -for (;;) {#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 ) -spin_lock_irq (host->host_lock); +spin_lock_irq (host->host_lock);#endif -if (!RING_FULL (&info->ring)) -break ; +while (RING_FULL (&info->ring)) {if (err) {#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 )spin_unlock_irq (host->host_lock);_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Juergen Gross
maintainerQuoted 11 lines · Pasi Kärkkäinen
Hi,
Quoted 6 lines · Juergen Gross
The locking in
scsifront_dev_reset_handler()is obviously wrong. In case of a full ring the host lock is aquired twice.Fixing this issue enables to get rid of the endless fo loop with an explicit break statement.
Is this patch needed in upstream Linux kernel aswell, now that Xen PVSCSI drivers are in upstream Linux ?
No, especially this part of the code was reorganized and doesn't have that issue.
Juergen
Quoted 34 lines
Thanks,
-- Pasi
Quoted 26 lines
Signed-off-by Juergen Gross <[email protected]>---
diff -r
078f1bb69ea5drivers/xen/scsifront/scsifront.cdrivers/xen/scsifront/scsifront.c +2
-4@@ -447,12 +447,10 @@ static int scsifront_dev_reset_handler(suint16_t rqid;int err =0 ; -for (;;) {#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 ) -spin_lock_irq (host->host_lock); +spin_lock_irq (host->host_lock);#endif -if (!RING_FULL (&info->ring)) -break ; +while (RING_FULL (&info->ring)) {if (err) {#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 )spin_unlock_irq (host->host_lock);_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 13.01.15 at 17:22, <"[email protected]".non-mime.internet> wrote:
The locking in
scsifront_dev_reset_handler()is obviously wrong. In case of a full ring the host lock is aquired twice.Fixing this issue enables to get rid of the endless fo loop with an explicit break statement.
Perhaps worth noting that it was my c/s 1209:4d1471ca031e that screwed this up.
Jan
Quoted 21 lines
Signed-off-by Juergen Gross <[email protected]>---
diff -r
078f1bb69ea5drivers/xen/scsifront/scsifront.cdrivers/xen/scsifront/scsifront.c +2
-4@@ -447,12 +447,10 @@ static int scsifront_dev_reset_handler(suint16_t rqid;int err =0 ; -for (;;) {#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 ) -spin_lock_irq (host->host_lock); +spin_lock_irq (host->host_lock);#endif -if (!RING_FULL (&info->ring)) -break ; +while (RING_FULL (&info->ring)) {if (err) {#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,12 )spin_unlock_irq (host->host_lock);