In add_stripe_bio() there is some code as shown below:
if (forwrite) {
/* check if page is covered */
sector_t sector = sh->dev[dd_idx].sector;
for (bi=sh->dev[dd_idx].towrite;
sector < sh->dev[dd_idx].sector + STRIPE_SECTORS &&
bi && bi->bi_sector <= sector;
bi = r5_next_bio(bi, sh->dev[dd_idx].sector)) {
if (bi->bi_sector + (bi->bi_size>>9) >= sector)
sector = bi->bi_sector + (bi->bi_size>>9);
}
if (sector >= sh->dev[dd_idx].sector + STRIPE_SECTORS)
set_bit(R5_OVERWRITE, &sh->dev[dd_idx].flags);
}
Say I have 3 bio(s) that is:
1. bi->bi_sector = 654618968;
bi->bi_size = 2*512;
2. bi->bi_sector = 654618970;
bi->bi_size = 1*512;
3. bi->bi_sector = 654618973;
bi->bi_size = 5*512;
I expected that the third bio could cause R5_OVERWRITE be set. But I didn't see this bit got set. What does this code really do? I thought it checks if the single 4K page can cover the bio chains targeted at this stripe cache(4K).
Thanks
M.