* HDD cont. HDDs are complex inside (~1M LoC) how to use it easily standard protocols to access storage devices - ATA, SATA, SCSI, USB, FW, Protocols: 1. reading 2. writing 3. control commands how much to access? - recall latencies are high - get too little data -- waste of latency - get too much: no room to hold it in RAM Every computer h/w device has a native size unit, defined and hardcoded by the manufacturer: CPU: - word length: used to be 32b now 64b - cache line: a unit of min size inside CPU caches (power of 2, usually 100s of bytes) MEM: - a page size (4KB), actually determined by CPU+ mem arch. - Intel Pentium (~2000): configurable pages sizes (4K, 8K, 16K) Side track: - when there was only one mem bus, lots of workloads became mem bound - Pentium solution: bigger page size - AMD's solution: each CPU has its own "nearline" memory 2 mem busses: a faster one closer to a specific CPU, and a slower one when a CPU needs to access mem of another. - Intel's counter solution: one CPU w/ multiple mem busses (e.g., 3) which is why total ram sizes had to be a multiple of 3 Net: - Maximum Transmission Unit (MTU) in Ethernet is 1500b - configurable, e.g., in 10/100GB you can have "jumbo packets" up to 9kb Storage: - Sector size of 512B (c. 1960s) - around c. 2010, storage sectors grew to 4Kb matches CPU page size, better for caching - for many years (still), devices can address both 512b and 4kb sectors. - small sectors mean more m-d that have to be managed - OS s/w offered backwards compatibility b/t 512b and 4kb sectors - storage vendors also offered backwards compatibility disks can be natively 4k or 512b, with legacy commands allowed - less efficient: to read an old 512b, internally disk had to retrieve 4k - worse is writing 512b into a 4kb sector OS sends a 512b to write disk has to retrieve encompassing 4kb sector from media store it in disk cache (ram) modify the 4kb in disk ram write back entire 4kb called a Read-Modify-Write (RMW) pattern (bad performance) How to address sectors? 1. old days: OS driver provided "CHS" values - C: cylinder, concentric circles around the platter - H: head, which specific head to access - S: sector, region on the cylinder, for a specific head - CHS was determined too complex to deal with, requires knowing a lot about internal geometry of the HDD 2. disk vendors assign a number (ID) to each sector in some order - could be from outer to inner cylinder, top/bottom platter order - could be from one head or another - called a Logical Block Address (LBA) number: 1, 2, 3, ..., N Now OS s/w just has to ask the disk to r/w LBA # X - disk will figure out where internally that LBA is - simplified addressing Often, LBAs were assigned from outer cylinders, so performance was better for low-numbered LBAs. Recall that rotational latency is faster than head seek, and outer cylinders have more sectors. Some times, with wear and tear, some LBAs will go bad: can't really read them any more, or writing doesn't work (written data doesn't persist). If the disk declares an LBA as "bad", it'll use a reserve room of unused LBAs, and would "remap" in the bad LBA, to one of the unused reserve sectors. Disks maintain m-d "remap table". Table has limited room. Remap table is not exposed to the "host" OS, but you can tell how many LBAs got mapped and the size of the table. When reading sequential data with remapped blocks, have to take a detour to access the remapped block: hurts performance. When remap table fills up too much, no more bad blocks can be remapped, and performance devolves into "random" access (bad for disks). If table fills up, the disk will declare itself as "bad" and stop functioning. Control commands 1. S.M.A.R.T: a set of commands to get status info on a disk. - make, model, size, mfg date - number of reads/writes that took place - remap table size and fullness disks can die in first ~3mo of operation ("infant mortality"), due to mfg defects, transportation, high loads, etc. enterprise disks or disks sold by storage vendors, often run a "burn in" period to get passed this initial failure phase. They also predict failures and will send warning or even replacements. During manufacturing, vendors determine quality of h/w (magnetics etc.) and mark disks as consumer (1-3 yrs warranty) vs. enterprise (pricier, 5 yr warranty). * Next time SAS/SATA/SCSI Control codes Q: scrubbing Q: fragmentation? Q: secure deletion