Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
blk-settings.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/bio.h>
#include <linux/blkdev.h>
#include <linux/bootmem.h>
#include <linux/gcd.h>
#include <linux/lcm.h>
#include <linux/jiffies.h>
#include <linux/gfp.h>
#include "blk.h"

Go to the source code of this file.

Functions

 EXPORT_SYMBOL (blk_max_low_pfn)
 
void blk_queue_prep_rq (struct request_queue *q, prep_rq_fn *pfn)
 
 EXPORT_SYMBOL (blk_queue_prep_rq)
 
void blk_queue_unprep_rq (struct request_queue *q, unprep_rq_fn *ufn)
 
 EXPORT_SYMBOL (blk_queue_unprep_rq)
 
void blk_queue_merge_bvec (struct request_queue *q, merge_bvec_fn *mbfn)
 
 EXPORT_SYMBOL (blk_queue_merge_bvec)
 
void blk_queue_softirq_done (struct request_queue *q, softirq_done_fn *fn)
 
 EXPORT_SYMBOL (blk_queue_softirq_done)
 
void blk_queue_rq_timeout (struct request_queue *q, unsigned int timeout)
 
 EXPORT_SYMBOL_GPL (blk_queue_rq_timeout)
 
void blk_queue_rq_timed_out (struct request_queue *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)
 
 EXPORT_SYMBOL_GPL (blk_queue_lld_busy)
 
void blk_set_default_limits (struct queue_limits *lim)
 
 EXPORT_SYMBOL (blk_set_default_limits)
 
void blk_set_stacking_limits (struct queue_limits *lim)
 
 EXPORT_SYMBOL (blk_set_stacking_limits)
 
void blk_queue_make_request (struct request_queue *q, make_request_fn *mfn)
 
 EXPORT_SYMBOL (blk_queue_make_request)
 
void blk_queue_bounce_limit (struct request_queue *q, u64 dma_mask)
 
 EXPORT_SYMBOL (blk_queue_bounce_limit)
 
void blk_limits_max_hw_sectors (struct queue_limits *limits, unsigned int max_hw_sectors)
 
 EXPORT_SYMBOL (blk_limits_max_hw_sectors)
 
void blk_queue_max_hw_sectors (struct request_queue *q, unsigned int max_hw_sectors)
 
 EXPORT_SYMBOL (blk_queue_max_hw_sectors)
 
void blk_queue_max_discard_sectors (struct request_queue *q, unsigned int max_discard_sectors)
 
 EXPORT_SYMBOL (blk_queue_max_discard_sectors)
 
void blk_queue_max_write_same_sectors (struct request_queue *q, unsigned int max_write_same_sectors)
 
 EXPORT_SYMBOL (blk_queue_max_write_same_sectors)
 
void blk_queue_max_segments (struct request_queue *q, unsigned short max_segments)
 
 EXPORT_SYMBOL (blk_queue_max_segments)
 
void blk_queue_max_segment_size (struct request_queue *q, unsigned int max_size)
 
 EXPORT_SYMBOL (blk_queue_max_segment_size)
 
void blk_queue_logical_block_size (struct request_queue *q, unsigned short size)
 
 EXPORT_SYMBOL (blk_queue_logical_block_size)
 
void blk_queue_physical_block_size (struct request_queue *q, unsigned int size)
 
 EXPORT_SYMBOL (blk_queue_physical_block_size)
 
void blk_queue_alignment_offset (struct request_queue *q, unsigned int offset)
 
 EXPORT_SYMBOL (blk_queue_alignment_offset)
 
void blk_limits_io_min (struct queue_limits *limits, unsigned int min)
 
 EXPORT_SYMBOL (blk_limits_io_min)
 
void blk_queue_io_min (struct request_queue *q, unsigned int min)
 
 EXPORT_SYMBOL (blk_queue_io_min)
 
void blk_limits_io_opt (struct queue_limits *limits, unsigned int opt)
 
 EXPORT_SYMBOL (blk_limits_io_opt)
 
void blk_queue_io_opt (struct request_queue *q, unsigned int opt)
 
 EXPORT_SYMBOL (blk_queue_io_opt)
 
void blk_queue_stack_limits (struct request_queue *t, struct request_queue *b)
 
 EXPORT_SYMBOL (blk_queue_stack_limits)
 
int blk_stack_limits (struct queue_limits *t, struct queue_limits *b, sector_t start)
 
 EXPORT_SYMBOL (blk_stack_limits)
 
int bdev_stack_limits (struct queue_limits *t, struct block_device *bdev, sector_t start)
 
 EXPORT_SYMBOL (bdev_stack_limits)
 
