[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] gnttab: Checking ->next is insufficient to decide if something is



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1225368066 0
# Node ID d49054ec0cc611391d3cbaae4ec77be1e8f7726b
# Parent  eb759c00a1f8147c103af82a01b97836f347f602
gnttab: Checking ->next is insufficient to decide if something is
queued in a singly-linked list (doesn't work for final item).

From: Jake Wires <jake.wires@xxxxxxxxxx>.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 drivers/xen/core/gnttab.c |    5 ++++-
 include/xen/gnttab.h      |    3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff -r eb759c00a1f8 -r d49054ec0cc6 drivers/xen/core/gnttab.c
--- a/drivers/xen/core/gnttab.c Thu Oct 30 11:59:46 2008 +0000
+++ b/drivers/xen/core/gnttab.c Thu Oct 30 12:01:06 2008 +0000
@@ -112,6 +112,7 @@ static void do_free_callbacks(void)
                next = callback->next;
                if (gnttab_free_count >= callback->count) {
                        callback->next = NULL;
+                       callback->queued = 0;
                        callback->fn(callback->arg);
                } else {
                        callback->next = gnttab_free_callback_list;
@@ -343,11 +344,12 @@ void gnttab_request_free_callback(struct
 {
        unsigned long flags;
        spin_lock_irqsave(&gnttab_list_lock, flags);
-       if (callback->next)
+       if (callback->queued)
                goto out;
        callback->fn = fn;
        callback->arg = arg;
        callback->count = count;
+       callback->queued = 1;
        callback->next = gnttab_free_callback_list;
        gnttab_free_callback_list = callback;
        check_free_callbacks();
@@ -365,6 +367,7 @@ void gnttab_cancel_free_callback(struct 
        for (pcb = &gnttab_free_callback_list; *pcb; pcb = &(*pcb)->next) {
                if (*pcb == callback) {
                        *pcb = callback->next;
+                       callback->queued = 0;
                        break;
                }
        }
diff -r eb759c00a1f8 -r d49054ec0cc6 include/xen/gnttab.h
--- a/include/xen/gnttab.h      Thu Oct 30 11:59:46 2008 +0000
+++ b/include/xen/gnttab.h      Thu Oct 30 12:01:06 2008 +0000
@@ -44,10 +44,11 @@
 #include <xen/features.h>
 
 struct gnttab_free_callback {
-       struct gnttab_free_callback *next;
+       struct list_head list;
        void (*fn)(void *);
        void *arg;
        u16 count;
+       u8 queued;
 };
 
 int gnttab_grant_foreign_access(domid_t domid, unsigned long frame,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.