All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Mason <chris.mason@oracle.com>
To: Jan Schmidt <list.btrfs@jan-o-sch.net>
Cc: Mark Fasheh <mfasheh@suse.de>,
	linux-btrfs@vger.kernel.org, Josef Bacik <josef@redhat.com>
Subject: Re: [PATCH 3/3] btrfs: extended inode refs
Date: Thu, 10 May 2012 09:35:09 -0400	[thread overview]
Message-ID: <20120510133509.GB11859@shiny> (raw)
In-Reply-To: <4FAB7B00.4090302@jan-o-sch.net>

On Thu, May 10, 2012 at 10:23:28AM +0200, Jan Schmidt wrote:
> On Wed, May 09, 2012 at 19:02 (+0200), Chris Mason wrote:
> >>>> +
> >>>> +	while (1) {
> >>>> +		ret = btrfs_find_one_extref(fs_root, inum, offset, path, &iref2,
> >>>> +					    &offset);
> >>>> +		if (ret < 0)
> >>>> +			break;
> >>>> +		if (ret) {
> >>>> +			ret = found ? 0 : -ENOENT;
> >>>> +			break;
> >>>> +		}
> >>>> +		++found;
> >>>> +
> >>>> +		slot = path->slots[0];
> >>>> +		eb = path->nodes[0];
> >>>> +		/* make sure we can use eb after releasing the path */
> >>>> +		atomic_inc(&eb->refs);
> >>>
> >>> You need a blocking read lock here, too. Grab it before releasing the path.
> > 
> > If you're calling btrfs_search_slot, it will give you a blocking lock
> > on the leaf.  If you set path->leave_spinning before the call, you'll
> > have a spinning lock on the leaf.
> > 
> > If you unlock a block that you got from a path (like eb =
> > path->nodes[0]), the path structure has a flag for each level that
> > indicates if that block was locked or not.  See btrfs_release_path().
> > So, don't fiddle the locks without fiddling the paths.
> > 
> > You can switch from spinning to/from blocking without touching the path, it
> > figures that out.
> 
> Note that we're releasing the path shortly after. My suggestion was to
> grab an *additional* read lock after atomic_inc(&eb->refs) (probably
> better extent_buffer_get(eb)) and before btrfs_path_release().
> 
> An alternative would be to set path->locks[0] to NULL, which would
> btrfs_release_path prevent from unlocking it, kidnapping its lock for
> our purpose. But I much prefer the open coded solution.

Thanks, I see now.

-chris

  reply	other threads:[~2012-05-10 13:35 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-05 20:09 [PATCH 0/3] " Mark Fasheh
2012-04-05 20:09 ` [PATCH 1/3] " Mark Fasheh
2012-04-12 13:08   ` Jan Schmidt
2012-04-24 22:23     ` Mark Fasheh
2012-04-25 10:19       ` Jan Schmidt
2012-04-05 20:09 ` [PATCH 2/3] " Mark Fasheh
2012-04-12 13:08   ` Jan Schmidt
2012-05-03 23:12     ` Mark Fasheh
2012-05-04 11:39       ` David Sterba
2012-04-12 15:53   ` Jan Schmidt
2012-05-01 18:39     ` Mark Fasheh
2012-04-05 20:09 ` [PATCH 3/3] " Mark Fasheh
2012-04-12 17:59   ` Jan Schmidt
2012-04-12 18:38     ` Jan Schmidt
2012-05-08 22:57     ` Mark Fasheh
2012-05-09 17:02       ` Chris Mason
2012-05-10  8:23         ` Jan Schmidt
2012-05-10 13:35           ` Chris Mason [this message]
2012-04-05 21:13 ` [PATCH 0/3] " Jeff Mahoney
2012-04-11 13:11   ` Jan Schmidt
2012-04-11 13:29     ` Jan Schmidt
2012-04-12 16:11     ` Chris Mason
2012-04-12 16:19       ` Mark Fasheh
2012-04-06  1:24 ` Liu Bo
2012-04-06  2:12   ` Liu Bo
2012-05-21 21:46 Mark Fasheh
2012-05-21 21:46 ` [PATCH 3/3] " Mark Fasheh
2012-07-06 14:57   ` Jan Schmidt
2012-07-09 20:24     ` Mark Fasheh
2012-08-08 18:55 [PATCH 0/3] " Mark Fasheh
2012-08-08 18:55 ` [PATCH 3/3] " Mark Fasheh
2012-08-15  8:46   ` Jan Schmidt

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=20120510133509.GB11859@shiny \
    --to=chris.mason@oracle.com \
    --cc=josef@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=list.btrfs@jan-o-sch.net \
    --cc=mfasheh@suse.de \
    --subject='Re: [PATCH 3/3] btrfs: extended inode refs' \
    /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

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.