From patchwork Thu Feb 1 09:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 195229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp31234dyb; Thu, 1 Feb 2024 01:35:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFE8kXIl6WSndqvFvAdxje8v6XNeoX6NMIhEy6xdw+CC6lIhZkEUlTiRbwsLDhssIE6heqJ X-Received: by 2002:a17:90a:db97:b0:296:1cd7:4741 with SMTP id h23-20020a17090adb9700b002961cd74741mr635924pjv.4.1706780119315; Thu, 01 Feb 2024 01:35:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706780119; cv=pass; d=google.com; s=arc-20160816; b=q5VDR75q7TOi8gmhTTQCZzA53LPcmZIfxx9x3r6XMHE3FZmpOX5anLXP8cWh03A47p 0zZv3FE+dwO4MnubJmYD5HtR9p4xiDsAQ3mpxHMdiFRDAr+dmUlMnmrRsfcNx0PVdCjU 5QE0aKaJMdy2pRyNOM4VfCBKBIzw6nBfcDYmXCS7L/RwMrYgZBqyYVxMT61kUn56Ig+r Cz8OSmgoeZ9pbdVIIl1dnQ7ZhFu29gYJfhOM/cdkY9CV+A8mFmlHP/FJl2tQWf5S6pUe yABFu+rc9nRXad9ve0SCrKzyfKbO3BhFoeo4sSYcGKFvp6LAFHtQh2OuLxOkj6Dw861I lbMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=wYzSQ7LkYaYosgM/AJHsamGhGmV1cPVUDvzL88OlU3Y=; fh=h3hROpDKOMyVv6DocEJuE0kpaN5k4M3gUl5zG1x+LSU=; b=pTUSRxwgiwRqpkyME+2Nxh+9GIWtiQINkPEWBYwHVDrVSmuXoR+YpS/Y0FQThLeaj/ V7xu/ZT/2ab06VHN3xFqn7a3s0fEcVIweutzsV5SxW9YTYge8gXpj6dkxfhtjDOfbDWh Nlt8s2GdGYnuFyjGT6uaU+KDs4FNgF/UldGtW0bB1hNV3mxRLlqxMr/amiE6/hwB8844 y+l/5QZIu1Wx38b4ix5q+cjtUC+BrQ6Il6vzzOn3KBpURUlOkZMONaH49F12Ll+Qw3xq c3OBDWdFD27IlZTWE33sUQcpIG7OmnN97kOtq9KFhAc5q+RD0DCRCtOu5S5CW7p/yFUz 5NHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-47878-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47878-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXU2F/bkV3fzaELPmSQG4G2EBtCsO7J0a9nmwEazOtgnUoIYce8WFmaVWkZ2zgQmgVqufT3snYvNW5dVDdTIoCL8XKNGw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y8-20020a17090aa40800b00290b369b456si3195697pjp.155.2024.02.01.01.35.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 01:35:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47878-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-47878-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47878-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1BE37282BF3 for ; Thu, 1 Feb 2024 09:35:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8CEAF4D9E3; Thu, 1 Feb 2024 09:30:44 +0000 (UTC) Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (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 646991649AD; Thu, 1 Feb 2024 09:30:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706779843; cv=none; b=cS+r96GcXzHOFxwYtdZ9Q3udmSso4vJfLoDCt55Dlsfn71D3aU5tsRQhwydacCK4GW5YxzJidbF0AJJ5H4UQh0E6cTD83UPYZiA2Gd3ZLS6BG6brFQZUI6oEyqFYKXxiqAuppKEDYFT3Gctr7+yaiTh46iDa2s87xqnEsNHKxkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706779843; c=relaxed/simple; bh=Pw8nxEepj3SW3fuzUXlVu8OndBo1SbgV3fSER76rjfk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ivz8vl+5acLGcqxweoSlnOR39eiPstaE/3RqCXdu0G6/fcY7Ty67Npx/jJFQI/7TwUyYzZkaW0r0S2ppdLG0LD+0gfQ7XBXQiZsIfluxfGbJj6m6LLJfT2eXrNg46/blzg6v7K5AuO0aM1XqRBonuD8vuBKrNK8dqGUjjAaMXS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4TQYY42zs3z4f3l7p; Thu, 1 Feb 2024 17:30:32 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 9DD691A0390; Thu, 1 Feb 2024 17:30:36 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXaBGtZLtl8V6KCg--.33515S18; Thu, 01 Feb 2024 17:30:36 +0800 (CST) From: Yu Kuai To: mpatocka@redhat.com, heinzm@redhat.com, xni@redhat.com, blazej.kucman@linux.intel.com, agk@redhat.com, snitzer@kernel.org, dm-devel@lists.linux.dev, song@kernel.org, yukuai3@huawei.com, jbrassow@f14.redhat.com, neilb@suse.de, shli@fb.com, akpm@osdl.org Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH v5 14/14] dm-raid: remove mddev_suspend/resume() Date: Thu, 1 Feb 2024 17:25:59 +0800 Message-Id: <20240201092559.910982-15-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240201092559.910982-1-yukuai1@huaweicloud.com> References: <20240201092559.910982-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgCXaBGtZLtl8V6KCg--.33515S18 X-Coremail-Antispam: 1UD129KBjvJXoWxCF4UXw48C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 X7UUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789688670372551576 X-GMAIL-MSGID: 1789688670372551576 From: Yu Kuai dm layer will make sure that no new IO can be issued and will wait for all dispatched IO to be done during suspend or before removing the device. Hence there is no need to call mddev_suspend/resume() again. BTW, mddev_suspend/resume() can't gurantee that there are no sync IO, and previous patch make sure that presuspend will stop sync thread. Signed-off-by: Yu Kuai --- drivers/md/dm-raid.c | 8 +++----- drivers/md/md.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 5f78cc19d6f3..ed8c28952b14 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -3241,7 +3241,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv) rs->md.in_sync = 1; /* Has to be held on running the array */ - mddev_suspend_and_lock_nointr(&rs->md); + mddev_lock_nointr(&rs->md); /* Keep array frozen until resume. */ md_frozen_sync_thread(&rs->md); @@ -3829,11 +3829,9 @@ static void raid_postsuspend(struct dm_target *ti) { struct raid_set *rs = ti->private; - if (!test_and_set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags)) { + if (!test_and_set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags)) /* Writes have to be stopped before suspending to avoid deadlocks. */ md_stop_writes(&rs->md); - mddev_suspend(&rs->md, false); - } } static void attempt_restore_of_faulty_devices(struct raid_set *rs) @@ -4091,7 +4089,7 @@ static void raid_resume(struct dm_target *ti) mddev->ro = 0; mddev->in_sync = 0; md_unfrozen_sync_thread(mddev); - mddev_unlock_and_resume(mddev); + mddev_unlock(mddev); } } diff --git a/drivers/md/md.c b/drivers/md/md.c index 2c245341148a..a8db84c200fe 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -437,6 +437,10 @@ int mddev_suspend(struct mddev *mddev, bool interruptible) { int err = 0; + /* Array is supended from dm_suspend() for dm-raid. */ + if (!mddev->gendisk) + return 0; + /* * hold reconfig_mutex to wait for normal io will deadlock, because * other context can't update super_block, and normal io can rely on @@ -488,6 +492,13 @@ EXPORT_SYMBOL_GPL(mddev_suspend); static void __mddev_resume(struct mddev *mddev, bool recovery_needed) { + /* + * Array is supended from dm_suspend() and resumed from dm_resume() for + * dm-raid. + */ + if (!mddev->gendisk) + return; + lockdep_assert_not_held(&mddev->reconfig_mutex); mutex_lock(&mddev->suspend_mutex);