xfs: fix build without xfsstats
PATCH 1/1 xfs: fix build without xfsstats
A recent rework of the xfsstats interface introduced a compile error for the procfs-disabled case:
fs/built-in.o: In function `xfs_free_ag_extent':fs/xfs/libxfs/xfs_alloc.c:1725: undefined reference to xfsstats' fs/built-in.o: In function xfs_alloc_ag_vextent':fs/xfs/libxfs/xfs_alloc.c:645: undefined reference to xfsstats' fs/built-in.o: In function xfs_attr_set':fs/xfs/libxfs/xfs_attr.c:353: undefined reference to xfsstats' fs/built-in.o: In function xfs_attr_remove':fs/xfs/libxfs/xfs_attr.c:483: undefined reference to xfsstats' fs/built-in.o: In function xfs_attr_get':fs/xfs/libxfs/xfs_attr.c:131: undefined reference to xfsstats' fs/built-in.o:fs/xfs/libxfs/xfs_bmap.c:1461: more undefined references to xfsstats' follow
This adds conditional compilation to each reference of the xfsstats global variable to get it to link again.
An alternative approach would be to always build the statistics implementation even when CONFIG_PROC_FS is disabled.
---
Found with ARM randconfig builds. You seem to have intentionally removed the XFS_STATS_INC etc macros and #ifdefs in ff6d6af2351c, so I suspect this is not what you had in mind then, but it's not clear what you want instead. Please regard this as a bug report if it looks wrong to you ;-)
Arnd
fs/xfs/xfs_stats.h +16 -4
@@ -213,9 +213,12 @@ struct xfsstats {__uint64_t xs_read_bytes; }; +extern struct xstats xfsstats; + +#ifdef CONFIG_PROC_FS +int xfs_stats_format (struct xfsstats __percpu *stats,char *buf);void xfs_stats_clearall (struct xfsstats __percpu *stats); -extern struct xstats xfsstats;#define XFS_STATS_INC (mp, v) \ do { \
@@ -235,14 +238,23 @@ do { \per_cpu_ptr (mp->m_stats.xs_stats,current_cpu ())->v += (inc); \ } while (0) -#if defined(CONFIG_PROC_FS ) - extern int xfs_init_procfs(void);extern void xfs_cleanup_procfs (void ); -#else /* !CONFIG_PROC_FS */ +static inline int xfs_stats_format (struct xfsstats __percpu *stats,char *buf) +{ +return 0 ; +} +static inline void xfs_stats_clearall (struct xfsstats __percpu *stats) +{ +} + +#define XFS_STATS_INC (mp, v) do { } while (0) +#define XFS_STATS_DEC (mp, v) do { } while (0) +#define XFS_STATS_ADD (mp, v, inc) do { } while (0) +static inline int xfs_init_procfs (void ) {return 0 ;
fs/xfs/xfs_super.c +23 -15
@@ -1475,10 +1475,12 @@ xfs_fs_fill_super( goto out_destroy_workqueues;/* Allocate stats memory before we do operations that might use it */ - mp->m_stats.xs_stats = alloc_percpu(struct xfsstats); -if (!mp->m_stats.xs_stats) { - error =PTR_ERR (mp->m_stats.xs_stats); - goto out_destroy_counters; +if (IS_ENABLED (CONFIG_PROC_FS )) { + mp->m_stats.xs_stats = alloc_percpu(struct xfsstats); +if (!mp->m_stats.xs_stats) { + error =PTR_ERR (mp->m_stats.xs_stats); + goto out_destroy_counters; + } } error =xfs_readsb (mp, flags);
@@ -1851,16 +1853,18 @@ init_xfs_fs(void) goto out_sysctl_unregister; } - xfsstats.xs_kobj.kobject.kset = xfs_kset; +if (IS_ENABLED (CONFIG_PROC_FS )) { + xfsstats.xs_kobj.kobject.kset = xfs_kset; - xfsstats.xs_stats = alloc_percpu(struct xfsstats); -if (!xfsstats.xs_stats) { - error = -ENOMEM ; - goto out_kset_unregister; + xfsstats.xs_stats = alloc_percpu(struct xfsstats); +if (!xfsstats.xs_stats) { + error = -ENOMEM ; + goto out_kset_unregister; + } + error =xfs_sysfs_init (&xfsstats.xs_kobj, &xfs_stats_ktype, +NULL ,"stats" ); } - error =xfs_sysfs_init (&xfsstats.xs_kobj, &xfs_stats_ktype,NULL , -"stats" );if (error) goto out_free_stats;
@@ -1887,9 +1891,11 @@ init_xfs_fs(void)xfs_sysfs_del (&xfs_dbg_kobj); out_remove_stats_kobj:#endif -xfs_sysfs_del (&xfsstats.xs_kobj); +if (IS_ENABLED (CONFIG_PROC_FS )) +xfs_sysfs_del (&xfsstats.xs_kobj); out_free_stats: -free_percpu (xfsstats.xs_stats); +if (IS_ENABLED (CONFIG_PROC_FS )) +free_percpu (xfsstats.xs_stats); out_kset_unregister:kset_unregister (xfs_kset); out_sysctl_unregister:
@@ -1916,8 +1922,10 @@ exit_xfs_fs(void)#ifdef DEBUG xfs_sysfs_del (&xfs_dbg_kobj);#endif -xfs_sysfs_del (&xfsstats.xs_kobj); -free_percpu (xfsstats.xs_stats); +if (IS_ENABLED (CONFIG_PROC_FS )) { +xfs_sysfs_del (&xfsstats.xs_kobj); +free_percpu (xfsstats.xs_stats); + }kset_unregister (xfs_kset);xfs_sysctl_unregister ();xfs_cleanup_procfs ();
Quoted 15 lines · Arnd Bergmann
A recent rework of the xfsstats interface introduced a compile error for the procfs-disabled case:
fs/built-in.o: In function `xfs_free_ag_extent':fs/xfs/libxfs/xfs_alloc.c:1725: undefined reference toxfsstats' fs/built-in.o: In functionxfs_alloc_ag_vextent':fs/xfs/libxfs/xfs_alloc.c:645: undefined reference toxfsstats' fs/built-in.o: In functionxfs_attr_set':fs/xfs/libxfs/xfs_attr.c:353: undefined reference toxfsstats' fs/built-in.o: In functionxfs_attr_remove':fs/xfs/libxfs/xfs_attr.c:483: undefined reference toxfsstats' fs/built-in.o: In functionxfs_attr_get':fs/xfs/libxfs/xfs_attr.c:131: undefined reference toxfsstats' fs/built-in.o:fs/xfs/libxfs/xfs_bmap.c:1461: more undefined references toxfsstats' follow
Quoted 5 lines
This adds conditional compilation to each reference of the xfsstats global variable to get it to link again.
An alternative approach would be to always build the statistics implementation even when
CONFIG_PROC_FSis disabled.
Yep, they live for realz in sysfs now, not procfs.
Reported a couple times already ;) Dave has a patch at:
https://marc.info/?l=linux-xfs&m=144476889031721&w=2
Thanks,
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs