Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2323372rwd; Wed, 14 Jun 2023 00:51:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7sJu7CVxdUaFw8pbAYpxxGkntONIqJ4CKLcdj0l36I5tKZDum3tc+uhNMdc9koR1wOlO0f X-Received: by 2002:a05:6402:74c:b0:514:a5f3:be61 with SMTP id p12-20020a056402074c00b00514a5f3be61mr8892346edy.31.1686729095499; Wed, 14 Jun 2023 00:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686729095; cv=none; d=google.com; s=arc-20160816; b=PEm6wNIi4m+uQ87rAW3iMtflK2+Vdtl8l23ak94rd9D0d8b7ljjEQy1v+XWHcm0lz/ H6/PJAidNsRGhcEdQX+0PChytIjGHOPQFVRFY/p8iEGaa9ovUZPq7sLCjwElcOZ5urih kVbnPM/EotIQKi8X6BBTdM05p/wIv1Sd+C2dD0DBVSID79dhgMin6Z+Dvs827PRjIpDU ZcvbSW5q5YNIv1wy1BGwlQv8YwjYe4bk9zgQUwzo94B0J6S1jEgsd1IaNEouTjZTYBb6 0qf6okcb175pdkpGeOOUgI2HUWiFcECLNhQk3nWM1lFVWoN+GPbf+hOvTk4JZTogrsGv oyhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=Eu1o3vQoxKPNGMMst7vpviGd7/79rx6Zp5icFRrY2no=; b=aY17tXorUBPaU2WWFiMl6EjDxZ35oH1nRgF9KixWixqXWzD6tee+epVPbVCIlMtfVS bEhhe9Vy+RmJFGGfrtvvYylz1yh6Y6kyfmqHma+z22d63jH2T+CrgjR7KrUiFz6gUi4e 4ti3x686/P9ybF7dvOvqIAw9zOUFX3j4skGhPf50wGOJS3OSV96aoLgo/XdaqLYF1EVd UzOQmkvnoF286bhqP8QsPiG2RGsfuBGBJQhrxulDvAsCHbVOSlwA4eZUH+kxFUgzPF68 BLcm2hGq3M152rcYzLWamPl6vbrDuQmhNweF/RJ4ANqHhB9pvM+w//byAkCsPpVvZGxW dkVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020aa7c911000000b005187d7ed52dsi717544edt.362.2023.06.14.00.51.10; Wed, 14 Jun 2023 00:51:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243411AbjFNHih (ORCPT + 99 others); Wed, 14 Jun 2023 03:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235148AbjFNHi0 (ORCPT ); Wed, 14 Jun 2023 03:38:26 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A042C1AD; Wed, 14 Jun 2023 00:38:24 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Qgy2f0nfTz4f3mVb; Wed, 14 Jun 2023 15:38:18 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgBn0LNpbolk9J6wLg--.62486S3; Wed, 14 Jun 2023 15:38:19 +0800 (CST) Subject: Re: [dm-devel] [PATCH -next v2 4/6] md: refactor idle/frozen_sync_thread() to fix deadlock To: Xiao Ni , Yu Kuai Cc: guoqing.jiang@linux.dev, agk@redhat.com, snitzer@kernel.org, dm-devel@redhat.com, song@kernel.org, linux-raid@vger.kernel.org, yangerkun@huawei.com, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, "yukuai (C)" References: <20230529132037.2124527-1-yukuai1@huaweicloud.com> <20230529132037.2124527-5-yukuai1@huaweicloud.com> <05aa3b09-7bb9-a65a-6231-4707b4b078a0@redhat.com> <74b404c4-4fdb-6eb3-93f1-0e640793bba6@huaweicloud.com> <6e738d9b-6e92-20b7-f9d9-e1cf71d26d73@huaweicloud.com> From: Yu Kuai Message-ID: <5bf97ec5-0cb4-1163-6917-2bc98d912c2b@huaweicloud.com> Date: Wed, 14 Jun 2023 15:38:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgBn0LNpbolk9J6wLg--.62486S3 X-Coremail-Antispam: 1UD129KBjvJXoW7WF1DCFWDWFy5WF1rJw1UKFg_yoW8ZF4Upr y0yF15Cr4jkr4Iv3s5K3WjqrW0y34UXa15Jr9xJry3Jwn5Kw4ftFy7CFW5uF98ZF95Jr4j k39YqayfJFZIy3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9F14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka 0xkIwI1lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7x kEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E 67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCw CI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E 3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcS sGvfC2KfnxnUUI43ZEXa7VUbXdbUUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,NICE_REPLY_A,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, 在 2023/06/14 15:12, Xiao Ni 写道: > On Wed, Jun 14, 2023 at 10:04 AM Yu Kuai wrote: >> >> Hi, >> >> 在 2023/06/14 9:48, Yu Kuai 写道: >> >> >>>> >>>> In the patch, sync_seq is added in md_reap_sync_thread. In >>>> idle_sync_thread, if sync_seq isn't equal >>>> >>>> mddev->sync_seq, it should mean there is someone that stops the sync >>>> thread already, right? Why do >>>> >>>> you say 'new started sync thread' here? >> >> If someone stops the sync thread, and new sync thread is not started, >> then this sync_seq won't make a difference, above wait_event() will not >> wait because !test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) will pass. >> So 'sync_seq' is only used when the old sync thread stops and new sync >> thread starts, add 'sync_seq' will bypass this case. > > Hi > > If a new sync thread starts, why can sync_seq be different? sync_seq > is only added in md_reap_sync_thread. And when a new sync request > starts, it can't stop the sync request again? > > Af first, the sync_seq is 0 > > admin1 > echo idle > sync_action > idle_sync_thread(sync_seq is 1) Wait, I'm confused here, how can sync_seq to be 1 here? I suppose you mean that there is a sync_thread just finished? Then the problem is that idle_sync_thread() read sync_seq after the old sync_thread is done, and new sync_thread start before wait_event() is called, should we wait for this new sync_thread? My answer here is that we should, but I'm also ok to not wait this new sync_thread, I don't think this behaviour matters. The key point here is that once wait_event() is called from idle_sync_thread(), this wait_event() should not wait for new sync_thread... > echo resync > sync_action (new sync) If this is behind "echo idle > sync_action", idle_sync_thread should not see that MD_RECOVERY_RUNNING is set and wait_event() won't wait at all. Thanks, Kuai > > Then admin2 echos idle > sync_action, sync_seq is still 1 > > Regards > Xiao > >> >> Thanks, >> Kuai >> > > . >