public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Mark Tinguely <tinguely@sgi.com>, xfs@oss.sgi.com
Subject: Re: [PATCH v3 3/5] xfs: fix segment in xfs_buf_item_format_segment
Date: Mon, 10 Dec 2012 12:34:06 +1100	[thread overview]
Message-ID: <20121210013406.GL15784@dastard> (raw)
In-Reply-To: <20121208122921.GC29107@infradead.org>

On Sat, Dec 08, 2012 at 07:29:21AM -0500, Christoph Hellwig wrote:
> On Tue, Dec 04, 2012 at 05:18:04PM -0600, Mark Tinguely wrote:
> > Not every segment in a multi-segment buffer is dirty in a
> > transaction and they will not be outputted. The assert in
> > xfs_buf_item_format_segment() that checks for the at least
> > one chunk of data in the segment to be used is not necessary
> > true for multi-segmented buffers.
> > 
> > Signed-off-by: Mark Tinguely <tinguely@sgi.com>
> > ---
> >  fs/xfs/xfs_buf_item.c |   20 +++++++++++++++-----
> >  1 file changed, 15 insertions(+), 5 deletions(-)
> > 
> > Index: b/fs/xfs/xfs_buf_item.c
> > ===================================================================
> > --- a/fs/xfs/xfs_buf_item.c
> > +++ b/fs/xfs/xfs_buf_item.c
> > @@ -287,6 +287,17 @@ xfs_buf_item_format_segment(
> >  	 */
> >  	base_size = offsetof(struct xfs_buf_log_format, blf_data_map) +
> >  			(blfp->blf_map_size * sizeof(blfp->blf_data_map[0]));
> > +
> > +	nvecs = 0;
> > +	first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
> > +	if (!(bip->bli_flags & XFS_BLI_STALE) && first_bit == -1) {
> > +		/*
> > +		 * If the map is not be dirty in the transaction, mark
> > +		 * the size as zero and do not advance the vector pointer.
> > +		 */
> > +		goto out;
> > +	}
> > +
> 
> I don't really like the style of this check.  What's the problem of
> doing it this way:
> 
>   1) fill out the first vecp
>   2) do the stale check as-is
>   3) handle the the first_bit == -1 case  ala:
> 
> 	if (first_bit == -1) {
> 		blfp->blf_size = 0;
> 		return vecp;
> 	}

Because if we have already written all the dirty regions and we have
a trailing clean buffer segment, vecp points past the memory
allocated for the vectors. Hence we can end up with memory
corruption if we write to vecp in this case.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

  reply	other threads:[~2012-12-10  1:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 23:18 [PATCH v3 0/5] discontiguous buffer patches Mark Tinguely
2012-12-04 23:18 ` [PATCH v3 1/5] xfs: use b_maps[] for discontiguous buffers Mark Tinguely
2012-12-08 12:23   ` Christoph Hellwig
2012-12-04 23:18 ` [PATCH v3 2/5] xfs: rename bli_format to avoid confusion with bli_formats Mark Tinguely
2012-12-08 12:23   ` Christoph Hellwig
2012-12-04 23:18 ` [PATCH v3 3/5] xfs: fix segment in xfs_buf_item_format_segment Mark Tinguely
2012-12-08 12:29   ` Christoph Hellwig
2012-12-10  1:34     ` Dave Chinner [this message]
2012-12-04 23:18 ` [PATCH v3 4/5] xfs: fix the multi-segment log buffer format Mark Tinguely
2012-12-08 12:38   ` Christoph Hellwig
2012-12-10  1:59     ` Dave Chinner
2012-12-04 23:18 ` [PATCH v3 5/5] xfs remove the XFS_TRANS_DEBUG routines Mark Tinguely
2012-12-08 12:39   ` 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=20121210013406.GL15784@dastard \
    --to=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=tinguely@sgi.com \
    --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