]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
xen/blkback: Move the check for misaligned I/O higher.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 15 Apr 2011 15:38:29 +0000 (11:38 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 15 Apr 2011 15:38:29 +0000 (11:38 -0400)
We move it up higher to be in same loop that actually computes
the sector number.

This way, all of the code that deals with verifying that the
request is correct is all done before we do any of the
page mapping, I/O submission, etc.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/xen/blkback/blkback.c

index 211b2005f963fffdb07b3a9cb2f913b5dd7362f4..9598e0fd0f9e067631043e95a81a4ba57dd81719 100644 (file)
@@ -521,6 +521,13 @@ static void dispatch_rw_block_io(struct blkif_st *blkif,
                    (req->u.rw.seg[i].last_sect < req->u.rw.seg[i].first_sect))
                        goto fail_response;
                preq.nr_sects += seg[i].nsec;
+
+               if (((int)preq.sector_number|(int)seg[i].nsec) &
+                   ((bdev_logical_block_size(preq.bdev) >> 9) - 1)) {
+                       DPRINTK("Misaligned I/O request from domain %d",
+                               blkif->domid);
+                       goto fail_response;
+               }
        }
 
        if (vbd_translate(&preq, blkif, operation) != 0) {
@@ -542,13 +549,6 @@ static void dispatch_rw_block_io(struct blkif_st *blkif,
        blkif_get(blkif);
 
        for (i = 0; i < nseg; i++) {
-               if (((int)preq.sector_number|(int)seg[i].nsec) &
-                   ((bdev_logical_block_size(preq.bdev) >> 9) - 1)) {
-                       DPRINTK("Misaligned I/O request from domain %d",
-                               blkif->domid);
-                       goto fail_put_bio;
-               }
-
                while ((bio == NULL) ||
                       (bio_add_page(bio,
                                     blkbk->pending_page(pending_req, i),