]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/md/raid10.c
block: unify flags for struct bio and struct request
[net-next-2.6.git] / drivers / md / raid10.c
index 03724992cdf20ea8ed46aaf2aee29ef845f29c54..62ecb6650fd023ce10c5dc619be058fa480f8d91 100644 (file)
@@ -799,12 +799,12 @@ static int make_request(mddev_t *mddev, struct bio * bio)
        int i;
        int chunk_sects = conf->chunk_mask + 1;
        const int rw = bio_data_dir(bio);
-       const bool do_sync = bio_rw_flagged(bio, BIO_RW_SYNCIO);
+       const bool do_sync = (bio->bi_rw & REQ_SYNC);
        struct bio_list bl;
        unsigned long flags;
        mdk_rdev_t *blocked_rdev;
 
-       if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) {
+       if (unlikely(bio->bi_rw & REQ_HARDBARRIER)) {
                md_barrier_request(mddev, bio);
                return 0;
        }
@@ -879,7 +879,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
                        mirror->rdev->data_offset;
                read_bio->bi_bdev = mirror->rdev->bdev;
                read_bio->bi_end_io = raid10_end_read_request;
-               read_bio->bi_rw = READ | (do_sync << BIO_RW_SYNCIO);
+               read_bio->bi_rw = READ | do_sync;
                read_bio->bi_private = r10_bio;
 
                generic_make_request(read_bio);
@@ -947,7 +947,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
                        conf->mirrors[d].rdev->data_offset;
                mbio->bi_bdev = conf->mirrors[d].rdev->bdev;
                mbio->bi_end_io = raid10_end_write_request;
-               mbio->bi_rw = WRITE | (do_sync << BIO_RW_SYNCIO);
+               mbio->bi_rw = WRITE | do_sync;
                mbio->bi_private = r10_bio;
 
                atomic_inc(&r10_bio->remaining);
@@ -1482,14 +1482,14 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
        int sectors = r10_bio->sectors;
        mdk_rdev_t*rdev;
        int max_read_errors = atomic_read(&mddev->max_corr_read_errors);
+       int d = r10_bio->devs[r10_bio->read_slot].devnum;
 
        rcu_read_lock();
-       {
-               int d = r10_bio->devs[r10_bio->read_slot].devnum;
+       rdev = rcu_dereference(conf->mirrors[d].rdev);
+       if (rdev) { /* If rdev is not NULL */
                char b[BDEVNAME_SIZE];
                int cur_read_error_count = 0;
 
-               rdev = rcu_dereference(conf->mirrors[d].rdev);
                bdevname(rdev->bdev, b);
 
                if (test_bit(Faulty, &rdev->flags)) {
@@ -1530,7 +1530,7 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
 
                rcu_read_lock();
                do {
-                       int d = r10_bio->devs[sl].devnum;
+                       d = r10_bio->devs[sl].devnum;
                        rdev = rcu_dereference(conf->mirrors[d].rdev);
                        if (rdev &&
                            test_bit(In_sync, &rdev->flags)) {
@@ -1564,7 +1564,7 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
                rcu_read_lock();
                while (sl != r10_bio->read_slot) {
                        char b[BDEVNAME_SIZE];
-                       int d;
+
                        if (sl==0)
                                sl = conf->copies;
                        sl--;
@@ -1601,7 +1601,7 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
                }
                sl = start;
                while (sl != r10_bio->read_slot) {
-                       int d;
+
                        if (sl==0)
                                sl = conf->copies;
                        sl--;
@@ -1716,7 +1716,7 @@ static void raid10d(mddev_t *mddev)
                                raid_end_bio_io(r10_bio);
                                bio_put(bio);
                        } else {
-                               const bool do_sync = bio_rw_flagged(r10_bio->master_bio, BIO_RW_SYNCIO);
+                               const bool do_sync = (r10_bio->master_bio->bi_rw & REQ_SYNC);
                                bio_put(bio);
                                rdev = conf->mirrors[mirror].rdev;
                                if (printk_ratelimit())
@@ -1730,7 +1730,7 @@ static void raid10d(mddev_t *mddev)
                                bio->bi_sector = r10_bio->devs[r10_bio->read_slot].addr
                                        + rdev->data_offset;
                                bio->bi_bdev = rdev->bdev;
-                               bio->bi_rw = READ | (do_sync << BIO_RW_SYNCIO);
+                               bio->bi_rw = READ | do_sync;
                                bio->bi_private = r10_bio;
                                bio->bi_end_io = raid10_end_read_request;
                                unplug = 1;
@@ -2161,22 +2161,22 @@ static conf_t *setup_conf(mddev_t *mddev)
        sector_t stride, size;
        int err = -EINVAL;
 
-       if (mddev->chunk_sectors < (PAGE_SIZE >> 9) ||
-           !is_power_of_2(mddev->chunk_sectors)) {
+       if (mddev->new_chunk_sectors < (PAGE_SIZE >> 9) ||
+           !is_power_of_2(mddev->new_chunk_sectors)) {
                printk(KERN_ERR "md/raid10:%s: chunk size must be "
                       "at least PAGE_SIZE(%ld) and be a power of 2.\n",
                       mdname(mddev), PAGE_SIZE);
                goto out;
        }
 
-       nc = mddev->layout & 255;
-       fc = (mddev->layout >> 8) & 255;
-       fo = mddev->layout & (1<<16);
+       nc = mddev->new_layout & 255;
+       fc = (mddev->new_layout >> 8) & 255;
+       fo = mddev->new_layout & (1<<16);
 
        if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks ||
-           (mddev->layout >> 17)) {
+           (mddev->new_layout >> 17)) {
                printk(KERN_ERR "md/raid10:%s: unsupported raid10 layout: 0x%8x\n",
-                      mdname(mddev), mddev->layout);
+                      mdname(mddev), mddev->new_layout);
                goto out;
        }
 
@@ -2241,7 +2241,6 @@ static conf_t *setup_conf(mddev_t *mddev)
        if (!conf->thread)
                goto out;
 
-       conf->scale_disks = 0;
        conf->mddev = mddev;
        return conf;
 
@@ -2300,11 +2299,6 @@ static int run(mddev_t *mddev)
                if (disk_idx >= conf->raid_disks
                    || disk_idx < 0)
                        continue;
-               if (conf->scale_disks) {
-                       disk_idx *= conf->scale_disks;
-                       rdev->raid_disk = disk_idx;
-                       /* MOVE 'rd%d' link !! */
-               }
                disk = conf->mirrors + disk_idx;
 
                disk->rdev = rdev;
@@ -2435,26 +2429,22 @@ static void *raid10_takeover_raid0(mddev_t *mddev)
                return ERR_PTR(-EINVAL);
        }
 
-       /* Update slot numbers to obtain
-        * degraded raid10 with missing mirrors
-        */
-       list_for_each_entry(rdev, &mddev->disks, same_set) {
-               rdev->raid_disk *= 2;
-       }
-
        /* Set new parameters */
        mddev->new_level = 10;
        /* new layout: far_copies = 1, near_copies = 2 */
        mddev->new_layout = (1<<8) + 2;
        mddev->new_chunk_sectors = mddev->chunk_sectors;
        mddev->delta_disks = mddev->raid_disks;
-       mddev->degraded = mddev->raid_disks;
        mddev->raid_disks *= 2;
        /* make sure it will be not marked as dirty */
        mddev->recovery_cp = MaxSector;
 
        conf = setup_conf(mddev);
-       conf->scale_disks = 2;
+       if (!IS_ERR(conf))
+               list_for_each_entry(rdev, &mddev->disks, same_set)
+                       if (rdev->raid_disk >= 0)
+                               rdev->new_raid_disk = rdev->raid_disk * 2;
+               
        return conf;
 }