提交 70a9b873 编写于 作者: M Martin K. Petersen 提交者: James Bottomley

[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: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
上级 2b301307
...@@ -1440,6 +1440,7 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -1440,6 +1440,7 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
{ {
int sector_size; int sector_size;
struct scsi_device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
sector_t old_capacity = sdkp->capacity;
if (sd_try_rc16_first(sdp)) { if (sd_try_rc16_first(sdp)) {
sector_size = read_capacity_16(sdkp, sdp, buffer); sector_size = read_capacity_16(sdkp, sdp, buffer);
...@@ -1531,10 +1532,11 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -1531,10 +1532,11 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)
string_get_size(sz, STRING_UNITS_10, cap_str_10, string_get_size(sz, STRING_UNITS_10, cap_str_10,
sizeof(cap_str_10)); sizeof(cap_str_10));
sd_printk(KERN_NOTICE, sdkp, if (sdkp->first_scan || old_capacity != sdkp->capacity)
"%llu %d-byte hardware sectors: (%s/%s)\n", sd_printk(KERN_NOTICE, sdkp,
(unsigned long long)sdkp->capacity, "%llu %d-byte hardware sectors: (%s/%s)\n",
sector_size, cap_str_10, cap_str_2); (unsigned long long)sdkp->capacity,
sector_size, cap_str_10, cap_str_2);
} }
/* Rescale capacity to 512-byte units */ /* Rescale capacity to 512-byte units */
...@@ -1571,6 +1573,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -1571,6 +1573,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
int res; int res;
struct scsi_device *sdp = sdkp->device; struct scsi_device *sdp = sdkp->device;
struct scsi_mode_data data; struct scsi_mode_data data;
int old_wp = sdkp->write_prot;
set_disk_ro(sdkp->disk, 0); set_disk_ro(sdkp->disk, 0);
if (sdp->skip_ms_page_3f) { if (sdp->skip_ms_page_3f) {
...@@ -1611,11 +1614,13 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -1611,11 +1614,13 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
} else { } else {
sdkp->write_prot = ((data.device_specific & 0x80) != 0); sdkp->write_prot = ((data.device_specific & 0x80) != 0);
set_disk_ro(sdkp->disk, sdkp->write_prot); set_disk_ro(sdkp->disk, sdkp->write_prot);
sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", if (sdkp->first_scan || old_wp != sdkp->write_prot) {
sdkp->write_prot ? "on" : "off"); sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
sd_printk(KERN_DEBUG, sdkp, sdkp->write_prot ? "on" : "off");
"Mode Sense: %02x %02x %02x %02x\n", sd_printk(KERN_DEBUG, sdkp,
buffer[0], buffer[1], buffer[2], buffer[3]); "Mode Sense: %02x %02x %02x %02x\n",
buffer[0], buffer[1], buffer[2], buffer[3]);
}
} }
} }
...@@ -1633,6 +1638,9 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -1633,6 +1638,9 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
int modepage; int modepage;
struct scsi_mode_data data; struct scsi_mode_data data;
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
int old_wce = sdkp->WCE;
int old_rcd = sdkp->RCD;
int old_dpofua = sdkp->DPOFUA;
if (sdp->skip_ms_page_8) if (sdp->skip_ms_page_8)
goto defaults; goto defaults;
...@@ -1704,12 +1712,14 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) ...@@ -1704,12 +1712,14 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
sdkp->DPOFUA = 0; sdkp->DPOFUA = 0;
} }
sd_printk(KERN_NOTICE, sdkp, if (sdkp->first_scan || old_wce != sdkp->WCE ||
"Write cache: %s, read cache: %s, %s\n", old_rcd != sdkp->RCD || old_dpofua != sdkp->DPOFUA)
sdkp->WCE ? "enabled" : "disabled", sd_printk(KERN_NOTICE, sdkp,
sdkp->RCD ? "disabled" : "enabled", "Write cache: %s, read cache: %s, %s\n",
sdkp->DPOFUA ? "supports DPO and FUA" sdkp->WCE ? "enabled" : "disabled",
: "doesn't support DPO or FUA"); sdkp->RCD ? "disabled" : "enabled",
sdkp->DPOFUA ? "supports DPO and FUA"
: "doesn't support DPO or FUA");
return; return;
} }
...@@ -1805,15 +1815,6 @@ static int sd_revalidate_disk(struct gendisk *disk) ...@@ -1805,15 +1815,6 @@ static int sd_revalidate_disk(struct gendisk *disk)
goto out; goto out;
} }
/* defaults, until the device tells us otherwise */
sdp->sector_size = 512;
sdkp->capacity = 0;
sdkp->media_present = 1;
sdkp->write_prot = 0;
sdkp->WCE = 0;
sdkp->RCD = 0;
sdkp->ATO = 0;
sd_spinup_disk(sdkp); sd_spinup_disk(sdkp);
/* /*
...@@ -1827,6 +1828,8 @@ static int sd_revalidate_disk(struct gendisk *disk) ...@@ -1827,6 +1828,8 @@ static int sd_revalidate_disk(struct gendisk *disk)
sd_read_app_tag_own(sdkp, buffer); sd_read_app_tag_own(sdkp, buffer);
} }
sdkp->first_scan = 0;
/* /*
* We now have all cache related info, determine how we deal * We now have all cache related info, determine how we deal
* with ordered requests. Note that as the current SCSI * 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,6 +1940,16 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
gd->private_data = &sdkp->driver; gd->private_data = &sdkp->driver;
gd->queue = sdkp->device->request_queue; gd->queue = sdkp->device->request_queue;
/* defaults, until the device tells us otherwise */
sdp->sector_size = 512;
sdkp->capacity = 0;
sdkp->media_present = 1;
sdkp->write_prot = 0;
sdkp->WCE = 0;
sdkp->RCD = 0;
sdkp->ATO = 0;
sdkp->first_scan = 1;
sd_revalidate_disk(gd); sd_revalidate_disk(gd);
blk_queue_prep_rq(sdp->request_queue, sd_prep_fn); blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);
......
...@@ -53,6 +53,7 @@ struct scsi_disk { ...@@ -53,6 +53,7 @@ struct scsi_disk {
unsigned WCE : 1; /* state of disk WCE bit */ unsigned WCE : 1; /* state of disk WCE bit */
unsigned RCD : 1; /* state of disk RCD bit, unused */ unsigned RCD : 1; /* state of disk RCD bit, unused */
unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
unsigned first_scan : 1;
}; };
#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册