xfs: #ifdef out perag code for userspace
cover xfs: #ifdef out perag code for userspace
Series of patches to get userspace and kernelspace to the point where xfsprogs can sync up ok and build with a minimum of stub functions etc.
PATCH 1/3 libxfs: #ifdef out perag code for userspace
The xfs_perag structure and initialization is unused in userspace, so #ifdef it out with __KERNEL__ to facilitate the xfsprogs sync and build.
---
fs/xfs/libxfs/xfs_ag.c +2 -0
@@ -248,6 +248,7 @@ xfs_initialize_perag(spin_unlock (&mp->m_perag_lock);radix_tree_preload_end (); +#ifdef __KERNEL__/* Place kernel structure only init below this point. */ spin_lock_init (&pag->pag_ici_lock);spin_lock_init (&pag->pagb_lock);
@@ -257,6 +258,7 @@ xfs_initialize_perag(init_waitqueue_head (&pag->pagb_wait); pag->pagb_count =0 ; pag->pagb_tree =RB_ROOT ; +#endif /* __KERNEL_ */ error =xfs_buf_hash_init (pag);if (error)
fs/xfs/libxfs/xfs_ag.h +5 -3
@@ -64,6 +64,10 @@ struct xfs_perag {/* Blocks reserved for the reverse mapping btree. */ struct xfs_ag_resv pag_rmapbt_resv; +/* for rcu-safe freeing */ +struct rcu_head rcu_head; + +#ifdef __KERNEL__/* -- kernel only structures below this line -- */ /*
@@ -90,9 +94,6 @@ struct xfs_perag {spinlock_t pag_buf_lock;/* lock for pag_buf_hash */ struct rhashtable pag_buf_hash; -/* for rcu-safe freeing */ -struct rcu_head rcu_head; -/* background prealloc block trimming */ struct delayed_work pag_blockgc_work;
@@ -102,6 +103,7 @@ struct xfs_perag {* or have some other means to control concurrency. */ struct rhashtable pagi_unlinked_hash; +#endif /* __KERNEL__ */ }; int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t agcount,
Re: [PATCH 1/3] libxfs: #ifdef out perag code for userspace
Quoted 5 lines · Eric Sandeen
The
xfs_peragstructure and initialization is unused in userspace, so #ifdef it out with__KERNEL__to facilitate the xfsprogs sync and build.Signed-off-by Eric Sandeen <[email protected]>
Looks severely whitespace damaged, but /me has gotten tired of dealing with all the navel gazing around #ifdef __KERNEL__. I want to move on to more difficult topics like grokking and evaluating online repair, and get us away from arguing about how to preprocessor.
This gets us closer to parity between the two libxfses, and reflects what the two libxfs maintainers more or less agree upon, so with patch 4/3 added in and the whitespace fixed...
--D
Quoted 49 lines
---
fs/xfs/libxfs/xfs_ag.c +2
-0@@ -248,6 +248,7 @@ xfs_initialize_perag(spin_unlock (&mp->m_perag_lock);radix_tree_preload_end (); +#ifdef __KERNEL__/* Place kernel structure only init below this point. */ spin_lock_init (&pag->pag_ici_lock);spin_lock_init (&pag->pagb_lock);@@ -257,6 +258,7 @@ xfs_initialize_perag(init_waitqueue_head (&pag->pagb_wait); pag->pagb_count =0 ; pag->pagb_tree =RB_ROOT ; +#endif /* __KERNEL_ */ error =xfs_buf_hash_init (pag);if (error)fs/xfs/libxfs/xfs_ag.h +5
-3@@ -64,6 +64,10 @@ struct xfs_perag {/* Blocks reserved for the reverse mapping btree. */ struct xfs_ag_resv pag_rmapbt_resv; +/* for rcu-safe freeing */ +struct rcu_head rcu_head; + +#ifdef __KERNEL__/* -- kernel only structures below this line -- */ /* @@ -90,9 +94,6 @@ struct xfs_perag {spinlock_t pag_buf_lock;/* lock for pag_buf_hash */ struct rhashtable pag_buf_hash; -/* for rcu-safe freeing */ -struct rcu_head rcu_head; -/* background prealloc block trimming */ struct delayed_work pag_blockgc_work;@@ -102,6 +103,7 @@ struct xfs_perag {* or have some other means to control concurrency. */ struct rhashtable pagi_unlinked_hash; +#endif /* __KERNEL__ */ }; int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t agcount,
PATCH 2/3 libxfs: #ifdef out perag code for userspace (xfsprogs version)
In reply to Eric SandeenThe xfs_perag structure and initialization is unused in userspace, so #ifdef it out with __KERNEL__ to facilitate the xfsprogs sync and build.
---
This is the synced userspace code, for clarity. I'll do a normal libxfs-sync.
libxfs/xfs_ag.c +2 -0
@@ -246,6 +246,7 @@ xfs_initialize_perag(spin_unlock (&mp->m_perag_lock);radix_tree_preload_end (); +#ifdef __KERNEL__/* Place kernel structure only init below this point. */ spin_lock_init (&pag->pag_ici_lock);spin_lock_init (&pag->pagb_lock);
@@ -255,6 +256,7 @@ xfs_initialize_perag(init_waitqueue_head (&pag->pagb_wait); pag->pagb_count =0 ; pag->pagb_tree =RB_ROOT ; +#endif /* __KERNEL_ */ error =xfs_buf_hash_init (pag);if (error)
libxfs/xfs_ag.h +5 -3
@@ -64,6 +64,10 @@ struct xfs_perag {/* Blocks reserved for the reverse mapping btree. */ struct xfs_ag_resv pag_rmapbt_resv; +/* for rcu-safe freeing */ +struct rcu_head rcu_head; + +#ifdef __KERNEL__/* -- kernel only structures below this line -- */ /*
@@ -90,9 +94,6 @@ struct xfs_perag {spinlock_t pag_buf_lock;/* lock for pag_buf_hash */ struct rhashtable pag_buf_hash; -/* for rcu-safe freeing */ -struct rcu_head rcu_head; -/* background prealloc block trimming */ struct delayed_work pag_blockgc_work;
@@ -102,6 +103,7 @@ struct xfs_perag {* or have some other means to control concurrency. */ struct rhashtable pagi_unlinked_hash; +#endif /* __KERNEL__ */ }; int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t agcount,
PATCH 3/3 xfsprogs: remove kernel stubs from xfs_shared.h
In reply to Eric SandeenThe kernel stubs added to xfs_shared.h don't belong there, and are mostly unnecessary with the #ifdef __KERNEL__ bits added to the xfs_ag.[ch] files. Move the one remaining needed stub in libxfs_priv.h.
---
libxfs/libxfs_priv.h +2 -0
@@ -75,6 +75,8 @@ extern kmem_zone_t *xfs_trans_zone;/* fake up kernel's iomap, (not) used in xfs_bmap.[ch] */ struct iomap ; +#define cancel_delayed_work_sync (work) do { } while(0) +#include "xfs_cksum.h" /*
libxfs/xfs_shared.h +0 -20
@@ -180,24 +180,4 @@ struct xfs_ino_geometry { }; -/* Faked up kernel bits */ -struct rb_root { -}; - -#define RB_ROOT (struct rb_root) { } - -typedef struct wait_queue_head { -}wait_queue_head_t ; - -#define init_waitqueue_head (wqh) do { } while(0) - -struct rhashtable { -}; - -struct delayed_work { -}; - -#define INIT_DELAYED_WORK (work, func) do { } while(0) -#define cancel_delayed_work_sync (work) do { } while(0) -#endif /* __XFS_SHARED_H__ */
Re: [PATCH 3/3] xfsprogs: remove kernel stubs from xfs_shared.h
Quoted 6 lines · Eric Sandeen
The kernel stubs added to
xfs_shared.hdon't belong there, and are mostly unnecessary with the #ifdef__KERNEL__bits added to the xfs_ag.[ch] files. Move the one remaining needed stub inlibxfs_priv.h.Signed-off-by Eric Sandeen <[email protected]>
LGTM
--D
Quoted 41 lines
---
libxfs/libxfs_priv.h +2
-0@@ -75,6 +75,8 @@ extern kmem_zone_t *xfs_trans_zone;/* fake up kernel's iomap, (not) used in xfs_bmap.[ch] */ struct iomap ; +#define cancel_delayed_work_sync (work) do { } while(0) +#include "xfs_cksum.h" /* libxfs/xfs_shared.h +0
-20@@ -180,24 +180,4 @@ struct xfs_ino_geometry { }; -/* Faked up kernel bits */ -struct rb_root { -}; - -#define RB_ROOT (struct rb_root) { } - -typedef struct wait_queue_head { -}wait_queue_head_t ; - -#define init_waitqueue_head (wqh) do { } while(0) - -struct rhashtable { -}; - -struct delayed_work { -}; - -#define INIT_DELAYED_WORK (work, func) do { } while(0) -#define cancel_delayed_work_sync (work) do { } while(0) -#endif /* __XFS_SHARED_H__ */
[PATCH 4/3] xfs: sync xfs_btree_split macros with userspace libxfs
In reply to Eric SandeenFrom: Darrick J. Wong <[email protected]>
Sync this one last bit of discrepancy between kernel and userspace libxfs.
--- fs/xfs/libxfs/xfs_btree.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/xfs/libxfs/xfs_btree.c +4 -0
@@ -2785,6 +2785,7 @@ __xfs_btree_split(return error; } +#ifdef __KERNEL__ struct xfs_btree_split_args { struct xfs_btree_cur *cur; int level;
@@ -2870,6 +2871,9 @@ xfs_btree_split(destroy_work_on_stack (&args.work); return args.result; } +#else /* !KERNEL */ +#define xfs_btree_split __xfs_btree_split +#endif /*
Eric Sandeen
Reviewed-byRe: [PATCH 4/3] xfs: sync xfs_btree_split macros with userspace libxfs
Quoted 6 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Sync this one last bit of discrepancy between kernel and userspace libxfs.
Signed-off-by Darrick J. Wong <[email protected]>
I was #ifdef before #ifdef was cool, man.
(tiny thing see below, use your discretion)
Quoted 17 lines
--- fs/xfs/libxfs/xfs_btree.c | 4 ++++ 1 file changed, 4 insertions(+)fs/xfs/libxfs/xfs_btree.c +1
-0@@ -2785,6 +2785,7 @@ __xfs_btree_split(return error; } +#ifdef __KERNEL__ struct xfs_btree_split_args { struct xfs_btree_cur *cur; int level;
fs/xfs/libxfs/xfs_btree.c xfs_btree_split( · line 2874
Quoted 4 lines
fs/xfs/libxfs/xfs_btree.c +1
-0@@ -2870,6 +2871,9 @@ xfs_btree_split(destroy_work_on_stack (&args.work); return args.result; } +#else /* !KERNEL */
If you wanted to change this to /* !__KERNEL__ */ to be spot-on, I wouldn't complain, and could just sync that up in userspace.
fs/xfs/libxfs/xfs_btree.c xfs_btree_split( · line 2876
Quoted 2 lines
fs/xfs/libxfs/xfs_btree.c +2
-0+#define xfs_btree_split __xfs_btree_split +#endif
and maybe #endif /* __KERNEL__ */
Up to you.
Quoted 4 lines
fs/xfs/libxfs/xfs_btree.c +0
-0/*