Neil,thanks for you help.Your explanation is helpful really. I went through the code of raid0_make_request again this evening, and I still had some questions. 1\ block = bio->bi_sector >> 1,it's the device offset in kilotytes. so why do we use block substract zone->zone_offset? The zone->zone_offset is the zone offset relative the mddev in sectors. 2\ the codes below: x = block >> chunksize_bits; tmp_dev = zone->dev[sector_div(x, zone->nb_dev)]; actually, we get the underlying device by 'sector_div(x, zone->nb_dev)'.The var x is the chunk nr relative to the start of the mddev in my opinion.But not all of the zone->nb_dev is the same, so wo cann't get the right rdev by 'sector_div(x, zone->nb_dev)', I think. Why?Could you explain them to me? Thanks! Regards. YangLiu 2006/6/16, Neil Brown <neilb@xxxxxxx>:
On Friday June 16, liudows2@xxxxxxxxx wrote: > > > Thanks a lot.I went through the code again following your guide.But I > still can't understand how the bio->bi_sector and bio->bi_dev are > computed.I don't know what the var 'block' stands for. > Could you explain them to me ? 'block' is simply "bi_sector/2" - the device offset in kilobytes rather than in sectors. raid0 supports having different devices of different sizes. The array is divided into 'zones'. The first zone has all devices, and extends as far as the smallest devices. The last zone extends to the end of the largest device, and may have only one, or several devices in it. The may be other zones depending on how many different sizes of device there are. The first thing that happens is the correct zone is found by lookng in the hash_table. Then we subtract the zone offset, divide by the chunk size, and then divide by the number of devices in that zone. The remainder of this last division tells us which device to use. Then we mutliply back out to find the offset in that device. I know that it rather brief, but I hope it helps. NeilBrown
- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html