The book ldd says for the function blk_queue_segment_boundary() like this:
Some devices cannot handle requests that cross a particular size
memory bound- ary; if your device is one of those, use this function
to tell the kernel about that boundary. For example, if your device
has trouble with requests that cross a 4- MB boundary, pass in a mask
of 0x3fffff. The default mask is 0xffffffff.
I don’t quite understand what the boundary means here, for example, I have a virtual block device, which are made of indeed 4MB files, so I want a request not exceed 4MB boundary,
unsigned long sector = blk_rq_pos(req);
unsigned long offset = sector << 9;
unsigned long nbytes = blk_rq_bytes(req);
int file_offset = offset % (1 << 22);
What I want is that (file_offset + nbytes) not greater than 4M, but indeed sometimes it exceeds 4M,
so, is there any misunderstanding of blk_queue_segment_boundary() ?
Some controllers (particulary IDE) can not handle DMA requests that cross memory regions at 4MB. Think of it as segment:index addressing where index can not be larger that the set boundary.
There is also a
blk_queue_max_segment_size. Both are used to construct correct requests to the device – requests get reordered and merged.There are other uses. For example, from
xen-blkfront.c:Requests are limited to
PAGE_SIZEfor better performance.