Commit 2d910543 authored by Roger Pau Monne's avatar Roger Pau Monne Committed by Konrad Rzeszutek Wilk

xen-blkback: workaround compiler bug in gcc 4.1

The code generat with gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54)
creates an unbound loop for the second foreach_grant_safe loop in
purge_persistent_gnt.

The workaround is to avoid having this second loop and instead
perform all the work inside the first loop by adding a new variable,
clean_used, that will be set when all the desired persistent grants
have been removed and we need to iterate over the remaining ones to
remove the WAS_ACTIVE flag.
Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
Reported-by: default avatarTom O'Neill <toneill@vmem.com>
Reported-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent 8e3f8755
...@@ -341,7 +341,7 @@ static void purge_persistent_gnt(struct xen_blkif *blkif) ...@@ -341,7 +341,7 @@ static void purge_persistent_gnt(struct xen_blkif *blkif)
struct persistent_gnt *persistent_gnt; struct persistent_gnt *persistent_gnt;
struct rb_node *n; struct rb_node *n;
unsigned int num_clean, total; unsigned int num_clean, total;
bool scan_used = false; bool scan_used = false, clean_used = false;
struct rb_root *root; struct rb_root *root;
if (blkif->persistent_gnt_c < xen_blkif_max_pgrants || if (blkif->persistent_gnt_c < xen_blkif_max_pgrants ||
...@@ -358,9 +358,8 @@ static void purge_persistent_gnt(struct xen_blkif *blkif) ...@@ -358,9 +358,8 @@ static void purge_persistent_gnt(struct xen_blkif *blkif)
num_clean = (xen_blkif_max_pgrants / 100) * LRU_PERCENT_CLEAN; num_clean = (xen_blkif_max_pgrants / 100) * LRU_PERCENT_CLEAN;
num_clean = blkif->persistent_gnt_c - xen_blkif_max_pgrants + num_clean; num_clean = blkif->persistent_gnt_c - xen_blkif_max_pgrants + num_clean;
num_clean = min(blkif->persistent_gnt_c, num_clean); num_clean = min(blkif->persistent_gnt_c, num_clean);
if (num_clean > if ((num_clean == 0) ||
(blkif->persistent_gnt_c - (num_clean > (blkif->persistent_gnt_c - atomic_read(&blkif->persistent_gnt_in_use))))
atomic_read(&blkif->persistent_gnt_in_use)))
return; return;
/* /*
...@@ -383,6 +382,11 @@ static void purge_persistent_gnt(struct xen_blkif *blkif) ...@@ -383,6 +382,11 @@ static void purge_persistent_gnt(struct xen_blkif *blkif)
BUG_ON(persistent_gnt->handle == BUG_ON(persistent_gnt->handle ==
BLKBACK_INVALID_HANDLE); BLKBACK_INVALID_HANDLE);
if (clean_used) {
clear_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags);
continue;
}
if (test_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags)) if (test_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags))
continue; continue;
if (!scan_used && if (!scan_used &&
...@@ -400,18 +404,18 @@ static void purge_persistent_gnt(struct xen_blkif *blkif) ...@@ -400,18 +404,18 @@ static void purge_persistent_gnt(struct xen_blkif *blkif)
* grants that were used since last purge in order to cope * grants that were used since last purge in order to cope
* with the requested num * with the requested num
*/ */
if (!scan_used) { if (!scan_used && !clean_used) {
pr_debug(DRV_PFX "Still missing %u purged frames\n", num_clean); pr_debug(DRV_PFX "Still missing %u purged frames\n", num_clean);
scan_used = true; scan_used = true;
goto purge_list; goto purge_list;
} }
finished: finished:
/* Remove the "used" flag from all the persistent grants */ if (!clean_used) {
foreach_grant_safe(persistent_gnt, n, root, node) { pr_debug(DRV_PFX "Finished scanning for grants to clean, removing used flag\n");
BUG_ON(persistent_gnt->handle == clean_used = true;
BLKBACK_INVALID_HANDLE); goto purge_list;
clear_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags);
} }
blkif->persistent_gnt_c -= (total - num_clean); blkif->persistent_gnt_c -= (total - num_clean);
blkif->vbd.overflow_max_grants = 0; blkif->vbd.overflow_max_grants = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment