public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Tony Battersby" <tonyb@cybernetics.com>
To: 'James Bottomley' <James.Bottomley@steeleye.com>
Cc: 'Alan Cox' <alan@lxorguk.ukuu.org.uk>,
	'SCSI Mailing List' <linux-scsi@vger.kernel.org>,
	marcelo@conectiva.com.br, dougg@torque.net
Subject: RE: [PATCH] 2.4.21 fix race condition in sg.c
Date: Fri, 27 Jun 2003 11:38:30 -0400	[thread overview]
Message-ID: <002b01c33cc2$2a353d40$e0019d89@cybernetics.com> (raw)
In-Reply-To: <1056726720.1825.27.camel@mulgrave>

> > Isn't smp_wmb() necessary to prevent the CPU from 
> > re-ordering the stores?
> 
> Ah, OK.  The answer's yes and no.  Your example is true for lockless
> access, but horribly racy (which is why, in practice, it's 
> almost never
> done).  The original code had locked access to done which prevents the
> race.  If we've lost the locked access, I don't think the fix can be
> correct.

I looked at the locking before attempting the patch, but I didn't see
anything protecting the done flag or status return fields.  It is true
that the done flag was set (without the patch) holding sg_dev_arr_lock,
but the code that looks at the done flag doesn't touch that lock.

If you think it needs a spinlock to be correct, then I will wait for
Doug's input, since he knows how it is supposed to work.

Anthony J. Battersby
Cybernetics


  reply	other threads:[~2003-06-27 15:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-27 13:52 [PATCH] 2.4.21 fix race condition in sg.c Tony Battersby
2003-06-27 14:10 ` James Bottomley
2003-06-27 14:31   ` Alan Cox
2003-06-27 14:47     ` James Bottomley
2003-06-27 14:57   ` Tony Battersby
2003-06-27 15:00     ` Jeff Garzik
2003-06-27 15:11     ` James Bottomley
2003-06-27 15:38       ` Tony Battersby [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-06-26 15:18 Tony Battersby
2003-06-26 22:15 ` Douglas Gilbert

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='002b01c33cc2$2a353d40$e0019d89@cybernetics.com' \
    --to=tonyb@cybernetics.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=dougg@torque.net \
    --cc=linux-scsi@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /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