All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Damien Le Moal <damien.lemoal@wdc.com>
Cc: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: Re: [PATCH 2/2] block: null_blk: Fix zoned command handling
Date: Tue, 31 Mar 2020 01:28:32 -0700	[thread overview]
Message-ID: <20200331082832.GC14655@infradead.org> (raw)
In-Reply-To: <20200330040116.178731-3-damien.lemoal@wdc.com>

> +blk_status_t null_handle_badblocks(struct nullb_cmd *cmd,
> +				   sector_t sector, sector_t nr_sectors);
> +blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, enum req_opf op);
> +
> +static inline blk_status_t null_process_cmd(struct nullb_cmd *cmd,
> +					    enum req_opf op, sector_t sector,
> +					    unsigned int nr_sectors)
> +{
> +	struct nullb_device *dev = cmd->nq->dev;
> +	blk_status_t ret;
> +
> +	if (dev->badblocks.shift != -1) {
> +		ret = null_handle_badblocks(cmd, sector, nr_sectors);
> +		if (ret != BLK_STS_OK)
> +			return ret;
> +	}
> +
> +	if (dev->memory_backed)
> +		return null_handle_memory_backed(cmd, op);
> +
> +	return BLK_STS_OK;

I think this should remaing non-inlined in null_blk_main.c.

> +blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, enum req_opf op)
>  {
>  	struct nullb_device *dev = cmd->nq->dev;
>  	int err;
>  
> +	if (!dev->memory_backed)
> +		return BLK_STS_OK;

Why does this duplicate the check done in the caller?

> +	if (dev->zoned) {
> +		cmd->error = null_handle_zoned(cmd, op, sector, nr_sectors);
> +		goto out;
>  	}
>  
> +	cmd->error = null_process_cmd(cmd, op, sector, nr_sectors);

Why not:

	if (dev->zoned)
		cmd->error = null_handle_zoned(cmd, op, sector, nr_sectors);
	else
		cmd->error = null_process_cmd(cmd, op, sector, nr_sectors);

And maybe rename null_handle_zoned to null_process_zoned_cmd to keep
things symmetric.

      parent reply	other threads:[~2020-03-31  8:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30  4:01 [PATCH 0/2] null_blk cleanup and fix Damien Le Moal
2020-03-30  4:01 ` [PATCH 1/2] null_blk: Cleanup zoned device initialization Damien Le Moal
2020-03-30  5:55   ` Johannes Thumshirn
2020-03-31  8:25   ` Christoph Hellwig
2020-03-30  4:01 ` [PATCH 2/2] block: null_blk: Fix zoned command handling Damien Le Moal
2020-03-30  5:59   ` Johannes Thumshirn
2020-03-31  8:28   ` Christoph Hellwig [this message]

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=20200331082832.GC14655@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@wdc.com \
    --cc=johannes.thumshirn@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.