[LU-17052] inux-prim.c:129:25: error: dereferencing pointer to incomplete type ‘struct xa_node’ Created: 25/Aug/23  Updated: 06/Sep/23  Resolved: 06/Sep/23

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.16.0

Type: Bug Priority: Minor
Reporter: Xinliang Liu Assignee: Xinliang Liu
Resolution: Fixed Votes: 0
Labels: None

Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

Recent commit "778791dd7d LU-8130 libcfs: don't use radix tree for xarray" breaks build on old kernel 4.17-4.19:

make[3]: Entering directory '/usr/src/kernels/4.19.90-2308.2.0.0213.oe1.aarch64'
  CC [M]  /home/openeuler/lustre-release/libcfs/libcfs/linux/linux-prim.o
/home/openeuler/lustre-release/libcfs/libcfs/linux/linux-prim.c: In function ‘xarray_node_ctor’:
/home/openeuler/lustre-release/libcfs/libcfs/linux/linux-prim.c:129:25: error: dereferencing pointer to incomplete type ‘struct xa_node’
  memset(node, 0, sizeof(*node));
                         ^~~~~
/home/openeuler/lustre-release/libcfs/libcfs/linux/linux-prim.c: In function ‘cfs_arch_init’:
/home/openeuler/lustre-release/libcfs/libcfs/linux/linux-prim.c:143:15: error: invalid application of ‘sizeof’ to incomplete type ‘struct xa_node’
        sizeof(struct xa_node), 0,
               ^~~~~~
/home/openeuler/lustre-release/libcfs/libcfs/linux/linux-prim.c: At top level: 


 Comments   
Comment by Xinliang Liu [ 25/Aug/23 ]

This break build might affect old kernel from v4.17 to v4.19. Because v4.17 adds <linux/xarray.h> and make fs.h #include  <linux/xarray.h>, v4.20 introduces full xarray support.

The cause is that fs.h(from kernel v4.17 commit b93b016313b3) is already included <linux/xarray.h>, so #include <libcfs/linux/xarray.h> which contains the definition of 'struct xa_node'  don't take effect.

 

cat libcfs/libcfs/linux/linux-prim.c
...
#include <linux/fs.h>
...
#ifndef HAVE_XARRAY_SUPPORT
#include <libcfs/linux/xarray.h>
#endif 

 

 

Comment by Gerrit Updater [ 25/Aug/23 ]

"xinliang <xinliang.liu@linaro.org>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/52090
Subject: LU-17052 libcfs: fix build for old kernel
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: faab3d6bd3d898b6e849705476318e82210a7c09

Comment by Gerrit Updater [ 06/Sep/23 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/c/fs/lustre-release/+/52090/
Subject: LU-17052 libcfs: fix build for old kernel
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 75dd69dd6ecac38267a8fbf475945b2a2f293ba9

Comment by Peter Jones [ 06/Sep/23 ]

Landed for 2.16

Generated at Sat Feb 10 03:32:13 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.