All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: sandeen@redhat.com
Cc: xfs <linux-xfs@vger.kernel.org>, Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH V3 RFC] xfsprogs: remove stubbed-out kernel functions out from xfs_shared.h
Date: Thu, 4 Nov 2021 12:08:45 -0700	[thread overview]
Message-ID: <20211104190845.GT24307@magnolia> (raw)
In-Reply-To: <fa2fe2c5-645b-6263-3493-b59b4d096488@redhat.com>

On Thu, Nov 04, 2021 at 12:15:04PM -0500, Eric Sandeen wrote:
> Remove these kernel stubs by #ifdeffing code instead.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> Dave preferred #ifdefs over stubs, and this is what I came up with.
>
> Honestly, I think this is worse, and will lead to more libxfs-sync pain
> unless we're willing to scatter #ifdefs around the kernel code as well,
> but I figured I'd put this out there for discussion.

Yuck.  Now I wish I'd pushed back harder on the patch author (Dave) to
provide the xfsprogs version of this, or whatever fixes are needed to
libxfs-diff to deuglify whatever the result was, rather than let this
fall to the maintainer (Eric). :/

--D

> 
> diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c
> index 9eda6eba..c01986f7 100644
> --- a/libxfs/xfs_ag.c
> +++ b/libxfs/xfs_ag.c
> @@ -170,7 +170,9 @@ __xfs_free_perag(
>  {
>  	struct xfs_perag *pag = container_of(head, struct xfs_perag, rcu_head);
> +#ifdef __KERNEL__
>  	ASSERT(!delayed_work_pending(&pag->pag_blockgc_work));
> +#endif	/* __KERNEL__ */
>  	ASSERT(atomic_read(&pag->pag_ref) == 0);
>  	kmem_free(pag);
>  }
> @@ -192,9 +194,11 @@ xfs_free_perag(
>  		ASSERT(pag);
>  		ASSERT(atomic_read(&pag->pag_ref) == 0);
> +#ifdef __KERNEL__
>  		cancel_delayed_work_sync(&pag->pag_blockgc_work);
>  		xfs_iunlink_destroy(pag);
>  		xfs_buf_hash_destroy(pag);
> +#endif	/* __KERNEL__ */
>  		call_rcu(&pag->rcu_head, __xfs_free_perag);
>  	}
> @@ -246,6 +250,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);
> @@ -267,6 +272,7 @@ xfs_initialize_perag(
>  		/* first new pag is fully initialized */
>  		if (first_initialised == NULLAGNUMBER)
>  			first_initialised = index;
> +#endif	/* __KERNEL__ */
>  	}
>  	index = xfs_set_inode_alloc(mp, agcount);
> @@ -277,10 +283,12 @@ xfs_initialize_perag(
>  	mp->m_ag_prealloc_blocks = xfs_prealloc_blocks(mp);
>  	return 0;
> +#ifdef __KERNEL__
>  out_hash_destroy:
>  	xfs_buf_hash_destroy(pag);
>  out_remove_pag:
>  	radix_tree_delete(&mp->m_perag_tree, index);
> +#endif	/* __KERNEL__ */
>  out_free_pag:
>  	kmem_free(pag);
>  out_unwind_new_pags:
> diff --git a/libxfs/xfs_ag.h b/libxfs/xfs_ag.h
> index 4c6f9045..dda1303e 100644
> --- a/libxfs/xfs_ag.h
> +++ b/libxfs/xfs_ag.h
> @@ -64,6 +64,9 @@ 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;
> +
>  	/* -- kernel only structures below this line -- */
>  	/*
> @@ -75,6 +78,7 @@ struct xfs_perag {
>  	spinlock_t	pag_state_lock;
>  	spinlock_t	pagb_lock;	/* lock for pagb_tree */
> +#ifdef __KERNEL__
>  	struct rb_root	pagb_tree;	/* ordered tree of busy extents */
>  	unsigned int	pagb_gen;	/* generation count for pagb_tree */
>  	wait_queue_head_t pagb_wait;	/* woken when pagb_gen changes */
> @@ -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,
> 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__ */
> 

  reply	other threads:[~2021-11-04 19:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-04  2:21 [PATCH] xfsprogs: move stubbed-out kernel functions out of xfs_shared.h Eric Sandeen
2021-11-04  2:28 ` Darrick J. Wong
2021-11-04  2:55   ` Eric Sandeen
2021-11-04  2:59 ` [PATCH V2] " Eric Sandeen
2021-11-04  3:14   ` Darrick J. Wong
2021-11-04  3:33     ` Eric Sandeen
2021-11-04 17:15 ` [PATCH V3 RFC] xfsprogs: remove stubbed-out kernel functions out from xfs_shared.h Eric Sandeen
2021-11-04 19:08   ` Darrick J. Wong [this message]
2021-11-04 22:38   ` Dave Chinner
2021-11-05 16:40     ` Eric Sandeen
2021-11-07 22:58       ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211104190845.GT24307@magnolia \
    --to=djwong@kernel.org \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.