Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp4126707rdb; Wed, 30 Aug 2023 17:11:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaifbwFJoYGhfusr5t5iME1qflnhRjZBwq2c3G+KrtiG0MwBaNUAIAZlQ1UOQKJrcux6Uz X-Received: by 2002:a50:fb87:0:b0:522:d801:7d07 with SMTP id e7-20020a50fb87000000b00522d8017d07mr1348448edq.10.1693440666681; Wed, 30 Aug 2023 17:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693440666; cv=none; d=google.com; s=arc-20160816; b=rH8g4L3KEuax/uKyhAiFrt9quMlcY2xHdj72ViQi6063f8jb21RHtOaIl4CNuFscw4 tvQ8fejol1lreivMIJ+CoVKunBBU0e3ItyIsKhML5H0aTzIAiY7iSjhvIX7uB9uif9ri f0qo0QrZx0+wBUa5C/TSk7ummIdO+URjfTcx6DYrsGVk8F7BSXrh1zfBZw8647/xh+lv uucS4I7oDCcE9zUrsFFcej8OxVJ3LpW+fGh6re6ymgIHalFO+BSL3NrCSmSO9Ql59Uiy ezuj9Qc7Towu3uI4PI7Ngiy9v4uN67Rt99lJ54Ypt91Pj494w9nRspoBRP5UG9BOvthB tMIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Lnad4aFz100dsvzqr4eIlRwjbEKBYYhDdl/Fb0WtEsg=; fh=6mSgySxwQN8uhK1slt2HTLSKBtKy6DXFm9iGLTePf10=; b=ojJ8G1fTlgEhD+HuDw6epwtFFds5Y1YZamGFuMwDLyiWcJWOJQeDSwUl9+tWZwPdYY a5WxMSBL0hVzMOu95PWuFQXo2Wmm6fTfGLBQU4VaytIXcOnO2BPbxIq5cLqyZn2CSxu8 HsGIcvOfLT8VeGFTmbVrk3YQWFf/ySWWceJf1ltiozs4bfjXw/1IjiKxXUCv2geV7xCS KpOtJZ1mTR0D0Pz/Bc0rfioXdYKgso7lkbPx3r/y6Zpw3LYrSxzLkQh8s7cZ+2R/vggf IWHegqrcz0dcWoyaIGJhCm3rhTWVJtnS6/gli7TI+W2sA7lsSocJ2D9c2OJ4JplkKKnw 24kQ== 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 e12-20020a50ec8c000000b005234f2c6b21si229653edr.202.2023.08.30.17.10.39; Wed, 30 Aug 2023 17:11:06 -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 S242721AbjH3TcD (ORCPT + 99 others); Wed, 30 Aug 2023 15:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242771AbjH3Jdj (ORCPT ); Wed, 30 Aug 2023 05:33:39 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB5B5CCB; Wed, 30 Aug 2023 02:33:36 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RbJy54gs1z4f3pBl; Wed, 30 Aug 2023 17:33:33 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgD3hqnrDO9kkRu9Bw--.49032S6; Wed, 30 Aug 2023 17:33:34 +0800 (CST) From: Yu Kuai To: song@kernel.org, xni@redhat.com Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH -next 2/2] md: fix potential hang for mddev_suspend() Date: Wed, 30 Aug 2023 17:29:02 +0800 Message-Id: <20230830092902.1236950-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230830092902.1236950-1-yukuai1@huaweicloud.com> References: <20230830092902.1236950-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgD3hqnrDO9kkRu9Bw--.49032S6 X-Coremail-Antispam: 1UD129KBjvdXoWrKr1ktF4DXFW7Wr15Ww1fXrb_yoWkXFgE9F s0v34xWF17ur18Kr1UZa1SvrWFkan8Wr4kWFWSgr43AF93X3y0yF9Yk3s8X34fuFWIyasa yw1jqF1rZFsrJjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb-kFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY02 0Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUjYiiDUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 From: Yu Kuai Commit 72adae23a72c ("md: Change active_io to percpu") drop that if 'active_io' is decreased to 0 and array is suspended, 'sb_wait' will be woke up. This is wrong, however, there is no regression reported and I think this is probably because 'sb_wait' is used in many scenarios and it's woke up from other context. Anyway, fix this potential problem by waking up 'sb_wait' in this case. Fixes: 72adae23a72c ("md: Change active_io to percpu") Signed-off-by: Yu Kuai --- drivers/md/md.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/md/md.c b/drivers/md/md.c index 0d69b1a2e2d5..1c7eb3cfadb4 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -399,6 +399,9 @@ static bool md_array_enter(struct mddev *mddev, struct bio *bio) static void md_array_exit(struct mddev *mddev) { percpu_ref_put(&mddev->active_io); + if (percpu_ref_is_zero(&mddev->active_io) && + wq_has_sleeper(&mddev->sb_wait)) + wake_up(&mddev->sb_wait); } void md_handle_request(struct mddev *mddev, struct bio *bio) -- 2.39.2