All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 4/4] xfs: rewrite and optimize the delalloc write path
Date: Tue, 30 Aug 2016 16:28:21 -0400	[thread overview]
Message-ID: <20160830202820.GA16503@bfoster.bfoster> (raw)
In-Reply-To: <20160826160753.GD17728@bfoster.bfoster>

On Fri, Aug 26, 2016 at 12:07:53PM -0400, Brian Foster wrote:
> On Fri, Aug 26, 2016 at 12:03:39PM -0400, Brian Foster wrote:
> > On Fri, Aug 26, 2016 at 04:33:44PM +0200, Christoph Hellwig wrote:
> > > On Thu, Aug 25, 2016 at 10:37:09AM -0400, Brian Foster wrote:
> ...
> > > (we could potentially re-derive offset_fsb from offset if we don't
> > > mind the inefficieny and recalculate maxbytes_fsb.  This already
> > > assumes mp is trivially derived from ip)
> > > 
> > > and return
> > > 
> > > alloc_blocks, end_fsb
> > > 
> > > so the function would be quite a monster in terms of its calling
> > > convention.  Additionally we'd have the related by not qute the
> > > same if blocks around XFS_MOUNT_DFLT_IOSIZE and the isize split
> > > over two functions, which doesn't exactly help understanding
> > > the flow.
> > > 
> > 
> > Not quite sure I follow the last bit, but I don't necessarily think the
> > whole thing has to be boxed into a helper to clean it up. E.g., I'd do
> > something like the appended diff (compile tested only).
> > 
> 
> ... and if the function signature is really an issue, trade off idx &
> prev for a conditional base preallocation size (applies on top of the
> previous diff):
> 
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 45e5268..c748429 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -381,7 +381,7 @@ STATIC xfs_fsblock_t
>  xfs_iomap_prealloc_size(
>  	struct xfs_inode	*ip,
>  	xfs_off_t		offset,
> -	struct xfs_bmbt_irec	*prev)
> +	xfs_extlen_t		base)
>  {
>  	struct xfs_mount	*mp = ip->i_mount;
>  	int			shift = 0;
> @@ -406,8 +406,8 @@ xfs_iomap_prealloc_size(
>  	 * always extends to MAXEXTLEN rather than falling short due to things
>  	 * like stripe unit/width alignment of real extents.
>  	 */
> -	if (prev->br_blockcount <= (MAXEXTLEN >> 1))
> -		alloc_blocks = prev->br_blockcount << 1;
> +	if (base <= (MAXEXTLEN >> 1))
> +		alloc_blocks = base << 1;
>  	else
>  		alloc_blocks = XFS_B_TO_FSB(mp, offset);
>  	if (!alloc_blocks)
> @@ -506,12 +506,10 @@ xfs_iomap_prealloc(
>  	struct xfs_inode	*ip,
>  	loff_t			offset,
>  	loff_t			count,
> -	xfs_extnum_t		idx,
> -	struct xfs_bmbt_irec	*prev)
> +	xfs_extlen_t		base)
>  {
>  	struct xfs_mount	*mp = ip->i_mount;
>  	xfs_fsblock_t		alloc_blocks;
> -	xfs_fileoff_t		offset_fsb = XFS_B_TO_FSBT(mp, offset);
>  
>  	if (offset + count <= XFS_ISIZE(ip))
>  		return 0;
> @@ -526,12 +524,11 @@ xfs_iomap_prealloc(
>  	 */
>  	if ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ||
>  	    XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_dalign) ||
> -	    idx == 0 ||
> -	    prev->br_startoff + prev->br_blockcount < offset_fsb)
> +	    !base)
>  		alloc_blocks = mp->m_writeio_blocks;
>  	else
>  		alloc_blocks =
> -			xfs_iomap_prealloc_size(ip, offset, prev);
> +			xfs_iomap_prealloc_size(ip, offset, base);
>  
>  	return alloc_blocks;
>  }
> @@ -603,8 +600,15 @@ xfs_file_iomap_begin_delay(
>  	end_fsb = orig_end_fsb =
>  		min(XFS_B_TO_FSB(mp, offset + count), maxbytes_fsb);
>  
> -	if (eof)
> -		prealloc = xfs_iomap_prealloc(ip, offset, count, idx, &prev);
> +	if (eof) {
> +		xfs_extlen_t	base = 0;
> +
> +		/* use prev extent as base if contiguous */
> +		if (idx > 0 &&
> +		    prev.br_startoff + prev.br_blockcount < offset_fsb)

This should probably be: startoff + blockcount == offset_fsb

Brian

> +			base = prev.br_blockcount;
> +		prealloc = xfs_iomap_prealloc(ip, offset, count, base);
> +	}
>  	if (prealloc) {
>  		xfs_off_t	aligned_offset;
>  		xfs_extlen_t	align;
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

      parent reply	other threads:[~2016-08-30 20:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-21 21:51 iomap write fixes Christoph Hellwig
2016-08-21 21:51 ` [PATCH 1/4] xfs: move xfs_bmbt_to_iomap up Christoph Hellwig
2016-08-25 12:38   ` Brian Foster
2016-08-21 21:51 ` [PATCH 2/4] xfs: factor our a helper to calculate the EOF alignment Christoph Hellwig
2016-08-25 12:38   ` Brian Foster
2016-08-21 21:51 ` [PATCH 3/4] xfs: make xfs_inode_set_eofblocks_tag cheaper for the common case Christoph Hellwig
2016-08-25 12:38   ` Brian Foster
2016-08-26 14:26     ` Christoph Hellwig
2016-08-26 16:02       ` Brian Foster
2016-08-30 14:40         ` Christoph Hellwig
2016-08-30 23:03           ` Dave Chinner
2016-08-21 21:51 ` [PATCH 4/4] xfs: rewrite and optimize the delalloc write path Christoph Hellwig
2016-08-25 14:37   ` Brian Foster
2016-08-26 14:33     ` Christoph Hellwig
2016-08-26 16:03       ` Brian Foster
2016-08-26 16:07         ` Brian Foster
2016-08-30 14:44           ` Christoph Hellwig
2016-08-30 20:28           ` Brian Foster [this message]

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=20160830202820.GA16503@bfoster.bfoster \
    --to=bfoster@redhat.com \
    --cc=hch@lst.de \
    --cc=xfs@oss.sgi.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.