public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@lst.de>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 16/21] implement generic xfs_btree_lshift
Date: Sat, 2 Aug 2008 11:28:03 +1000	[thread overview]
Message-ID: <20080802012803.GO6201@disturbed> (raw)
In-Reply-To: <20080801195249.GJ1263@lst.de>

On Fri, Aug 01, 2008 at 09:52:49PM +0200, Christoph Hellwig wrote:
> > > +xfs_btree_copy_ptrs(
> > > +	struct xfs_btree_cur	*cur,
> > > +	union xfs_btree_ptr	*src_ptr,
> > > +	union xfs_btree_ptr	*dst_ptr,
> > > +	int			numptrs)
> > > +{
> > > +	ASSERT(numptrs > 0);
> > > +
> > > +	if (cur->bc_flags & XFS_BTREE_LONG_PTRS)
> > > +		memcpy(dst_ptr, src_ptr, numptrs * sizeof(__be64));
> > > +	else
> > > +		memcpy(dst_ptr, src_ptr, numptrs * sizeof(__be32));
> > > +}
> > 
> > These should really use memmove, not memcpy. There is no guarantee
> > the source and destination do not overlap.
> > 
> > At minimum, we need comments to say this must only be used to
> > copy between blocks, and xfs_btree_move_ptrs() must be used to
> > copy within a block. I note the original patchset of mine
> > commented on this distinction when defining the ->move_* and
> > ->copy_* operations.
> > 
> > FWIW, that also helps explain why they have different interfaces...
> 
> There were some comments in the pre-walkthru cleanup version but they
> were already lost in that patch.  But yes, adding some comments makes
> sense.  Or moving back to single one that unlike your very first
> version always passes src and dst pointers and always uses memmove.

It might make sense to go back to a single implementation,
though at the time I did it it made sense to split the move/copy
operations because it made both cases simpler. Seeing as you've
stuck more closely to the original structure of the code, the
distinction is not as great as so it might be best to go back to a
single memmove based interface.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2008-08-02  1:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-29 19:31 [PATCH 16/21] implement generic xfs_btree_lshift Christoph Hellwig
2008-07-30  6:24 ` Dave Chinner
2008-08-01 19:52   ` Christoph Hellwig
2008-08-02  1:28     ` Dave Chinner [this message]
2008-08-02 15:35       ` Christoph Hellwig

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=20080802012803.GO6201@disturbed \
    --to=david@fromorbit.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox