Changes between Version 1 and Version 2 of Ticket #252


Ignore:
Timestamp:
Dec 16, 2012, 5:27:03 PM (12 years ago)
Author:
Alex Samorukov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #252 – Description

    v1 v2  
    1 I decided to add autoscan functionality for drives on MegaSAS controllers. Main motivation for this was that devices on such controllers having random numbers, from 0 to ~250 and it is very annoying to write smartd configuration (i used shell + MegaCli in the past). There is no ioctl documentation provided, so i did patch based on MegaCli tool behaviour (with strace and LD_PRELAOD for IOCTL) and FreeBSD driver sources which contain similar code. What this patch is doing:
     1I decided to add autoscan functionality for drives on MegaSAS controllers. Main motivation for this was that devices on such controllers having random numbers, from 0 to ~250 and it is very annoying to write smartd configuration (i used shell + MegaCli in the past). There is no ioctl documentation provided, so i did patch based on MegaCli tool behavior (with strace and LD_PRELAOD for IOCTL) and FreeBSD driver sources which contain similar code. What this patch is doing:
    22
    3 1) In autoscan mode, if megaraid_sas_ioctl is found in /proc/devices it is trying to identify SCSI host number with megasas controllers using sysfs (/sys/class/scsi_host/hostN/proc_name). If sysfs is not mounted it scans first 16 buses. I believe that native tool do the same.
    4 2) If controller is found i am getting device list using driver ioctl and adding them to device list
     3 * In autoscan mode, if megaraid_sas_ioctl is found in /proc/devices it is trying to identify SCSI host number with megasas controllers using sysfs (/sys/class/scsi_host/hostN/proc_name). If sysfs is not mounted it scans first 16 buses. I believe that native tool do the same.
     4 * If controller is found i am getting device list using driver ioctl and adding them to device list
    55
    66Code changes:
    7 1) megaraid.h updated to include constant/structures to get drive list
    8 2) set_fd added to linux_smart_device. I need this to override is_open check in megaraid.
    9 3) -d megaraid allows to specify devices in pseudo /dev/bus/N format. We can`t easy get drive name from the bus number, and also it is possible that drive name is not exists at all (unconfigured RAID).
    10 4) Added private functions get_dev_megasas, megasas_dcmd_cmd and megasas_pd_get_list to the linux_smart_interface.
    11 5) I disabled "MegaRAID SAT layer is reportedly buggy" error. Everything was fixed after chk_cond check was added. I am unable to reproduce problem with different hardware.
    12 6) I added set_info().dev_type = strprintf("megaraid,%d", tgt) to set device number in type. Without it --scan will show just -"d megaraid" devices.  Not sure if this is correct.
     7 * megaraid.h updated to include constant/structures to get drive list
     8 * set_fd added to linux_smart_device. I need this to override is_open check in megaraid.
     9 * -d megaraid allows to specify devices in pseudo /dev/bus/N format. We can`t easy get drive name from the bus number, and also it is possible that drive name is not exists at all (unconfigured RAID).
     10 * Added private functions get_dev_megasas, megasas_dcmd_cmd and megasas_pd_get_list to the linux_smart_interface.
     11 * I disabled "MegaRAID SAT layer is reportedly buggy" error. Everything was fixed after chk_cond check was added. I am unable to reproduce problem with different hardware.
     12 * I added set_info().dev_type = strprintf("megaraid,%d", tgt) to set device number in type. Without it --scan will show just -"d megaraid" devices.  Not sure if this is correct.
     13 * scsiata.cpp - set device type as sat+<oldname> if  scsidev->get_dev_type() is not "scsi".
     14
     15Example:
     16{{{
     17[root@p2986890 smartmontools]# ./smartctl --scan
     18/dev/sda -d scsi # /dev/sda, SCSI device
     19/dev/bus/0 -d megaraid,5 # /dev/bus/0 [megaraid_disk_05], SCSI device
     20/dev/bus/0 -d megaraid,7 # /dev/bus/0 [megaraid_disk_07], SCSI device
     21[root@p2986890 smartmontools]# ./smartctl --scan-open
     22# /dev/sda -d scsi # /dev/sda, SCSI device open failed: DELL or MegaRaid controller, please try adding '-d megaraid,N'
     23/dev/bus/0 -d sat+megaraid,5 # /dev/bus/0 [megaraid_disk_05] [SAT], ATA device
     24/dev/bus/0 -d sat+megaraid,7 # /dev/bus/0 [megaraid_disk_07] [SAT], ATA device
     25
     26[root@p2986890 smartmontools]# ./smartd -d
     27smartd 6.1 2012-12-14 r3732M [x86_64-linux-2.6.32-279.14.1.el6.x86_64] (local build)
     28Copyright (C) 2002-12, Bruce Allen, Christian Franke, www.smartmontools.org
     29
     30No configuration file /usr/local/etc/smartd.conf found, scanning devices
     31glob(3) found no matches for pattern /dev/hd[a-t]
     32glob(3) found no matches for pattern /dev/sd[a-c][a-z]
     33Device: /dev/sda, open() failed: DELL or MegaRaid controller, please try adding '-d megaraid,N'
     34Device: /dev/bus/0 [megaraid_disk_05], type changed from 'megaraid,5' to 'sat+megaraid,5'
     35Device: /dev/bus/0 [megaraid_disk_05] [SAT], opened
     36Device: /dev/bus/0 [megaraid_disk_05] [SAT], WDC WD1003FBYX-01Y7B1, S/N:WD-XXXX, WWN:XXXX, FW:01.01V02, 1.00 TB
     37Device: /dev/bus/0 [megaraid_disk_05] [SAT], found in smartd database: Western Digital RE4 Serial ATA
     38Device: /dev/bus/0 [megaraid_disk_05] [SAT], not capable of SMART Health Status check
     39Device: /dev/bus/0 [megaraid_disk_05] [SAT], is SMART capable. Adding to "monitor" list.
     40Device: /dev/bus/0 [megaraid_disk_07], type changed from 'megaraid,7' to 'sat+megaraid,7'
     41Device: /dev/bus/0 [megaraid_disk_07] [SAT], opened
     42Device: /dev/bus/0 [megaraid_disk_07] [SAT], WDC WD1003FBYX-01Y7B1, S/N:WD-XXXX, WWN:XXXX, FW:01.01V02, 1.00 TB
     43Device: /dev/bus/0 [megaraid_disk_07] [SAT], found in smartd database: Western Digital RE4 Serial ATA
     44Device: /dev/bus/0 [megaraid_disk_07] [SAT], not capable of SMART Health Status check
     45Device: /dev/bus/0 [megaraid_disk_07] [SAT], is SMART capable. Adding to "monitor" list.
     46Monitoring 2 ATA and 0 SCSI devices
     47Device: /dev/bus/0 [megaraid_disk_05] [SAT], opened ATA device
     48Device: /dev/bus/0 [megaraid_disk_05] [SAT], previous self-test completed without error
     49Device: /dev/bus/0 [megaraid_disk_07] [SAT], opened ATA device
     50Device: /dev/bus/0 [megaraid_disk_07] [SAT], previous self-test completed without error
     51}}}