From patchwork Thu Aug 3 13:29:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 130616 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp1156971vqx; Thu, 3 Aug 2023 06:43:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlH9jukmLlRyRMm4CPhjpTjez1KqxLzIeUx5L9h3D1DDxaUzW+qwZFg7rps3abdkRlh6g0UO X-Received: by 2002:a17:907:75d1:b0:993:f15f:efbe with SMTP id jl17-20020a17090775d100b00993f15fefbemr7187425ejc.5.1691070190703; Thu, 03 Aug 2023 06:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691070190; cv=none; d=google.com; s=arc-20160816; b=cFxCfYM7/gw7fRmO5Fvir9YqmZbS71+VD5B9858q1Olfe8SIW4Qg1wSstNTCf3WdpT RDQaloGUb8KbI8KaUpLfsGz+lo7GcwzSlSEORlwvLhSkZ1F/YVFS3+qZhDvp6B+jUJZ0 rA3AdTgOIR0wd5nyxQueLEAt8qSjookz2tZGmvwF6/jbEvaESHAoq1UhwZy4T5zC81za n+LU8pb783KQOwTOkZPzzZ33aksVMkBfUREL5poLkJPjSWE6X5lQ8RG4v2L/7otcz5R9 iupS3SuDoSWac1GzmlnFbCvhf3QRacEIx53ewo4mCbFDBqJKhAaP2a7k57VHoe9hnyP4 +iSQ== 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=iXOxdV1uhGXHJgsgj1m8xRZJgE8QoZcoyNuZrzIZsKQ=; fh=Ktvf84aTmiKPjIiQsnocICsaz7FvZSNYviQ4CE4oKUo=; b=vfkEZDNAu99iDswrK13O9YYsNxx2KhppeCBhjtEi5yaTdvnRprafxiHXfmA3+wDKxD ETsV7Cy0mQwB6P50MGcwcVf5RnI5XOwRp8qsISQ/jA+6MkqDXy4pBAU/AgJr9rN/J5d5 93z7vpZhcbiO+CxCg1lL0OH/uRPMAy9FqLWlSibB+YQGj+sj2S1Paq0jPgx1eGA5ArnT EkEmXFCcR6Et9AqMHtgWXi5UVQgUzrOmk2tRyVIcBEXqDVRhXcBXNNlrB4ixIdpnLGUo R7mXvwC/FMDshuuqecvkqkGbuubYHZuQWb4uesd5hfoE1pZzy+2REKxzfMp3O6QcA0ij H7Kw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rk21-20020a170907215500b0098f99532db4si2306657ejb.664.2023.08.03.06.42.46; Thu, 03 Aug 2023 06:43:10 -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 S236391AbjHCNfH (ORCPT + 99 others); Thu, 3 Aug 2023 09:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234697AbjHCNdw (ORCPT ); Thu, 3 Aug 2023 09:33:52 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 065614ECD; Thu, 3 Aug 2023 06:32:36 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4RGqXH0CgYz4f3kp1; Thu, 3 Aug 2023 21:32:31 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHuKtqrMtkWHLlPQ--.49699S21; Thu, 03 Aug 2023 21:32:33 +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 17/29] md/raid5: replace suspend with quiesce() callback Date: Thu, 3 Aug 2023 21:29:18 +0800 Message-Id: <20230803132930.2742286-18-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230803132930.2742286-1-yukuai1@huaweicloud.com> References: <20230803132930.2742286-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgAHuKtqrMtkWHLlPQ--.49699S21 X-Coremail-Antispam: 1UD129KBjvJXoWxWFykZr18Cry7tr1kAw1fWFg_yoW5Xr4Dpw sIgFsrXr4UWF9xu34Dua1kWFyFk3yUKrWktryxW39Yva47GrykurWfXw45Zry7G34rZFs7 t3y5J348ZFWvqrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20E Y4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267 AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUqiihUUUUU= 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,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773215616406305137 X-GMAIL-MSGID: 1773215616406305137 From: Yu Kuai raid5 is the only personality to suspend array in check_reshape() and start_reshape() callback, suspend and quiesce() callback can both wait for all normal io to be done, and prevent new io to be dispatched, the difference is that suspend is implemented in common layer, and quiesce() callback is implemented in raid5. In order to cleanup all the usage of mddev_suspend(), the new apis __mddev_suspend() need to be called before 'reconfig_mutex' is held, and it's not good to affect all the personalities in common layer just for raid5. Hence replace suspend with quiesce() callaback, prepare to reomove all the users of mddev_suspend(). Signed-off-by: Yu Kuai --- drivers/md/raid5.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index b4b2d0d5855d..4709b7ad0317 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -70,6 +70,8 @@ MODULE_PARM_DESC(devices_handle_discard_safely, "Set to Y if all devices in each array reliably return zeroes on reads from discarded regions"); static struct workqueue_struct *raid5_wq; +static void raid5_quiesce(struct mddev *mddev, int quiesce); + static inline struct hlist_head *stripe_hash(struct r5conf *conf, sector_t sect) { int hash = (sect >> RAID5_STRIPE_SHIFT(conf)) & HASH_MASK; @@ -2492,15 +2494,12 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors) unsigned long cpu; int err = 0; - /* - * Never shrink. And mddev_suspend() could deadlock if this is called - * from raid5d. In that case, scribble_disks and scribble_sectors - * should equal to new_disks and new_sectors - */ + /* Never shrink. */ if (conf->scribble_disks >= new_disks && conf->scribble_sectors >= new_sectors) return 0; - mddev_suspend(conf->mddev); + + raid5_quiesce(conf->mddev, true); cpus_read_lock(); for_each_present_cpu(cpu) { @@ -2514,7 +2513,8 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors) } cpus_read_unlock(); - mddev_resume(conf->mddev); + raid5_quiesce(conf->mddev, false); + if (!err) { conf->scribble_disks = new_disks; conf->scribble_sectors = new_sectors; @@ -8550,8 +8550,8 @@ static int raid5_start_reshape(struct mddev *mddev) * the reshape wasn't running - like Discard or Read - have * completed. */ - mddev_suspend(mddev); - mddev_resume(mddev); + raid5_quiesce(mddev, true); + raid5_quiesce(mddev, false); /* Add some new drives, as many as will fit. * We know there are enough to make the newly sized array work.