Skip to contentSkip to conversation

Decrease number of pointer derefs in multipath.c

PATCH In review Jesper Juhl 2 participants 2 messages Dec 8, 2005 – Dec 9, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Decrease number of pointer derefs in multipath.c

Hi,

Here's a small patch to decrease the number of pointer derefs in drivers/md/multipath.c

Benefits of the patch:
- Fewer pointer dereferences should make the code slightly faster.
- Size of generated code is smaller
- improved readability

Please consider applying.

---

 drivers/md/multipath.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

orig:
text data bss dec hex filename
3747 68 0 3815 ee7 drivers/md/multipath.o

patched:
text data bss dec hex filename
3736 68 0 3804 edc drivers/md/multipath.o

drivers/md/multipath.c +4 -3
@@ -308,6 +308,7 @@ static void print_multipath_conf (multip
 static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
 {
 	multipath_conf_t *conf = mddev->private;
+	struct request_queue *q;
 	int found = 0;
 	int path;
 	struct multipath_info *p;
@@ -316,8 +317,8 @@ static int multipath_add_disk(mddev_t *m
 
 	for (path=0; path<mddev->raid_disks; path++) 
 		if ((p=conf->multipaths+path)->rdev == NULL) {
-			blk_queue_stack_limits(mddev->queue,
-					       rdev->bdev->bd_disk->queue);
+			q = rdev->bdev->bd_disk->queue;
+			blk_queue_stack_limits(mddev->queue, q);
 
 		/* as we don't honour merge_bvec_fn, we must never risk
 		 * violating it, so limit ->max_sector to one PAGE, as
@@ -325,7 +326,7 @@ static int multipath_add_disk(mddev_t *m
 		 * (Note: it is very unlikely that a device with
 		 * merge_bvec_fn will be involved in multipath.)
 		 */
-			if (rdev->bdev->bd_disk->queue->merge_bvec_fn &&
+			if (q->merge_bvec_fn &&
 			    mddev->queue->max_sectors > (PAGE_SIZE>>9))
 				blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
 
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jesper Juhl

Hi,

Here's a small patch to decrease the number of pointer derefs in drivers/md/multipath.c

Benefits of the patch:
- Fewer pointer dereferences should make the code slightly faster.
- Size of generated code is smaller
- improved readability

Quoted 4 lines

Please consider applying.

looks good to me.

Ingo