From: Christoph Hellwig <hch@lst.de>
To: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: linux-block@vger.kernel.org, hch@lst.de, bvanassche@acm.org,
axboe@kernel.dk
Subject: Re: [PATCH 2/5] null_blk: create a helper for badblocks
Date: Mon, 1 Jul 2019 08:29:15 +0200 [thread overview]
Message-ID: <20190701062915.GG20073@lst.de> (raw)
In-Reply-To: <20190629050442.8459-3-chaitanya.kulkarni@wdc.com>
> + if (dev->queue_mode == NULL_Q_BIO &&
> + bio_op(cmd->bio) != REQ_OP_FLUSH) {
> + is_flush = false;
> + sector = cmd->bio->bi_iter.bi_sector;
> + size = bio_sectors(cmd->bio);
> + }
> + if (dev->queue_mode != NULL_Q_BIO &&
> + req_op(cmd->rq) != REQ_OP_FLUSH) {
> + is_flush = false;
> + sector = blk_rq_pos(cmd->rq);
> + size = blk_rq_sectors(cmd->rq);
> + }
> + if (is_flush)
> + goto out;
This isn't really new in your patch, but looks very odd. Why not:
if (dev->queue_mode == NULL_Q_BIO) {
if (bio_op(cmd->bio) == REQ_OP_FLUSH)
return BLK_STS_OK;
sector = cmd->bio->bi_iter.bi_sector;
size = bio_sectors(cmd->bio);
} else {
if (req_op(cmd->rq) == REQ_OP_FLUSH)
return BLK_STS_OK;
sector = blk_rq_pos(cmd->rq);
size = blk_rq_sectors(cmd->rq);
}
> + if (badblocks_check(bb, sector, size, &first_bad, &bad_sectors)) {
> + cmd->error = BLK_STS_IOERR;
> + sts = BLK_STS_IOERR;
> + }
> +out:
> + return sts;
Also I find the idea of a goto label that just does a return rather odd.
Please just return directly to make it obvious what is going on.
But in general for the whole series: I'd much prefer moving the
bio vs request handling out of null_handle_cmd and into the callers
rather than hiding them one layer deeper in helpers. Patch 1 is
a good help for that, and anything else factoring out common code,
but code for request vs bio should much rather move to the callers.
next prev parent reply other threads:[~2019-07-01 6:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-29 5:04 [PATCH 0/5] null_blk: simplify null_handle_cmd() Chaitanya Kulkarni
2019-06-29 5:04 ` [PATCH 1/5] null_blk: create a helper for throttling Chaitanya Kulkarni
2019-07-01 6:22 ` Christoph Hellwig
2019-06-29 5:04 ` [PATCH 2/5] null_blk: create a helper for badblocks Chaitanya Kulkarni
2019-07-01 6:29 ` Christoph Hellwig [this message]
2019-06-29 5:04 ` [PATCH 3/5] null_blk: create a helper for mem-backed ops Chaitanya Kulkarni
2019-06-29 5:04 ` [PATCH 4/5] null_blk: create a helper for zoned devices Chaitanya Kulkarni
2019-07-01 6:30 ` Christoph Hellwig
2019-06-29 5:04 ` [PATCH 5/5] null_blk: create a helper for req completion Chaitanya Kulkarni
2019-07-01 6:31 ` Christoph Hellwig
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=20190701062915.GG20073@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=chaitanya.kulkarni@wdc.com \
--cc=linux-block@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.