All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Saout <christophe@saout.de>
To: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Possibly wrong BIO usage in ide_multwrite
Date: Mon, 5 Jan 2004 04:52:19 +0100	[thread overview]
Message-ID: <20040105035219.GA6393@leto.cs.pocnet.net> (raw)
In-Reply-To: <200401032302.32914.bzolnier@elka.pw.edu.pl>

Hi Bartlomiej,

I've been playing with the code a bit.

I simple (but not really cleaner) solution to my original problem that
is minimal invasive is to use an unused field from struct request, in
this case nr_cbio_segments. It actually really counts the remaining
segments, only in rq->bio instead of rq->cbio. (The bio_kmap_irq
in ide_map_buffer prevents us from using anything else than rq->bio to
walk the request).

This segment count is then used to correctly restore the bi_idx fields
before ending requests instead of assuming they were zero.

(Well, I just also see that you could probably drop the scratch buffer
and just copy rq->cbio to rq->bio before ending the request... brrr,
no, that's just too ugly...)

BTW, what was ide_multwrite expected to return? These if clauses in
multwrite_intr are never executed.

Please don't shoot me for this proposal.


--- linux.orig/drivers/ide/ide-disk.c	2004-01-04 23:29:01.000000000 +0100
+++ linux/drivers/ide/ide-disk.c	2004-01-04 23:32:32.000000000 +0100
@@ -279,7 +279,7 @@
 			 * all bvecs in this one.
 			 */
 			if (++bio->bi_idx >= bio->bi_vcnt) {
-				bio->bi_idx = 0;
+				bio->bi_idx = bio->bi_vcnt - bio->nr_cbio_segments;
 				bio = bio->bi_next;
 			}
 
@@ -288,7 +288,8 @@
 				mcount = 0;
 			} else {
 				rq->bio = bio;
-				rq->current_nr_sectors = bio_iovec(bio)->bv_len >> 9;
+				rq->nr_cbio_segments = bio_segments(bio);
+				rq->current_nr_sectors = bio_cur_sectors(bio);
 				rq->hard_cur_sectors = rq->current_nr_sectors;
 			}
 		}
@@ -312,6 +313,7 @@
 	ide_hwgroup_t *hwgroup	= HWGROUP(drive);
 	ide_hwif_t *hwif	= HWIF(drive);
 	struct request *rq	= &hwgroup->wrq;
+	struct bio *bio		= rq->bio;
 	u8 stat;
 
 	stat = hwif->INB(IDE_STATUS_REG);
@@ -322,8 +324,10 @@
 			 *	of the request
 			 */
 			if (rq->nr_sectors) {
-				if (ide_multwrite(drive, drive->mult_count))
+				if (ide_multwrite(drive, drive->mult_count)) {
+					bio->bi_idx = bio->bi_vcnt - bio->nr_cbio_segments;
 					return ide_stopped;
+				}
 				ide_set_handler(drive, &multwrite_intr, WAIT_CMD, NULL);
 				return ide_started;
 			}
@@ -333,6 +337,7 @@
 			 *	we can end the original request.
 			 */
 			if (!rq->nr_sectors) {	/* all done? */
+				bio->bi_idx = bio->bi_vcnt - bio->nr_cbio_segments;
 				rq = hwgroup->rq;
 				ide_end_request(drive, 1, rq->nr_sectors);
 				return ide_stopped;

  parent reply	other threads:[~2004-01-05  3:52 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-01 17:18 Possibly wrong BIO usage in ide_multwrite Christophe Saout
2004-01-01 11:27 ` Bartlomiej Zolnierkiewicz
2004-01-02  3:20   ` Christophe Saout
2004-01-02  4:43     ` CPRM ?? " Andre Hedrick
2004-01-02 11:30       ` Jens Axboe
2004-01-03  7:53         ` Andre Hedrick
2004-01-03 10:57           ` Jens Axboe
2004-01-03 19:55             ` Andre Hedrick
2004-01-04 10:42               ` Jens Axboe
2004-01-04 22:02                 ` Andre Hedrick
2004-01-05 10:17                   ` Jens Axboe
2004-01-02 12:45       ` Christophe Saout
2004-01-03  7:51         ` Andre Hedrick
2004-01-03 22:02     ` Bartlomiej Zolnierkiewicz
2004-01-04 17:30       ` Christophe Saout
2004-01-05 16:12         ` Bartlomiej Zolnierkiewicz
2004-01-05 16:48           ` Christophe Saout
2004-01-05 19:37           ` Frederik Deweerdt
2004-01-05 20:13             ` Bartlomiej Zolnierkiewicz
2004-01-05  3:52       ` Christophe Saout [this message]
2004-01-05 17:08         ` Bartlomiej Zolnierkiewicz
2004-01-05 22:51           ` Christophe Saout
2004-01-05 23:59             ` Bartlomiej Zolnierkiewicz
2004-01-06 11:33               ` Christophe Saout
2004-01-06 14:38                 ` Bartlomiej Zolnierkiewicz
2004-01-06 15:21                   ` Christophe Saout
2004-01-05  4:03       ` Christophe Saout
2004-01-05 16:47         ` Bartlomiej Zolnierkiewicz
2004-01-05 16:49           ` Jens Axboe
2004-01-05 17:13             ` Bartlomiej Zolnierkiewicz
2004-01-05 18:16               ` Jens Axboe
2004-01-05 18:27                 ` Bartlomiej Zolnierkiewicz
2004-01-01 23:02 ` Andre Hedrick

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040105035219.GA6393@leto.cs.pocnet.net \
    --to=christophe@saout.de \
    --cc=B.Zolnierkiewicz@elka.pw.edu.pl \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.