Message ID | 20231016092439.493646-1-yukuai1@huaweicloud.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3179644vqb; Sun, 15 Oct 2023 18:29:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOR8R95vjLNKB8qrKBtcY/1XC4YMuDe5kelCOLdBr6s08LSfid1q+eKrKiWa9/vjnP2mha X-Received: by 2002:a05:6a00:391c:b0:690:d0d4:6fb0 with SMTP id fh28-20020a056a00391c00b00690d0d46fb0mr36040376pfb.3.1697419743954; Sun, 15 Oct 2023 18:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697419743; cv=none; d=google.com; s=arc-20160816; b=oJvN/QEvTc7gZ8RlCPHKRFUkNjQM/4PbGvu1nw3oz+oG7DzrinDBVqrECcR0I8M8c4 nAxnwBuINyAZJgqahpqKIKkunM8r8EgHzKvHKqET+iMCAZ754u3WoIY/hJm79ZK5qj2T oQjl9lnKpyqpFDqcngvGme3U0E3Hbe5mmAAuSYkx1B7ItQD9ycTeCbBFLt5TeTNedoHd 7jMXj1U8FCVD7U8rr5UTBeH/3EeYO5jaQHhNGmvQTP4jNdV8Ot/N4mMg3cLcq1J5Y8rU T5pZWjjRhW1sRB4fVsmUAJuQgXacg+oWiNPFoy+fAHYaUE8+IqGjOF3Aarr0YCef14gY h/nA== 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 :message-id:date:subject:cc:to:from; bh=GsyQ7Vzz0sN4sQDSe9cBu+hUHYrXXzqvrUJJwO/h7mE=; fh=d9c5gHOb3LccGp7KhO2PTidd9oOuOSBo1OJ/8DRRGxA=; b=LB8Okr+eXw6dfLb4hcRvJapYT0vIgHw/laM3XeDgsL2L4uwqzGB/yjy9IOo9ZO4CRj 7luJrOoLRvayr9Hlk92fCxpNuYg+p5+/sya5kQIgpyxzqjonmDYPZ4B9WBJtSgdq4Q1+ EvPv2V+xb2C3sTTVs+4NiB5T2IfmzYCM+GFzQ44KZgCtp1FzaQJRPXsXBaws54y/GU+c F1QfBILpzF1R1JVVVOag32TqMxdL6DjKD01PkwQjFCn5e2+lJbfLzLrRNMetrzZooTvS XERQoQ2CVIryN+I9FEU4hCYxMsi79cdngk2+CaZjU3Y4wE0nQoMGCzpVj+hpUREMAVBv BlXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z8-20020aa78888000000b006b7abfbf700si5330481pfe.394.2023.10.15.18.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 18:29:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 7088E805935B; Sun, 15 Oct 2023 18:28:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230442AbjJPB2m (ORCPT <rfc822;hjfbswb@gmail.com> + 19 others); Sun, 15 Oct 2023 21:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjJPB2l (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 15 Oct 2023 21:28:41 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10AB0D6; Sun, 15 Oct 2023 18:28:40 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4S7zyn0Mw0z4f3n5j; Mon, 16 Oct 2023 09:28:33 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgB3BdXCkSxl3zBODA--.42064S4; Mon, 16 Oct 2023 09:28:35 +0800 (CST) From: Yu Kuai <yukuai1@huaweicloud.com> To: song@kernel.org 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 0/6] md: remvoe rcu protection to access rdev from conf Date: Mon, 16 Oct 2023 17:24:33 +0800 Message-Id: <20231016092439.493646-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgB3BdXCkSxl3zBODA--.42064S4 X-Coremail-Antispam: 1UD129KBjvdXoWruF18CFWUAr1fJryxXw45trb_yoW3ZrbEvF WjqFyfKr4xtFy3Gw13Wrn7uryUAF4q9Fn2qF1DKrWYvry3Zr1UKr4DZr4fXw1UuFZ09r1k Xry8Gw18Ar4jvjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbxxFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M28lY4IEw2IIxx k0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK 6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7 xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40E FcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr 0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8v x2IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1l IxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxV AFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_ Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjTRNg AwUUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.7 required=5.0 tests=DATE_IN_FUTURE_06_12, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 15 Oct 2023 18:28:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779873605678395128 X-GMAIL-MSGID: 1779873605678395128 |
Series |
md: remvoe rcu protection to access rdev from conf
|
|
Message
Yu Kuai
Oct. 16, 2023, 9:24 a.m. UTC
From: Yu Kuai <yukuai3@huawei.com>
Yu Kuai (6):
md: remove useless debug code to print configuration
md: remove flag RemoveSynchronized
md/raid1: remove rcu protection to access rdev from conf
md/raid10: remove rcu protection to access rdev from conf
md/raid5: remove rcu protection to access rdev from conf
md/md-multipath: remove rcu protection to access rdev from conf
drivers/md/md-multipath.c | 29 ++---
drivers/md/md.c | 37 +-----
drivers/md/raid1.c | 94 ++++-----------
drivers/md/raid10.c | 248 +++++++++-----------------------------
drivers/md/raid5-cache.c | 11 +-
drivers/md/raid5-ppl.c | 16 +--
drivers/md/raid5.c | 225 ++++++++++------------------------
drivers/md/raid5.h | 4 +-
8 files changed, 163 insertions(+), 501 deletions(-)
Comments
On Sun, Oct 15, 2023 at 6:28 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > From: Yu Kuai <yukuai3@huawei.com> > > Yu Kuai (6): > md: remove useless debug code to print configuration > md: remove flag RemoveSynchronized > md/raid1: remove rcu protection to access rdev from conf > md/raid10: remove rcu protection to access rdev from conf > md/raid5: remove rcu protection to access rdev from conf > md/md-multipath: remove rcu protection to access rdev from conf While a cover letter is highly recommended for a patchset. An empty cover letter like this doesn't really add value. If the description of each patch is clear enough, it is OK to not have a cover-letter. Thanks, Song > > drivers/md/md-multipath.c | 29 ++--- > drivers/md/md.c | 37 +----- > drivers/md/raid1.c | 94 ++++----------- > drivers/md/raid10.c | 248 +++++++++----------------------------- > drivers/md/raid5-cache.c | 11 +- > drivers/md/raid5-ppl.c | 16 +-- > drivers/md/raid5.c | 225 ++++++++++------------------------ > drivers/md/raid5.h | 4 +- > 8 files changed, 163 insertions(+), 501 deletions(-) > > -- > 2.39.2 >
Hi, 在 2023/10/19 1:58, Song Liu 写道: > On Sun, Oct 15, 2023 at 6:28 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: >> >> From: Yu Kuai <yukuai3@huawei.com> >> >> Yu Kuai (6): >> md: remove useless debug code to print configuration >> md: remove flag RemoveSynchronized >> md/raid1: remove rcu protection to access rdev from conf >> md/raid10: remove rcu protection to access rdev from conf >> md/raid5: remove rcu protection to access rdev from conf >> md/md-multipath: remove rcu protection to access rdev from conf > > While a cover letter is highly recommended for a patchset. An empty > cover letter like this doesn't really add value. If the description of each > patch is clear enough, it is OK to not have a cover-letter. Yes, I was hoping commit message in each patch is clear enough,I'll try to explain everything more detailed. Thanks, Kuai > > Thanks, > Song > >> >> drivers/md/md-multipath.c | 29 ++--- >> drivers/md/md.c | 37 +----- >> drivers/md/raid1.c | 94 ++++----------- >> drivers/md/raid10.c | 248 +++++++++----------------------------- >> drivers/md/raid5-cache.c | 11 +- >> drivers/md/raid5-ppl.c | 16 +-- >> drivers/md/raid5.c | 225 ++++++++++------------------------ >> drivers/md/raid5.h | 4 +- >> 8 files changed, 163 insertions(+), 501 deletions(-) >> >> -- >> 2.39.2 >> > . >
Hi, 在 2023/10/19 9:04, Yu Kuai 写道: > Hi, > > 在 2023/10/19 1:58, Song Liu 写道: >> On Sun, Oct 15, 2023 at 6:28 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: >>> >>> From: Yu Kuai <yukuai3@huawei.com> >>> >>> Yu Kuai (6): >>> md: remove useless debug code to print configuration >>> md: remove flag RemoveSynchronized >>> md/raid1: remove rcu protection to access rdev from conf >>> md/raid10: remove rcu protection to access rdev from conf >>> md/raid5: remove rcu protection to access rdev from conf >>> md/md-multipath: remove rcu protection to access rdev from conf >> >> While a cover letter is highly recommended for a patchset. An empty >> cover letter like this doesn't really add value. If the description of >> each >> patch is clear enough, it is OK to not have a cover-letter. > > Yes, I was hoping commit message in each patch is clear enough,I'll try > to explain everything more detailed. I'll add following cover letter in the next version: The lifetime of rdev: 1. md_import_device() generate a rdev based on underlying disk; mddev_lock() rdev = kzalloc(); rdev->bdev = blkdev_get_by_dev(); mddev_unlock() 2. bind_rdev_to_array() add this rdev to mddev->disks; mddev_lock() kobject_add(&rdev->kobj, &mddev->kobj, ...); list_add_rcu(&rdev->same_set, &mddev->disks); mddev_unlock() 3. remove_and_add_spares() add this rdev to conf; mddev_lock() rdev_addable(); pers->hot_add_disk(); rcu_assign_pointer(conf->rdev, rdev); mddev_unlock() 4. Use this array with rdev; 5. remove_and_add_spares() remove rdev from conf; // triggered by sysfs/ioctl mddev_lock() rdev_removeable(); pers->hot_remove_disk(); rcu_assign_pointer(conf->rdev, NULL); synchronize_rcu(); mddev_unlock() // triggered by deamon mddev_lock() rdev_removeable(); synchronize_rcu(); -> this can't protect accessing rdev from conf pers->hot_remove_disk(); rcu_assign_pointer(conf->rdev, NULL); mddev_unlock() 6. md_kick_rdev_from_array() remove rdev from mddev->disks; mddev_lock() list_del_rcu(&rdev->same_set); synchronize_rcu(); list_add(&rdev->same_set, &mddev->deleting) mddev_unlock() export_rdev There are two seperate rcu protection for rdev, and this pathset remove the protection of conf(step 3 and 5), because it's safe to access rdev from conf in following cases: - If 'reconfig_mutex' is held, because rdev can't be added or rmoved to conf; - If there is normal IO inflight, because mddev_suspend() will prevent rdev to be added or removed to conf; - If sync thread is running, because remove_and_add_spares() can only be called from daemon thread when sync thread is done, and 'MD_RECOVERY_RUNNING' is also checked for ioctl/sysfs; - if rcu_read_lock() or any spinlock is held, because synchronize_rcu() from step 6 prevent rdev to be freed until rcu_read_unlock() or spinlock is released; Thanks, Kuai > > Thanks, > Kuai > >> >> Thanks, >> Song >> >>> >>> drivers/md/md-multipath.c | 29 ++--- >>> drivers/md/md.c | 37 +----- >>> drivers/md/raid1.c | 94 ++++----------- >>> drivers/md/raid10.c | 248 +++++++++----------------------------- >>> drivers/md/raid5-cache.c | 11 +- >>> drivers/md/raid5-ppl.c | 16 +-- >>> drivers/md/raid5.c | 225 ++++++++++------------------------ >>> drivers/md/raid5.h | 4 +- >>> 8 files changed, 163 insertions(+), 501 deletions(-) >>> >>> -- >>> 2.39.2 >>> >> . >> > > . >