From patchwork Thu Apr 13 11:32:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13210172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D691C77B61 for ; Thu, 13 Apr 2023 11:33:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230290AbjDMLd2 (ORCPT ); Thu, 13 Apr 2023 07:33:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229790AbjDMLd1 (ORCPT ); Thu, 13 Apr 2023 07:33:27 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91BED113; Thu, 13 Apr 2023 04:33:25 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PxyBS2JZNz4f3wgy; Thu, 13 Apr 2023 19:33:20 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCH77KA6DdkC6FCHQ--.33135S4; Thu, 13 Apr 2023 19:33:22 +0800 (CST) From: Yu Kuai To: dm-devel@redhat.com, song@kernel.org, logang@deltatee.com Cc: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH -next v6 0/5] md: protect md_thread with rcu Date: Thu, 13 Apr 2023 19:32:12 +0800 Message-Id: <20230413113217.1934353-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 MIME-Version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xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org From: Yu Kuai Changes in v6: - remove first patch from v5, and use rcu_asign_pointer() directly from caller. - always use rcu_read_lock/unlock to protect mddev_set_timeout(). Changes in v5: - use rcu_dereference_protected() instead of rcu_access_pointer() where rcu_read_lock/unlock is not required. - add patch 4,5 to handle that bitmap timeout is set multiple times. Changes in v4: - remove patch 2 from v3 - fix sparse errors and warnings from v3, in order to do that, all access to md_thread need to be modified, patch 2-4 is splited to avoid a huge patch. Changes in v3: - remove patch 3 from v2 - use rcu instead of a new lock Changes in v2: - fix a compile error for md-cluster in patch 2 - replace spin_lock/unlock with spin_lock/unlock_irq in patch 5 - don't wake up inside the new lock in md wakeup_thread in patch 5 Yu Kuai (5): md: factor out a helper to wake up md_thread directly dm-raid: remove useless checking in raid_message() md/bitmap: always wake up md_thread in timeout_store md/bitmap: factor out a helper to set timeout md: protect md_thread with rcu drivers/md/dm-raid.c | 4 +- drivers/md/md-bitmap.c | 43 +++++++++++-------- drivers/md/md-cluster.c | 7 ++-- drivers/md/md-multipath.c | 4 +- drivers/md/md.c | 88 +++++++++++++++++++++------------------ drivers/md/md.h | 8 ++-- drivers/md/raid1.c | 7 ++-- drivers/md/raid1.h | 2 +- drivers/md/raid10.c | 21 ++++++---- drivers/md/raid10.h | 2 +- drivers/md/raid5-cache.c | 22 ++++++---- drivers/md/raid5.c | 15 +++---- drivers/md/raid5.h | 2 +- 13 files changed, 126 insertions(+), 99 deletions(-)