Re: [PATCH v2 12/17] md/raid5-cache: Move struct r5l_log definition to raid5-log.h

From: Christoph Hellwig
Date: Mon May 30 2022 - 01:59:17 EST


On Thu, May 26, 2022 at 10:35:59AM -0600, Logan Gunthorpe wrote:
> 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.

What about just moving any code that does the rcu_access_pointer on
conf->log to raid5-cache.c and doing an out of line call for it
instead?