]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - block/blk.h
block: add blk_run_queue_async
[linux-3.10.git] / block / blk.h
index 3ee94358b43d0ba8d1194daaac7d34534e87bfa5..c9df8fc3c99979de8fe21f439b82989d1361e859 100644 (file)
@@ -13,14 +13,16 @@ extern struct kobj_type blk_queue_ktype;
 void init_request_from_bio(struct request *req, struct bio *bio);
 void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
                        struct bio *bio);
+int blk_rq_append_bio(struct request_queue *q, struct request *rq,
+                     struct bio *bio);
+void blk_dequeue_request(struct request *rq);
 void __blk_queue_free_tags(struct request_queue *q);
 
-void blk_unplug_work(struct work_struct *work);
-void blk_unplug_timeout(unsigned long data);
 void blk_rq_timed_out_timer(unsigned long data);
 void blk_delete_timer(struct request *);
 void blk_add_timer(struct request *);
 void __generic_unplug_device(struct request_queue *);
+void blk_run_queue_async(struct request_queue *q);
 
 /*
  * Internal atomic flags for request handling
@@ -31,7 +33,7 @@ enum rq_atomic_flags {
 
 /*
  * EH timer and IO completion will both attempt to 'grab' the request, make
- * sure that only one of them suceeds
+ * sure that only one of them succeeds
  */
 static inline int blk_mark_rq_complete(struct request *rq)
 {
@@ -43,6 +45,45 @@ static inline void blk_clear_rq_complete(struct request *rq)
        clear_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags);
 }
 
+/*
+ * Internal elevator interface
+ */
+#define ELV_ON_HASH(rq)                (!hlist_unhashed(&(rq)->hash))
+
+void blk_insert_flush(struct request *rq);
+void blk_abort_flushes(struct request_queue *q);
+
+static inline struct request *__elv_next_request(struct request_queue *q)
+{
+       struct request *rq;
+
+       while (1) {
+               if (!list_empty(&q->queue_head)) {
+                       rq = list_entry_rq(q->queue_head.next);
+                       return rq;
+               }
+
+               if (!q->elevator->ops->elevator_dispatch_fn(q, 0))
+                       return NULL;
+       }
+}
+
+static inline void elv_activate_rq(struct request_queue *q, struct request *rq)
+{
+       struct elevator_queue *e = q->elevator;
+
+       if (e->ops->elevator_activate_req_fn)
+               e->ops->elevator_activate_req_fn(q, rq);
+}
+
+static inline void elv_deactivate_rq(struct request_queue *q, struct request *rq)
+{
+       struct elevator_queue *e = q->elevator;
+
+       if (e->ops->elevator_deactivate_req_fn)
+               e->ops->elevator_deactivate_req_fn(q, rq);
+}
+
 #ifdef CONFIG_FAIL_IO_TIMEOUT
 int blk_should_fake_timeout(struct request_queue *);
 ssize_t part_timeout_show(struct device *, struct device_attribute *, char *);
@@ -63,13 +104,19 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req,
                      struct bio *bio);
 int attempt_back_merge(struct request_queue *q, struct request *rq);
 int attempt_front_merge(struct request_queue *q, struct request *rq);
+int blk_attempt_req_merge(struct request_queue *q, struct request *rq,
+                               struct request *next);
 void blk_recalc_rq_segments(struct request *rq);
-void blk_recalc_rq_sectors(struct request *rq, int nsect);
+void blk_rq_set_mixed_merge(struct request *rq);
 
 void blk_queue_congestion_threshold(struct request_queue *q);
 
 int blk_dev_init(void);
 
+void elv_quiesce_start(struct request_queue *q);
+void elv_quiesce_end(struct request_queue *q);
+
+
 /*
  * Return the threshold (number of used requests) at which the queue is
  * considered to be congested.  It include a little hysteresis to keep the
@@ -88,32 +135,35 @@ static inline int queue_congestion_off_threshold(struct request_queue *q)
        return q->nr_congestion_off;
 }
 
-#if defined(CONFIG_BLK_DEV_INTEGRITY)
-
-#define rq_for_each_integrity_segment(bvl, _rq, _iter)         \
-       __rq_for_each_bio(_iter.bio, _rq)                       \
-               bip_for_each_vec(bvl, _iter.bio->bi_integrity, _iter.i)
-
-#endif /* BLK_DEV_INTEGRITY */
-
 static inline int blk_cpu_to_group(int cpu)
 {
+       int group = NR_CPUS;
 #ifdef CONFIG_SCHED_MC
        const struct cpumask *mask = cpu_coregroup_mask(cpu);
-       return cpumask_first(mask);
+       group = cpumask_first(mask);
 #elif defined(CONFIG_SCHED_SMT)
-       return cpumask_first(topology_thread_cpumask(cpu));
+       group = cpumask_first(topology_thread_cpumask(cpu));
 #else
        return cpu;
 #endif
+       if (likely(group < NR_CPUS))
+               return group;
+       return cpu;
 }
 
-static inline int blk_do_io_stat(struct request_queue *q)
+/*
+ * Contribute to IO statistics IFF:
+ *
+ *     a) it's attached to a gendisk, and
+ *     b) the queue had IO stats enabled when this request was started, and
+ *     c) it's a file system request or a discard request
+ */
+static inline int blk_do_io_stat(struct request *rq)
 {
-       if (q)
-               return blk_queue_io_stat(q);
-
-       return 0;
+       return rq->rq_disk &&
+              (rq->cmd_flags & REQ_IO_STAT) &&
+              (rq->cmd_type == REQ_TYPE_FS ||
+               (rq->cmd_flags & REQ_DISCARD));
 }
 
 #endif