diff mbox

ceph: fix symbol versioning for ceph_monc_do_statfs

Message ID 1465823125-171114-1-git-send-email-arnd@arndb.de (mailing list archive)
State New, archived
Headers show

Commit Message

Arnd Bergmann June 13, 2016, 1:04 p.m. UTC
The genksyms helper in the kernel cannot parse a type definition
like "typeof(((type *)0)->keyfld)" that is used in the DEFINE_RB_FUNCS
helper, causing the following EXPORT_SYMBOL() statement to be ignored
when computing the crcs, and triggering a warning about this:

WARNING: "ceph_monc_do_statfs" [fs/ceph/ceph.ko] has no CRC

To work around the problem, we can rewrite the type to reference
an undefined 'extern' symbol instead of a NULL pointer. This is
evidently ok for genksyms, and it no longer complains about the
line when calling it with 'genksyms -w'.

I've looked briefly into extending genksyms instead, but it seems
really hard to do. Jan Beulich introduced basic support for 'typeof'
a while ago in dc53324060f3 ("genksyms: fix typeof() handling"),
but that is not sufficient for the expression we have here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: fcd00b68bbe2 ("libceph: DEFINE_RB_FUNCS macro")
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Michal Marek <mmarek@suse.cz>
---
 include/linux/ceph/libceph.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ilya Dryomov June 13, 2016, 1:19 p.m. UTC | #1
On Mon, Jun 13, 2016 at 3:04 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> The genksyms helper in the kernel cannot parse a type definition
> like "typeof(((type *)0)->keyfld)" that is used in the DEFINE_RB_FUNCS
> helper, causing the following EXPORT_SYMBOL() statement to be ignored
> when computing the crcs, and triggering a warning about this:
>
> WARNING: "ceph_monc_do_statfs" [fs/ceph/ceph.ko] has no CRC
>
> To work around the problem, we can rewrite the type to reference
> an undefined 'extern' symbol instead of a NULL pointer. This is
> evidently ok for genksyms, and it no longer complains about the
> line when calling it with 'genksyms -w'.
>
> I've looked briefly into extending genksyms instead, but it seems
> really hard to do. Jan Beulich introduced basic support for 'typeof'
> a while ago in dc53324060f3 ("genksyms: fix typeof() handling"),
> but that is not sufficient for the expression we have here.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: fcd00b68bbe2 ("libceph: DEFINE_RB_FUNCS macro")
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Michal Marek <mmarek@suse.cz>
> ---
>  include/linux/ceph/libceph.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
> index 690985daad1c..6b79a6ba39ca 100644
> --- a/include/linux/ceph/libceph.h
> +++ b/include/linux/ceph/libceph.h
> @@ -214,8 +214,9 @@ static void erase_##name(struct rb_root *root, type *t)                     \
>  }
>
>  #define DEFINE_RB_LOOKUP_FUNC(name, type, keyfld, nodefld)             \
> +extern type __lookup_##name##_key;                                     \
>  static type *lookup_##name(struct rb_root *root,                       \
> -                          typeof(((type *)0)->keyfld) key)             \
> +                          typeof(__lookup_##name##_key.keyfld) key)    \
>  {                                                                      \
>         struct rb_node *n = root->rb_node;                              \
>                                                                         \

Out of curiosity, did you figure out why is it that only
ceph_monc_do_statfs() is affected and not the other exports in
net/ceph/osd_client.c?

Thanks,

                Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann June 13, 2016, 2:59 p.m. UTC | #2
On Monday, June 13, 2016 3:19:12 PM CEST Ilya Dryomov wrote:
> > diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
> > index 690985daad1c..6b79a6ba39ca 100644
> > --- a/include/linux/ceph/libceph.h
> > +++ b/include/linux/ceph/libceph.h
> > @@ -214,8 +214,9 @@ static void erase_##name(struct rb_root *root, type *t)                     \
> >  }
> >
> >  #define DEFINE_RB_LOOKUP_FUNC(name, type, keyfld, nodefld)             \
> > +extern type __lookup_##name##_key;                                     \
> >  static type *lookup_##name(struct rb_root *root,                       \
> > -                          typeof(((type *)0)->keyfld) key)             \
> > +                          typeof(__lookup_##name##_key.keyfld) key)    \
> >  {                                                                      \
> >         struct rb_node *n = root->rb_node;                              \
> >                                                                         \
> 
> Out of curiosity, did you figure out why is it that only
> ceph_monc_do_statfs() is affected and not the other exports in
> net/ceph/osd_client.c?

No, I did not investigate it further at that point. My guess is that
something resets the state of the genksyms parser when it encounters
some tokens (like the semicolon I added earlier, or an EXPORT_SYMBOL
statement), and that this happens in one file but not the other.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek Aug. 26, 2016, 12:40 p.m. UTC | #3
On 2016-06-13 15:04, Arnd Bergmann wrote:
> The genksyms helper in the kernel cannot parse a type definition
> like "typeof(((type *)0)->keyfld)" that is used in the DEFINE_RB_FUNCS
> helper, causing the following EXPORT_SYMBOL() statement to be ignored
> when computing the crcs, and triggering a warning about this:
> 
> WARNING: "ceph_monc_do_statfs" [fs/ceph/ceph.ko] has no CRC

FYI, Nick fixed the genksyms state machine to cope with this syntax. See
commits

5c6f3225d00d kbuild: Regenerate genksyms lexer
4fab91605a6b kbuild: genksyms fix for typeof handling

in today's linux-next. So the workaround can eventually be reverted.

Michal
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
index 690985daad1c..6b79a6ba39ca 100644
--- a/include/linux/ceph/libceph.h
+++ b/include/linux/ceph/libceph.h
@@ -214,8 +214,9 @@  static void erase_##name(struct rb_root *root, type *t)			\
 }
 
 #define DEFINE_RB_LOOKUP_FUNC(name, type, keyfld, nodefld)		\
+extern type __lookup_##name##_key;					\
 static type *lookup_##name(struct rb_root *root,			\
-			   typeof(((type *)0)->keyfld) key)		\
+			   typeof(__lookup_##name##_key.keyfld) key)	\
 {									\
 	struct rb_node *n = root->rb_node;				\
 									\