Bias the location of pages freed for min_free_kbytes in the same MAX_ORDER_NR_PAGES...
[sfrench/cifs-2.6.git] / block / ll_rw_blk.c
index c6b2a477d33e2c3a33f41bb53c7dcb0a211ee77a..a83823fcd74f3f90a42d8a470cad9947c5cdd56f 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;
+       }
 }
 
 /**
@@ -1875,7 +1854,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
 
        init_timer(&q->unplug_timer);
 
-       snprintf(q->kobj.name, KOBJ_NAME_LEN, "%s", "queue");
+       kobject_set_name(&q->kobj, "%s", "queue");
        q->kobj.ktype = &queue_ktype;
        kobject_init(&q->kobj);
 
@@ -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;
        }
@@ -3061,7 +3040,7 @@ out:
        return 0;
 
 end_io:
-       bio_endio(bio, nr_sectors << 9, err);
+       bio_endio(bio, err);
        return 0;
 }
 
@@ -3208,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;
                }
 
@@ -3423,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 {
@@ -3479,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;
@@ -3555,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)
 {
        /*
@@ -3576,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,
 };
 
@@ -3951,7 +3928,6 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
                        max_hw_sectors_kb = q->max_hw_sectors >> 1,
                        page_kb = 1 << (PAGE_CACHE_SHIFT - 10);
        ssize_t ret = queue_var_store(&max_sectors_kb, page, count);
-       int ra_kb;
 
        if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb)
                return -EINVAL;
@@ -3960,14 +3936,6 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
         * values synchronously:
         */
        spin_lock_irq(q->queue_lock);
-       /*
-        * Trim readahead window as well, if necessary:
-        */
-       ra_kb = q->backing_dev_info.ra_pages << (PAGE_CACHE_SHIFT - 10);
-       if (ra_kb > max_sectors_kb)
-               q->backing_dev_info.ra_pages =
-                               max_sectors_kb >> (PAGE_CACHE_SHIFT - 10);
-
        q->max_sectors = max_sectors_kb << 1;
        spin_unlock_irq(q->queue_lock);