Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 209172
b: refs/heads/master
c: c96053b
h: refs/heads/master
v: v3
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Aug 12, 2010
1 parent af4cd78 commit 8b60a5d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 65988525abde0b0a5833c4e20f32967184a5dcf0
refs/heads/master: c96053b767d494d7c30e2be68097ac9defa9403f
23 changes: 18 additions & 5 deletions trunk/drivers/md/dm-stripe.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct stripe {

struct stripe_c {
uint32_t stripes;
int stripes_shift;
sector_t stripes_mask;

/* The size of this target / num. stripes */
sector_t stripe_width;
Expand Down Expand Up @@ -162,16 +164,21 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)

/* Set pointer to dm target; used in trigger_event */
sc->ti = ti;

sc->stripes = stripes;
sc->stripe_width = width;

if (stripes & (stripes - 1))
sc->stripes_shift = -1;
else {
sc->stripes_shift = ffs(stripes) - 1;
sc->stripes_mask = ((sector_t) stripes) - 1;
}

ti->split_io = chunk_size;
ti->num_flush_requests = stripes;

sc->chunk_shift = ffs(chunk_size) - 1;
sc->chunk_mask = ((sector_t) chunk_size) - 1;
for (sc->chunk_shift = 0; chunk_size; sc->chunk_shift++)
chunk_size >>= 1;
sc->chunk_shift--;

/*
* Get the stripe destinations.
Expand Down Expand Up @@ -213,7 +220,13 @@ static void stripe_map_sector(struct stripe_c *sc, sector_t sector,
sector_t offset = dm_target_offset(sc->ti, sector);
sector_t chunk = offset >> sc->chunk_shift;

*stripe = sector_div(chunk, sc->stripes);
if (sc->stripes_shift < 0)
*stripe = sector_div(chunk, sc->stripes);
else {
*stripe = chunk & sc->stripes_mask;
chunk >>= sc->stripes_shift;
}

*result = (chunk << sc->chunk_shift) | (offset & sc->chunk_mask);
}

Expand Down

0 comments on commit 8b60a5d

Please sign in to comment.