diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2009-03-09 11:33:31 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2009-03-17 21:43:52 -0400 |
commit | 70a9b8734660698eb91efb8947a9e691d40235e1 (patch) | |
tree | cd0e464836c37b675ed57e9a0ff89522e031748b | |
parent | 2b301307f63dbecf06d91f58f003c7fb7addee24 (diff) |
[SCSI] sd: Make revalidate less chatty
sd_revalidate ends up being called several times during device setup.
With this patch we print everything during the first scan. Subsequent
invocations will only print a message if the parameter in question has
actually changed (LUN capacity has increased, etc.).
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r-- | drivers/scsi/sd.c | 61 | ||||
-rw-r--r-- | drivers/scsi/sd.h | 1 |
2 files changed, 38 insertions, 24 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8eebaa8c6f52..aeab5d9dff27 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -1440,6 +1440,7 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) | |||
1440 | { | 1440 | { |
1441 | int sector_size; | 1441 | int sector_size; |
1442 | struct scsi_device *sdp = sdkp->device; | 1442 | struct scsi_device *sdp = sdkp->device; |
1443 | sector_t old_capacity = sdkp->capacity; | ||
1443 | 1444 | ||
1444 | if (sd_try_rc16_first(sdp)) { | 1445 | if (sd_try_rc16_first(sdp)) { |
1445 | sector_size = read_capacity_16(sdkp, sdp, buffer); | 1446 | sector_size = read_capacity_16(sdkp, sdp, buffer); |
@@ -1531,10 +1532,11 @@ got_data: | |||
1531 | string_get_size(sz, STRING_UNITS_10, cap_str_10, | 1532 | string_get_size(sz, STRING_UNITS_10, cap_str_10, |
1532 | sizeof(cap_str_10)); | 1533 | sizeof(cap_str_10)); |
1533 | 1534 | ||
1534 | sd_printk(KERN_NOTICE, sdkp, | 1535 | if (sdkp->first_scan || old_capacity != sdkp->capacity) |
1535 | "%llu %d-byte hardware sectors: (%s/%s)\n", | 1536 | sd_printk(KERN_NOTICE, sdkp, |
1536 | (unsigned long long)sdkp->capacity, | 1537 | "%llu %d-byte hardware sectors: (%s/%s)\n", |
1537 | sector_size, cap_str_10, cap_str_2); | 1538 | (unsigned long long)sdkp->capacity, |
1539 | sector_size, cap_str_10, cap_str_2); | ||
1538 | } | 1540 | } |
1539 | 1541 | ||
1540 | /* Rescale capacity to 512-byte units */ | 1542 | /* Rescale capacity to 512-byte units */ |
@@ -1571,6 +1573,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) | |||
1571 | int res; | 1573 | int res; |
1572 | struct scsi_device *sdp = sdkp->device; | 1574 | struct scsi_device *sdp = sdkp->device; |
1573 | struct scsi_mode_data data; | 1575 | struct scsi_mode_data data; |
1576 | int old_wp = sdkp->write_prot; | ||
1574 | 1577 | ||
1575 | set_disk_ro(sdkp->disk, 0); | 1578 | set_disk_ro(sdkp->disk, 0); |
1576 | if (sdp->skip_ms_page_3f) { | 1579 | if (sdp->skip_ms_page_3f) { |
@@ -1611,11 +1614,13 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) | |||
1611 | } else { | 1614 | } else { |
1612 | sdkp->write_prot = ((data.device_specific & 0x80) != 0); | 1615 | sdkp->write_prot = ((data.device_specific & 0x80) != 0); |
1613 | set_disk_ro(sdkp->disk, sdkp->write_prot); | 1616 | set_disk_ro(sdkp->disk, sdkp->write_prot); |
1614 | sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", | 1617 | if (sdkp->first_scan || old_wp != sdkp->write_prot) { |
1615 | sdkp->write_prot ? "on" : "off"); | 1618 | sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", |
1616 | sd_printk(KERN_DEBUG, sdkp, | 1619 | sdkp->write_prot ? "on" : "off"); |
1617 | "Mode Sense: %02x %02x %02x %02x\n", | 1620 | sd_printk(KERN_DEBUG, sdkp, |
1618 | buffer[0], buffer[1], buffer[2], buffer[3]); | 1621 | "Mode Sense: %02x %02x %02x %02x\n", |
1622 | buffer[0], buffer[1], buffer[2], buffer[3]); | ||
1623 | } | ||
1619 | } | 1624 | } |
1620 | } | 1625 | } |
1621 | 1626 | ||
@@ -1633,6 +1638,9 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) | |||
1633 | int modepage; | 1638 | int modepage; |
1634 | struct scsi_mode_data data; | 1639 | struct scsi_mode_data data; |
1635 | struct scsi_sense_hdr sshdr; | 1640 | struct scsi_sense_hdr sshdr; |
1641 | int old_wce = sdkp->WCE; | ||
1642 | int old_rcd = sdkp->RCD; | ||
1643 | int old_dpofua = sdkp->DPOFUA; | ||
1636 | 1644 | ||
1637 | if (sdp->skip_ms_page_8) | 1645 | if (sdp->skip_ms_page_8) |
1638 | goto defaults; | 1646 | goto defaults; |
@@ -1704,12 +1712,14 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) | |||
1704 | sdkp->DPOFUA = 0; | 1712 | sdkp->DPOFUA = 0; |
1705 | } | 1713 | } |
1706 | 1714 | ||
1707 | sd_printk(KERN_NOTICE, sdkp, | 1715 | if (sdkp->first_scan || old_wce != sdkp->WCE || |
1708 | "Write cache: %s, read cache: %s, %s\n", | 1716 | old_rcd != sdkp->RCD || old_dpofua != sdkp->DPOFUA) |
1709 | sdkp->WCE ? "enabled" : "disabled", | 1717 | sd_printk(KERN_NOTICE, sdkp, |
1710 | sdkp->RCD ? "disabled" : "enabled", | 1718 | "Write cache: %s, read cache: %s, %s\n", |
1711 | sdkp->DPOFUA ? "supports DPO and FUA" | 1719 | sdkp->WCE ? "enabled" : "disabled", |
1712 | : "doesn't support DPO or FUA"); | 1720 | sdkp->RCD ? "disabled" : "enabled", |
1721 | sdkp->DPOFUA ? "supports DPO and FUA" | ||
1722 | : "doesn't support DPO or FUA"); | ||
1713 | 1723 | ||
1714 | return; | 1724 | return; |
1715 | } | 1725 | } |
@@ -1805,15 +1815,6 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1805 | goto out; | 1815 | goto out; |
1806 | } | 1816 | } |
1807 | 1817 | ||
1808 | /* defaults, until the device tells us otherwise */ | ||
1809 | sdp->sector_size = 512; | ||
1810 | sdkp->capacity = 0; | ||
1811 | sdkp->media_present = 1; | ||
1812 | sdkp->write_prot = 0; | ||
1813 | sdkp->WCE = 0; | ||
1814 | sdkp->RCD = 0; | ||
1815 | sdkp->ATO = 0; | ||
1816 | |||
1817 | sd_spinup_disk(sdkp); | 1818 | sd_spinup_disk(sdkp); |
1818 | 1819 | ||
1819 | /* | 1820 | /* |
@@ -1827,6 +1828,8 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1827 | sd_read_app_tag_own(sdkp, buffer); | 1828 | sd_read_app_tag_own(sdkp, buffer); |
1828 | } | 1829 | } |
1829 | 1830 | ||
1831 | sdkp->first_scan = 0; | ||
1832 | |||
1830 | /* | 1833 | /* |
1831 | * We now have all cache related info, determine how we deal | 1834 | * We now have all cache related info, determine how we deal |
1832 | * with ordered requests. Note that as the current SCSI | 1835 | * with ordered requests. Note that as the current SCSI |
@@ -1937,6 +1940,16 @@ static void sd_probe_async(void *data, async_cookie_t cookie) | |||
1937 | gd->private_data = &sdkp->driver; | 1940 | gd->private_data = &sdkp->driver; |
1938 | gd->queue = sdkp->device->request_queue; | 1941 | gd->queue = sdkp->device->request_queue; |
1939 | 1942 | ||
1943 | /* defaults, until the device tells us otherwise */ | ||
1944 | sdp->sector_size = 512; | ||
1945 | sdkp->capacity = 0; | ||
1946 | sdkp->media_present = 1; | ||
1947 | sdkp->write_prot = 0; | ||
1948 | sdkp->WCE = 0; | ||
1949 | sdkp->RCD = 0; | ||
1950 | sdkp->ATO = 0; | ||
1951 | sdkp->first_scan = 1; | ||
1952 | |||
1940 | sd_revalidate_disk(gd); | 1953 | sd_revalidate_disk(gd); |
1941 | 1954 | ||
1942 | blk_queue_prep_rq(sdp->request_queue, sd_prep_fn); | 1955 | blk_queue_prep_rq(sdp->request_queue, sd_prep_fn); |
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h index 75638e7d3f66..708778cf5f06 100644 --- a/drivers/scsi/sd.h +++ b/drivers/scsi/sd.h | |||
@@ -53,6 +53,7 @@ struct scsi_disk { | |||
53 | unsigned WCE : 1; /* state of disk WCE bit */ | 53 | unsigned WCE : 1; /* state of disk WCE bit */ |
54 | unsigned RCD : 1; /* state of disk RCD bit, unused */ | 54 | unsigned RCD : 1; /* state of disk RCD bit, unused */ |
55 | unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ | 55 | unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ |
56 | unsigned first_scan : 1; | ||
56 | }; | 57 | }; |
57 | #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) | 58 | #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) |
58 | 59 | ||