]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - block/blk-barrier.c
block: set the bounce_pfn to the actual DMA limit rather than to max memory
[linux-2.6.git] / block / blk-barrier.c
index 7ce0a32a21fd2667dbe28c6fde25861145724c87..f0faefca032ff59d739460be5e7898a61d33cc48 100644 (file)
@@ -13,7 +13,6 @@
  * blk_queue_ordered - does this queue support ordered writes
  * @q:        the request queue
  * @ordered:  one of QUEUE_ORDERED_*
- * @prepare_flush_fn: rq setup helper for cache flush ordered writes
  *
  * Description:
  *   For journalled file systems, doing ordered writes on a commit
@@ -22,8 +21,7 @@
  *   feature should call this function and indicate so.
  *
  **/
-int blk_queue_ordered(struct request_queue *q, unsigned ordered,
-                     prepare_flush_fn *prepare_flush_fn)
+int blk_queue_ordered(struct request_queue *q, unsigned ordered)
 {
        if (ordered != QUEUE_ORDERED_NONE &&
            ordered != QUEUE_ORDERED_DRAIN &&
@@ -38,7 +36,6 @@ int blk_queue_ordered(struct request_queue *q, unsigned ordered,
 
        q->ordered = ordered;
        q->next_ordered = ordered;
-       q->prepare_flush_fn = prepare_flush_fn;
 
        return 0;
 }
@@ -137,11 +134,10 @@ static void queue_flush(struct request_queue *q, unsigned which)
        }
 
        blk_rq_init(q, rq);
+       rq->cmd_type = REQ_TYPE_FS;
        rq->cmd_flags = REQ_HARDBARRIER | REQ_FLUSH;
-       rq->rq_disk = q->bar_rq.rq_disk;
+       rq->rq_disk = q->orig_bar_rq->rq_disk;
        rq->end_io = end_io;
-       if (q->prepare_flush_fn)
-               q->prepare_flush_fn(q, rq);
 
        elv_insert(q, rq, ELEVATOR_INSERT_FRONT);
 }
@@ -315,6 +311,15 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
        if (!q)
                return -ENXIO;
 
+       /*
+        * some block devices may not have their queue correctly set up here
+        * (e.g. loop device without a backing file) and so issuing a flush
+        * here will panic. Ensure there is a request function before issuing
+        * the barrier.
+        */
+       if (!q->make_request_fn)
+               return -ENXIO;
+
        bio = bio_alloc(gfp_mask, 0);
        bio->bi_end_io = bio_end_empty_barrier;
        bio->bi_bdev = bdev;