From patchwork Thu Feb 1 09:25:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 195220 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp30210dyb; Thu, 1 Feb 2024 01:32:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcFgtkuMpKpun/BExdPHs+REqgZD9X5sFlvHB1p+lkDVWC8vAEVGolAFdLkOMLsy6AF+r3 X-Received: by 2002:a05:6808:424d:b0:3bd:e980:fc58 with SMTP id dp13-20020a056808424d00b003bde980fc58mr1519905oib.52.1706779976145; Thu, 01 Feb 2024 01:32:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706779976; cv=pass; d=google.com; s=arc-20160816; b=X9uwo+af1xUeR+eJ6dt5whvyOjre4HxbM1T9jnkAuWNE9vRR4nmzr4CzQyTfrZc3uI CBfsnDWvZ7dPh4Qym622PCR2nteeHlIhWD4dKEH2H5t+4t7n+APT3uYdh9YtJQXFUPZ6 +vcvn+OUd72diHX5t6sA42MwHUjKnWhVW4+qyiADRf8EO5t3RzenLrNXIJ4cCqiq6S27 b5KR0OgmmlH88Y2cWgNwF7Dzq4pEiXaxpPoH7ApRHiNhyYjr0K8S+zlQTP3AWtyJ/NfD Ga6RfWZG3lm9QmCZQRO/+Ulr8IkriQwTi5VoL6wO4Eh3FFqW05cffN6o8knHX59obhhQ nBLQ== 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=2c7chQ78HGOCdj1Eb70sTGCt/X3LxWmlJXF0/NePjQ4=; fh=H91B07heJB58d9sgtcRt4cj8P1RhWCLTu38CLfL/q90=; b=zLvOKE+ME4KJH5rMrKkEKH1KXOoOhPB8Tg/AgP/TlUNaPDtYAhmaXVnn7F18AgLekM gq7KTv3f3jfVw4ejiXwXLrX6U/hS7stbs4IIKhXQ4pGpsAQqBJ2NBP0QwLlixX80ACwt fVjpMalgAWRhZeDqFiNfUZYgNkmjrO7nNYiywkHZd7K2vs7Algkyz84bdr51zUsyT40b WFSt1ny+TvogKYu+vY5fA14a15sA1b3Ez6r9Rzg1LMbUIEjcPfJOk0WcBY5yndoNgKNa BVutATbyHez/+6emI3y7pZPAQDpKCrZMEq6MRMUBznqd3oA3yqPgvXgc3ATrBpwEjzA1 Fvcw==; 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-47870-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47870-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCV6zXKwKBP3VqXeUYXBCHmFOPvOWkSoo6SkurwnVgbPuT4VR+WvDs/3v2FVBkZlz49anDIbxuEc7PWAsjZN68B1q3GqVg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p9-20020a05622a00c900b0042bf3484953si937834qtw.552.2024.02.01.01.32.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 01:32:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47870-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-47870-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47870-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E87291C27F39 for ; Thu, 1 Feb 2024 09:32:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE82115F330; Thu, 1 Feb 2024 09:30:36 +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 6941215B990; Thu, 1 Feb 2024 09:30:32 +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=1706779834; cv=none; b=lEpLZ8jXEOpHJRBuHp1DSQhgRlqHuJzSZaOR2PoWIH/mam7h59ihptqksKR1AqNetjK7OK154hPbJgvV79AUl3IENvM7ZcG2KKOoGhaUezHJMfwJuIqVB6E+wUYkI8MWtMUOX2548aPAckbNjNs3SmXerz312in52YN2VDxHdgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706779834; c=relaxed/simple; bh=P78HzqbyoW17tfVjgGA+69KAblnYGxtOVqNCc1oclCo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tykn6fFwNjbVGh4uPTvZF1t7l3WNDCwTek1JD/+QsQj7BI0oOWPh32j9wKZGUlTadiOcFExJ8kl8T86bMv2z248PGLFeAcIyzp0FMs+Y+KDEhRjJNZ+13ACVDQCMRfM8pDVl8EV5mAPUGuoIYPHWjFpwwiCY/dP3wmglruoQn68= 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.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4TQYXx1zxMz4f3l7R; Thu, 1 Feb 2024 17:30:25 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 7855C1A027B; Thu, 1 Feb 2024 17:30:29 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXaBGtZLtl8V6KCg--.33515S10; Thu, 01 Feb 2024 17:30:29 +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 06/14] md: fix missing release of 'active_io' for flush Date: Thu, 1 Feb 2024 17:25:51 +0800 Message-Id: <20240201092559.910982-7-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--.33515S10 X-Coremail-Antispam: 1UD129KBjvJXoW7Ww1UCw1Utw1xZF4kXr1fZwb_yoW8WF4fp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x35dzhxuhorxvhhfrp/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789688520276591481 X-GMAIL-MSGID: 1789688520276591481 From: Yu Kuai submit_flushes atomic_set(&mddev->flush_pending, 1); rdev_for_each_rcu(rdev, mddev) atomic_inc(&mddev->flush_pending); bi->bi_end_io = md_end_flush submit_bio(bi); /* flush io is done first */ md_end_flush if (atomic_dec_and_test(&mddev->flush_pending)) percpu_ref_put(&mddev->active_io) -> active_io is not released if (atomic_dec_and_test(&mddev->flush_pending)) -> missing release of active_io For consequence, mddev_suspend() will wait for 'active_io' to be zero forever. Fix this problem by releasing 'active_io' in submit_flushes() if 'flush_pending' is decreased to zero. Fixes: fa2bbff7b0b4 ("md: synchronize flush io with array reconfiguration") Reported-by: Blazej Kucman Closes: https://lore.kernel.org/lkml/20240130172524.0000417b@linux.intel.com/ Signed-off-by: Yu Kuai --- drivers/md/md.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 85fde05c37dd..9e41a9aaba8b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -579,8 +579,12 @@ static void submit_flushes(struct work_struct *ws) rcu_read_lock(); } rcu_read_unlock(); - if (atomic_dec_and_test(&mddev->flush_pending)) + if (atomic_dec_and_test(&mddev->flush_pending)) { + /* The pair is percpu_ref_get() from md_flush_request() */ + percpu_ref_put(&mddev->active_io); + queue_work(md_wq, &mddev->flush_work); + } } static void md_submit_flush_data(struct work_struct *ws)