Message ID | 20230424203329.2369688-6-bvanassche@acm.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mq-deadline: Improve support for zoned block devices | expand |
On Mon, Apr 24, 2023 at 01:33:25PM -0700, Bart Van Assche wrote: > Make the deadline_skip_seq_writes() code shorter without changing its > functionality. > > Reviewed-by: Damien Le Moal <dlemoal@kernel.org> > Cc: Christoph Hellwig <hch@lst.de> > Cc: Ming Lei <ming.lei@redhat.com> > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > --- > block/mq-deadline.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/block/mq-deadline.c b/block/mq-deadline.c > index a016cafa54b3..6276afede9cd 100644 > --- a/block/mq-deadline.c > +++ b/block/mq-deadline.c > @@ -304,14 +304,11 @@ static struct request *deadline_skip_seq_writes(struct deadline_data *dd, > struct request *rq) > { > sector_t pos = blk_rq_pos(rq); > - sector_t skipped_sectors = 0; > > - while (rq) { > - if (blk_rq_pos(rq) != pos + skipped_sectors) > - break; > - skipped_sectors += blk_rq_sectors(rq); > + do { > + pos += blk_rq_sectors(rq); > rq = deadline_latter_request(rq); > - } > + } while (rq && blk_rq_pos(rq) == pos); Looks good, although I'd maybe rename pos to next_pos for clarity. Reviewed-by: Christoph Hellwig <hch@lst.de>
diff --git a/block/mq-deadline.c b/block/mq-deadline.c index a016cafa54b3..6276afede9cd 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -304,14 +304,11 @@ static struct request *deadline_skip_seq_writes(struct deadline_data *dd, struct request *rq) { sector_t pos = blk_rq_pos(rq); - sector_t skipped_sectors = 0; - while (rq) { - if (blk_rq_pos(rq) != pos + skipped_sectors) - break; - skipped_sectors += blk_rq_sectors(rq); + do { + pos += blk_rq_sectors(rq); rq = deadline_latter_request(rq); - } + } while (rq && blk_rq_pos(rq) == pos); return rq; }