linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@suse.de>
To: Tejun Heo <tj@kernel.org>
Cc: jeff@garzik.org, linux-ide@vger.kernel.org,
	jens.axboe@oracle.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org, ben@decadent.org.uk,
	davem@davemloft.net, bzolnier@gmail.com
Subject: Re: [PATCH 6/8] SCSI: implement sd_unlock_native_capacity()
Date: Sun, 16 May 2010 08:39:35 -0500	[thread overview]
Message-ID: <1274017175.14187.9.camel@mulgrave.site> (raw)
In-Reply-To: <1273946974-29131-7-git-send-email-tj@kernel.org>

On Sat, 2010-05-15 at 20:09 +0200, Tejun Heo wrote:
> Implement sd_unlock_native_capacity() method which calls into
> hostt->unlock_native_capacity() if implemented.  This will be invoked
> by block layer if partitions extend beyond the end of the device and
> can be used to implement, for example, on-demand ATA host protected
> area unlocking.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Ben Hutchings <ben@decadent.org.uk>
> ---
>  drivers/scsi/sd.c        |   22 ++++++++++++++++++++++
>  include/scsi/scsi_host.h |    8 ++++++++
>  2 files changed, 30 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 8b827f3..b85906e 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -97,6 +97,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
>  #endif
>  
>  static int  sd_revalidate_disk(struct gendisk *);
> +static void sd_unlock_native_capacity(struct gendisk *disk);
>  static int  sd_probe(struct device *);
>  static int  sd_remove(struct device *);
>  static void sd_shutdown(struct device *);
> @@ -1100,6 +1101,7 @@ static const struct block_device_operations sd_fops = {
>  #endif
>  	.media_changed		= sd_media_changed,
>  	.revalidate_disk	= sd_revalidate_disk,
> +	.unlock_native_capacity	= sd_unlock_native_capacity,
>  };
>  
>  static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
> @@ -2101,6 +2103,26 @@ static int sd_revalidate_disk(struct gendisk *disk)
>  }
>  
>  /**
> + *	sd_unlock_native_capacity - unlock native capacity
> + *	@disk: struct gendisk to set capacity for
> + *
> + *	Block layer calls this function if it detects that partitions
> + *	on @disk reach beyond the end of the device.  If the SCSI host
> + *	implements ->unlock_native_capacity() method, it's invoked to
> + *	give it a chance to adjust the device capacity.
> + *
> + *	CONTEXT:
> + *	Defined by block layer.  Might sleep.
> + */
> +static void sd_unlock_native_capacity(struct gendisk *disk)
> +{
> +	struct scsi_device *sdev = scsi_disk(disk)->device;
> +
> +	if (sdev->host->hostt->unlock_native_capacity)
> +		sdev->host->hostt->unlock_native_capacity(sdev);
> +}
> +
> +/**
>   *	sd_format_disk_name - format disk name
>   *	@prefix: name prefix - ie. "sd" for SCSI disks
>   *	@index: index of the disk to format name for
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index c50a97f..b7bdecb 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -327,6 +327,14 @@ struct scsi_host_template {
>  			sector_t, int []);
>  
>  	/*
> +	 * This function is called when one or more partitions on the
> +	 * device reach beyond the end of the device.
> +	 *
> +	 * Status: OPTIONAL
> +	 */
> +	void (*unlock_native_capacity)(struct scsi_device *);
> +
> +	/*

I still principally dislike this threading of the operation up and down
the stack.  Although we've done it before, we're trying to get away from
the paradigm of driver conditions to scsi and scsi conditions to block
for all stuff where driver could condition straight to block (alignment
is a classic example of the new way of doing things).

The reason you need the threading is because the block ops gets hidden
at the top of the stack in the upper layers (this was a design choice to
try to prevent the lower layers mucking with it).  The way we get around
this is to use a queue operation instead.  As far as I can tell, there's
no logical reason for the unlock to be a block op, so lets make it a
queue op instead.  The consumer in 

static bool disk_unlock_native_capacity(struct gendisk *disk)

then becomes

	blk_unlock_native_capacity(disk->queue)

Block's implementation of this would probably call directly through the
queue.

You place the usual function in the queue template so the ata slave
configure can say

	blk_queue_unlock_native_function(rq, <unlock_function>)

Then there's no need for anything at all in SCSI ... and it becomes a
whole lot more obvious how to do legacy ide (if we ever get problems
there).

James



  parent reply	other threads:[~2010-05-16 13:39 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-15 18:09 [PATCHSET] block,libata: implement ->unlock_native_capacity() Tejun Heo
2010-05-15 18:09 ` [PATCH 1/8] buffer: make invalidate_bdev() drain all percpu LRU add caches Tejun Heo
2010-05-16  7:11   ` David Miller
2010-05-15 18:09 ` [PATCH 2/8] block: restart partition scan after resizing a device Tejun Heo
2010-05-16  7:15   ` David Miller
2010-05-15 18:09 ` [PATCH 3/8] block,ide: simplify bdops->set_capacity() to ->unlock_native_capacity() Tejun Heo
2010-05-15 18:48   ` Bartlomiej Zolnierkiewicz
2010-05-15 18:58     ` Tejun Heo
2010-05-16  7:15   ` David Miller
2010-05-15 18:09 ` [PATCH 4/8] block: use struct parsed_partitions *state universally in partition check code Tejun Heo
2010-05-16  7:16   ` David Miller
2010-05-15 18:09 ` [PATCH 5/8] block: improve automatic native capacity unlocking Tejun Heo
2010-05-16  7:17   ` David Miller
2010-05-15 18:09 ` [PATCH 6/8] SCSI: implement sd_unlock_native_capacity() Tejun Heo
2010-05-16  7:18   ` David Miller
2010-05-16 13:39   ` James Bottomley [this message]
2010-05-16 15:07     ` Ben Hutchings
2010-05-16 16:00       ` James Bottomley
2010-05-16 17:00         ` Tejun Heo
2010-05-16 19:23           ` James Bottomley
2010-05-17  5:30             ` Tejun Heo
2010-06-02 17:50   ` Jeff Garzik
2010-05-15 18:09 ` [PATCH 7/8] libata: use the enlarged capacity after late HPA unlock Tejun Heo
2010-05-15 19:22   ` Jeff Garzik
2010-05-16  7:18   ` David Miller
2010-05-15 18:09 ` [PATCH 8/8] libata: implement on-demand HPA unlocking Tejun Heo
2010-05-15 19:22   ` Jeff Garzik
2010-05-16  7:19   ` David Miller
2010-05-19  7:05 ` [PATCHSET] block,libata: implement ->unlock_native_capacity() Tejun Heo
2010-05-19  7:08   ` Jens Axboe
2010-06-02 16:37 ` Tejun Heo

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=1274017175.14187.9.camel@mulgrave.site \
    --to=james.bottomley@suse.de \
    --cc=ben@decadent.org.uk \
    --cc=bzolnier@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jeff@garzik.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=tj@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;
as well as URLs for NNTP newsgroup(s).