All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org, hch@lst.de
Subject: Re: [PATCH 07/13] xfs: refactor incore dquot initialization functions
Date: Mon, 23 Apr 2018 09:54:58 -0400	[thread overview]
Message-ID: <20180423135457.GG43600@bfoster.bfoster> (raw)
In-Reply-To: <152440959784.29601.7345409188558922914.stgit@magnolia>

On Sun, Apr 22, 2018 at 08:06:37AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Create two incore dquot initialization functions that will help us to
> disentangle dqget and dqread.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/xfs/xfs_dquot.c |   80 +++++++++++++++++++++++++++++++++-------------------
>  1 file changed, 50 insertions(+), 30 deletions(-)
> 
> 
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 62415f1..7154909 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -491,26 +491,14 @@ xfs_qm_dqtobp(
>  	return 0;
>  }
>  
> -
> -/*
> - * Read in the ondisk dquot using dqtobp() then copy it to an incore version,
> - * and release the buffer immediately.
> - *
> - * If XFS_QMOPT_DQALLOC is set, allocate a dquot on disk if it needed.
> - */
> -int
> -xfs_qm_dqread(
> +/* Allocate and initialize everything we need for an incore dquot. */
> +STATIC struct xfs_dquot *
> +xfs_qm_dqinit_once(

I find the init_once() naming confusing. How about something more
straightforward like xfs_dquot_alloc()?

>  	struct xfs_mount	*mp,
>  	xfs_dqid_t		id,
> -	uint			type,
> -	uint			flags,
> -	struct xfs_dquot	**O_dqpp)
> +	uint			type)
>  {
>  	struct xfs_dquot	*dqp;
> -	struct xfs_disk_dquot	*ddqp;
> -	struct xfs_buf		*bp;
> -	struct xfs_trans	*tp = NULL;
> -	int			error;
>  
>  	dqp = kmem_zone_zalloc(xfs_qm_dqzone, KM_SLEEP);
>  
> @@ -549,7 +537,52 @@ xfs_qm_dqread(
>  	}
>  
>  	XFS_STATS_INC(mp, xs_qm_dquot);
> +	return dqp;
> +}
> +
> +/* Copy the in-core quota fields in from the on-disk buffer. */
> +STATIC void
> +xfs_qm_dqinit_from_buf(
> +	struct xfs_dquot	*dqp,
> +	struct xfs_disk_dquot	*ddqp)
> +{
> +	/* copy everything from disk dquot to the incore dquot */
> +	memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t));
> +	xfs_qm_dquot_logitem_init(dqp);

I wonder if the logitem init should really be part of the "init from
buf" helper?

Otherwise looks fine:

Reviewed-by: Brian Foster <bfoster@redhat.com>

