All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/8] xfs: simplify the xlog_write_partial calling conventions
Date: Thu, 17 Jun 2021 12:24:13 -0400	[thread overview]
Message-ID: <YMt3LVRwLEwS6kuq@bfoster> (raw)
In-Reply-To: <20210616163212.1480297-7-hch@lst.de>

On Wed, Jun 16, 2021 at 06:32:10PM +0200, Christoph Hellwig wrote:
> Lift the iteration to the next log_vec into the callers, and drop
> the pointless log argument that can be trivially derived.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Heh, I actually had patches in my local tree very similar to these last
few to fix up the xlog_write() iteration logic. Nice cleanup overall:

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

>  fs/xfs/xfs_log.c | 38 +++++++++++++++-----------------------
>  1 file changed, 15 insertions(+), 23 deletions(-)
> 
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 5d55d4fff63035..4afa8ff1a82076 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -2232,14 +2232,11 @@ xlog_write_get_more_iclog_space(
>  /*
>   * Write log vectors into a single iclog which is smaller than the current chain
>   * length. We write until we cannot fit a full record into the remaining space
> - * and then stop. We return the log vector that is to be written that cannot
> - * wholly fit in the iclog.
> + * and then stop.
>   */
> -static struct xfs_log_vec *
> +static int
>  xlog_write_partial(
> -	struct xlog		*log,
> -	struct list_head	*lv_chain,
> -	struct xfs_log_vec	*log_vector,
> +	struct xfs_log_vec	*lv,
>  	struct xlog_ticket	*ticket,
>  	struct xlog_in_core	**iclogp,
>  	uint32_t		*log_offset,
> @@ -2248,8 +2245,7 @@ xlog_write_partial(
>  	uint32_t		*data_cnt)
>  {
>  	struct xlog_in_core	*iclog = *iclogp;
> -	struct xfs_log_vec	*lv = log_vector;
> -	struct xfs_log_iovec	*reg;
> +	struct xlog		*log = iclog->ic_log;
>  	struct xlog_op_header	*ophdr;
>  	int			index = 0;
>  	uint32_t		rlen;
> @@ -2257,9 +2253,8 @@ xlog_write_partial(
>  
>  	/* walk the logvec, copying until we run out of space in the iclog */
>  	for (index = 0; index < lv->lv_niovecs; index++) {
> -		uint32_t	reg_offset = 0;
> -
> -		reg = &lv->lv_iovecp[index];
> +		struct xfs_log_iovec	*reg = &lv->lv_iovecp[index];
> +		uint32_t		reg_offset = 0;
>  
>  		/*
>  		 * The first region of a continuation must have a non-zero
> @@ -2278,7 +2273,7 @@ xlog_write_partial(
>  					&iclog, log_offset, *len, record_cnt,
>  					data_cnt);
>  			if (error)
> -				return ERR_PTR(error);
> +				return error;
>  		}
>  
>  		ophdr = reg->i_addr;
> @@ -2329,7 +2324,7 @@ xlog_write_partial(
>  					*len + sizeof(struct xlog_op_header),
>  					record_cnt, data_cnt);
>  			if (error)
> -				return ERR_PTR(error);
> +				return error;
>  
>  			ophdr = iclog->ic_datap + *log_offset;
>  			ophdr->oh_tid = cpu_to_be32(ticket->t_tid);
> @@ -2365,10 +2360,7 @@ xlog_write_partial(
>  	 * the caller so it can go back to fast path copying.
>  	 */
>  	*iclogp = iclog;
> -	lv = list_next_entry(lv, lv_list);
> -	if (list_entry_is_head(lv, lv_chain, lv_list))
> -		return NULL;
> -	return lv;
> +	return 0;
>  }
>  
>  /*
> @@ -2450,13 +2442,13 @@ xlog_write(
>  		if (!lv)
>  			break;
>  
> -		lv = xlog_write_partial(log, lv_chain, lv, ticket, &iclog,
> -					&log_offset, &len, &record_cnt,
> -					&data_cnt);
> -		if (IS_ERR_OR_NULL(lv)) {
> -			error = PTR_ERR_OR_ZERO(lv);
> +		error = xlog_write_partial(lv, ticket, &iclog, &log_offset,
> +					   &len, &record_cnt, &data_cnt);
> +		if (error)
> +			break;
> +		lv = list_next_entry(lv, lv_list);
> +		if (list_entry_is_head(lv, lv_chain, lv_list))
>  			break;
> -		}
>  	}
>  	ASSERT((len == 0 && !lv) || error);
>  
> -- 
> 2.30.2
> 


  reply	other threads:[~2021-06-17 16:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 16:32 log write cleanups Christoph Hellwig
2021-06-16 16:32 ` [PATCH 1/8] xfs: change the type of ic_datap Christoph Hellwig
2021-06-17 16:22   ` Brian Foster
2021-06-18  5:52   ` Chandan Babu R
2021-06-16 16:32 ` [PATCH 2/8] xfs: list entry elements don't need to be initialized Christoph Hellwig
2021-06-17 16:23   ` Brian Foster
2021-06-18  5:59   ` Chandan Babu R
2021-06-16 16:32 ` [PATCH 3/8] xfs: factor out a helper to write a log_iovec into the iclog Christoph Hellwig
2021-06-17 16:23   ` Brian Foster
2021-06-18 13:24     ` Christoph Hellwig
2021-06-18  7:42   ` Chandan Babu R
2021-06-16 16:32 ` [PATCH 4/8] xfs: remove xlog_write_adv_cnt and simplify xlog_write_partial Christoph Hellwig
2021-06-17 16:23   ` Brian Foster
2021-06-18  7:50   ` Chandan Babu R
2021-06-16 16:32 ` [PATCH 5/8] xfs: remove xlog_verify_dest_ptr Christoph Hellwig
2021-06-17 16:24   ` Brian Foster
2021-06-18 10:31   ` Chandan Babu R
2021-06-16 16:32 ` [PATCH 6/8] xfs: simplify the xlog_write_partial calling conventions Christoph Hellwig
2021-06-17 16:24   ` Brian Foster [this message]
2021-06-18 11:07   ` Chandan Babu R
2021-06-16 16:32 ` [PATCH 7/8] xfs: factor out a xlog_write_full_log_vec helper Christoph Hellwig
2021-06-17 16:24   ` Brian Foster
2021-06-18 13:33     ` Christoph Hellwig
2021-06-16 16:32 ` [PATCH 8/8] xfs: simplify the list iteration in xlog_write Christoph Hellwig
2021-06-17 16:24   ` Brian Foster
2021-06-18 22:51 ` log write cleanups 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=YMt3LVRwLEwS6kuq@bfoster \
    --to=bfoster@redhat.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.