mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Yu Kuai <yukuai1@huaweicloud.com>
Cc: hch@lst.de, axboe@kernel.dk, kbusch@kernel.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	yukuai3@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com,
	johnny.chenyi@huawei.com
Subject: Re: [PATCH v2 1/3] brd: protect page with rcu
Date: Mon, 28 Apr 2025 14:52:07 +0200	[thread overview]
Message-ID: <20250428125207.GB27794@lst.de> (raw)
In-Reply-To: <20250427083925.157984-2-yukuai1@huaweicloud.com>

On Sun, Apr 27, 2025 at 04:39:23PM +0800, Yu Kuai wrote:
>  	page = brd_lookup_page(brd, sector);
>  
>  	kaddr = bvec_kmap_local(&bv);
>  	if (op_is_write(opf)) {
> -		BUG_ON(!page);
> -		memcpy_to_page(page, offset, kaddr, bv.bv_len);
> +		if (page)
> +			memcpy_to_page(page, offset, kaddr, bv.bv_len);

This could use a comment on why page can be NULL here.

>  	} else if (page) {
>  		memcpy_from_page(kaddr, page, offset, bv.bv_len);
>  	} else {
>  		memset(kaddr, 0, bv.bv_len);

And why the above change my if/else cascade doesn't really make much sense
any more and this should become:

	} else {
		if (page)
	 		memcpy_from_page(kaddr, page, offset, bv.bv_len);
		else
	 		memset(kaddr, 0, bv.bv_len);
 	}

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

  reply	other threads:[~2025-04-28 12:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-27  8:39 [PATCH v2 0/3] brd: discard bugfix Yu Kuai
2025-04-27  8:39 ` [PATCH v2 1/3] brd: protect page with rcu Yu Kuai
2025-04-28 12:52   ` Christoph Hellwig [this message]
2025-04-29  1:48     ` Yu Kuai
2025-04-27  8:39 ` [PATCH v2 2/3] brd: fix aligned_sector from brd_do_discard() Yu Kuai
2025-04-27  8:39 ` [PATCH v2 3/3] brd: fix discard end sector Yu Kuai

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=20250428125207.GB27794@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=johnny.chenyi@huawei.com \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai1@huaweicloud.com \
    --cc=yukuai3@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®