From: Tejun Heo <tj@kernel.org>
To: jeff@garzik.org, linux-ide@vger.kernel.org,
jens.axboe@oracle.com, linux-scsi@vger.kernel.org,
James.Bottomley@suse.de, linux-kernel@vger.kernel.org
Cc: ben@decadent.org.uk, Tejun Heo <tj@kernel.org>
Subject: [PATCH 2/4] SCSI: implement sd_set_capacity()
Date: Thu, 13 May 2010 17:56:44 +0200 [thread overview]
Message-ID: <1273766206-17402-3-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1273766206-17402-1-git-send-email-tj@kernel.org>
Implement sd_set_capacity() method which calls into
hostt->set_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 | 26 ++++++++++++++++++++++++++
include/scsi/scsi_host.h | 11 +++++++++++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 8b827f3..59d5e8f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -97,6 +97,8 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
#endif
static int sd_revalidate_disk(struct gendisk *);
+static unsigned long long sd_set_capacity(struct gendisk *disk,
+ unsigned long long new_capacity);
static int sd_probe(struct device *);
static int sd_remove(struct device *);
static void sd_shutdown(struct device *);
@@ -1100,6 +1102,7 @@ static const struct block_device_operations sd_fops = {
#endif
.media_changed = sd_media_changed,
.revalidate_disk = sd_revalidate_disk,
+ .set_capacity = sd_set_capacity,
};
static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
@@ -2101,6 +2104,29 @@ static int sd_revalidate_disk(struct gendisk *disk)
}
/**
+ * sd_set_capacity - set disk capacity
+ * @disk: struct gendisk to set capacity for
+ * @new_capacity: new target capacity
+ *
+ * Block layer calls this function if it detects that partitions
+ * on @disk reach beyond the end of the device. If the SCSI host
+ * implements set_capacity method, it's invoked to give it a
+ * chance to adjust the device capacity.
+ *
+ * CONTEXT:
+ * Defined by block layer. Might sleep.
+ */
+static unsigned long long sd_set_capacity(struct gendisk *disk,
+ unsigned long long new_capacity)
+{
+ struct scsi_device *sdev = scsi_disk(disk)->device;
+
+ if (sdev->host->hostt->set_capacity)
+ return sdev->host->hostt->set_capacity(sdev, new_capacity);
+ return 0;
+}
+
+/**
* 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..31dba89 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -327,6 +327,17 @@ 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. This function
+ * should return the new capacity if disk was successfully
+ * enlarged. Return values smaller than the current capacity
+ * are ignored.
+ *
+ * Status: OPTIONAL
+ */
+ sector_t (*set_capacity)(struct scsi_device *, sector_t);
+
+ /*
* Can be used to export driver statistics and other infos to the
* world outside the kernel ie. userspace and it also provides an
* interface to feed the driver with information.
--
1.6.4.2
next prev parent reply other threads:[~2010-05-13 15:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-13 15:56 [PATCHSET] libata: implement ->set_capacity() Tejun Heo
2010-05-13 15:56 ` [PATCH 1/4] block: restart partition scan after resizing a device Tejun Heo
2010-05-13 15:56 ` Tejun Heo [this message]
2010-05-13 15:56 ` [PATCH 3/4] libata: use the enlarged capacity after late HPA unlock Tejun Heo
2010-05-13 15:56 ` [PATCH 4/4] libata: implement on-demand HPA unlocking Tejun Heo
2010-05-13 16:06 ` [PATCHSET] libata: implement ->set_capacity() James Bottomley
2010-05-13 16:22 ` Tejun Heo
2010-05-13 16:38 ` James Bottomley
2010-05-13 16:54 ` Tejun Heo
2010-05-13 17:18 ` James Bottomley
2010-05-13 18:40 ` Tejun Heo
2010-05-13 17:13 ` Alan Cox
2010-05-13 17:40 ` Jens Axboe
2010-05-13 18:25 ` Tejun Heo
2010-05-15 13:22 ` Ben Hutchings
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=1273766206-17402-3-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=James.Bottomley@suse.de \
--cc=ben@decadent.org.uk \
--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 \
/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