Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp723619ioo; Thu, 26 May 2022 13:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxePShWRfy8Df/gvYDbZPN54z+kjP5NpnmpS/0F855SxD+Hrg16Rem8hkoY6F25irRxouRo X-Received: by 2002:a05:6402:3293:b0:42b:aef6:7d3 with SMTP id f19-20020a056402329300b0042baef607d3mr12814092eda.371.1653596131911; Thu, 26 May 2022 13:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653596131; cv=none; d=google.com; s=arc-20160816; b=YsgApzAVmtAudzV0ySCa26QD3iK4tiLfS4MSb6q2J6lqKd4Iiw62mrxXPZ5uoPWhsN mLYu9SWWWzFkBeKaNfok5Sx0JMAxLUho7hhPBp4X16S61NFxuOlb7Ga7o4CePR9dL6wA +8kJL3as/gDDBTYkrCG8pejlOw9hOFH8Rc+66hcDeGsiZ/WH8lgowoqzLo05NcWBcEcX xq/NJEujuNDSqesJPQox9qO6nN+oAhhZ+BB47DsKymt3dR89lLLnZQtIEIZQ/mizDMgk 0jQzzlmnY4+sfVCK+NTpFbYj9nTqGorFuLxkAY0Tz6xjy7L+Sm79wYpMenGrivNFHGti ZYGA== 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=XV1DXWrKKUyaYd2rc55uj5hiPcVYzJEV2A7rBcUZk4Q=; b=rHG1hC28bZTNtMzSnHAP9BtXBeTu1Q+V4sW0KxZYYFgWamAHtWltY8XDxE4hmfHOej bHm4H/vOuP5ioAvNwbEaNRQFa2+CpN0QVdJSXR8j+1KOKp4nfovgQWyvNT7Swh/AsWjY LcyqskA97j5lDLojfHPVP7ZsjwUpbRZmzZFAcgFyaFQtQtdpEg0c/vhuwMK6T+irWFn4 jRVYiK7cIWSZNkb5hO10sO9LRESERbwJkeTE4WJN6ABXxb6cz6aXNbG6z4TXtfQeqjrQ QBdd5yTt3fqFRfYx/OpNN+kxR9JwyCot6eYraPUcSioeXG7DExZmgfLxbC6kfoXeNCMJ 3GEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=MAm+qCnV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e20-20020a17090658d400b006fe8ee84794si2912092ejs.370.2022.05.26.13.14.56; Thu, 26 May 2022 13:15:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b=MAm+qCnV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deltatee.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345275AbiEZQhM (ORCPT + 99 others); Thu, 26 May 2022 12:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344564AbiEZQge (ORCPT ); Thu, 26 May 2022 12:36:34 -0400 Received: from ale.deltatee.com (ale.deltatee.com [204.191.154.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C231948E61; Thu, 26 May 2022 09:36:23 -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=XV1DXWrKKUyaYd2rc55uj5hiPcVYzJEV2A7rBcUZk4Q=; b=MAm+qCnVxM/C65FlKFwRk9eaTh sHUhQOA8U1pN6j1RcbR64Gi1JDtEar1gF/WD8Il1BKzm/JyEOXD++tsl+9zJkCbCh2ttIx73vjZai 2M/nf7Xw+NOwPQZPtcnU2gsqcmDJdvdO5SjYWqHwEV28TMpGDWbaGyytQP7W8Qt6RJ0KJkejcvi7S Woy3kIHq73SNuRSW8SllyaZfDQhlTh3xRGZGgDFFiSUPMydlYdXjZ7a17c3iW50NeSxV4OKT2E1Qy jV8OoPeKKzibrwASWzwOX9g4bB9VS8GV03qUolDYhJVGl8E9Qo3n7DjavVILftIUwx85jLowSWSMq vkbqAHcw==; 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 1nuGTF-008A7V-RK; Thu, 26 May 2022 10:36:22 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.94.2) (envelope-from ) id 1nuGTA-0008Xj-6S; Thu, 26 May 2022 10:36:16 -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, 26 May 2022 10:35:59 -0600 Message-Id: <20220526163604.32736-13-logang@deltatee.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220526163604.32736-1-logang@deltatee.com> References: <20220526163604.32736-1-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Subject: [PATCH v2 12/17] md/raid5-cache: Move struct r5l_log definition to raid5-log.h 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 Move struct r5l_log definition to raid5-log.h. While this reduces encapsulation, it is necessary for the definition of r5l_log to be public so that rcu_access_pointer() can be used on conf-log in the next patch. rcu_access_pointer(p) doesn't technically dereference the log pointer however, it does use typeof(*p) and some older GCC versions (anything earlier than gcc-10) will wrongly try to dereference the structure: include/linux/rcupdate.h:384:9: error: dereferencing pointer to incomplete type ‘struct r5l_log’ typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ ^ include/linux/rcupdate.h:495:31: note: in expansion of macro ‘__rcu_access_pointer’ #define rcu_access_pointer(p) __rcu_access_pointer((p), __UNIQUE_ID(rcu), __rcu) To prevent this, simply provide the definition where rcu_access_pointer() may be used. Reported-by: Donald Buczek Signed-off-by: Logan Gunthorpe --- drivers/md/raid5-cache.c | 75 ---------------------------------------- drivers/md/raid5-log.h | 75 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c index a3c4d43d6deb..6349cfaae2c8 100644 --- a/drivers/md/raid5-cache.c +++ b/drivers/md/raid5-cache.c @@ -79,81 +79,6 @@ static char *r5c_journal_mode_str[] = {"write-through", * - return IO for pending writes */ -struct r5l_log { - struct md_rdev *rdev; - - u32 uuid_checksum; - - sector_t device_size; /* log device size, round to - * BLOCK_SECTORS */ - sector_t max_free_space; /* reclaim run if free space is at - * this size */ - - sector_t last_checkpoint; /* log tail. where recovery scan - * starts from */ - u64 last_cp_seq; /* log tail sequence */ - - sector_t log_start; /* log head. where new data appends */ - u64 seq; /* log head sequence */ - - sector_t next_checkpoint; - - struct mutex io_mutex; - struct r5l_io_unit *current_io; /* current io_unit accepting new data */ - - spinlock_t io_list_lock; - struct list_head running_ios; /* io_units which are still running, - * and have not yet been completely - * written to the log */ - struct list_head io_end_ios; /* io_units which have been completely - * written to the log but not yet written - * to the RAID */ - struct list_head flushing_ios; /* io_units which are waiting for log - * cache flush */ - struct list_head finished_ios; /* io_units which settle down in log disk */ - struct bio flush_bio; - - struct list_head no_mem_stripes; /* pending stripes, -ENOMEM */ - - struct kmem_cache *io_kc; - mempool_t io_pool; - struct bio_set bs; - mempool_t meta_pool; - - struct md_thread *reclaim_thread; - unsigned long reclaim_target; /* number of space that need to be - * reclaimed. if it's 0, reclaim spaces - * used by io_units which are in - * IO_UNIT_STRIPE_END state (eg, reclaim - * dones't wait for specific io_unit - * switching to IO_UNIT_STRIPE_END - * state) */ - wait_queue_head_t iounit_wait; - - struct list_head no_space_stripes; /* pending stripes, log has no space */ - spinlock_t no_space_stripes_lock; - - bool need_cache_flush; - - /* for r5c_cache */ - enum r5c_journal_mode r5c_journal_mode; - - /* all stripes in r5cache, in the order of seq at sh->log_start */ - struct list_head stripe_in_journal_list; - - spinlock_t stripe_in_journal_lock; - atomic_t stripe_in_journal_count; - - /* to submit async io_units, to fulfill ordering of flush */ - struct work_struct deferred_io_work; - /* to disable write back during in degraded mode */ - struct work_struct disable_writeback_work; - - /* to for chunk_aligned_read in writeback mode, details below */ - spinlock_t tree_lock; - struct radix_tree_root big_stripe_tree; -}; - /* * Enable chunk_aligned_read() with write back cache. * diff --git a/drivers/md/raid5-log.h b/drivers/md/raid5-log.h index 1c184fe20939..5948c41f1f2e 100644 --- a/drivers/md/raid5-log.h +++ b/drivers/md/raid5-log.h @@ -2,6 +2,81 @@ #ifndef _RAID5_LOG_H #define _RAID5_LOG_H +struct r5l_log { + struct md_rdev *rdev; + + u32 uuid_checksum; + + sector_t device_size; /* log device size, round to + * BLOCK_SECTORS */ + sector_t max_free_space; /* reclaim run if free space is at + * this size */ + + sector_t last_checkpoint; /* log tail. where recovery scan + * starts from */ + u64 last_cp_seq; /* log tail sequence */ + + sector_t log_start; /* log head. where new data appends */ + u64 seq; /* log head sequence */ + + sector_t next_checkpoint; + + struct mutex io_mutex; + struct r5l_io_unit *current_io; /* current io_unit accepting new data */ + + spinlock_t io_list_lock; + struct list_head running_ios; /* io_units which are still running, + * and have not yet been completely + * written to the log */ + struct list_head io_end_ios; /* io_units which have been completely + * written to the log but not yet written + * to the RAID */ + struct list_head flushing_ios; /* io_units which are waiting for log + * cache flush */ + struct list_head finished_ios; /* io_units which settle down in log disk */ + struct bio flush_bio; + + struct list_head no_mem_stripes; /* pending stripes, -ENOMEM */ + + struct kmem_cache *io_kc; + mempool_t io_pool; + struct bio_set bs; + mempool_t meta_pool; + + struct md_thread *reclaim_thread; + unsigned long reclaim_target; /* number of space that need to be + * reclaimed. if it's 0, reclaim spaces + * used by io_units which are in + * IO_UNIT_STRIPE_END state (eg, reclaim + * dones't wait for specific io_unit + * switching to IO_UNIT_STRIPE_END + * state) */ + wait_queue_head_t iounit_wait; + + struct list_head no_space_stripes; /* pending stripes, log has no space */ + spinlock_t no_space_stripes_lock; + + bool need_cache_flush; + + /* for r5c_cache */ + enum r5c_journal_mode r5c_journal_mode; + + /* all stripes in r5cache, in the order of seq at sh->log_start */ + struct list_head stripe_in_journal_list; + + spinlock_t stripe_in_journal_lock; + atomic_t stripe_in_journal_count; + + /* to submit async io_units, to fulfill ordering of flush */ + struct work_struct deferred_io_work; + /* to disable write back during in degraded mode */ + struct work_struct disable_writeback_work; + + /* to for chunk_aligned_read in writeback mode, details below */ + spinlock_t tree_lock; + struct radix_tree_root big_stripe_tree; +}; + int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev); void r5l_exit_log(struct r5conf *conf); int r5l_write_stripe(struct r5conf *conf, struct stripe_head *head_sh); -- 2.30.2