]> err.no Git - linux-2.6/blobdiff - drivers/block/ll_rw_blk.c
[PATCH] printk: drivers/char/applicom.c
[linux-2.6] / drivers / block / ll_rw_blk.c
index 808390c742004dbc59adb75955de9f9327dec60d..fd94ea27d594f39473546477f81486c22cdf17c3 100644 (file)
@@ -717,7 +717,7 @@ struct request *blk_queue_find_tag(request_queue_t *q, int tag)
 {
        struct blk_queue_tag *bqt = q->queue_tags;
 
-       if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
+       if (unlikely(bqt == NULL || tag >= bqt->max_depth))
                return NULL;
 
        return bqt->tag_index[tag];
@@ -775,9 +775,9 @@ EXPORT_SYMBOL(blk_queue_free_tags);
 static int
 init_tag_map(request_queue_t *q, struct blk_queue_tag *tags, int depth)
 {
-       int bits, i;
        struct request **tag_index;
        unsigned long *tag_map;
+       int nr_ulongs;
 
        if (depth > q->nr_requests * 2) {
                depth = q->nr_requests * 2;
@@ -789,24 +789,17 @@ init_tag_map(request_queue_t *q, struct blk_queue_tag *tags, int depth)
        if (!tag_index)
                goto fail;
 
-       bits = (depth / BLK_TAGS_PER_LONG) + 1;
-       tag_map = kmalloc(bits * sizeof(unsigned long), GFP_ATOMIC);
+       nr_ulongs = ALIGN(depth, BITS_PER_LONG) / BITS_PER_LONG;
+       tag_map = kmalloc(nr_ulongs * sizeof(unsigned long), GFP_ATOMIC);
        if (!tag_map)
                goto fail;
 
        memset(tag_index, 0, depth * sizeof(struct request *));
-       memset(tag_map, 0, bits * sizeof(unsigned long));
+       memset(tag_map, 0, nr_ulongs * sizeof(unsigned long));
        tags->max_depth = depth;
-       tags->real_max_depth = bits * BITS_PER_LONG;
        tags->tag_index = tag_index;
        tags->tag_map = tag_map;
 
-       /*
-        * set the upper bits if the depth isn't a multiple of the word size
-        */
-       for (i = depth; i < bits * BLK_TAGS_PER_LONG; i++)
-               __set_bit(i, tag_map);
-
        return 0;
 fail:
        kfree(tag_index);
@@ -871,32 +864,24 @@ int blk_queue_resize_tags(request_queue_t *q, int new_depth)
        struct blk_queue_tag *bqt = q->queue_tags;
        struct request **tag_index;
        unsigned long *tag_map;
-       int bits, max_depth;
+       int max_depth, nr_ulongs;
 
        if (!bqt)
                return -ENXIO;
 
-       /*
-        * don't bother sizing down
-        */
-       if (new_depth <= bqt->real_max_depth) {
-               bqt->max_depth = new_depth;
-               return 0;
-       }
-
        /*
         * save the old state info, so we can copy it back
         */
        tag_index = bqt->tag_index;
        tag_map = bqt->tag_map;
-       max_depth = bqt->real_max_depth;
+       max_depth = bqt->max_depth;
 
        if (init_tag_map(q, bqt, new_depth))
                return -ENOMEM;
 
        memcpy(bqt->tag_index, tag_index, max_depth * sizeof(struct request *));
-       bits = max_depth / BLK_TAGS_PER_LONG;
-       memcpy(bqt->tag_map, tag_map, bits * sizeof(unsigned long));
+       nr_ulongs = ALIGN(max_depth, BITS_PER_LONG) / BITS_PER_LONG;
+       memcpy(bqt->tag_map, tag_map, nr_ulongs * sizeof(unsigned long));
 
        kfree(tag_index);
        kfree(tag_map);
@@ -926,11 +911,16 @@ void blk_queue_end_tag(request_queue_t *q, struct request *rq)
 
        BUG_ON(tag == -1);
 
-       if (unlikely(tag >= bqt->real_max_depth))
+       if (unlikely(tag >= bqt->max_depth))
+               /*
+                * This can happen after tag depth has been reduced.
+                * FIXME: how about a warning or info message here?
+                */
                return;
 
        if (unlikely(!__test_and_clear_bit(tag, bqt->tag_map))) {
-               printk("attempt to clear non-busy tag (%d)\n", tag);
+               printk(KERN_ERR "%s: attempt to clear non-busy tag (%d)\n",
+                      __FUNCTION__, tag);
                return;
        }
 
@@ -939,7 +929,8 @@ void blk_queue_end_tag(request_queue_t *q, struct request *rq)
        rq->tag = -1;
 
        if (unlikely(bqt->tag_index[tag] == NULL))
-               printk("tag %d is missing\n", tag);
+               printk(KERN_ERR "%s: tag %d is missing\n",
+                      __FUNCTION__, tag);
 
        bqt->tag_index[tag] = NULL;
        bqt->busy--;
@@ -972,8 +963,9 @@ int blk_queue_start_tag(request_queue_t *q, struct request *rq)
 
        if (unlikely((rq->flags & REQ_QUEUED))) {
                printk(KERN_ERR 
-                      "request %p for device [%s] already tagged %d",
-                      rq, rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->tag);
+                      "%s: request %p for device [%s] already tagged %d",
+                      __FUNCTION__, rq,
+                      rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->tag);
                BUG();
        }
 
@@ -1016,7 +1008,8 @@ void blk_queue_invalidate_tags(request_queue_t *q)
                rq = list_entry_rq(tmp);
 
                if (rq->tag == -1) {
-                       printk("bad tag found on list\n");
+                       printk(KERN_ERR
+                              "%s: bad tag found on list\n", __FUNCTION__);
                        list_del_init(&rq->queuelist);
                        rq->flags &= ~REQ_QUEUED;
                } else
@@ -1446,7 +1439,7 @@ EXPORT_SYMBOL(blk_remove_plug);
  */
 void __generic_unplug_device(request_queue_t *q)
 {
-       if (test_bit(QUEUE_FLAG_STOPPED, &q->queue_flags))
+       if (unlikely(test_bit(QUEUE_FLAG_STOPPED, &q->queue_flags)))
                return;
 
        if (!blk_remove_plug(q))
@@ -1770,7 +1763,7 @@ EXPORT_SYMBOL(blk_init_queue_node);
 
 int blk_get_queue(request_queue_t *q)
 {
-       if (!test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)) {
+       if (likely(!test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
                atomic_inc(&q->refcnt);
                return 0;
        }
@@ -1849,7 +1842,6 @@ static void __freed_request(request_queue_t *q, int rw)
                clear_queue_congested(q, rw);
 
        if (rl->count[rw] + 1 <= q->nr_requests) {
-               smp_mb();
                if (waitqueue_active(&rl->wait[rw]))
                        wake_up(&rl->wait[rw]);
 
@@ -1977,7 +1969,6 @@ static struct request *get_request_wait(request_queue_t *q, int rw)
        DEFINE_WAIT(wait);
        struct request *rq;
 
-       generic_unplug_device(q);
        do {
                struct request_list *rl = &q->rq;
 
@@ -1989,6 +1980,7 @@ static struct request *get_request_wait(request_queue_t *q, int rw)
                if (!rq) {
                        struct io_context *ioc;
 
+                       generic_unplug_device(q);
                        io_schedule();
 
                        /*
@@ -2592,7 +2584,7 @@ static int __make_request(request_queue_t *q, struct bio *bio)
        spin_lock_prefetch(q->queue_lock);
 
        barrier = bio_barrier(bio);
-       if (barrier && (q->ordered == QUEUE_ORDERED_NONE)) {
+       if (unlikely(barrier) && (q->ordered == QUEUE_ORDERED_NONE)) {
                err = -EOPNOTSUPP;
                goto end_io;
        }
@@ -2693,7 +2685,7 @@ get_rq:
        /*
         * REQ_BARRIER implies no merging, but lets make it explicit
         */
-       if (barrier)
+       if (unlikely(barrier))
                req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE);
 
        req->errors = 0;
@@ -2817,7 +2809,7 @@ static inline void block_wait_queue_running(request_queue_t *q)
 {
        DEFINE_WAIT(wait);
 
-       while (test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags)) {
+       while (unlikely(test_bit(QUEUE_FLAG_DRAIN, &q->queue_flags))) {
                struct request_list *rl = &q->rq;
 
                prepare_to_wait_exclusive(&rl->drain, &wait,
@@ -2926,7 +2918,7 @@ end_io:
                        goto end_io;
                }
 
-               if (test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))
+               if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
                        goto end_io;
 
                block_wait_queue_running(q);