From: Yu Kuai <yukuai1@huaweicloud.com>
To: Christoph Hellwig <hch@lst.de>, Yu Kuai <yukuai1@huaweicloud.com>
Cc: xni@redhat.com, colyli@kernel.org, agk@redhat.com,
snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org,
linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev,
linux-raid@vger.kernel.org, yi.zhang@huawei.com,
yangerkun@huawei.com, johnny.chenyi@huawei.com,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH RFC md-6.16 v3 11/19] md/md-llbitmap: implement bitmap IO
Date: Mon, 12 May 2025 16:15:34 +0800 [thread overview]
Message-ID: <a2d1a5c4-c041-064f-307e-eaa677e5a81c@huaweicloud.com> (raw)
In-Reply-To: <20250512051519.GA1555@lst.de>
Hi,
在 2025/05/12 13:15, Christoph Hellwig 写道:
> On Mon, May 12, 2025 at 09:19:19AM +0800, Yu Kuai wrote:
>> +static bool is_raid456(struct mddev *mddev)
>> +{
>> + return (mddev->level == 4 || mddev->level == 5 || mddev->level == 6);
>> +}
>
> This really should be in a common helper somewhere..
Perhaps md.h?
>
>> +static int llbitmap_read(struct llbitmap *llbitmap, enum llbitmap_state *state,
>> + loff_t pos)
>> +{
>> + pos += BITMAP_SB_SIZE;
>> + *state = llbitmap->barrier[pos >> PAGE_SHIFT].data[offset_in_page(pos)];
>> + return 0;
>> +}
>
> This always return 0, and could just return void.
Ok
>
>> +static void llbitmap_set_page_dirty(struct llbitmap *llbitmap, int idx, int offset)
>
> Overly long line.
>
> Also should the second and third argument be unsigned?
Ok
>
>> + /*
>> + * if the bit is already dirty, or other page bytes is the same bit is
>> + * already BitDirty, then mark the whole bytes in the bit as dirty
>> + */
>> + if (test_and_set_bit(bit, barrier->dirty)) {
>> + infectious = true;
>> + } else {
>> + for (pos = bit * io_size; pos < (bit + 1) * io_size - 1;
>> + pos++) {
>> + if (pos == offset)
>> + continue;
>> + if (barrier->data[pos] == BitDirty ||
>> + barrier->data[pos] == BitNeedSync) {
>> + infectious = true;
>> + break;
>> + }
>> + }
>> +
>> + }
>> + if (!infectious)
>> + return;
>
> Mabe use a goto and/or a helper function containing the for loop to
> clean up the control flow here a bit?
Ok, I;ll add a helper function.
>
>> +static int llbitmap_write(struct llbitmap *llbitmap, enum llbitmap_state state,
>> + loff_t pos)
>> +{
>> + int idx;
>> + int offset;
>
> Unsigned?
>
>> +
>> + pos += BITMAP_SB_SIZE;
>> + idx = pos >> PAGE_SHIFT;
>> + offset = offset_in_page(pos);
>> +
>> + llbitmap->barrier[idx].data[offset] = state;
>> + if (state == BitDirty || state == BitNeedSync)
>> + llbitmap_set_page_dirty(llbitmap, idx, offset);
>> + return 0;
>
> and this could also be a void return.
Ok.
>
>> + sector = mddev->bitmap_info.offset + (idx << PAGE_SECTORS_SHIFT);
>
> Overly long line.
>
>> + if (rdev->raid_disk < 0 || test_bit(Faulty, &rdev->flags))
>
> Same here.
>
>> + int nr_pages = (llbitmap->chunks + BITMAP_SB_SIZE + PAGE_SIZE - 1) / PAGE_SIZE;
>
> Unsigned for the type, and DIV_ROUND_UP for the calculation.
Ok.
>
>> + struct page *page;
>> + int i = 0;
>> +
>> + llbitmap->nr_pages = nr_pages;
>> + while (i < nr_pages) {
>> + page = llbitmap_read_page(llbitmap, i);
>> + if (IS_ERR(page)) {
>> + llbitmap_free_pages(llbitmap);
>> + return PTR_ERR(page);
>> + }
>> +
>> + if (percpu_ref_init(&llbitmap->barrier[i].active, active_release,
>> + PERCPU_REF_ALLOW_REINIT, GFP_KERNEL)) {
>> + __free_page(page);
>> + return -ENOMEM;
>
> Doesn't this also need a llbitmap_free_pages for the error case?
Of course, my bad that I forgot this.
Thanks again for the review!
Kuai
>
> .
>
next prev parent reply other threads:[~2025-05-12 8:15 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 1:19 [PATCH RFC md-6.16 v3 00/19] md: introduce a new lockless bitmap Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 01/19] md/md-bitmap: add {start, end}_discard in bitmap_operations Yu Kuai
2025-05-12 4:39 ` Christoph Hellwig
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 02/19] md: support discard for bitmap ops Yu Kuai
2025-05-12 4:41 ` Christoph Hellwig
2025-05-12 6:05 ` Yu Kuai
2025-05-12 6:12 ` Christoph Hellwig
2025-05-12 6:22 ` Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 03/19] md/md-bitmap: remove parameter slot from bitmap_create() Yu Kuai
2025-05-12 4:41 ` Christoph Hellwig
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 04/19] md: add a new sysfs api bitmap_version Yu Kuai
2025-05-12 4:51 ` Christoph Hellwig
2025-05-12 6:12 ` Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 05/19] md: delay registration of bitmap_ops until creating bitmap Yu Kuai
2025-05-12 4:53 ` Christoph Hellwig
2025-05-12 6:25 ` Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 06/19] md: add a new parameter 'offset' to md_super_write() Yu Kuai
2025-05-12 4:55 ` Christoph Hellwig
2025-05-12 6:32 ` Yu Kuai
2025-05-12 6:39 ` Christoph Hellwig
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 07/19] md/md-bitmap: add a new helper skip_sync_blocks() in bitmap_operations Yu Kuai
2025-05-12 4:56 ` Christoph Hellwig
2025-05-22 2:44 ` Xiao Ni
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 08/19] md/md-bitmap: add a new helper blocks_synced() " Yu Kuai
2025-05-12 4:57 ` Christoph Hellwig
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 09/19] md: add a new recovery_flag MD_RECOVERY_LAZY_RECOVER Yu Kuai
2025-05-12 4:57 ` Christoph Hellwig
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 10/19] md/md-llbitmap: add data structure definition and comments Yu Kuai
2025-05-12 5:09 ` Christoph Hellwig
2025-05-12 8:05 ` Yu Kuai
2025-05-12 13:24 ` Christoph Hellwig
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 11/19] md/md-llbitmap: implement bitmap IO Yu Kuai
2025-05-12 5:15 ` Christoph Hellwig
2025-05-12 8:15 ` Yu Kuai [this message]
2025-05-12 13:25 ` Christoph Hellwig
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 12/19] md/md-llbitmap: implement bit state machine Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 13/19] md/md-llbitmap: implement APIs for page level dirty bits synchronization Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 14/19] md/md-llbitmap: implement APIs to mange bitmap lifetime Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 15/19] md/md-llbitmap: implement APIs to dirty bits and clear bits Yu Kuai
2025-05-12 5:17 ` Christoph Hellwig
2025-05-12 8:23 ` Yu Kuai
2025-05-12 13:26 ` Christoph Hellwig
2025-05-12 13:30 ` Christoph Hellwig
2025-05-12 13:36 ` Yu Kuai
2025-05-13 6:32 ` Yu Kuai
2025-05-13 6:48 ` Christoph Hellwig
2025-05-13 7:14 ` Yu Kuai
2025-05-13 7:43 ` Christoph Hellwig
2025-05-13 9:32 ` Yu Kuai
2025-05-14 5:17 ` Christoph Hellwig
2025-05-15 13:38 ` Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 16/19] md/md-llbitmap: implement APIs for sync_thread Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 17/19] md/md-llbitmap: implement all bitmap operations Yu Kuai
2025-05-12 5:18 ` Christoph Hellwig
2025-05-12 8:28 ` Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 18/19] md/md-llbitmap: implement sysfs APIs Yu Kuai
2025-05-12 1:19 ` [PATCH RFC md-6.16 v3 19/19] md/md-llbitmap: add Kconfig Yu Kuai
2025-05-12 5:19 ` Christoph Hellwig
2025-05-12 8:30 ` Yu Kuai
2025-05-12 5:21 ` [PATCH RFC md-6.16 v3 00/19] md: introduce a new lockless bitmap Christoph Hellwig
2025-05-12 8:40 ` Yu Kuai
2025-05-12 13:27 ` Christoph Hellwig
2025-05-12 13:41 ` 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=a2d1a5c4-c041-064f-307e-eaa677e5a81c@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=agk@redhat.com \
--cc=colyli@kernel.org \
--cc=dm-devel@lists.linux.dev \
--cc=hch@lst.de \
--cc=johnny.chenyi@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=snitzer@kernel.org \
--cc=song@kernel.org \
--cc=xni@redhat.com \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.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;
as well as URLs for NNTP newsgroup(s).