📄 gdth_proc.c
字号:
if (piowr->iu.event.erase == 0xff) { pevt = (gdth_evt_str *)piowr->iu.event.evt; if (pevt->event_source == ES_TEST) pevt->event_data.size = sizeof(pevt->event_data.eu.test); else if (pevt->event_source == ES_DRIVER) pevt->event_data.size = sizeof(pevt->event_data.eu.driver); else if (pevt->event_source == ES_SYNC) pevt->event_data.size = sizeof(pevt->event_data.eu.sync); else { pevt->event_data.size = sizeof(pevt->event_data.eu.async); gdth_log_event(&pevt->event_data, NULL); } GDTH_LOCK_HA(ha, flags); gdth_store_event(ha, pevt->event_source, pevt->event_idx, &pevt->event_data); GDTH_UNLOCK_HA(ha, flags); } else if (piowr->iu.event.erase == 0xfe) { gdth_clear_events(); } else if (piowr->iu.event.erase == 0) { piord->iu.event.handle = gdth_read_event(ha,piowr->iu.event.handle, (gdth_evt_str *)piord->iu.event.evt); } else { piord->iu.event.handle = piowr->iu.event.handle; gdth_readapp_event(ha, (unchar)piowr->iu.event.erase, (gdth_evt_str *)piord->iu.event.evt); } piord->size = sizeof(gdth_iord_str); piord->status = S_OK; break; default: return(-EINVAL); } /* we return a buffer ID to detect the right buffer during READ-IOCTL */ return 1;}static int gdth_get_info(char *buffer,char **start,off_t offset, int length,int vh,int hanum,int busnum){ int size = 0,len = 0; off_t begin = 0,pos = 0; gdth_ha_str *ha; gdth_iord_str *piord; int id, i, j, k, sec, flag; int no_mdrv = 0, drv_no, is_mirr; ulong32 cnt; gdth_cmd_str gdtcmd; gdth_evt_str estr; Scsi_Cmnd * scp; Scsi_Device *sdev; char hrec[161]; struct timeval tv; gdth_dskstat_str *pds; gdth_diskinfo_str *pdi; gdth_arrayinf_str *pai; gdth_defcnt_str *pdef; gdth_cdrinfo_str *pcdi; gdth_hget_str *phg; TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum)); ha = HADATA(gdth_ctr_tab[hanum]); id = length; sdev = scsi_get_host_dev(gdth_ctr_vtab[vh]); scp = scsi_allocate_device(sdev, 1, FALSE); scp->cmd_len = 12; scp->use_sg = 0; /* look for buffer ID in length */ if (id > 1) { /* request is i.e. "cat /proc/scsi/gdth/0" */ /* format: %-15s\t%-10s\t%-15s\t%s */ /* driver parameters */ size = sprintf(buffer+len,"Driver Parameters:\n"); len += size; pos = begin + len; if (reserve_list[0] == 0xff) strcpy(hrec, "--"); else { sprintf(hrec, "%d", reserve_list[0]); for (i = 1; i < MAX_RES_ARGS; i++) { if (reserve_list[i] == 0xff) break; sprintf(hrec,"%s,%d", hrec, reserve_list[i]); } } size = sprintf(buffer+len, " reserve_mode: \t%d \treserve_list: \t%s\n", reserve_mode, hrec); len += size; pos = begin + len; size = sprintf(buffer+len, " max_ids: \t%-3d \thdr_channel: \t%d\n", max_ids, hdr_channel); len += size; pos = begin + len; if (pos < offset) { len = 0; begin = pos; } if (pos > offset + length) goto stop_output; /* controller information */ size = sprintf(buffer+len,"\nDisk Array Controller Information:\n"); len += size; pos = begin + len; strcpy(hrec, ha->binfo.type_string); size = sprintf(buffer+len, " Number: \t%d \tName: \t%s\n", hanum, hrec); len += size; pos = begin + len; if (ha->more_proc) sprintf(hrec, "%d.%02d.%02d-%c%03X", (unchar)(ha->binfo.upd_fw_ver>>24), (unchar)(ha->binfo.upd_fw_ver>>16), (unchar)(ha->binfo.upd_fw_ver), ha->bfeat.raid ? 'R':'N', ha->binfo.upd_revision); else sprintf(hrec, "%d.%02d", (unchar)(ha->cpar.version>>8), (unchar)(ha->cpar.version)); size = sprintf(buffer+len, " Driver Ver.: \t%-10s\tFirmware Ver.: \t%s\n", GDTH_VERSION_STR, hrec); len += size; pos = begin + len; if (pos < offset) { len = 0; begin = pos; } if (pos > offset + length) goto stop_output; if (ha->more_proc) { /* more information: 1. about controller */ size = sprintf(buffer+len, " Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n", ha->binfo.ser_no, ha->binfo.memsize / 1024); len += size; pos = begin + len; if (pos < offset) { len = 0; begin = pos; } if (pos > offset + length) goto stop_output; /* 2. about physical devices */ size = sprintf(buffer+len,"\nPhysical Devices:"); len += size; pos = begin + len; flag = FALSE; if (!gdth_ioctl_alloc(hanum, GDTH_SCRATCH)) goto stop_output; for (i = 0; i < ha->bus_cnt; ++i) { /* 2.a statistics (and retries/reassigns) */ TRACE2(("pdr_statistics() chn %d\n",i)); pds = (gdth_dskstat_str *)(ha->pscratch + GDTH_SCRATCH/4); gdtcmd.BoardNode = LOCALBOARD; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = virt_to_bus(pds); gdtcmd.u.ioctl.param_size = 3*GDTH_SCRATCH/4; gdtcmd.u.ioctl.subfunc = DSK_STATISTICS | L_CTRL_PATTERN; gdtcmd.u.ioctl.channel = ha->raw[i].address | INVALID_CHANNEL; pds->bid = ha->raw[i].local_no; pds->first = 0; pds->entries = ha->raw[i].pdev_cnt; cnt = (3*GDTH_SCRATCH/4 - 5 * sizeof(ulong32)) / sizeof(pds->list[0]); if (pds->entries > cnt) pds->entries = cnt; gdth_do_cmd(scp, &gdtcmd, 30); if (scp->SCp.Message != S_OK) pds->count = 0; TRACE2(("pdr_statistics() entries %d status %d\n", pds->count, scp->SCp.Message)); /* other IOCTLs must fit into area GDTH_SCRATCH/4 */ for (j = 0; j < ha->raw[i].pdev_cnt; ++j) { /* 2.b drive info */ TRACE2(("scsi_drv_info() chn %d dev %d\n", i, ha->raw[i].id_list[j])); pdi = (gdth_diskinfo_str *)ha->pscratch; gdtcmd.BoardNode = LOCALBOARD; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = virt_to_bus(pdi); gdtcmd.u.ioctl.param_size = sizeof(gdth_diskinfo_str); gdtcmd.u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN; gdtcmd.u.ioctl.channel = ha->raw[i].address | ha->raw[i].id_list[j]; gdth_do_cmd(scp, &gdtcmd, 30); if (scp->SCp.Message == S_OK) { strncpy(hrec,pdi->vendor,8); strncpy(hrec+8,pdi->product,16); strncpy(hrec+24,pdi->revision,4); hrec[28] = 0; size = sprintf(buffer+len, "\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n", 'A'+i,pdi->target_id,pdi->lun,hrec); len += size; pos = begin + len; flag = TRUE; pdi->no_ldrive &= 0xffff; if (pdi->no_ldrive == 0xffff) strcpy(hrec,"--"); else sprintf(hrec,"%d",pdi->no_ldrive); size = sprintf(buffer+len, " Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n", pdi->blkcnt/(1024*1024/pdi->blksize), hrec); len += size; pos = begin + len; } else { pdi->devtype = 0xff; } if (pdi->devtype == 0) { /* search retries/reassigns */ for (k = 0; k < pds->count; ++k) { if (pds->list[k].tid == pdi->target_id && pds->list[k].lun == pdi->lun) { size = sprintf(buffer+len, " Retries: \t%-6d \tReassigns: \t%d\n", pds->list[k].retries, pds->list[k].reassigns); len += size; pos = begin + len; break; } } /* 2.c grown defects */ TRACE2(("scsi_drv_defcnt() chn %d dev %d\n", i, ha->raw[i].id_list[j])); pdef = (gdth_defcnt_str *)ha->pscratch; gdtcmd.BoardNode = LOCALBOARD; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = virt_to_bus(pdef); gdtcmd.u.ioctl.param_size = sizeof(gdth_defcnt_str); gdtcmd.u.ioctl.subfunc = SCSI_DEF_CNT | L_CTRL_PATTERN; gdtcmd.u.ioctl.channel = ha->raw[i].address | ha->raw[i].id_list[j]; pdef->sddc_type = 0x08; gdth_do_cmd(scp, &gdtcmd, 30); if (scp->SCp.Message == S_OK) { size = sprintf(buffer+len, " Grown Defects:\t%d\n", pdef->sddc_cnt); len += size; pos = begin + len; } } } } gdth_ioctl_free(hanum); if (!flag) { size = sprintf(buffer+len, "\n --\n"); len += size; pos = begin + len; } if (pos < offset) { len = 0; begin = pos; } if (pos > offset + length) goto stop_output; /* 3. about logical drives */ size = sprintf(buffer+len,"\nLogical Drives:"); len += size; pos = begin + len; flag = FALSE; if (!gdth_ioctl_alloc(hanum, GDTH_SCRATCH)) goto stop_output; for (i = 0; i < MAX_HDRIVES; ++i) { if (!ha->hdr[i].is_logdrv) continue; drv_no = i; j = k = 0; is_mirr = FALSE; do { /* 3.a log. drive info */ TRACE2(("cache_drv_info() drive no %d\n",drv_no)); pcdi = (gdth_cdrinfo_str *)ha->pscratch; gdtcmd.BoardNode = LOCALBOARD; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = virt_to_bus(pcdi); gdtcmd.u.ioctl.param_size = sizeof(gdth_cdrinfo_str); gdtcmd.u.ioctl.subfunc = CACHE_DRV_INFO; gdtcmd.u.ioctl.channel = drv_no; gdth_do_cmd(scp, &gdtcmd, 30); if (scp->SCp.Message != S_OK) break; pcdi->ld_dtype >>= 16; j++; if (pcdi->ld_dtype > 2) { strcpy(hrec, "missing"); } else if (pcdi->ld_error & 1) { strcpy(hrec, "fault"); } else if (pcdi->ld_error & 2) { strcpy(hrec, "invalid"); k++; j--; } else { strcpy(hrec, "ok"); } if (drv_no == i) { size = sprintf(buffer+len, "\n Number: \t%-2d \tStatus: \t%s\n", drv_no, hrec); len += size; pos = begin + len; flag = TRUE; no_mdrv = pcdi->cd_ldcnt; if (no_mdrv > 1 || pcdi->ld_slave != -1) { is_mirr = TRUE; strcpy(hrec, "RAID-1"); } else if (pcdi->ld_dtype == 0) { strcpy(hrec, "Disk"); } else if (pcdi->ld_dtype == 1) { strcpy(hrec, "RAID-0"); } else if (pcdi->ld_dtype == 2) { strcpy(hrec, "Chain"); } else { strcpy(hrec, "???"); } size = sprintf(buffer+len, " Capacity [MB]:\t%-6d \tType: \t%s\n", pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize), hrec); len += size; pos = begin + len; } else { size = sprintf(buffer+len, " Slave Number: \t%-2d \tStatus: \t%s\n", drv_no & 0x7fff, hrec); len += size; pos = begin + len; } drv_no = pcdi->ld_slave; } while (drv_no != -1); if (is_mirr) { size = sprintf(buffer+len, " Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n", no_mdrv - j - k, k); len += size; pos = begin + len; } if (!ha->hdr[i].is_arraydrv) strcpy(hrec, "--"); else sprintf(hrec, "%d", ha->hdr[i].master_no); size = sprintf(buffer+len, " To Array Drv.:\t%s\n", hrec); len += size; pos = begin + len; } gdth_ioctl_free(hanum); if (!flag) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -