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

[Xen-changelog] Fix error path in blkback driver where a grant mapping in the



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 55194bd55b86383fa82797f99f95587f6d14fa30
# Parent  c352591ebfdfbaa1d1132268455b9b13829af0a2
Fix error path in blkback driver where a grant mapping in the
middle of a batch fails. Spotted by Harry Butterworth (IBM).

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r c352591ebfdf -r 55194bd55b86 
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Sun Nov  6 
15:40:33 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Sun Nov  6 
16:50:24 2005
@@ -340,7 +340,7 @@
        struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
        int nbio = 0;
        request_queue_t *q;
-       int ret;
+       int ret, errors = 0;
 
        /* Check that number of segments is sane. */
        nseg = req->nr_segments;
@@ -374,23 +374,23 @@
        BUG_ON(ret);
 
        for (i = 0; i < nseg; i++) {
-               if (unlikely(map[i].handle < 0)) {
-                       DPRINTK("invalid buffer -- could not remap it\n");
-                       fast_flush_area(pending_idx, nseg);
-                       goto bad_descriptor;
+               if (likely(map[i].handle >= 0)) {
+                       pending_handle(pending_idx, i) = map[i].handle;
+                       phys_to_machine_mapping[__pa(MMAP_VADDR(
+                               pending_idx, i)) >> PAGE_SHIFT] =
+                               FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT);
+                       fas        = req->frame_and_sects[i];
+                       seg[i].buf = map[i].dev_bus_addr | 
+                               (blkif_first_sect(fas) << 9);
+               } else {
+                       errors++;
                }
-
-               phys_to_machine_mapping[__pa(MMAP_VADDR(
-                       pending_idx, i)) >> PAGE_SHIFT] =
-                       FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT);
-
-               pending_handle(pending_idx, i) = map[i].handle;
-       }
-
-       for (i = 0; i < nseg; i++) {
-               fas         = req->frame_and_sects[i];
-               seg[i].buf  = map[i].dev_bus_addr | 
-                       (blkif_first_sect(fas) << 9);
+       }
+
+       if (errors) {
+               DPRINTK("invalid buffer -- could not remap it\n");
+               fast_flush_area(pending_idx, nseg);
+               goto bad_descriptor;
        }
 
        if (vbd_translate(&preq, blkif, operation) != 0) {

_______________________________________________
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®.