md: comment add_stripe_bio
PATCH 1/1 md: comment add_stripe_bio
From: Dan Williams <[email protected]>
Document the overloading of struct bio fields.
Signed-off-by Dan Williams <[email protected]>
---
[ drop this if you think it is too much commenting/unnecessary, but I figured I would leave some
breadcrumbs for the next guy. ]
drivers/md/raid5.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-)
drivers/md/raid5.c +22 -4
@@ -1231,10 +1231,13 @@ static void compute_block_2(struct stripe_head *sh, int dd_idx1, int dd_idx2) -/* -* Each stripe/dev can have one or more bion attached. -* toread/towrite point to the first in a chain. -* The bi_next chain must be in order. +/* add_stripe_bio - attach a bio to the toread/towrite list for an +* rdev in the given stripe. This routine assumes that the toread/towrite +* lists are in submission order +* @sh: stripe targeted by bi->bi_sector +* @bi: bio to add (this routines assumes ownership of the bi->bi_next field) +* @dd_idx: data disk determined from the logical sector +* @forwrite: read/write flag */ static int add_stripe_bio (struct stripe_head *sh,struct bio *bi,int dd_idx,int forwrite) {
@@ -1249,12 +1252,18 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, inspin_lock (&sh->lock);spin_lock_irq (&conf->device_lock); + +/* pick the list to manipulate */ if (forwrite) { bip = &sh->dev[dd_idx].towrite;if (*bip ==NULL && sh->dev[dd_idx].written ==NULL ) firstwrite =1 ; }else bip = &sh->dev[dd_idx].toread; + +/* scroll through the list to see if this bio overlaps with a +* pending request +*/ while (*bip && (*bip)->bi_sector < bi->bi_sector) {if ((*bip)->bi_sector + ((*bip)->bi_size >>9 ) > bi->bi_sector) goto overlap;
@@ -1263,10 +1272,19 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, inif (*bip && (*bip)->bi_sector < bi->bi_sector + ((bi->bi_size)>>9 )) goto overlap; +/* add this bio into the chain and make sure we are not dropping +* a link that was previously established +*/ BUG_ON (*bip && bi->bi_next && (*bip) != bi->bi_next);if (*bip) bi->bi_next = *bip; + +/* attach the bio to the end of the list, if this is the first bio +* added then we are directly manipulating toread/towrite +*/ *bip = bi; + +/* keep count of the number of stripes that this bio touches */ bi->bi_phys_segments ++;spin_unlock_irq (&conf->device_lock);spin_unlock (&sh->lock);