|
@@ -0,0 +1,130 @@
|
|
|
+/*
|
|
|
+ * Functions related to setting various queue properties from drivers
|
|
|
+ */
|
|
|
+#include <linux/kernel.h>
|
|
|
+#include <linux/module.h>
|
|
|
+#include <linux/init.h>
|
|
|
+#include <linux/bio.h>
|
|
|
+#include <linux/blkdev.h>
|
|
|
+#include <linux/bootmem.h> /* for max_pfn/max_low_pfn */
|
|
|
+#include <linux/gcd.h>
|
|
|
+#include <linux/lcm.h>
|
|
|
+#include <linux/jiffies.h>
|
|
|
+#include <linux/gfp.h>
|
|
|
+
|
|
|
+#include "blk.h"
|
|
|
+
|
|
|
+unsigned long blk_max_low_pfn;
|
|
|
+EXPORT_SYMBOL(blk_max_low_pfn);
|
|
|
+
|
|
|
+unsigned long blk_max_pfn;
|
|
|
+
|
|
|
+/**
|
|
|
+ * blk_queue_prep_rq - set a prepare_request function for queue
|
|
|
+ * @q: queue
|
|
|
+ * @pfn: prepare_request function
|
|
|
+ *
|
|
|
+ * It's possible for a queue to register a prepare_request callback which
|
|
|
+ * is invoked before the request is handed to the request_fn. The goal of
|
|
|
+ * the function is to prepare a request for I/O, it can be used to build a
|
|
|
+ * cdb from the request data for instance.
|
|
|
+ *
|
|
|
+ */
|
|
|
+void blk_queue_prep_rq(struct request_queue *q, prep_rq_fn *pfn)
|
|
|
+{
|
|
|
+ q->prep_rq_fn = pfn;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(blk_queue_prep_rq);
|
|
|
+
|
|
|
+/**
|
|
|
+ * blk_queue_unprep_rq - set an unprepare_request function for queue
|
|
|
+ * @q: queue
|
|
|
+ * @ufn: unprepare_request function
|
|
|
+ *
|
|
|
+ * It's possible for a queue to register an unprepare_request callback
|
|
|
+ * which is invoked before the request is finally completed. The goal
|
|
|
+ * of the function is to deallocate any data that was allocated in the
|
|
|
+ * prepare_request callback.
|
|
|
+ *
|
|
|
+ */
|
|
|
+void blk_queue_unprep_rq(struct request_queue *q, unprep_rq_fn *ufn)
|
|
|
+{
|
|
|
+ q->unprep_rq_fn = ufn;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(blk_queue_unprep_rq);
|
|
|
+
|
|
|
+/**
|
|
|
+ * blk_queue_merge_bvec - set a merge_bvec function for queue
|
|
|
+ * @q: queue
|
|
|
+ * @mbfn: merge_bvec_fn
|
|
|
+ *
|
|
|
+ * Usually queues have static limitations on the max sectors or segments that
|
|
|
+ * we can put in a request. Stacking drivers may have some settings that
|
|
|
+ * are dynamic, and thus we have to query the queue whether it is ok to
|
|
|
+ * add a new bio_vec to a bio at a given offset or not. If the block device
|
|
|
+ * has such limitations, it needs to register a merge_bvec_fn to control
|
|
|
+ * the size of bio's sent to it. Note that a block device *must* allow a
|
|
|
+ * single page to be added to an empty bio. The block device driver may want
|
|
|
+ * to use the bio_split() function to deal with these bio's. By default
|
|
|
+ * no merge_bvec_fn is defined for a queue, and only the fixed limits are
|
|
|
+ * honored.
|
|
|
+ */
|
|
|
+void blk_queue_merge_bvec(struct request_queue *q, merge_bvec_fn *mbfn)
|
|
|
+{
|
|
|
+ q->merge_bvec_fn = mbfn;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(blk_queue_merge_bvec);
|
|
|
+
|
|
|
+void blk_queue_softirq_done(struct request_queue *q, softirq_done_fn *fn)
|
|
|
+{
|
|
|
+ q->softirq_done_fn = fn;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(blk_queue_softirq_done);
|
|
|
+
|
|
|
+void blk_queue_rq_timeout(struct request_queue *q, unsigned int timeout)
|
|
|
+{
|
|
|
+ q->rq_timeout = timeout;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(blk_queue_rq_timeout);
|
|
|
+
|
|
|
+void blk_queue_rq_timed_out(struct request_queue *q, rq_timed_out_fn *fn)
|
|
|
+{
|
|
|
+ q->rq_timed_out_fn = fn;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(blk_queue_rq_timed_out);
|
|
|
+
|
|
|
+void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn)
|
|
|
+{
|
|
|
+ q->lld_busy_fn = fn;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL_GPL(blk_queue_lld_busy);
|
|
|
+
|
|
|
+/**
|
|
|
+ * blk_set_default_limits - reset limits to default values
|
|
|
+ * @lim: the queue_limits structure to reset
|
|
|
+ *
|
|
|
+ * Description:
|
|
|
+ * Returns a queue_limit struct to its default state.
|
|
|
+ */
|
|
|
+void blk_set_default_limits(struct queue_limits *lim)
|
|
|
+{
|
|
|
+ lim->max_segments = BLK_MAX_SEGMENTS;
|
|
|
+ lim->max_integrity_segments = 0;
|
|
|
+ lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
|
|
|
+ lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
|
|
|
+ lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
|
|
|
+ lim->max_write_same_sectors = 0;
|
|
|
+ lim->max_discard_sectors = 0;
|
|
|
+ lim->discard_granularity = 0;
|
|
|
+ lim->discard_alignment = 0;
|
|
|
+ lim->discard_misaligned = 0;
|
|
|
+ lim->discard_zeroes_data = 0;
|
|
|
+ lim->logical_block_size = lim->physical_block_size = lim->io_min = 512;
|
|
|
+ lim->bounce_pfn = (unsigned long)(BLK_BOUNCE_ANY >> PAGE_SHIFT);
|
|
|
+ lim->alignment_offset = 0;
|
|
|
+ lim->io_opt = 0;
|
|
|
+ lim->misaligned = 0;
|
|
|
+ lim->cluster = 1;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(blk_set_default_limits);
|
|
|
+
|