FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 07-28-2010, 03:21 PM
Mike Snitzer
 
Default dm stripe: optimize sector division

From: Mikulas Patocka <mpatocka@redhat.com>

Optimize sector division --- if the number of stripes is a power of two,
we don't have to do expensive division and can do shift and mask instead.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-stripe.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

v2: minor code cleanup in stripe_map_sector

Index: linux-2.6-block/drivers/md/dm-stripe.c
================================================== =================
--- linux-2.6-block.orig/drivers/md/dm-stripe.c
+++ linux-2.6-block/drivers/md/dm-stripe.c
@@ -25,6 +25,7 @@ struct stripe {

struct stripe_c {
uint32_t stripes;
+ int stripes_shift;

/* The size of this target / num. stripes */
sector_t stripe_width;
@@ -164,6 +165,10 @@ static int stripe_ctr(struct dm_target *
sc->ti = ti;

sc->stripes = stripes;
+ if (!(stripes & (stripes - 1)))
+ sc->stripes_shift = ffs(stripes) - 1;
+ else
+ sc->stripes_shift = -1;
sc->stripe_width = width;
ti->split_io = chunk_size;
ti->num_flush_requests = stripes;
@@ -213,7 +218,12 @@ static void stripe_map_sector(struct str
{
sector_t offset = sector - sc->ti->begin;
sector_t chunk = offset >> sc->chunk_shift;
- *stripe = sector_div(chunk, sc->stripes);
+
+ if (likely(sc->stripes_shift >= 0)) {
+ *stripe = chunk & ((1 << sc->stripes_shift) - 1);
+ chunk >>= sc->stripes_shift;
+ } else
+ *stripe = sector_div(chunk, sc->stripes);
*result = (chunk << sc->chunk_shift) | (offset & sc->chunk_mask);
}


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 

Thread Tools




All times are GMT. The time now is 05:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org