aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-05-15 14:09:32 -0400
committerJeff Garzik <jgarzik@redhat.com>2010-06-02 13:50:04 -0400
commit72ec24bd7725545bc149d80cbd21a7578d9aa206 (patch)
treea67f8fdda3b0dd69bb45ca19508b68431f1b69d8 /drivers/scsi/sd.c
parented4e2f801cf1484a68c4b41878353f26e6554c6a (diff)
SCSI: implement sd_unlock_native_capacity()
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> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 829cc37abc41..8802e48bc063 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -97,6 +97,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
97#endif 97#endif
98 98
99static int sd_revalidate_disk(struct gendisk *); 99static int sd_revalidate_disk(struct gendisk *);
100static void sd_unlock_native_capacity(struct gendisk *disk);
100static int sd_probe(struct device *); 101static int sd_probe(struct device *);
101static int sd_remove(struct device *); 102static int sd_remove(struct device *);
102static void sd_shutdown(struct device *); 103static void sd_shutdown(struct device *);
@@ -1101,6 +1102,7 @@ static const struct block_device_operations sd_fops = {
1101#endif 1102#endif
1102 .media_changed = sd_media_changed, 1103 .media_changed = sd_media_changed,
1103 .revalidate_disk = sd_revalidate_disk, 1104 .revalidate_disk = sd_revalidate_disk,
1105 .unlock_native_capacity = sd_unlock_native_capacity,
1104}; 1106};
1105 1107
1106static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd) 1108static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
@@ -2121,6 +2123,26 @@ static int sd_revalidate_disk(struct gendisk *disk)
2121} 2123}
2122 2124
2123/** 2125/**
2126 * sd_unlock_native_capacity - unlock native capacity
2127 * @disk: struct gendisk to set capacity for
2128 *
2129 * Block layer calls this function if it detects that partitions
2130 * on @disk reach beyond the end of the device. If the SCSI host
2131 * implements ->unlock_native_capacity() method, it's invoked to
2132 * give it a chance to adjust the device capacity.
2133 *
2134 * CONTEXT:
2135 * Defined by block layer. Might sleep.
2136 */
2137static void sd_unlock_native_capacity(struct gendisk *disk)
2138{
2139 struct scsi_device *sdev = scsi_disk(disk)->device;
2140
2141 if (sdev->host->hostt->unlock_native_capacity)
2142 sdev->host->hostt->unlock_native_capacity(sdev);
2143}
2144
2145/**
2124 * sd_format_disk_name - format disk name 2146 * sd_format_disk_name - format disk name
2125 * @prefix: name prefix - ie. "sd" for SCSI disks 2147 * @prefix: name prefix - ie. "sd" for SCSI disks
2126 * @index: index of the disk to format name for 2148 * @index: index of the disk to format name for