All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] xfs: #ifdef out perag code for userspace
@ 2021-11-10  1:56 Eric Sandeen
  2021-11-10  1:58 ` [PATCH 1/3] libxfs: " Eric Sandeen
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Eric Sandeen @ 2021-11-10  1:56 UTC (permalink / raw)
  To: xfs

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] libxfs: #ifdef out perag code for userspace
  2021-11-10  1:56 [PATCH 0/3] xfs: #ifdef out perag code for userspace Eric Sandeen
@ 2021-11-10  1:58 ` Eric Sandeen
  2021-11-10  4:23   ` Darrick J. Wong
  2021-11-10  2:00 ` [PATCH 2/3] libxfs: #ifdef out perag code for userspace (xfsprogs version) Eric Sandeen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Eric Sandeen @ 2021-11-10  1:58 UTC (permalink / raw)
  To: xfs

The xfs_perag structure and initialization is unused in userspace,
so #ifdef it out with __KERNEL__ to facilitate the xfsprogs sync
and build.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
index 005abfd9fd34..ecfb213d8fa3 100644
--- a/fs/xfs/libxfs/xfs_ag.c
+++ b/fs/xfs/libxfs/xfs_ag.c
@@ -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)
diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h
index 4c6f9045baca..01c36cfe6909 100644
--- a/fs/xfs/libxfs/xfs_ag.h
+++ b/fs/xfs/libxfs/xfs_ag.h
@@ -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,


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] libxfs: #ifdef out perag code for userspace (xfsprogs version)
  2021-11-10  1:56 [PATCH 0/3] xfs: #ifdef out perag code for userspace Eric Sandeen
  2021-11-10  1:58 ` [PATCH 1/3] libxfs: " Eric Sandeen
@ 2021-11-10  2:00 ` Eric Sandeen
  2021-11-10  2:02 ` [PATCH 3/3] xfsprogs: remove kernel stubs from xfs_shared.h Eric Sandeen
  2021-11-10  2:34 ` [PATCH 4/3] xfs: sync xfs_btree_split macros with userspace libxfs Darrick J. Wong
  3 siblings, 0 replies; 8+ messages in thread
From: Eric Sandeen @ 2021-11-10  2:00 UTC (permalink / raw)
  To: xfs

The xfs_perag structure and initialization is unused in userspace,
so #ifdef it out with __KERNEL__ to facilitate the xfsprogs sync
and build.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

This is the synced userspace code, for clarity. I'll do a normal
libxfs-sync.

diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c
index 9eda6eba..149f9857 100644
--- a/libxfs/xfs_ag.c
+++ b/libxfs/xfs_ag.c
@@ -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)
diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h
index 4c6f9045..01c36cfe 100644
--- a/libxfs/xfs_ag.h
+++ b/libxfs/xfs_ag.h
@@ -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,


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] xfsprogs: remove kernel stubs from xfs_shared.h
  2021-11-10  1:56 [PATCH 0/3] xfs: #ifdef out perag code for userspace Eric Sandeen
  2021-11-10  1:58 ` [PATCH 1/3] libxfs: " Eric Sandeen
  2021-11-10  2:00 ` [PATCH 2/3] libxfs: #ifdef out perag code for userspace (xfsprogs version) Eric Sandeen
@ 2021-11-10  2:02 ` Eric Sandeen
  2021-11-10  4:26   ` Darrick J. Wong
  2021-11-10  2:34 ` [PATCH 4/3] xfs: sync xfs_btree_split macros with userspace libxfs Darrick J. Wong
  3 siblings, 1 reply; 8+ messages in thread
From: Eric Sandeen @ 2021-11-10  2:02 UTC (permalink / raw)
  To: xfs

The 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.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h
index 15bae1ff..3957a2e0 100644
--- a/libxfs/libxfs_priv.h
+++ b/libxfs/libxfs_priv.h
@@ -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"
  
  /*
diff --git a/libxfs/xfs_shared.h b/libxfs/xfs_shared.h
index bafee48c..25c4cab5 100644
--- a/libxfs/xfs_shared.h
+++ b/libxfs/xfs_shared.h
@@ -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__ */


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/3] xfs: sync xfs_btree_split macros with userspace libxfs
  2021-11-10  1:56 [PATCH 0/3] xfs: #ifdef out perag code for userspace Eric Sandeen
                   ` (2 preceding siblings ...)
  2021-11-10  2:02 ` [PATCH 3/3] xfsprogs: remove kernel stubs from xfs_shared.h Eric Sandeen
@ 2021-11-10  2:34 ` Darrick J. Wong
  2021-11-10 17:12   ` Eric Sandeen
  3 siblings, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2021-11-10  2:34 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

From: Darrick J. Wong <djwong@kernel.org>

Sync this one last bit of discrepancy between kernel and userspace
libxfs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/libxfs/xfs_btree.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index b4e19aacb9de..d8a859bc797a 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -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
 
 
 /*

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] libxfs: #ifdef out perag code for userspace
  2021-11-10  1:58 ` [PATCH 1/3] libxfs: " Eric Sandeen
