scsi interview questions
Top scsi frequently asked interview questions
How to get the unique number (serial number/ID) for Processor (CPU), SCSI, Display, and IDE using C++ program other than WMI and asm code?
Source: (StackOverflow)
I am trying to debug a situation where the SSD on my hardware is not being detected by the right device driver. The device driver that should own the SSD's is a software RAID driver (megasr) that will automically configure 2 SSD's in mirroring mode. I am pretty sure that the megasr driver is not detecting/owning the SSD's, but I am unsure which driver actually detects them.
Is there a way in Linux that I can determine which device driver owns a particular disk inside the /dev directory.
So I would like to determine which driver owns the device /dev/sda, for example.
The OS is RHEL 6.x.
Many thanks.
Source: (StackOverflow)
Which case would be considered correct?
Doing reads with a Read 16 command no matter if the LBA's are 32 or 64 bit.
If the max LBA is 32 bit then do a Read 10 command and if the max LBA is 64 bit then do a Read 16 command.
What are the pros and cons of each choice?
I know for a Read Capacity command it is correct to run a 10 and if it returns FFFFFFFFh then run a 16. Why is this the case? The Read Capacity 16 command works for both cases and avoids even needing the Read Capacity 10 at all.
Source: (StackOverflow)
In a Linux VM (Vmware workstation or similar), how can I simulate a failure on a previously working disc?
I have a situation happening in production where a disc fails (probably a controller, cable or firmware problem). Obviously this is not predictable or reproducible, I want to test my monitoring to ensure that it alerts correctly.
I'd ideally like to be able to simulate a situation where it fails writes but succeeds reads, as well as a complete failure, i.e. the scsi interface reports errors back to the kernel.
Source: (StackOverflow)
Does iSCSI introduce any layers (other than the TCP-headers themselves) on top of the SCSI packet? Are there any reference manuals for iSCSI other than the RFC itself? I need this information for controlling a RF-receiver over a Paralan iSCSI-to-SCSI-converter.
Source: (StackOverflow)
For best performance, is it better to use a virtual IDE HDD or virtual SCSI HDD?
If, SCSI, does it matter whether you use an BusLogic or LSILogic?
Source: (StackOverflow)
We use the /proc and /sys file systems in Linux to discover various types of system configuration information. Typically, we spelunk around through the different files and directories until we find the information that we need.
I'm wondering if anyone knows of a definitive resource that documents how one would navigate through the /proc and /sys file systems to locate specific information. We primarily grab USB, PCI and SCSI information from various files in these file systems.
Thanks,
Source: (StackOverflow)
I try to issue a scsi read(10) and write(10) to a SSD. I use this example code as a reference/basic code.
This is my scsi read:
#define READ_REPLY_LEN 32
#define READ_CMDLEN 10
void scsi_read()
{
unsigned char Readbuffer[ SCSI_OFF + READ_REPLY_LEN ];
unsigned char cmdblk [ READ_CMDLEN ] =
{ 0x28, /* command */
0, /* lun/reserved */
0, /* lba */
0, /* lba */
0, /* lba */
0, /* lba */
0, /* reserved */
0, /* transfer length */
READ_REPLY_LEN, /* transfer length */
0 };/* reserved/flag/link */
memset(Readbuffer,0,sizeof(Readbuffer));
memcpy( cmd + SCSI_OFF, cmdblk, sizeof(cmdblk) );
/*
* +------------------+
* | struct sg_header | <- cmd
* +------------------+
* | copy of cmdblk | <- cmd + SCSI_OFF
* +------------------+
*/
if (handle_scsi_cmd(sizeof(cmdblk), 0, cmd,
sizeof(Readbuffer) - SCSI_OFF, Readbuffer )) {
fprintf( stderr, "read failed\n" );
exit(2);
}
hex_dump(Readbuffer,sizeof(Readbuffer));
}
And this is my scsi write:
void scsi_write ( void )
{
unsigned char Writebuffer[SCSI_OFF];
unsigned char cmdblk [] =
{ 0x2A, /* 0: command */
0, /* 1: lun/reserved */
0, /* 2: LBA */
0, /* 3: LBA */
0, /* 4: LBA */
0, /* 5: LBA */
0, /* 6: reserved */
0, /* 7: transfer length */
0, /* 8: transfer length */
0 };/* 9: control */
memset(Writebuffer,0,sizeof(Writebuffer));
memcpy( cmd + SCSI_OFF, cmdblk, sizeof(cmdblk) );
cmd[SCSI_OFF+sizeof(cmdblk)+0] = 'A';
cmd[SCSI_OFF+sizeof(cmdblk)+1] = 'b';
cmd[SCSI_OFF+sizeof(cmdblk)+2] = 'c';
cmd[SCSI_OFF+sizeof(cmdblk)+3] = 'd';
cmd[SCSI_OFF+sizeof(cmdblk)+4] = 'e';
cmd[SCSI_OFF+sizeof(cmdblk)+5] = 'f';
cmd[SCSI_OFF+sizeof(cmdblk)+6] = 'g';
cmd[SCSI_OFF+sizeof(cmdblk)+7] = 0;
/*
* +------------------+
* | struct sg_header | <- cmd
* +------------------+
* | copy of cmdblk | <- cmd + SCSI_OFF
* +------------------+
* | data to write |
* +------------------+
*/
if (handle_scsi_cmd(sizeof(cmdblk), 8, cmd,
sizeof(Writebuffer) - SCSI_OFF, Writebuffer )) {
fprintf( stderr, "write failed\n" );
exit(2);
}
}
In the following example I do
- scsi read
- scsi write
- scsi read
And I print the hexdumps of the data which is written (scsi write) and what is read (scsi read)
Read(10)
[0000] 00 00 00 44 00 00 00 44 00 00 00 00 00 00 00 00 ...D...D ........
[0010] 00 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
[0020] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
[0030] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
[0040] 00 00 00 00 ....
Write(10):
[0000] 00 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 ........ ........
[0010] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
[0020] 00 00 00 00 2A 00 00 00 00 00 00 00 00 00 41 62 ........ ......Ab
[0030] 63 64 65 66 67 00 cdefg.
Read(10):
[0000] 00 00 00 44 00 00 00 44 00 00 00 00 00 00 00 00 ...D...D ........
[0010] 04 00 20 00 70 00 02 00 00 00 00 0A 00 00 00 00 ....p... ........
[0020] 04 00 00 00 41 62 63 64 65 66 67 00 00 00 00 00 ....Abcd efg.....
[0030] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
[0040] 00 00 00 00 ....
fter running the three commands again, I should read Abcdefg
with the first read. Right? But running them again changes nothing. You could now assume, that the memory I use has still the data from previous funcions, but I get the same result even though I run memset(Readbuff,0,sizeof(Readbuff))
before the sys_read()
happens.
I assumed, that the LBA I try to write is maybe forbidden to write, and I read the cache. But interating over LBA Adresses from 0x00-0xFF changes nothing - That means, I read the same data (Abcdefg
).
Do you know an example implementation of scsi read or writes with the scsi generic interface?
Source: (StackOverflow)
I am implementing USB as a host using OHCI. And using SCSI to read a mass storage device.
All my control transfers run successfully. I have done all the initialization using Control Transfers however I am facing problem with Data Transfers.
I am having troubles in successfully implementing the READ command in SCSI, be it READ(6), READ(10), etc.
The following is a snapshot of the Command Block Wrapper(CBW)-
The highlighted portion is the SCSI command.
As You can see I have requested 512 bytes- which is the size of 1 LBA for my mass storage device.
The following is what comes in the 512 byte buffer from the device-
FYI- The buffer was initialized to 0xff
These 512 bytes are not present anywhere on my mass storage device. I opened the mass storage device on HXD and checked the bytes to see that the block I received doesnt exist on my mass storage!
And the Command Status Wrapper (CSW) I got was as follows-
Last byte in CSW is 0x01 which means the command failed.
I have 3 questions
1- What could be the reason why this READ is failing? Am I supposed to run any other SCSI command before this for any reason?
2- I request for 512 bytes and I even get that but the bytes 8-11 in CSW which show residue still show a certain value a which happens to be greater than 512 (as this is little endian format). How is this possible?
3- What could the 512 bytes I receive from the device possibly be?
Any helps with this I have been stuck here for a looong time now and I dont have a USB analyzer.
Pseudo code for Data Transfers-
Set the Endpoint Descriptor (ED) 1 (Indication the OUT Endpoint)
Set the Transfer Descriptor (TD) 1 (Send SCSI command)
Set the BulkHead ED to ED 1
Start the descriptor processing
and then
stop it
Set the Endpoint Descriptor (ED) 1 (Indication the IN Endpoint)
Set the Transfer Descriptor (TD) 1 (Read the 512 bytes)
Set the Transfer Descriptor (TD) 2 (Read the 13 CSW bytes)
Set the BulkHead ED to ED 1
Start the descriptor processing
and then
stop it
Source: (StackOverflow)
We have expend existing LUN size on EMC Storage and now i want to re-scan on Host side but i don't know how to figure out SCSI ID of that specific LUN. I am new to storage.. This is what i am doing but don't know whether it is a right way or not
Pseudo name=emcpowerj
CLARiiON ID=APM00112500570 [Oracle_Cluster]
Logical device ID=200601602E002900B6BCA114C9F8E011 [LUN01]
state=alive; policy=CLAROpt; priority=0; queued-IOs=0;
Owner: default=SP A, current=SP A Array failover mode: 1
==============================================================================
--------------- Host --------------- - Stor - -- I/O Path -- -- Stats ---
### HW Path I/O Paths Interf. Mode State Q-IOs Errors
==============================================================================
2 qla2xxx sdaj SP A1 active alive 0 1
2 qla2xxx sdaw SP B1 active alive 0 4
1 qla2xxx sdj SP A0 active alive 0 1
1 qla2xxx sdw SP B0 active alive 0 4
Here i am running find command on sdX device to find out SCSI ID to i can do echo 1 > /sys/bus/scsi/drivers/X:X:X:X/rescan
to do re-scan LUN
$ find /sys/devices -name "*block*" | grep -e "sdaj" -e "sdaw" -e "sdj" -e "sdw"
/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.1/host2/rport-2:0-1/target2:0:1/**2:0:1:8**/block:sdaw
/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.1/host2/rport-2:0-0/target2:0:0/**2:0:0:8**/block:sdaj
/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host1/rport-1:0-1/target1:0:1/**1:0:1:8**/block:sdw
/sys/devices/pci0000:00/0000:00:09.0/0000:05:00.0/host1/rport-1:0-0/target1:0:0/**1:0:0:8**/block:sdj
or there is a alternative or other way to scan LUN?
Source: (StackOverflow)
I'm looking at the SBC-3 item 5.15 (READ CAPACITY (10) command). The description of the PMI bit (bit 0 of byte 8 in the CDB) is copied below:
"A PMI bit set to one specifies that the device server return information on the last logical block after that specified in the LOGICAL BLOCK ADDRESS field before a substantial vendor specific delay in data transfer may
be encountered."
My questions:
- If both PMI bit and LOGICAL BLOCK ADDRESS (bytes 2-5 in the CDB) aren't zero, should I (as a target) still report the last LBA on my disk?
- If not the above, that what should be reported in this case?
- What should I do with the LOGICAL BLOCK ADDRESS (bytes 2-5) value when the PMI bit is set?
(I know, that the PMI bit became obsolete in the SBC-4, but I still need to implement this functionality according to the current standard)
Source: (StackOverflow)
i need to get a list or any other enumerable class with info about any connected SCSI-disks, with info just like /proc/scsi/sg/devices
Please help me and thanks in advance
Source: (StackOverflow)
Is it possible for multiple computers to connect to the same target at the same time, using the same initiator IQN?
Thank you.
Source: (StackOverflow)
I've got an old HDD with which I planned to fiddle around a little. First thing I'm trying to do is spinning the motor with different speeds.
Questions are:
- Is there a general way to do this or does it depend on the HDD model?
- Where do I find a list of commands, that I can send to the HDD controller to control the speed of the motor?
I actually found a function, that apparently spins down the motor, here it is:
/* spin-down a disk */
static void spindown_disk(const char *name)
{
struct sg_io_hdr io_hdr;
unsigned char sense_buf[255];
char dev_name[100];
int fd;
dprintf("spindown: %s\n", name);
/* fabricate SCSI IO request */
memset(&io_hdr, 0x00, sizeof(io_hdr));
io_hdr.interface_id = 'S';
io_hdr.dxfer_direction = SG_DXFER_NONE;
/* SCSI stop unit command */
io_hdr.cmdp = (unsigned char *) "\x1b\x00\x00\x00\x00\x00";
io_hdr.cmd_len = 6;
io_hdr.sbp = sense_buf;
io_hdr.mx_sb_len = (unsigned char) sizeof(sense_buf);
/* open disk device (kernel 2.4 will probably need "sg" names here) */
snprintf(dev_name, sizeof(dev_name), "/dev/%s", name);
if ((fd = open(dev_name, O_RDONLY)) < 0) {
perror(dev_name);
return;
}
/* execute SCSI request */
if (ioctl(fd, SG_IO, &io_hdr) < 0) {
char buf[100];
snprintf(buf, sizeof(buf), "ioctl on %s:", name);
perror(buf);
} else if (io_hdr.masked_status != 0) {
fprintf(stderr, "error: SCSI command failed with status 0x%02x\n",
io_hdr.masked_status);
if (io_hdr.masked_status == CHECK_CONDITION) {
phex(sense_buf, io_hdr.sb_len_wr, "sense buffer:\n");
}
}
close(fd);
}
Though I don't really understand where the actual command is sent to the controller, nor do I know how to control the speed, I don't see any rpm specifications.
Source: (StackOverflow)