From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Hannes Reinecke <hare@suse.de>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 8/8] Remove reap_ref
Date: Sun, 23 Mar 2008 10:19:36 -0500 [thread overview]
Message-ID: <1206285576.3494.17.camel@localhost.localdomain> (raw)
In-Reply-To: <20080318133228.ACA1F159169@pentland.suse.de>
On Tue, 2008-03-18 at 14:32 +0100, Hannes Reinecke wrote:
> struct scsi_target contains a 'reap_ref' counter, which is
> basically a reference counter for the target.
Actually, it's not a reference counter, it's an indicator that the
target may not be removed regardless of whether it has any children.
> As we now have proper reference counting we can remove it.
> This also cleans out the calling sequence for scsi_target_reap(),
> which now will only be called from the release function of the
> scsi_device, so we're guaranteed to always have a valid target.
Unfortunately, no. This patch is founded on a wrong assumption.
The way the reap_ref works is that it's effectively a semaphore on
"don't delete target, I'm using it"---protecting critical target use
sections where we're manipulating or adding its children. We have to
have a separate counter for this because the target is eligible for
deletion any time it doesn't have any children. Unfortunately, there
are several times in the life cycle of a target when this may be true:
most notably at creation, but also around deletion (we don't want early
kills on the target until we're ready).
So, when a target is created, it comes with a reap_ref of one. You
don't reduce it to zero until you're done with the scan otherwise your
target may be killed by a racing delete. Likewise in deletion, you
raise the reap ref do your deletion and then reap, so the target doesn't
disappear prematurely due to a racing scan.
James
prev parent reply other threads:[~2008-03-23 15:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-18 13:32 [PATCH 8/8] Remove reap_ref Hannes Reinecke
2008-03-23 15:19 ` James Bottomley [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=1206285576.3494.17.camel@localhost.localdomain \
--to=james.bottomley@hansenpartnership.com \
--cc=hare@suse.de \
--cc=linux-scsi@vger.kernel.org \
/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