void disk_stack_limits (struct gendisk *disk, struct block_device *bdev, sector_t offset)
 
 EXPORT_SYMBOL (disk_stack_limits)
 
void blk_queue_dma_pad (struct request_queue *q, unsigned int mask)
 
 EXPORT_SYMBOL (blk_queue_dma_pad)
 
void blk_queue_update_dma_pad (struct request_queue *q, unsigned int mask)
 
 EXPORT_SYMBOL (blk_queue_update_dma_pad)
 
int blk_queue_dma_drain (struct request_queue *q, dma_drain_needed_fn *dma_drain_needed, void *buf, unsigned int size)
 
 EXPORT_SYMBOL_GPL (blk_queue_dma_drain)
 
void blk_queue_segment_boundary (struct request_queue *q, unsigned long mask)
 
 EXPORT_SYMBOL (blk_queue_segment_boundary)
 
void blk_queue_dma_alignment (struct request_queue *q, int mask)
 
 EXPORT_SYMBOL (blk_queue_dma_alignment)
 
void blk_queue_update_dma_alignment (struct request_queue *q, int mask)
 
 EXPORT_SYMBOL (blk_queue_update_dma_alignment)
 
void blk_queue_flush (struct request_queue *q, unsigned int flush)
 
 EXPORT_SYMBOL_GPL (blk_queue_flush)
 
void blk_queue_flush_queueable (struct request_queue *q, bool queueable)
 
 EXPORT_SYMBOL_GPL (blk_queue_flush_queueable)
 
 subsys_initcall (blk_settings_init)
 

Variables

unsigned long blk_max_low_pfn
 
unsigned long blk_max_pfn
 

Function Documentation

int bdev_stack_limits ( struct queue_limits *  t,
struct block_device bdev,
sector_t  start 
)

bdev_stack_limits - adjust queue limits for stacked drivers : the stacking driver limits (top device) : the component block_device (bottom) : first data sector within component device

Description: Merges queue limits for a top device and a block_device. Returns 0 if alignment didn't change. Returns -1 if adding the bottom device caused misalignment.

Definition at line 641 of file blk-settings.c.

void blk_limits_io_min ( struct queue_limits *  limits,
unsigned int  min 
)

blk_limits_io_min - set minimum request size for a device : the queue limits : smallest I/O size in bytes

Description: Some devices have an internal block size bigger than the reported hardware sector size. This function can be used to signal the smallest I/O the device can perform without incurring a performance penalty.

Definition at line 418 of file blk-settings.c.

void blk_limits_io_opt ( struct queue_limits *  limits,
unsigned int  opt 
)

blk_limits_io_opt - set optimal request size for a device : the queue limits : smallest I/O size in bytes

Description: Storage devices may report an optimal I/O size, which is the device's preferred unit for sustained I/O. This is rarely reported for disk drives. For RAID arrays it is usually the stripe width or the internal track size. A properly aligned multiple of optimal_io_size is the preferred request size for workloads where sustained throughput is desired.

Definition at line 463 of file blk-settings.c.

void blk_limits_max_hw_sectors ( struct queue_limits *  limits,
unsigned int  max_hw_sectors 
)

blk_limits_max_hw_sectors - set hard and soft limit of max sectors for request : the queue limits : max hardware sectors in the usual 512b unit

Description: Enables a low level driver to set a hard upper limit, max_hw_sectors, on the size of requests. max_hw_sectors is set by the device driver based upon the combined capabilities of I/O controller and storage device.

max_sectors is a soft limit imposed by the block layer for filesystem type requests. This value can be overridden on a per-device basis in /sys/block/<device>/queue/max_sectors_kb. The soft limit can not exceed max_hw_sectors.

Definition at line 250 of file blk-settings.c.

void blk_queue_alignment_offset ( struct request_queue q,
unsigned int  offset 
)

blk_queue_alignment_offset - set physical block alignment offset : the request queue for the device : alignment offset in bytes

Description: Some devices are naturally misaligned to compensate for things like the legacy DOS partition table 63-sector offset. Low-level drivers should call this function for devices whose first sector is not naturally aligned.

Definition at line 399 of file blk-settings.c.

void blk_queue_bounce_limit ( struct request_queue q,
u64  dma_mask 
)

blk_queue_bounce_limit - set bounce buffer limit for queue : the request queue for the device : the maximum address the device can handle

Description: Different hardware can have different requirements as to what pages it can do I/O directly to. A low level driver can call blk_queue_bounce_limit to have lower memory pages allocated as bounce buffers for doing I/O to pages residing above .

