All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Ewan Milne <emilne@redhat.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>,
	SCSI development list <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] scsi: sd: add a capacity_override attribute
Date: Fri, 20 Mar 2015 12:03:48 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1503201201180.1618-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <1426865631.19806.77.camel@localhost.localdomain>

On Fri, 20 Mar 2015, Ewan Milne wrote:

> On Fri, 2015-03-20 at 11:19 -0400, Alan Stern wrote:
> > On Fri, 20 Mar 2015, Ewan Milne wrote:
> > 
> > > On Tue, 2015-03-17 at 14:08 -0400, Alan Stern wrote:
> > > > This patch provides a sysfs interface allowing users to override the
> > > > capacity of a SCSI disk.  This will help in situations where a buggy
> > > > USB-SATA adapter fails to support READ CAPACITY(16) and reports only
> > > > the low 32 bits of the capacity in its READ CAPACITY(10) reply.  For
> > > > an example, see this thread:
> > > > 
> > > > 	http://marc.info/?l=linux-scsi&m=140908235510961&w=2
> > > > 
> > > > The interface is awkward because it requires the user to tell the
> > > > system to re-read the disk's partition table afterward, but at least
> > > > it provides a way to handle deficient hardware.
> > > 
> > > I think that it is confusing that writing into the capacity_override
> > > sysfs node does not get immediately reflected in the gendisk structure.
> > > Would it hurt to call sd_revalidate_disk() after the value is changed
> > > in capacity_override_store()?
> > 
> > It wouldn't hurt, but it wouldn't help much either.
> > 
> > sd_revalidate_disk() might cause the new size to show up in the
> > gendisk structure, but it would not cause the partition table to be
> > parsed again.  That's the real reason for doing this -- when a drive
> > seems to have fewer blocks than it really does, partitions that extend
> > beyond the "end" of the drive are rejected.
> 
> OK, I see.
> 
> > 
> > > The thing is, if someone overrides the capacity but does not do anything
> > > right away to revalidate the disk, it could change at some arbitrary
> > > time in the future when the revalidation happens for some other reason.
> > 
> > That's why the documentation says that users must force the system to 
> > re-read the partition table after writing the sysfs attribute.  In my 
> > tests, doing that caused a revalidation.
> > 
> > Are you saying that could have been a coincidence?  It's possible -- I 
> > don't understand the design of the block layer.
> 
> No, I think that re-reading the partition table will revalidate.  What I
> was concerned about is some unsuspecting user writing to the
> capacity_override sysfs node, observing that it didn't seem to do
> anything, and being surprised when it changed later.  (I've seen some
> issues with multipath, for example, which will stop using a path if the
> capacity changes.)  I guess it's a "principle of least surprise" thing.
> 
> Having said that, if this is what is needed to make the devices work...
> 
> Reviewed-by: Ewan D. Milne <emilne@redhat.com>

Thanks.  I don't _mind_ adding an sd_revalidate_disk() call if you 
think it will improve the patch.  What's your suggestion?

Alan Stern


  reply	other threads:[~2015-03-20 16:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-17 18:08 [PATCH] scsi: sd: add a capacity_override attribute Alan Stern
2015-03-20 14:40 ` Ewan Milne
2015-03-20 15:19   ` Alan Stern
2015-03-20 15:33     ` Ewan Milne
2015-03-20 16:03       ` Alan Stern [this message]
2015-03-20 16:32         ` Ewan Milne

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=Pine.LNX.4.44L0.1503201201180.1618-100000@iolanthe.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=emilne@redhat.com \
    --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 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.