Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp76134iof; Sun, 5 Jun 2022 21:36:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNyE1yqw1quuWGxC0I4pfPwQ+pq+iTs52PGVHkpt51B87ZyrIqZwKHSmWFXH4a3/8mWHf3 X-Received: by 2002:a62:c146:0:b0:51b:8c73:acad with SMTP id i67-20020a62c146000000b0051b8c73acadmr22611432pfg.22.1654490207802; Sun, 05 Jun 2022 21:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654490207; cv=none; d=google.com; s=arc-20160816; b=cb6JDnd2W50J+FXDzNSduvBGCnN0qeenqx4kgvZfc/rYrdxv+tu/WKMZH8amW/FF7B ntgHy7ffe6YmyKQRcSm7zBewyTRmK3GonKhNiLFm98Tc3Iwr1KNv7R2vpVbbeLciwnjk qkKS3cF3xZDjyLBQyn9LPTRBxbL0fuqMt3FnmhFNqSnqd4hEtnefxby8K7m+XD4Who4Y YU7/C7So6gEBCzfGi2u16ghDwVCMzMsQqKXjWwXTa4hZerpbsxdaYatiEVl63BmitWu+ vUo5qXAAuzcYUz3kr3HczqzSQ8sTvC35g8Bn2C/bbCfowKYtL0BqhCEPaRE4yQosDOtT jQEg== 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=KPxyHl5McdIBsrZVYzmedsuwOe9Hs+sIzKMYT+CRgdg=; b=uVUMLfMHzpO/gh27/33DSj8syC3zagmJ/ssnWuTbxIAQhJjUHHBWqV2lGEvJpVRpSn xVocMD4UZU0Ul7Zh3tgL7H4D+itOuFlBPTuHlfXh5QQk/j/fJE4yhA9Xwq8I/z4To5I2 bHKBFfhfMimWesGOJkRjFuDesftNrIlQuLiDUu5NZLsUx6XBZkre9/KprIh1f633zICp PBIjkxU3LK0NnBVLJ7/8+DBdVu4BxovS7YABZMsPMpk/7ijLcDy04U5+YpMPx9AUpReY re06aAWu+4GUk/LIaSJi5UknbeNQIHXA2s7HjQOVq1Y9p+7VwVzoYwsJn33uUmja/ofJ pCtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=LrSxondl; 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 s11-20020a6550cb000000b003c6c6e29bc6si18247690pgp.416.2022.06.05.21.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:36:47 -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=LrSxondl; 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 C2FFF986F5; Sun, 5 Jun 2022 21:01:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238069AbiFBSTL (ORCPT + 99 others); Thu, 2 Jun 2022 14:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237945AbiFBSSg (ORCPT ); Thu, 2 Jun 2022 14:18:36 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA0904E39D; Thu, 2 Jun 2022 11:18:24 -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=KPxyHl5McdIBsrZVYzmedsuwOe9Hs+sIzKMYT+CRgdg=; b=LrSxondlmjxzZxumaLp+VeRQmL +w29AInQ3Q5NOcs2iyjAo8P1tOCCAdrn2QglNlg7cBAfz8mUSwyE59rJwCEaj2qqdW/IpSxBdkJ69 qBtVxXDt8alIh8LRXVDde0zJPaoajE5Q6+N2M966Oy7YZQMDJO1vOlbmGusYi7ic1L7hXqJHqh3+V TEcNUmWG3wNoO+32fdszC037WEzcF7Okw5gvPh1W70Z6lzq9ybdMJ/wyQOEcqOYxD5o4rLyLKozSk fLfK5ywNlZP4kFUNTvY8kBU3ckFYJkspm8bZlcLUF+L08srAfP2Nh0I9EmHuSaP3moj7EiUtMCTZw /w7aY6dQ==; 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 1nwpOo-00EPmV-R8; Thu, 02 Jun 2022 12:18:23 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1nwpOm-000DDP-52; Thu, 02 Jun 2022 12:18:20 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu Cc: Christoph Hellwig , Donald Buczek , Guoqing Jiang , Xiao Ni , Stephen Bates , Martin Oliveira , David Sloan , Logan Gunthorpe Date: Thu, 2 Jun 2022 12:18:11 -0600 Message-Id: <20220602181818.50729-6-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220602181818.50729-1-logang@deltatee.com> References: <20220602181818.50729-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, hch@infradead.org, buczek@molgen.mpg.de, guoqing.jiang@linux.dev, xni@redhat.com, sbates@raithlin.com, Martin.Oliveira@eideticom.com, David.Sloan@eideticom.com, 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 autolearn=no autolearn_force=no version=3.4.6 Subject: [PATCH v3 05/11] md/raid5-cache: Drop RCU usage of conf->log 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 The only place that uses RCU to access conf->log is in r5l_log_disk_error(). This function is mostly used in the IO path and once with mddev_lock() held in raid5_change_consistency_policy(). It is known that the IO will be suspended before the log is freed and r5l_log_exit() is called with the mddev_lock() held. This should mean that conf->log can not be freed while the function is being called, so the RCU protection is not necessary. Drop the rcu_read_lock() as well as the synchronize_rcu() and rcu_assign_pointer() usage. Signed-off-by: Logan Gunthorpe --- drivers/md/raid5-cache.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c index 69b95005abca..48020d36b334 100644 --- a/drivers/md/raid5-cache.c +++ b/drivers/md/raid5-cache.c @@ -1590,18 +1590,13 @@ void r5l_quiesce(struct r5l_log *log, int quiesce) bool r5l_log_disk_error(struct r5conf *conf) { - struct r5l_log *log; - bool ret; - /* don't allow write if journal disk is missing */ - rcu_read_lock(); - log = rcu_dereference(conf->log); + struct r5l_log *log = conf->log; + /* don't allow write if journal disk is missing */ if (!log) - ret = test_bit(MD_HAS_JOURNAL, &conf->mddev->flags); + return test_bit(MD_HAS_JOURNAL, &conf->mddev->flags); else - ret = test_bit(Faulty, &log->rdev->flags); - rcu_read_unlock(); - return ret; + return test_bit(Faulty, &log->rdev->flags); } #define R5L_RECOVERY_PAGE_POOL_SIZE 256 @@ -3148,7 +3143,7 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev) spin_lock_init(&log->stripe_in_journal_lock); atomic_set(&log->stripe_in_journal_count, 0); - rcu_assign_pointer(conf->log, log); + conf->log = log; set_bit(MD_HAS_JOURNAL, &conf->mddev->flags); return 0; @@ -3173,7 +3168,6 @@ void r5l_exit_log(struct r5conf *conf) lockdep_assert_held(&conf->mddev->reconfig_mutex); conf->log = NULL; - synchronize_rcu(); /* Ensure disable_writeback_work wakes up and exits */ wake_up(&conf->mddev->sb_wait); -- 2.30.2