]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/block/xen-blkfront.c
Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[karo-tx-linux.git] / drivers / block / xen-blkfront.c
index 96e9b00db08118a164d03845df86139169e78f71..c3dae2e0f290e8ad64b4f3e6c869c2fca14cd1a1 100644 (file)
@@ -791,7 +791,8 @@ static void blkif_restart_queue(struct work_struct *work)
 static void blkif_free(struct blkfront_info *info, int suspend)
 {
        struct llist_node *all_gnts;
-       struct grant *persistent_gnt;
+       struct grant *persistent_gnt, *tmp;
+       struct llist_node *n;
 
        /* Prevent new requests being issued until we fix things up. */
        spin_lock_irq(&info->io_lock);
@@ -804,10 +805,17 @@ static void blkif_free(struct blkfront_info *info, int suspend)
        /* Remove all persistent grants */
        if (info->persistent_gnts_c) {
                all_gnts = llist_del_all(&info->persistent_gnts);
-               llist_for_each_entry(persistent_gnt, all_gnts, node) {
+               persistent_gnt = llist_entry(all_gnts, typeof(*(persistent_gnt)), node);
+               while (persistent_gnt) {
                        gnttab_end_foreign_access(persistent_gnt->gref, 0, 0UL);
                        __free_page(pfn_to_page(persistent_gnt->pfn));
-                       kfree(persistent_gnt);
+                       tmp = persistent_gnt;
+                       n = persistent_gnt->node.next;
+                       if (n)
+                               persistent_gnt = llist_entry(n, typeof(*(persistent_gnt)), node);
+                       else
+                               persistent_gnt = NULL;
+                       kfree(tmp);
                }
                info->persistent_gnts_c = 0;
        }
@@ -835,7 +843,7 @@ static void blkif_free(struct blkfront_info *info, int suspend)
 static void blkif_completion(struct blk_shadow *s, struct blkfront_info *info,
                             struct blkif_response *bret)
 {
-       int i;
+       int i = 0;
        struct bio_vec *bvec;
        struct req_iterator iter;
        unsigned long flags;
@@ -852,7 +860,8 @@ static void blkif_completion(struct blk_shadow *s, struct blkfront_info *info,
                 */
                rq_for_each_segment(bvec, s->request, iter) {
                        BUG_ON((bvec->bv_offset + bvec->bv_len) > PAGE_SIZE);
-                       i = offset >> PAGE_SHIFT;
+                       if (bvec->bv_offset < offset)
+                               i++;
                        BUG_ON(i >= s->req.u.rw.nr_segments);
                        shared_data = kmap_atomic(
                                pfn_to_page(s->grants_used[i]->pfn));
@@ -861,7 +870,7 @@ static void blkif_completion(struct blk_shadow *s, struct blkfront_info *info,
                                bvec->bv_len);
                        bvec_kunmap_irq(bvec_data, &flags);
                        kunmap_atomic(shared_data);
-                       offset += bvec->bv_len;
+                       offset = bvec->bv_offset + bvec->bv_len;
                }
        }
        /* Add the persistent grant into the list of free grants */