All of lore.kernel.org
 help / color / mirror / Atom feed
* a code question on raid5.c
@ 2012-11-15 19:14 Ming Lei
  0 siblings, 0 replies; only message in thread
From: Ming Lei @ 2012-11-15 19:14 UTC (permalink / raw)
  To: linux-raid


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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-11-15 19:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-15 19:14 a code question on raid5.c Ming Lei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.