All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>, Carlos Maiolino <cem@kernel.org>,
	Wilfred Mallawa <wilfred.mallawa@wdc.com>,
	Damien Le Moal <dlemoal@kernel.org>,
	Hans Holmberg <hans.holmberg@wdc.com>,
	Andrey Albershteyn <aalbersh@kernel.org>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/5] xfs: fix racy open zone caching
Date: Tue, 11 Aug 2026 17:03:20 +0200	[thread overview]
Message-ID: <20260811150320.GA19302@lst.de> (raw)
In-Reply-To: <20260810182142.GW3556460@frogsfrogsfrogs>

On Mon, Aug 10, 2026 at 11:21:42AM -0700, Darrick J. Wong wrote:
> > +	if (oz && !atomic_inc_not_zero(&oz->oz_ref))
> > +		oz = NULL;
> 
> Do we still need to test oz for null-ness here?  AFAICT we've already
> handled those cases here.

Yeah, that can go away.

> > +	spin_lock(&ip->i_flags_lock);
> > +	old_oz = VFS_I(ip)->i_private;
> > +	if (old_oz && old_oz->oz_allocated < rtg_blocks(old_oz->oz_rtg))
> > +		swap(oz, old_oz);
> >  	atomic_inc(&oz->oz_ref);
> 
> Hmm, I'm confused about oz_ref handling here.
> 
> If old_oz still has space, we swap oz and old_oz, after which oz alias
> i_private and old_oz is the zone that the caller passed in.  The above
> line then increments oz->oz_ref and puts the zone that the caller passed
> in.
> 
> Doesn't that cause oz->oz_ref to be too high?  We already had a ref
> via i_private, and now we have another one.

The caller needs a reference, and i_private needs a reference.  But this
is a bit to oclever to understand, we probably should be doing
atomic_inc_not_zero for the i_private case as well.  I'll rework this
to be a bit more clear.


  reply	other threads:[~2026-08-11 15:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 15:37 zoned xfs updates Christoph Hellwig
2026-08-10 15:37 ` [PATCH 1/5] xfs: handle NULL open_zone for merged ioends in xfs_ioend_put_open_zones Christoph Hellwig
2026-08-10 18:09   ` Darrick J. Wong
2026-08-10 15:37 ` [PATCH 2/5] xfs: fix racy open zone caching Christoph Hellwig
2026-08-10 18:21   ` Darrick J. Wong
2026-08-11 15:03     ` Christoph Hellwig [this message]
2026-08-10 15:37 ` [PATCH 3/5] xfs: fix zoned write iomap flags assignments Christoph Hellwig
2026-08-10 16:25   ` Andrey Albershteyn
2026-08-10 17:16     ` Christoph Hellwig
2026-08-10 18:11   ` Darrick J. Wong
2026-08-10 15:37 ` [PATCH 4/5] xfs: factor out a xfs_iomap_set_anon_write helper Christoph Hellwig
2026-08-10 18:13   ` Darrick J. Wong
2026-08-10 15:37 ` [PATCH 5/5] xfs: split ioend handling into a separate source file Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2026-08-11 16:48 zoned xfs updates v2 Christoph Hellwig
2026-08-11 16:48 ` [PATCH 2/5] xfs: fix racy open zone caching Christoph Hellwig
2026-08-11 17:05   ` Damien Le Moal
2026-08-11 17:12   ` 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=20260811150320.GA19302@lst.de \
    --to=hch@lst.de \
    --cc=aalbersh@kernel.org \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=hans.holmberg@wdc.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=wilfred.mallawa@wdc.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.