]> err.no Git - linux-2.6/blobdiff - block/ll_rw_blk.c
USB: always visit drivers/usb/misc/
[linux-2.6] / block / ll_rw_blk.c
index eb27b335d238173faa459077bb609878596fde79..cd9d2c5d91ae22664081e83136f9da4f3a9aae4c 100644 (file)
@@ -431,7 +431,6 @@ static void queue_flush(struct request_queue *q, unsigned which)
 static inline struct request *start_ordered(struct request_queue *q,
                                            struct request *rq)
 {
-       q->bi_size = 0;
        q->orderr = 0;
        q->ordered = q->next_ordered;
        q->ordseq |= QUEUE_ORDSEQ_STARTED;
@@ -528,56 +527,36 @@ int blk_do_ordered(struct request_queue *q, struct request **rqp)
        return 1;
 }
 
-static int flush_dry_bio_endio(struct bio *bio, unsigned int bytes, int error)
-{
-       struct request_queue *q = bio->bi_private;
-
-       /*
-        * This is dry run, restore bio_sector and size.  We'll finish
-        * this request again with the original bi_end_io after an
-        * error occurs or post flush is complete.
-        */
-       q->bi_size += bytes;
-
-       if (bio->bi_size)
-               return 1;
-
-       /* Reset bio */
-       set_bit(BIO_UPTODATE, &bio->bi_flags);
-       bio->bi_size = q->bi_size;
-       bio->bi_sector -= (q->bi_size >> 9);
-       q->bi_size = 0;
-
-       return 0;
-}
-
-static int ordered_bio_endio(struct request *rq, struct bio *bio,
-                            unsigned int nbytes, int error)
+static void req_bio_endio(struct request *rq, struct bio *bio,
+                         unsigned int nbytes, int error)
 {
        struct request_queue *q = rq->q;
-       bio_end_io_t *endio;
-       void *private;
-
-       if (&q->bar_rq != rq)
-               return 0;
-
-       /*
-        * Okay, this is the barrier request in progress, dry finish it.
-        */
-       if (error && !q->orderr)
-               q->orderr = error;
 
-       endio = bio->bi_end_io;
-       private = bio->bi_private;
-       bio->bi_end_io = flush_dry_bio_endio;
-       bio->bi_private = q;
+       if (&q->bar_rq != rq) {
+               if (error)
+                       clear_bit(BIO_UPTODATE, &bio->bi_flags);
+               else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
+                       error = -EIO;
 
-       bio_endio(bio, nbytes, error);
+               if (unlikely(nbytes > bio->bi_size)) {
+                       printk("%s: want %u bytes done, only %u left\n",
+                              __FUNCTION__, nbytes, bio->bi_size);
+                       nbytes = bio->bi_size;
+               }
 
-       bio->bi_end_io = endio;
-       bio->bi_private = private;
+               bio->bi_size -= nbytes;
+               bio->bi_sector += (nbytes >> 9);
+               if (bio->bi_size == 0)
+                       bio_endio(bio, error);
+       } else {
 
-       return 1;
+               /*
+                * Okay, this is the barrier request in progress, just
+                * record the error;
+                */
+               if (error && !q->orderr)
+                       q->orderr = error;
+       }
 }
 
 /**
@@ -1364,28 +1343,28 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
         */
        bvprv = NULL;
        rq_for_each_segment(bvec, rq, iter) {
-                       int nbytes = bvec->bv_len;
+               int nbytes = bvec->bv_len;
 
-                       if (bvprv && cluster) {
-                               if (sg[nsegs - 1].length + nbytes > q->max_segment_size)
-                                       goto new_segment;
+               if (bvprv && cluster) {
+                       if (sg[nsegs - 1].length + nbytes > q->max_segment_size)
+                               goto new_segment;
 
-                               if (!BIOVEC_PHYS_MERGEABLE(bvprv, bvec))
-                                       goto new_segment;
-                               if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bvec))
-                                       goto new_segment;
+                       if (!BIOVEC_PHYS_MERGEABLE(bvprv, bvec))
+                               goto new_segment;
+                       if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bvec))
+                               goto new_segment;
 
