Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp49493pxh; Thu, 7 Apr 2022 13:37:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvOLZf+pSAgkU7FCTnEQm8peg38WuNEpNbXCDh0wpQtVqyyRjNzYHIYkpikm/DMo6ARhog X-Received: by 2002:a17:902:8a95:b0:156:a40a:71e5 with SMTP id p21-20020a1709028a9500b00156a40a71e5mr15798189plo.144.1649363870592; Thu, 07 Apr 2022 13:37:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649363870; cv=none; d=google.com; s=arc-20160816; b=ig+Ar5FAFBfBltTQAQyhL/B1ah5gcgxf6w4RXSS3+jfvqV0NJSe+fRTA0P+0lAX0s2 a7s8ZOCogXlqkxLddwXk0/+kNrPWuqeIapw1y632PavHmaJvmN+wARuRBt7OrC7zDwC5 6ji2QvgRPE1hNvJ0TTxgfwb4QDtK6585k2NHSpt/OdwgMg24gd057v9cnpGtsHbmhHGE ggBqnLuVtBDAuR8ssas++h13L83rsYozXmeSY8fH2UinC2G8w141sVTYmrqDg+b/CG/w 07ICGOFGp8Jok/J2sr+kP0rx7VDLIjftfOFJjMRQz15Ph9m70ZMS7ki4RAq6C42//E49 mbCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=UgtYxnZUE1oxXmbmvyRy5xJTosToTlA4CekiENW7Cls=; b=VBE+HlfzE8OlXDFMiSeXZdwLGAG9Shp6bZadn/BwHVHFyxDUArPsZ3jFb04h6vBf5c o4nisf7Ju5qu70aGqzd3cUm1jVASYtl6eBrRjzH3iRBj9SufeOGQL+QuaWXBM3K6Rpql GEy/bwDQsl/8jVMKmvxu/mtdmt4XnwSGtm0f/AEfT4ufeclmCyKZPfGXZwyxkE7/NZZ+ XWrNKeEuJsSwjswPLeiT/gJ2ynsNIWt4W8s+6KYliKcQh6FTqIeHzczA85PVDUHG3tHb AxTtx5baPERkhKPc6miPxrqyQZCxX60jWND/SLndih+k8wQBJIdrZQjDC2t1MEyhj1Jn X4tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=jnjOkpzV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g4-20020a056a000b8400b004fa7d7af61fsi20664687pfj.53.2022.04.07.13.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:37:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=jnjOkpzV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A2203A4280; Thu, 7 Apr 2022 12:48:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346104AbiDGRYG (ORCPT + 99 others); Thu, 7 Apr 2022 13:24:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346073AbiDGRX4 (ORCPT ); Thu, 7 Apr 2022 13:23:56 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ABC513D47; Thu, 7 Apr 2022 10:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:Cc:To:From:content-disposition; bh=UgtYxnZUE1oxXmbmvyRy5xJTosToTlA4CekiENW7Cls=; b=jnjOkpzVmSD5gJjs8S1zA0j10R r8dfSrudZSfcdJ6AAZAo1oZsAdoESIfQHFSPlJ7K+lH2O2+0XIKu+O97UNcy7GzUIsNQWJ3OBSHFT H0q70jDul3A8ZIXl2ZZ9agedNP8En3+70WLhOKx6bVNMRhMjANV6kEoaM6EDuCWex3Qbjl/UOq6J/ ErssYOokp0bCgJqgPK0GwYQn/1gHzMPdqqPg5e/9DU6ur/wctu3zIbxLFBZwSYr1ayzdVoUkRJOvb j717nYL9BwU6GOiHFobGxOmppewwQU5f3HkGv8QfuQE0UE3wJS80RHGyBjHxcbbVarOob8wsDd3iq bTEGeynw==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ncVRg-002CRf-CN; Thu, 07 Apr 2022 10:57:21 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1ncVRf-0002QG-LB; Thu, 07 Apr 2022 10:57:19 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu Cc: Guoqing Jiang , Logan Gunthorpe Date: Thu, 7 Apr 2022 10:57:12 -0600 Message-Id: <20220407165713.9243-7-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220407165713.9243-1-logang@deltatee.com> References: <20220407165713.9243-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, song@kernel.org, guoqing.jiang@linux.dev, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Subject: [PATCH v1 6/7] md/raid5-ppl: Annotate with rcu_dereference_protected() X-SA-Exim-Version: 4.2.1 (built Sat, 13 Feb 2021 17:57:42 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To suppress the last remaining sparse warnings about accessing rdev, add rcu_dereference_protected calls to a couple places in raid5-ppl. All of these places are called under raid5_run and therefore are occurring before the array has started and is thus safe. There's no sensible check to do for the second argument of rcu_dereference_protected() so a comment is added instead. Signed-off-by: Logan Gunthorpe --- drivers/md/raid5-ppl.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c index d3962d92df18..55d065a87b89 100644 --- a/drivers/md/raid5-ppl.c +++ b/drivers/md/raid5-ppl.c @@ -883,7 +883,9 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e, (unsigned long long)r_sector, dd_idx, (unsigned long long)sector); - rdev = conf->disks[dd_idx].rdev; + /* Array has not started so rcu dereference is safe */ + rdev = rcu_dereference_protected( + conf->disks[dd_idx].rdev, 1); if (!rdev || (!test_bit(In_sync, &rdev->flags) && sector >= rdev->recovery_offset)) { pr_debug("%s:%*s data member disk %d missing\n", @@ -934,7 +936,10 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e, parity_sector = raid5_compute_sector(conf, r_sector_first + i, 0, &disk, &sh); BUG_ON(sh.pd_idx != le32_to_cpu(e->parity_disk)); - parity_rdev = conf->disks[sh.pd_idx].rdev; + + /* Array has not started so rcu dereference is safe */ + parity_rdev = rcu_dereference_protected( + conf->disks[sh.pd_idx].rdev, 1); BUG_ON(parity_rdev->bdev->bd_dev != log->rdev->bdev->bd_dev); pr_debug("%s:%*s write parity at sector %llu, disk %s\n", @@ -1404,7 +1409,9 @@ int ppl_init_log(struct r5conf *conf) for (i = 0; i < ppl_conf->count; i++) { struct ppl_log *log = &ppl_conf->child_logs[i]; - struct md_rdev *rdev = conf->disks[i].rdev; + /* Array has not started so rcu dereference is safe */ + struct md_rdev *rdev = + rcu_dereference_protected(conf->disks[i].rdev, 1); mutex_init(&log->io_mutex); spin_lock_init(&log->io_list_lock); -- 2.30.2