linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai1@huaweicloud.com>
Cc: mariusz.tkaczyk@linux.intel.com, xni@redhat.com,
	linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	yi.zhang@huawei.com, yangerkun@huawei.com,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH v3 2/2] md: simplify md_seq_ops
Date: Tue, 9 Jan 2024 09:21:12 +0800	[thread overview]
Message-ID: <b6a79bb8-e0fc-09b4-90e7-8112100a3fd0@huaweicloud.com> (raw)
In-Reply-To: <CAPhsuW6sdnJYtE+iy+x=C2qVKzeN18zibx+qQBF4Y=KRsAmTTg@mail.gmail.com>

Hi,

在 2024/01/09 7:38, Song Liu 写道:
> On Tue, Sep 26, 2023 at 11:19 PM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>>
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> Before this patch, the implementation is hacky and hard to understand:
>>
>> 1) md_seq_start set pos to 1;
>> 2) md_seq_show found pos is 1, then print Personalities;
>> 3) md_seq_next found pos is 1, then it update pos to the first mddev;
>> 4) md_seq_show found pos is not 1 or 2, show mddev;
>> 5) md_seq_next found pos is not 1 or 2, update pos to next mddev;
>> 6) loop 4-5 until the last mddev, then md_seq_next update pos to 2;
>> 7) md_seq_show found pos is 2, then print unused devices;
>> 8) md_seq_next found pos is 2, stop;
>>
>> This patch remove the magic value and use seq_list_start/next/stop()
>> directly, and move printing "Personalities" to md_seq_start(),
>> "unsed devices" to md_seq_stop():
>>
>> 1) md_seq_start print Personalities, and then set pos to first mddev;
>> 2) md_seq_show show mddev;
>> 3) md_seq_next update pos to next mddev;
>> 4) loop 2-3 until the last mddev;
>> 5) md_seq_stop print unsed devices;
>>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> 
> Just realized this introduced a behavior change:
> 
> When there is not md devices, before this patch, we have
> 
> [root@eth50-1 ~]# cat /proc/mdstat
> Personalities : [raid0] [raid1] [raid10] [raid6] [raid5] [raid4]
> unused devices: <none>
> 
> After this patch, "cat /proc/mdstat" returns nothing. This causes
> some confusion for users who want to read "Personalities" line,
> for example, the mdadm test suite reads it.
> 
> I haven't figured out the best fix yet.

Yes, that's a problem. And after reviewing seq_read_iter() in detail, I
realize that I also can't use seq_printf() in m->op->start() directly,
because if seq buffer overflowed, md_seq_start() can be called more than
once.

I'll fix these problems soon.

Thanks,
Kuai

> 
> Thanks,
> Song
> 
> .
> 


  reply	other threads:[~2024-01-09  1:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-27  6:12 [PATCH v3 0/2] md: simplify md_seq_ops Yu Kuai
2023-09-27  6:12 ` [PATCH v3 1/2] md: factor out a helper from mddev_put() Yu Kuai
2023-09-27  6:12 ` [PATCH v3 2/2] md: simplify md_seq_ops Yu Kuai
2024-01-08 23:38   ` Song Liu
2024-01-09  1:21     ` Yu Kuai [this message]
2024-01-09  7:48       ` Yu Kuai
2024-01-09  8:12         ` Song Liu
2024-01-09  8:28           ` Yu Kuai
2023-09-28  6:37 ` [PATCH v3 0/2] " Song Liu

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=b6a79bb8-e0fc-09b4-90e7-8112100a3fd0@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mariusz.tkaczyk@linux.intel.com \
    --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).