-                               sg[nsegs - 1].length += nbytes;
-                       } else {
+                       sg[nsegs - 1].length += nbytes;
+               } else {
 new_segment:
-                               memset(&sg[nsegs],0,sizeof(struct scatterlist));
-                               sg[nsegs].page = bvec->bv_page;
-                               sg[nsegs].length = nbytes;
-                               sg[nsegs].offset = bvec->bv_offset;
+                       memset(&sg[nsegs],0,sizeof(struct scatterlist));
+                       sg[nsegs].page = bvec->bv_page;
+                       sg[nsegs].length = nbytes;
+                       sg[nsegs].offset = bvec->bv_offset;
 
-                               nsegs++;
-                       }
-                       bvprv = bvec;
+                       nsegs++;
+               }
+               bvprv = bvec;
        } /* segments in rq */
 
        return nsegs;
@@ -2422,7 +2401,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
                return bio->bi_size;
 
        /* if it was boucned we must call the end io function */
-       bio_endio(bio, bio->bi_size, 0);
+       bio_endio(bio, 0);
        __blk_rq_unmap_user(orig_bio);
        bio_put(bio);
        return ret;
@@ -2531,7 +2510,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
                return PTR_ERR(bio);
 
        if (bio->bi_size != len) {
-               bio_endio(bio, bio->bi_size, 0);
+               bio_endio(bio, 0);
                bio_unmap_user(bio);
                return -EINVAL;
        }
@@ -2941,15 +2920,9 @@ static void init_request_from_bio(struct request *req, struct bio *bio)
 
        req->errors = 0;
        req->hard_sector = req->sector = bio->bi_sector;
-       req->hard_nr_sectors = req->nr_sectors = bio_sectors(bio);
-       req->current_nr_sectors = req->hard_cur_sectors = bio_cur_sectors(bio);
-       req->nr_phys_segments = bio_phys_segments(req->q, bio);
-       req->nr_hw_segments = bio_hw_segments(req->q, bio);
-       req->buffer = bio_data(bio);    /* see ->buffer comment above */
-       req->bio = req->biotail = bio;
        req->ioprio = bio_prio(bio);
-       req->rq_disk = bio->bi_bdev->bd_disk;
        req->start_time = jiffies;
+       blk_rq_bio_prep(req->q, req, bio);
 }
 
 static int __make_request(struct request_queue *q, struct bio *bio)
@@ -3067,7 +3040,7 @@ out:
        return 0;
 
 end_io:
-       bio_endio(bio, nr_sectors << 9, err);
+       bio_endio(bio, err);
        return 0;
 }
 
@@ -3214,7 +3187,7 @@ static inline void __generic_make_request(struct bio *bio)
                                bdevname(bio->bi_bdev, b),
                                (long long) bio->bi_sector);
 end_io:
-                       bio_endio(bio, bio->bi_size, -EIO);
+                       bio_endio(bio, -EIO);
                        break;
                }
 
@@ -3429,8 +3402,7 @@ static int __end_that_request_first(struct request *req, int uptodate,
                if (nr_bytes >= bio->bi_size) {
                        req->bio = bio->bi_next;
                        nbytes = bio->bi_size;
-                       if (!ordered_bio_endio(req, bio, nbytes, error))
-                               bio_endio(bio, nbytes, error);
+                       req_bio_endio(req, bio, nbytes, error);
                        next_idx = 0;
                        bio_nbytes = 0;
                } else {
@@ -3485,8 +3457,7 @@ static int __end_that_request_first(struct request *req, int uptodate,
         * if the request wasn't completed, update state
         */
        if (bio_nbytes) {
-               if (!ordered_bio_endio(req, bio, bio_nbytes, error))
-                       bio_endio(bio, bio_nbytes, error);
+               req_bio_endio(req, bio, bio_nbytes, error);
                bio->bi_idx += next_idx;
                bio_iovec(bio)->bv_offset += nr_bytes;
                bio_iovec(bio)->bv_len -= nr_bytes;
@@ -3561,7 +3532,7 @@ static void blk_done_softirq(struct softirq_action *h)
        }
 }
 
-static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
+static int __cpuinit blk_cpu_notify(struct notifier_block *self, unsigned long action,
                          void *hcpu)
 {
        /*
@@ -3582,7 +3553,7 @@ static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
 }
 
 
-static struct notifier_block __devinitdata blk_cpu_notifier = {
+static struct notifier_block blk_cpu_notifier __cpuinitdata = {
        .notifier_call  = blk_cpu_notify,
 };