]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] MD - Embed bio in mp_bh rather than separate allocation.
authorNeil Brown <neilb@cse.unsw.edu.au>
Fri, 19 Jul 2002 02:07:01 +0000 (19:07 -0700)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Fri, 19 Jul 2002 02:07:01 +0000 (19:07 -0700)
Embed bio in mp_bh rather than separate allocation.

multipath currently allocates an mp_bh and a bio for each
request.  With this patch, the bio is made to be part of the
mp_bh so there is only one allocation, and it from a private
pool (the bio was allocated from a shared pool).

Also remove "remaining" and "cmd" from mp_bh which aren't used.
And remove spare (unused) from multipath_private_data.

drivers/md/multipath.c
include/linux/raid/multipath.h

index 3e05cfaa91538bbe2115a4454443aabeca48fcfa..7bc0662a6020944e8351b2fc65477b8b9cae4fc2 100644 (file)
@@ -121,7 +121,6 @@ static void multipath_end_bh_io (struct multipath_bh *mp_bh, int uptodate)
        multipath_conf_t *conf = mddev_to_conf(mp_bh->mddev);
 
        bio_endio(bio, uptodate);
-       bio_put(mp_bh->bio);
        mempool_free(mp_bh, conf->pool);
 }
 
@@ -164,7 +163,6 @@ static int multipath_make_request (request_queue_t *q, struct bio * bio)
 {
        mddev_t *mddev = q->queuedata;
        multipath_conf_t *conf = mddev_to_conf(mddev);
-       struct bio *real_bio;
        struct multipath_bh * mp_bh;
        struct multipath_info *multipath;
 
@@ -172,20 +170,17 @@ static int multipath_make_request (request_queue_t *q, struct bio * bio)
 
        mp_bh->master_bio = bio;
        mp_bh->mddev = mddev;
-       mp_bh->cmd = bio_data_dir(bio);
 
        /*
         * read balancing logic:
         */
        multipath = conf->multipaths + multipath_read_balance(conf);
 
-       real_bio = bio_clone(bio, GFP_NOIO);
-       real_bio->bi_bdev = multipath->bdev;
-       real_bio->bi_rw = bio_data_dir(bio);
-       real_bio->bi_end_io = multipath_end_request;
-       real_bio->bi_private = mp_bh;
-       mp_bh->bio = real_bio;
-       generic_make_request(real_bio);
+       mp_bh->bio = *bio;
+       mp_bh->bio.bi_bdev = multipath->bdev;
+       mp_bh->bio.bi_end_io = multipath_end_request;
+       mp_bh->bio.bi_private = mp_bh;
+       generic_make_request(&mp_bh->bio);
        return 0;
 }
 
@@ -598,7 +593,8 @@ static void multipathd (void *data)
                        printk(KERN_INFO "dirty sb detected, updating.\n");
                        md_update_sb(mddev);
                }
-               bio = mp_bh->bio;
+               bio = &mp_bh->bio;
+               bio->bi_sector = mp_bh->master_bio->bi_sector;
                bdev = bio->bi_bdev;
                
                multipath_map (mddev, &bio->bi_bdev);
index f34b54b8376708d825f8ea20ee42471ae5b251ac..886448c201fc01bc7315c7ca8ed23c23a8b67adc 100644 (file)
@@ -2,6 +2,7 @@
 #define _MULTIPATH_H
 
 #include <linux/raid/md.h>
+#include <linux/bio.h>
 
 struct multipath_info {
        int             number;
@@ -24,7 +25,6 @@ struct multipath_private_data {
        int                     raid_disks;
        int                     working_disks;
        mdk_thread_t            *thread;
-       struct multipath_info   *spare;
        spinlock_t              device_lock;
 
        mempool_t               *pool;
@@ -45,13 +45,9 @@ typedef struct multipath_private_data multipath_conf_t;
  */
 
 struct multipath_bh {
-       atomic_t                remaining; /* 'have we finished' count,
-                                           * used from IRQ handlers
-                                           */
-       int                     cmd;
        mddev_t                 *mddev;
        struct bio              *master_bio;
-       struct bio              *bio;
-       struct multipath_bh     *next_mp; /* next for retry or in free list */
+       struct bio              bio;
+       struct multipath_bh     *next_mp; /* next for retry */
 };
 #endif