Definition at line 206 of file blk-settings.c.

void blk_queue_dma_alignment ( struct request_queue q,
int  mask 
)

blk_queue_dma_alignment - set dma length and memory alignment : the request queue for the device : alignment mask

description: set required memory and length alignment for direct dma transactions. this is used when building direct io requests for the queue.

Definition at line 776 of file blk-settings.c.

int blk_queue_dma_drain ( struct request_queue q,
dma_drain_needed_fn *  dma_drain_needed,
void buf,
unsigned int  size 
)

blk_queue_dma_drain - Set up a drain buffer for excess dma. : the request queue for the device : fn which returns non-zero if drain is necessary : physically contiguous buffer : size of the buffer in bytes

Some devices have excess DMA problems and can't simply discard (or zero fill) the unwanted piece of the transfer. They have to have a real area of memory to transfer it into. The use case for this is ATAPI devices in DMA mode. If the packet command causes a transfer bigger than the transfer size some HBAs will lock up if there aren't DMA elements to contain the excess transfer. What this API does is adjust the queue so that the buf is always appended silently to the scatterlist.

Note: This routine adjusts max_hw_segments to make room for appending the drain buffer. If you call blk_queue_max_segments() after calling this routine, you must set the limit to one fewer than your device can support otherwise there won't be room for the drain buffer.

Definition at line 733 of file blk-settings.c.

void blk_queue_dma_pad ( struct request_queue q,
unsigned int  mask 
)

blk_queue_dma_pad - set pad mask : the request queue for the device : pad mask

Set dma pad mask.

Appending pad buffer to a request modifies the last entry of a scatter list such that it includes the pad buffer.

Definition at line 689 of file blk-settings.c.

void blk_queue_flush ( struct request_queue q,
unsigned int  flush 
)

blk_queue_flush - configure queue's cache flush capability : the request queue for the device : 0, REQ_FLUSH or REQ_FLUSH | REQ_FUA

Tell block layer cache flush capability of . If it supports flushing, REQ_FLUSH should be set. If it supports bypassing write cache for individual writes, REQ_FUA should be set.

Definition at line 814 of file blk-settings.c.

void blk_queue_flush_queueable ( struct request_queue q,
bool  queueable 
)

Definition at line 825 of file blk-settings.c.

void blk_queue_io_min ( struct request_queue q,
unsigned int  min 
)

blk_queue_io_min - set minimum request size for the queue : the request queue for the device : smallest I/O size in bytes

Description: Storage devices may report a granularity or preferred minimum I/O size which is the smallest request the device can perform without incurring a performance penalty. For disk drives this is often the physical block size. For RAID arrays it is often the stripe chunk size. A properly aligned multiple of minimum_io_size is the preferred request size for workloads where a high number of I/O operations is desired.

Definition at line 444 of file blk-settings.c.

void blk_queue_io_opt ( struct request_queue q,
unsigned int  opt 
)

blk_queue_io_opt - set optimal request size for the queue : the request queue for the device : optimal request size in bytes

Description: Storage devices may report an optimal I/O size, which is the device's preferred unit for sustained I/O. This is rarely reported for disk drives. For RAID arrays it is usually the stripe width or the internal track size. A properly aligned multiple of optimal_io_size is the preferred request size for workloads where sustained throughput is desired.

Definition at line 482 of file blk-settings.c.

void blk_queue_lld_busy ( struct request_queue q,
lld_busy_fn *  fn 
)

Definition at line 96 of file blk-settings.c.

void blk_queue_logical_block_size ( struct request_queue q,
unsigned short  size 
)

blk_queue_logical_block_size - set logical block size for the queue : the request queue for the device : the logical block size, in bytes

Description: This should be set to the lowest possible block size that the storage device can address. The default of 512 covers most hardware.

Definition at line 354 of file blk-settings.c.

void blk_queue_make_request ( struct request_queue q,
make_request_fn *  mfn 
)

blk_queue_make_request - define an alternate make_request function for a device : the request queue for the device to be affected : the alternate make_request function

Description: The normal way for &struct bios to be passed to a device driver is for them to be collected into requests on a request queue, and then to allow the device driver to select requests off that queue when it is ready. This works well for many block devices. However some block devices (typically virtual devices such as md or lvm) do not benefit from the processing on the request queue, and are served best by having the requests passed directly to them. This can be achieved by providing a function to blk_queue_make_request().

Caveat: The driver that does this must be able to deal appropriately with buffers in "highmemory". This can be accomplished by either calling __bio_kmap_atomic() to get a temporary kernel mapping, or by calling blk_queue_bounce() to create a buffer in normal memory.

