gdth_proc.c
来自「Linux Kernel 2.6.9 for OMAP1710」· C语言 代码 · 共 1,112 行 · 第 1/3 页
C
1,112 行
begin = pos; } if (pos > offset + length) goto stop_output; if (ha->more_proc) { /* more information: 2. about physical devices */ size = sprintf(buffer+len,"\nPhysical Devices:"); len += size; pos = begin + len; flag = FALSE; buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); if (!buf) 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 *)(buf + GDTH_SCRATCH/4); gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = paddr + GDTH_SCRATCH/4; 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;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) gdth_do_req(scp, &gdtcmd, cmnd, 30); if (scp->sr_command->SCp.Status != S_OK) #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status != S_OK) #else gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); if (scp.SCp.Status != S_OK) #endif { pds->count = 0; } /* 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 *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = paddr; 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];#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) gdth_do_req(scp, &gdtcmd, cmnd, 30); if (scp->sr_command->SCp.Status == S_OK) #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status == S_OK) #else gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); if (scp.SCp.Status == S_OK) #endif { 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 *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = paddr; 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;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) gdth_do_req(scp, &gdtcmd, cmnd, 30); if (scp->sr_command->SCp.Status == S_OK) #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status == S_OK) #else gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); if (scp.SCp.Status == S_OK) #endif { size = sprintf(buffer+len, " Grown Defects:\t%d\n", pdef->sddc_cnt); len += size; pos = begin + len; } } if (pos < offset) { len = 0; begin = pos; } if (pos > offset + length) goto stop_output; } } gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); if (!flag) { size = sprintf(buffer+len, "\n --\n"); len += size; pos = begin + len; } /* 3. about logical drives */ size = sprintf(buffer+len,"\nLogical Drives:"); len += size; pos = begin + len; flag = FALSE; buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < MAX_LDRIVES; ++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 *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = paddr; gdtcmd.u.ioctl.param_size = sizeof(gdth_cdrinfo_str); gdtcmd.u.ioctl.subfunc = CACHE_DRV_INFO; gdtcmd.u.ioctl.channel = drv_no;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) gdth_do_req(scp, &gdtcmd, cmnd, 30); if (scp->sr_command->SCp.Status != S_OK) #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status != S_OK)#else gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); if (scp.SCp.Status != S_OK)#endif { 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; if (pos < offset) { len = 0; begin = pos; } if (pos > offset + length) goto stop_output; } 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; if (pos < offset) { len = 0; begin = pos; } if (pos > offset + length) goto stop_output; } gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); if (!flag) { size = sprintf(buffer+len, "\n --\n"); len += size; pos = begin + len; } /* 4. about array drives */ size = sprintf(buffer+len,"\nArray Drives:"); len += size; pos = begin + len; flag = FALSE; buf = gdth_ioctl_alloc(hanum, GDTH_SCRATCH, FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < MAX_LDRIVES; ++i) { if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master)) continue; /* 4.a array drive info */ TRACE2(("array_info() drive no %d\n",i)); pai = (gdth_arrayinf_str *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = paddr; gdtcmd.u.ioctl.param_size = sizeof(gdth_arrayinf_str); gdtcmd.u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN; gdtcmd.u.ioctl.channel = i;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) gdth_do_req(scp, &gdtcmd, cmnd, 30); if (scp->sr_command->SCp.Status == S_OK) #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) gdth_do_cmd(scp, &gdtcmd, cmnd, 30); if (scp->SCp.Status == S_OK) #else gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); if (scp.SCp.Status == S_OK) #endif { if (pai->ai_state == 0) strcpy(hrec, "idle"); else if (pai->ai_state == 2) strcpy(hrec, "build"); else if (pai->ai_state == 4) strcpy(hrec, "ready"); else if (pai->ai_state == 6) strcpy(hrec, "fail"); else if (pai->ai_state == 8 || pai->ai_state == 10) strcpy(hrec, "rebuild"); else strcpy(hrec, "error"); if (pai->ai_ext_state & 0x10) strcat(hrec, "/expand"); else if (pai->ai_ext_state & 0x1) strcat(hrec, "/patch"); size = sprintf(buffer+len, "\n Number: \t%-2d \tStatus: \t%s\n", i,hrec); len += size; pos = begin + len; flag = TRUE; if (pai->ai_type == 0) strcpy(hrec, "RAID-0"); else if (pai->ai_type == 4) strcpy(hrec, "RAID-4"); else if (pai->ai_type == 5) strcpy(hrec, "RAID-5"); else strcpy(hrec, "RAID-10"); size = sprintf(buffer+len, " Capacity [MB]:\t%-6d \tType: \t%s\n", pai->ai_size/(1024*1024/pai->ai_secsize), hrec); len += size; pos = begin + len; if (pos < offset) { len = 0; begin = pos; } if (pos > offset + length) goto stop_output; } } gdth_ioctl_free(hanum, GDTH_SCRATCH, buf, paddr); if (!flag) { size = sprintf(buffer+len, "\n --\n"); len += size; pos = begin + len; } /* 5. about host drives */ size = sprintf(buffer+len,"\nHost Drives:"); len += size; pos = begin + len; flag = FALSE; buf = gdth_ioctl_alloc(hanum, sizeof(gdth_hget_str), FALSE, &paddr); if (!buf) goto stop_output; for (i = 0; i < MAX_LDRIVES; ++i) { if (!ha->hdr[i].is_logdrv || (ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master)) continue; /* 5.a get host drive list */ TRACE2(("host_get() drv_no %d\n",i)); phg = (gdth_hget_str *)buf; gdtcmd.Service = CACHESERVICE; gdtcmd.OpCode = GDT_IOCTL; gdtcmd.u.ioctl.p_param = paddr; gdtcmd.u.ioctl.param_size = sizeof(gdth_hget_str); gdtcmd.u.ioctl.subfunc = HOST_GET | LA_CTRL_PATTERN; gdtcmd.u.ioctl.channel = i; phg->entries = MAX_HDRIVES; phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?