From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D71D1186E; Tue, 9 Jan 2024 01:21:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4T8Cn42k2Yz4f3jpk; Tue, 9 Jan 2024 09:21:12 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 414671A01E3; Tue, 9 Jan 2024 09:21:14 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgCXaBGIn5xlFvAaAQ--.9179S3; Tue, 09 Jan 2024 09:21:14 +0800 (CST) Subject: Re: [PATCH v3 2/2] md: simplify md_seq_ops To: Song Liu , Yu Kuai 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)" References: <20230927061241.1552837-1-yukuai1@huaweicloud.com> <20230927061241.1552837-3-yukuai1@huaweicloud.com> From: Yu Kuai Message-ID: Date: Tue, 9 Jan 2024 09:21:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgCXaBGIn5xlFvAaAQ--.9179S3 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hhfrp/ Hi, 在 2024/01/09 7:38, Song Liu 写道: > On Tue, Sep 26, 2023 at 11:19 PM Yu Kuai wrote: >> >> From: Yu Kuai >> >> 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 > > 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: > > 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 > > . >