iowait is basically The average time (in milliseconds) for I/O requests issued to the device to be served.
This includes the time spent by the requests in queue and the time spent servicing them.
Measured on a per io basis from the front of the io scheduler until io is done. It covers the time that is taken through scheduler, driver, controller, transport (for san), and storage needed to complete each io. It is the average time, in milliseconds, for I/O requests completed by storage and includes the time spent by the requests in the scheduler queue and time spent by storage servicing them.
There are multiple phases of an IO while it is being transferred. After application sends an IO, a request is allocated for it, when the request is granted kernel sees whether it can merge the io to any existing request queue. Time spent in the request queue adds to the total service time. Then after merging is done, the io is submitted to storage. If the storage is under pressure or can't cope with the IO numbers, then our IO has to wait to be serviced by the storage also. So, there are essentially two waiting phases which iostat measure up.
The proc file /proc/diskstats is the one that it refers for the purpose.