> +
> +	/*
> +	 * Reservation counters are defined as reservation plus current usage
> +	 * to avoid having to add every time.
> +	 */
> +	dqp->q_res_bcount = be64_to_cpu(ddqp->d_bcount);
> +	dqp->q_res_icount = be64_to_cpu(ddqp->d_icount);
> +	dqp->q_res_rtbcount = be64_to_cpu(ddqp->d_rtbcount);
> +
> +	/* initialize the dquot speculative prealloc thresholds */
> +	xfs_dquot_set_prealloc_limits(dqp);
> +}
> +
> +/*
> + * Read in the ondisk dquot using dqtobp() then copy it to an incore version,
> + * and release the buffer immediately.
> + *
> + * If XFS_QMOPT_DQALLOC is set, allocate a dquot on disk if it needed.
> + */
> +int
> +xfs_qm_dqread(
> +	struct xfs_mount	*mp,
> +	xfs_dqid_t		id,
> +	uint			type,
> +	uint			flags,
> +	struct xfs_dquot	**O_dqpp)
> +{
> +	struct xfs_dquot	*dqp;
> +	struct xfs_disk_dquot	*ddqp;
> +	struct xfs_buf		*bp;
> +	struct xfs_trans	*tp = NULL;
> +	int			error;
>  
> +	dqp = xfs_qm_dqinit_once(mp, id, type);
>  	trace_xfs_dqread(dqp);
>  
>  	if (flags & XFS_QMOPT_DQALLOC) {
> @@ -574,20 +607,7 @@ xfs_qm_dqread(
>  		goto error1;
>  	}
>  
> -	/* copy everything from disk dquot to the incore dquot */
> -	memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t));
> -	xfs_qm_dquot_logitem_init(dqp);
> -
> -	/*
> -	 * Reservation counters are defined as reservation plus current usage
> -	 * to avoid having to add every time.
> -	 */
> -	dqp->q_res_bcount = be64_to_cpu(ddqp->d_bcount);
> -	dqp->q_res_icount = be64_to_cpu(ddqp->d_icount);
> -	dqp->q_res_rtbcount = be64_to_cpu(ddqp->d_rtbcount);
> -
> -	/* initialize the dquot speculative prealloc thresholds */
> -	xfs_dquot_set_prealloc_limits(dqp);
> +	xfs_qm_dqinit_from_buf(dqp, ddqp);
>  
>  	/* Mark the buf so that this will stay incore a little longer */
>  	xfs_buf_set_ref(bp, XFS_DQUOT_REF);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2018-04-23 13:55 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-22 15:05 [PATCH 00/13] xfs-4.18: quota refactor Darrick J. Wong
2018-04-22 15:05 ` [PATCH 01/13] xfs: refactor XFS_QMOPT_DQNEXT out of existence Darrick J. Wong
2018-04-23 13:54   ` Brian Foster
2018-04-23 17:13   ` Christoph Hellwig
2018-04-22 15:06 ` [PATCH 02/13] xfs: refactor dquot cache handling Darrick J. Wong
2018-04-23 13:54   ` Brian Foster
2018-04-23 17:14   ` Christoph Hellwig
2018-04-22 15:06 ` [PATCH 03/13] xfs: delegate dqget input checks to helper function Darrick J. Wong
2018-04-23 13:54   ` Brian Foster
2018-04-23 17:19   ` Christoph Hellwig
2018-04-22 15:06 ` [PATCH 04/13] xfs: remove unnecessary xfs_qm_dqattach parameter Darrick J. Wong
2018-04-23 13:54   ` Brian Foster
2018-04-23 17:19   ` Christoph Hellwig
2018-04-22 15:06 ` [PATCH 05/13] xfs: split out dqget for inodes from regular dqget Darrick J. Wong
2018-04-23 13:54   ` Brian Foster
2018-04-23 17:23   ` Christoph Hellwig
2018-04-23 21:57     ` Darrick J. Wong
2018-04-22 15:06 ` [PATCH 06/13] xfs: fetch dquots directly during quotacheck Darrick J. Wong
2018-04-23 13:54   ` Brian Foster
2018-04-23 17:25   ` Christoph Hellwig
2018-04-22 15:06 ` [PATCH 07/13] xfs: refactor incore dquot initialization functions Darrick J. Wong
2018-04-23 13:54   ` Brian Foster [this message]
2018-04-23 17:27   ` Christoph Hellwig
2018-04-24 16:01     ` Eric Sandeen
2018-04-22 15:06 ` [PATCH 08/13] xfs: refactor xfs_qm_dqtobp and xfs_qm_dqalloc Darrick J. Wong
2018-04-23 17:31   ` Christoph Hellwig
2018-04-24 13:07   ` Brian Foster
2018-04-24 14:08     ` Darrick J. Wong
2018-04-22 15:06 ` [PATCH 09/13] xfs: remove xfs_qm_dqread flags argument Darrick J. Wong
2018-04-23 17:32   ` Christoph Hellwig
2018-04-28  6:38     ` Darrick J. Wong
2018-04-22 15:07 ` [PATCH 10/13] xfs: replace XFS_QMOPT_DQALLOC with XFS_DQGET_{ALLOC, EXISTS} Darrick J. Wong
2018-04-23 17:33   ` Christoph Hellwig
2018-04-24 13:07     ` Brian Foster
2018-04-24 14:08       ` Darrick J. Wong
2018-04-22 15:07 ` [PATCH 11/13] xfs: report failing address when dquot verifier fails Darrick J. Wong
2018-04-23 17:33   ` Christoph Hellwig
2018-04-22 15:07 ` [PATCH 12/13] xfs: rename on-disk dquot counter zap functions Darrick J. Wong
2018-04-23 17:35   ` Christoph Hellwig
2018-04-28  6:47     ` Darrick J. Wong
2018-04-22 15:07 ` [PATCH 13/13] xfs: refactor dquot iteration Darrick J. Wong
2018-04-24 13:08   ` Brian Foster
2018-04-24 14:04     ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2018-04-30  5:43 [PATCH v2 00/13] xfs-4.18: quota refactor Darrick J. Wong
2018-04-30  5:43 ` [PATCH 07/13] xfs: refactor incore dquot initialization functions Darrick J. Wong

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=20180423135457.GG43600@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    /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.