lkml.org 
[lkml]   [2002]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: swsusp: don't eat ide disks

    On Sun, 3 Nov 2002, Pavel Machek wrote:
    >
    > How do I quiesce a queue? Is it ll_rw_blk stuff?

    Just send a request down the request list, and make sure that

    - the command is marked as being non-mergeable or re-orderable by
    software (as all special commands are)

    - the command is not re-orderable / mergeable by hardware (and since the
    command in question would be something like "flush" or "spindown",
    hardware really would be quite broken if it re-ordered it ;)

    and then just wait for its completion.

    The code is not that complicated, it looks roughly something like

    struct request *rq;

    rq = blk_get_request(q, WRITE, __GFP_WAIT);
    rq->flags = REQ_BLOCK_PC;
    rq->data = NULL;
    rq->data_len = 0;
    rq->timeout = 5*HZ; /* Or whatever */
    memset(rq->cmd, 0, sizeof(rq->cmd));
    rq->cmd[0] = SYNCHRONIZE_CACHE;
    .. fill in whatever bytes the SYNCHRONIZE_CACHE cmd needs ..
    rq->cmd_len = 10;
    err = blk_do_rq(q, bdev, rq);
    blk_put_request(rq);

    and you're done. The above should work pretty much on all block drivers
    out there, btw: the ones that don't understand SCSI commands should just
    ignore requests that aren't the regular REQ_CMD commands.

    See drivers/block/scsi_ioctl.c for other examples of sending down commands
    to block devices.

    Linus

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:30    [W:2.734 / U:0.032 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site