Definition at line 174 of file blk-settings.c.

void blk_queue_max_discard_sectors ( struct request_queue q,
unsigned int  max_discard_sectors 
)

blk_queue_max_discard_sectors - set max sectors for a single discard : the request queue for the device : maximum number of sectors to discard

Definition at line 283 of file blk-settings.c.

void blk_queue_max_hw_sectors ( struct request_queue q,
unsigned int  max_hw_sectors 
)

blk_queue_max_hw_sectors - set max sectors for a request for this queue : the request queue for the device : max hardware sectors in the usual 512b unit

Description: See description for blk_limits_max_hw_sectors().

Definition at line 272 of file blk-settings.c.

void blk_queue_max_segment_size ( struct request_queue q,
unsigned int  max_size 
)

blk_queue_max_segment_size - set max segment size for blk_rq_map_sg : the request queue for the device : max size of segment in bytes

Description: Enables a low level driver to set an upper limit on the size of a coalesced segment

Definition at line 332 of file blk-settings.c.

void blk_queue_max_segments ( struct request_queue q,
unsigned short  max_segments 
)

blk_queue_max_segments - set max hw segments for a request for this queue : the request queue for the device : max number of segments

Description: Enables a low level driver to set an upper limit on the number of hw data segments in a request.

Definition at line 311 of file blk-settings.c.

void blk_queue_max_write_same_sectors ( struct request_queue q,
unsigned int  max_write_same_sectors 
)

blk_queue_max_write_same_sectors - set max sectors for a single write same : the request queue for the device : maximum number of sectors to write per command

Definition at line 295 of file blk-settings.c.

void blk_queue_merge_bvec ( struct request_queue q,
merge_bvec_fn *  mbfn 
)

blk_queue_merge_bvec - set a merge_bvec function for queue : queue : 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.

Definition at line 72 of file blk-settings.c.

void blk_queue_physical_block_size ( struct request_queue q,
unsigned int  size 
)

blk_queue_physical_block_size - set physical block size for the queue : the request queue for the device : the physical block size, in bytes

Description: This should be set to the lowest possible sector size that the hardware can operate on without reverting to read-modify-write operations.

Definition at line 376 of file blk-settings.c.

void blk_queue_prep_rq ( struct request_queue q,
prep_rq_fn *  pfn 
)

blk_queue_prep_rq - set a prepare_request function for queue : queue : 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.

Definition at line 33 of file blk-settings.c.

void blk_queue_rq_timed_out ( struct request_queue q,
rq_timed_out_fn *  fn 
)

Definition at line 90 of file blk-settings.c.

void blk_queue_rq_timeout ( struct request_queue q,
unsigned int  timeout 
)

Definition at line 84 of file blk-settings.c.

void blk_queue_segment_boundary ( struct request_queue q,
unsigned long  mask 
)

blk_queue_segment_boundary - set boundary rules for segment merging : the request queue for the device : the memory boundary mask

Definition at line 754 of file blk-settings.c.

void blk_queue_softirq_done ( struct request_queue q,
softirq_done_fn *  fn 
)

Definition at line 78 of file blk-settings.c.

void blk_queue_stack_limits ( struct request_queue t,
struct request_queue b 
)

blk_queue_stack_limits - inherit underlying queue limits for stacked drivers : the stacking driver (top) : the underlying device (bottom)

Definition at line 493 of file blk-settings.c.

void blk_queue_unprep_rq ( struct request_queue q,
unprep_rq_fn *  ufn 
)

blk_queue_unprep_rq - set an unprepare_request function for queue : queue : 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.

Definition at line 50 of file blk-settings.c.

void blk_queue_update_dma_alignment ( struct request_queue q,
int  mask 
)

blk_queue_update_dma_alignment - update dma length and memory alignment : the request queue for the device : alignment mask

description: update required memory and length alignment for direct dma transactions. If the requested alignment is larger than the current alignment, then the current queue alignment is updated to the new value, otherwise it is left alone. The design of this is to allow multiple objects (driver, device, transport etc) to set their respective alignments without having them interfere.

Definition at line 796 of file blk-settings.c.

void blk_queue_update_dma_pad ( struct request_queue q,
unsigned int  mask 
)

blk_queue_update_dma_pad - update pad mask : the request queue for the device : pad mask

Update dma pad mask.

Appending pad buffer to a request modifies the last entry of a scatter list such that it includes the pad buffer.

Definition at line 705 of file blk-settings.c.

void blk_set_default_limits ( struct queue_limits *  lim)

blk_set_default_limits - reset limits to default values : the queue_limits structure to reset

Description: Returns a queue_limit struct to its default state.

Definition at line 109 of file blk-settings.c.

void blk_set_stacking_limits ( struct queue_limits *  lim)

blk_set_stacking_limits - set default limits for stacking devices : the queue_limits structure to reset

Description: Returns a queue_limit struct to its default state. Should be used by stacking drivers like DM that have no internal limits.

Definition at line 139 of file blk-settings.c.

int blk_stack_limits ( struct queue_limits *  t,
struct queue_limits *  b,
sector_t  start 
)

blk_stack_limits - adjust queue_limits for stacked devices : the stacking driver limits (top device) : the underlying queue limits (bottom, component device) : first data sector within component device

Description: This function is used by stacking drivers like MD and DM to ensure that all component devices have compatible block sizes and alignments. The stacking driver must provide a queue_limits struct (top) and then iteratively call the stacking function for all component (bottom) devices. The stacking function will attempt to combine the values and ensure proper alignment.

Returns 0 if the top and bottom queue_limits are compatible. The top device's block sizes and alignment offsets may be adjusted to ensure alignment with the bottom device. If no compatible sizes and alignments exist, -1 is returned and the resulting top queue_limits will have the misaligned flag set to indicate that the alignment_offset is undefined.

Definition at line 520 of file blk-settings.c.

void disk_stack_limits ( struct gendisk *  disk,
struct block_device bdev,
sector_t  offset 
)

disk_stack_limits - adjust queue limits for stacked drivers : MD/DM gendisk (top) : the underlying block device (bottom) : offset to beginning of data within component device

Description: Merges the limits for a top level gendisk and a bottom level block_device.

Definition at line 662 of file blk-settings.c.

EXPORT_SYMBOL ( blk_max_low_pfn  )
EXPORT_SYMBOL ( blk_queue_prep_rq  )
EXPORT_SYMBOL ( blk_queue_unprep_rq  )
EXPORT_SYMBOL ( blk_queue_merge_bvec  )
EXPORT_SYMBOL ( blk_queue_softirq_done  )
EXPORT_SYMBOL ( blk_set_default_limits  )
EXPORT_SYMBOL ( blk_set_stacking_limits  )
EXPORT_SYMBOL ( blk_queue_make_request  )
EXPORT_SYMBOL ( blk_queue_bounce_limit  )
EXPORT_SYMBOL ( blk_limits_max_hw_sectors  )
EXPORT_SYMBOL ( blk_queue_max_hw_sectors  )
EXPORT_SYMBOL ( blk_queue_max_discard_sectors  )
EXPORT_SYMBOL ( blk_queue_max_write_same_sectors  )
EXPORT_SYMBOL ( blk_queue_max_segments  )
EXPORT_SYMBOL ( blk_queue_max_segment_size  )
EXPORT_SYMBOL ( blk_queue_logical_block_size  )
EXPORT_SYMBOL ( blk_queue_physical_block_size  )
EXPORT_SYMBOL ( blk_queue_alignment_offset  )
EXPORT_SYMBOL ( blk_limits_io_min  )
EXPORT_SYMBOL ( blk_queue_io_min  )
EXPORT_SYMBOL ( blk_limits_io_opt  )
EXPORT_SYMBOL ( blk_queue_io_opt  )
EXPORT_SYMBOL ( blk_queue_stack_limits  )
EXPORT_SYMBOL ( blk_stack_limits  )
EXPORT_SYMBOL ( bdev_stack_limits  )
EXPORT_SYMBOL ( disk_stack_limits  )
EXPORT_SYMBOL ( blk_queue_dma_pad  )
EXPORT_SYMBOL ( blk_queue_update_dma_pad  )
EXPORT_SYMBOL ( blk_queue_segment_boundary  )
EXPORT_SYMBOL ( blk_queue_dma_alignment  )
EXPORT_SYMBOL ( blk_queue_update_dma_alignment  )
EXPORT_SYMBOL_GPL ( blk_queue_rq_timeout  )
EXPORT_SYMBOL_GPL ( blk_queue_rq_timed_out  )
EXPORT_SYMBOL_GPL ( blk_queue_lld_busy  )
EXPORT_SYMBOL_GPL ( blk_queue_dma_drain  )
EXPORT_SYMBOL_GPL ( blk_queue_flush  )
EXPORT_SYMBOL_GPL ( blk_queue_flush_queueable  )
subsys_initcall ( blk_settings_init  )

Variable Documentation

unsigned long blk_max_low_pfn

Definition at line 17 of file blk-settings.c.

unsigned long blk_max_pfn

Definition at line 20 of file blk-settings.c.