lkml.org 
[lkml]   [2009]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 11/18] swim: dequeue in-flight request
    Hello.

    Tejun Heo wrote:

    > swim processes requests one-by-one synchronously and can easily be
    > converted to dequeuing model. Convert it.
    >
    > [ Impact: dequeue in-flight request ]
    >
    > Signed-off-by: Tejun Heo <tj@kernel.org>
    > Cc: Laurent Vivier <Laurent@lvivier.info>
    > ---
    > drivers/block/swim.c | 47 +++++++++++++++++++++++------------------------
    > 1 files changed, 23 insertions(+), 24 deletions(-)
    >
    > diff --git a/drivers/block/swim.c b/drivers/block/swim.c
    > index fc6a1c3..dedd489 100644
    > --- a/drivers/block/swim.c
    > +++ b/drivers/block/swim.c
    > @@ -514,7 +514,7 @@ static int floppy_read_sectors(struct floppy_state *fs,
    > ret = swim_read_sector(fs, side, track, sector,
    > buffer);
    > if (try-- == 0)
    > - return -1;
    > + return -EIO;
    > } while (ret != 512);
    >
    > buffer += ret;
    > @@ -528,38 +528,37 @@ static void redo_fd_request(struct request_queue *q)
    > struct request *req;
    > struct floppy_state *fs;
    >
    > - while ((req = elv_next_request(q))) {
    > + req = elv_next_request(q);
    > + if (req)
    > + blkdev_dequeue_request(req);
    > +
    > + while (req) {
    > + int err = -EIO;
    >
    > fs = req->rq_disk->private_data;
    > - if (blk_rq_pos(req) >= fs->total_secs) {
    > - __blk_end_request_cur(req, -EIO);
    > - continue;
    > - }
    > - if (!fs->disk_in) {
    > - __blk_end_request_cur(req, -EIO);
    > - continue;
    > - }
    > - if (rq_data_dir(req) == WRITE) {
    > - if (fs->write_protected) {
    > - __blk_end_request_cur(req, -EIO);
    > - continue;
    > - }
    > - }
    > + if (blk_rq_pos(req) >= fs->total_secs)
    > + goto done;
    > + if (!fs->disk_in)
    > + goto done;
    > + if (rq_data_dir(req) == WRITE && fs->write_protected)
    > + goto done;
    > +
    > switch (rq_data_dir(req)) {
    > case WRITE:
    > /* NOT IMPLEMENTED */
    > - __blk_end_request_cur(req, -EIO);
    > break;
    > case READ:
    > - if (floppy_read_sectors(fs, blk_rq_pos(req),
    > - blk_rq_cur_sectors(req),
    > - req->buffer)) {
    > - __blk_end_request_cur(req, -EIO);
    > - continue;
    > - }
    > - __blk_end_request_cur(req, 0);
    > + err = floppy_read_sectors(fs, blk_rq_pos(req),
    > + blk_rq_cur_sectors(req),
    > + req->buffer);
    > break;
    > }
    > + done:
    > + if (!__blk_end_request_cur(req, err)) {
    > + req = elv_next_request(q);
    > + if (req)
    > + blkdev_dequeue_request(req);
    > + }
    > }
    > }

    And without duplication:

    @@ -528,38 +528,37 @@
    static void redo_fd_request(struct request_queue *q)
    {
    - struct request *req;
    struct floppy_state *fs;

    - while ((req = elv_next_request(q))) {
    + while (1) {
    + struct request *req = elv_next_request(q);
    + int err;
    +
    + if (req == NULL)
    + break;
    + blkdev_dequeue_request(req);

    +again:
    + err = -EIO;
    fs = req->rq_disk->private_data;
    - if (blk_rq_pos(req) >= fs->total_secs) {
    - __blk_end_request_cur(req, -EIO);
    - continue;
    - }
    - if (!fs->disk_in) {
    - __blk_end_request_cur(req, -EIO);
    - continue;
    - }
    - if (rq_data_dir(req) == WRITE) {
    - if (fs->write_protected) {
    - __blk_end_request_cur(req, -EIO);
    - continue;
    - }
    - }
    + if (blk_rq_pos(req) >= fs->total_secs)
    + goto done;
    + if (!fs->disk_in)
    + goto done;
    + if (rq_data_dir(req) == WRITE && fs->write_protected)
    + goto done;
    +
    switch (rq_data_dir(req)) {
    case WRITE:
    /* NOT IMPLEMENTED */
    - __blk_end_request_cur(req, -EIO);
    break;
    case READ:
    - if (floppy_read_sectors(fs, blk_rq_pos(req),
    - blk_rq_cur_sectors(req),
    - req->buffer)) {
    - __blk_end_request_cur(req, -EIO);
    - continue;
    - }
    - __blk_end_request_cur(req, 0);
    + err = floppy_read_sectors(fs, blk_rq_pos(req),
    + blk_rq_cur_sectors(req),
    + req->buffer);
    break;
    }
    + done:
    + if (__blk_end_request_cur(req, err))
    + goto again;
    }
    }


    MBR, Sergei




    \
     
     \ /
      Last update: 2009-05-16 15:45    [W:0.027 / U:62.032 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site