@ 2021-11-10  4:23   ` Darrick J. Wong
  0 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2021-11-10  4:23 UTC (permalink / raw)
  To: sandeen; +Cc: xfs

On Tue, Nov 09, 2021 at 07:58:34PM -0600, Eric Sandeen wrote:
> The xfs_perag structure and initialization is unused in userspace,
> so #ifdef it out with __KERNEL__ to facilitate the xfsprogs sync
> and build.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

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...

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
> 
> diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
> index 005abfd9fd34..ecfb213d8fa3 100644
> --- a/fs/xfs/libxfs/xfs_ag.c
> +++ b/fs/xfs/libxfs/xfs_ag.c
> @@ -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)
> diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h
> index 4c6f9045baca..01c36cfe6909 100644
> --- a/fs/xfs/libxfs/xfs_ag.h
> +++ b/fs/xfs/libxfs/xfs_ag.h
> @@ -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,
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] xfsprogs: remove kernel stubs from xfs_shared.h
  2021-11-10  2:02 ` [PATCH 3/3] xfsprogs: remove kernel stubs from xfs_shared.h Eric Sandeen
@ 2021-11-10  4:26   ` Darrick J. Wong
  0 siblings, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2021-11-10  4:26 UTC (permalink / raw)
  To: sandeen; +Cc: xfs

On Tue, Nov 09, 2021 at 08:02:14PM -0600, Eric Sandeen wrote:
> The 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.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

LGTM
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
> 
> diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h
> index 15bae1ff..3957a2e0 100644
> --- a/libxfs/libxfs_priv.h
> +++ b/libxfs/libxfs_priv.h
> @@ -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"
>  /*
> diff --git a/libxfs/xfs_shared.h b/libxfs/xfs_shared.h
> index bafee48c..25c4cab5 100644
> --- a/libxfs/xfs_shared.h
> +++ b/libxfs/xfs_shared.h
> @@ -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__ */
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/3] xfs: sync xfs_btree_split macros with userspace libxfs
  2021-11-10  2:34 ` [PATCH 4/3] xfs: sync xfs_btree_split macros with userspace libxfs Darrick J. Wong
@ 2021-11-10 17:12   ` Eric Sandeen
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Sandeen @ 2021-11-10 17:12 UTC (permalink / raw)
  To: Darrick J. Wong, Eric Sandeen; +Cc: xfs

On 11/9/21 8:34 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Sync this one last bit of discrepancy between kernel and userspace
> libxfs.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

I was #ifdef before #ifdef was cool, man.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

(tiny thing see below, use your discretion)

> ---
>   fs/xfs/libxfs/xfs_btree.c |    4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
> index b4e19aacb9de..d8a859bc797a 100644
> --- a/fs/xfs/libxfs/xfs_btree.c
> +++ b/fs/xfs/libxfs/xfs_btree.c
> @@ -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 */

If you wanted to change this to /* !__KERNEL__ */ to be spot-on, I wouldn't
complain, and could just sync that up in userspace.

> +#define xfs_btree_split		__xfs_btree_split
> +#endif

and maybe #endif	/* __KERNEL__ */

Up to you.

>   
>   
>   /*
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-11-10 17:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10  1:56 [PATCH 0/3] xfs: #ifdef out perag code for userspace Eric Sandeen
2021-11-10  1:58 ` [PATCH 1/3] libxfs: " Eric Sandeen
2021-11-10  4:23   ` Darrick J. Wong
2021-11-10  2:00 ` [PATCH 2/3] libxfs: #ifdef out perag code for userspace (xfsprogs version) Eric Sandeen
2021-11-10  2:02 ` [PATCH 3/3] xfsprogs: remove kernel stubs from xfs_shared.h Eric Sandeen
2021-11-10  4:26   ` Darrick J. Wong
2021-11-10  2:34 ` [PATCH 4/3] xfs: sync xfs_btree_split macros with userspace libxfs Darrick J. Wong
2021-11-10 17:12   ` Eric Sandeen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.