<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <HTML ><HEAD ><TITLE >blk_init_queue</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="The Linux Kernel API" HREF="book1.html"><LINK REL="UP" TITLE="Block Devices" HREF="c11504.html"><LINK REL="PREVIOUS" TITLE="blk_queue_make_request" HREF="r11576.html"><LINK REL="NEXT" TITLE="generic_make_request" HREF="r11663.html"></HEAD ><BODY CLASS="REFENTRY" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The Linux Kernel API</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="r11576.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="r11663.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="AEN11616" ></A ><SPAN CLASS="phrase" ><SPAN CLASS="PHRASE" >blk_init_queue</SPAN ></SPAN ></H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN11620" ></A ><H2 >Name</H2 >blk_init_queue -- prepare a request queue for use with a block device </DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN11623" ></A ><H2 >Synopsis</H2 ><DIV CLASS="FUNCSYNOPSIS" ><A NAME="AEN11625" ></A ><P ></P ><P ><CODE ><CODE CLASS="FUNCDEF" >void <TT CLASS="FUNCTION" >blk_init_queue </TT ></CODE >(request_queue_t * <TT CLASS="PARAMETER" ><I >q</I ></TT >, request_fn_proc * <TT CLASS="PARAMETER" ><I >rfn</I ></TT >);</CODE ></P ><P ></P ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN11633" ></A ><H2 >Arguments</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="PARAMETER" ><I >q</I ></TT ></DT ><DD ><P > The &request_queue_t to be initialised </P ></DD ><DT ><TT CLASS="PARAMETER" ><I >rfn</I ></TT ></DT ><DD ><P > The function to be called to process requests that have been placed on the queue. </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN11646" ></A ><H2 >Description</H2 ><P > If a block device wishes to use the standard request handling procedures, which sorts requests and coalesces adjacent requests, then it must call <TT CLASS="FUNCTION" >blk_init_queue</TT >. The function <TT CLASS="PARAMETER" ><I >rfn</I ></TT > will be called when there are requests on the queue that need to be processed. If the device supports plugging, then <TT CLASS="PARAMETER" ><I >rfn</I ></TT > may not be called immediately when requests are available on the queue, but may be called at some time later instead. Plugged queues are generally unplugged when a buffer belonging to one of the requests on the queue is needed, or due to memory pressure. </P ><P > <TT CLASS="PARAMETER" ><I >rfn</I ></TT > is not required, or even expected, to remove all requests off the queue, but only as many as it can handle at a time. If it does leave requests on the queue, it is responsible for arranging that the requests get dealt with eventually. </P ><P > A global spin lock <TT CLASS="ENVAR" >$io_request_lock</TT > must be held while manipulating the requests on the request queue. </P ><P > The request on the head of the queue is by default assumed to be potentially active, and it is not considered for re-ordering or merging whenever the given queue is unplugged. This behaviour can be changed with <TT CLASS="FUNCTION" >blk_queue_headactive</TT >. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN11658" ></A ><H2 >Note</H2 ><P > <TT CLASS="FUNCTION" >blk_init_queue</TT > must be paired with a <TT CLASS="FUNCTION" >blk_cleanup_queue</TT > call when the block device is deactivated (such as at module unload). </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="r11576.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="book1.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="r11663.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><SPAN CLASS="phrase" ><SPAN CLASS="PHRASE" >blk_queue_make_request</SPAN ></SPAN ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="c11504.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><SPAN CLASS="phrase" ><SPAN CLASS="PHRASE" >generic_make_request</SPAN ></SPAN ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >