LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Luben Tuikov <ltuikov@yahoo.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Infinite retries reading the partition table
Date: Fri, 1 Dec 2006 00:32:31 -0800 (PST)	[thread overview]
Message-ID: <520003.85125.qm@web31807.mail.mud.yahoo.com> (raw)
In-Reply-To: <20061130232916.6cbd1408.akpm@osdl.org>

--- Andrew Morton <akpm@osdl.org> wrote:
> On Thu, 30 Nov 2006 22:34:57 -0800 (PST)
> Luben Tuikov <ltuikov@yahoo.com> wrote:
> 
> > --- Andrew Morton <akpm@osdl.org> wrote:
> > > On Wed, 29 Nov 2006 17:22:48 -0800 (PST)
> > > Luben Tuikov <ltuikov@yahoo.com> wrote:
> > > 
> > > > Suppose reading sector 0 always reports an error,
> > > > sense key HARDWARE ERROR.
> > > > 
> > > > What I'm observing is that the request to read sector 0,
> > > > reading partition information, is retried forever, ad infinitum.
> > > > 
> > > > Does anyone have a patch to resolve this? (2.6.19-rc6)
> > > > 
> > > 
> > > Please send a backtrace so we can see where the offending loop occurs.
> > 
> > I posted a patch to linux-scsi
> 
> hm.  Does sending patches to linux-scsi get them applied?  It might, I
> don't know.

Good question -- I don't know either.

> > which resolves this issue:
> > http://marc.theaimsgroup.com/?l=linux-scsi&m=116485834119885&w=2
> 
> That looks like it prevents the IO error.  But why was an IO error causing
> an infinite loop?   What piece of code was initiating the retries?

Here is what happens: sector 0 is broken -- the device cannot read
the media at that location.  The device properly returns a certain
type of uncorrectable MEDIUM ERROR (ASC: UNRECOVERABLE READ ERR).

SCSI Core loops around its retries (which this patch fixes) and
eventually gives up and sends it for "completion".  This is what
happens when scsi_check_sense() returns NEEDS_RETRY to
scsi_decide_disposition() to scsi_softirq().  The first chunk
of the patch fixes this.

We end up in scsi_io_completion(), where good_bytes = 0, and
result = 0x08000002 (DRIVER SENSE and CHECK CONDITION).

This statement in scsi_io_completion() causes the infinite retry loop:
   if (scsi_end_request(cmd, 1, good_bytes, !!result) == NULL)
         return;
substitute to get: scsi_end_request(cmd, uptodate=1, uptodate bytes=0, retry=1)
Yeah, but it doesn't make sense to call scsi_end_request() with uptodate=1 and
uptodate bytes = 0.  This causes the infinite retry, since the code
tries to re-read the whole xfer size (0 bytes were uptodate and retry=1),
from the bad media.

That is, we want to set uptodate=1 iff there was at least 1 byte up to date.
Else if nothing was read, uptodate bytes = 0, then we should pass
uptodate = 0, uptodate_bytes = total xfer, to mean the whole xfer is
not uptodate; and retry iff there was no error. (This is the very bottom
of the function.)

... I know, I know, but that's what we've got.

See this commit 03aba2f79594ca94d159c8bab454de9bcc385b76 as well.

      Luben


  reply	other threads:[~2006-12-01  8:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-30  1:22 Luben Tuikov
2006-12-01  5:47 ` Andrew Morton
2006-12-01  6:34   ` Luben Tuikov
2006-12-01  7:29     ` Andrew Morton
2006-12-01  8:32       ` Luben Tuikov [this message]
2006-12-05 20:40         ` Michael Reed
2006-12-06  5:00           ` Luben Tuikov
2006-12-06  5:08             ` Andrew Morton
2006-12-06  6:10               ` Luben Tuikov
2006-12-06 15:59               ` James Bottomley
2006-12-06 20:24                 ` Luben Tuikov
2006-12-07 18:16                   ` James Bottomley
2006-12-07 19:14                     ` Luben Tuikov
2006-12-07 21:15                       ` James Bottomley
2006-12-06 10:48       ` Etienne.Vogt
2006-11-30  1:53 Luben Tuikov

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=520003.85125.qm@web31807.mail.mud.yahoo.com \
    --to=ltuikov@yahoo.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --subject='Re: Infinite retries reading the partition table' \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).