Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
[firefly-linux-kernel-4.4.55.git] / drivers / md / raid5.c
index 9f0fbecd1eb544200c0b2c16ed7a4ea218239a5c..c1b0d52bfcb0f7b014bbc48f4823e3b9b028dcce 100644 (file)
@@ -463,7 +463,6 @@ static inline void insert_hash(struct r5conf *conf, struct stripe_head *sh)
        hlist_add_head(&sh->hash, hp);
 }
 
-
 /* find an idle stripe, make sure it is unhashed, and return it. */
 static struct stripe_head *get_free_stripe(struct r5conf *conf, int hash)
 {
@@ -531,9 +530,7 @@ static void init_stripe(struct stripe_head *sh, sector_t sector, int previous)
        BUG_ON(stripe_operations_active(sh));
 
        pr_debug("init_stripe called, stripe %llu\n",
-               (unsigned long long)sh->sector);
-
-       remove_hash(sh);
+               (unsigned long long)sector);
 retry:
        seq = read_seqcount_begin(&conf->gen_lock);
        sh->generation = conf->generation - previous;
@@ -542,7 +539,6 @@ retry:
        stripe_set_idx(sector, conf, previous, sh);
        sh->state = 0;
 
-
        for (i = sh->disks; i--; ) {
                struct r5dev *dev = &sh->dev[i];
 
@@ -1350,7 +1346,6 @@ ops_run_compute6_2(struct stripe_head *sh, struct raid5_percpu *percpu)
        }
 }
 
-
 static void ops_complete_prexor(void *stripe_head_ref)
 {
        struct stripe_head *sh = stripe_head_ref;
@@ -2419,7 +2414,6 @@ static sector_t raid5_compute_sector(struct r5conf *conf, sector_t r_sector,
        return new_sector;
 }
 
-
 static sector_t compute_blocknr(struct stripe_head *sh, int i, int previous)
 {
        struct r5conf *conf = sh->raid_conf;
@@ -2437,7 +2431,6 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i, int previous)
        sector_t r_sector;
        struct stripe_head sh2;
 
-
        chunk_offset = sector_div(new_sector, sectors_per_chunk);
        stripe = new_sector;
 
@@ -2541,7 +2534,6 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i, int previous)
        return r_sector;
 }
 
-
 static void
 schedule_reconstruction(struct stripe_head *sh, struct stripe_head_state *s,
                         int rcw, int expand)
@@ -2925,8 +2917,11 @@ static int fetch_block(struct stripe_head *sh, struct stripe_head_state *s,
             (sh->raid_conf->level <= 5 && s->failed && fdev[0]->towrite &&
              (!test_bit(R5_Insync, &dev->flags) || test_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) &&
              !test_bit(R5_OVERWRITE, &fdev[0]->flags)) ||
-            (sh->raid_conf->level == 6 && s->failed && s->to_write &&
-             s->to_write - s->non_overwrite < sh->raid_conf->raid_disks - 2 &&
+            ((sh->raid_conf->level == 6 ||
+              sh->sector >= sh->raid_conf->mddev->recovery_cp)
+             && s->failed && s->to_write &&
+             (s->to_write - s->non_overwrite <
+              sh->raid_conf->raid_disks - sh->raid_conf->max_degraded) &&
              (!test_bit(R5_Insync, &dev->flags) || test_bit(STRIPE_PREREAD_ACTIVE, &sh->state))))) {
                /* we would like to get this block, possibly by computing it,
                 * otherwise read it if the backing disk is insync
@@ -3013,7 +3008,6 @@ static void handle_stripe_fill(struct stripe_head *sh,
        set_bit(STRIPE_HANDLE, &sh->state);
 }
 
-
 /* handle_stripe_clean_event
  * any written block on an uptodate or failed drive can be returned.
  * Note that if we 'wrote' to a failed drive, it will be UPTODATE, but
@@ -3304,7 +3298,6 @@ static void handle_parity_checks5(struct r5conf *conf, struct stripe_head *sh,
        }
 }
 
-
 static void handle_parity_checks6(struct r5conf *conf, struct stripe_head *sh,
                                  struct stripe_head_state *s,
                                  int disks)
@@ -3939,7 +3932,6 @@ static void handle_stripe(struct stripe_head *sh)
                        }
                }
 
-
        /* Finish reconstruct operations initiated by the expansion process */
        if (sh->reconstruct_state == reconstruct_state_result) {
                struct stripe_head *sh_src
@@ -4137,7 +4129,6 @@ static int raid5_mergeable_bvec(struct request_queue *q,
                return max;
 }
 
-
 static int in_chunk_boundary(struct mddev *mddev, struct bio *bio)
 {
        sector_t sector = bio->bi_iter.bi_sector + get_start_sect(bio->bi_bdev);
@@ -4167,7 +4158,6 @@ static void add_bio_to_retry(struct bio *bi,struct r5conf *conf)
        md_wakeup_thread(conf->mddev->thread);
 }
 
-
 static struct bio *remove_bio_from_retry(struct r5conf *conf)
 {
        struct bio *bi;
@@ -4191,7 +4181,6 @@ static struct bio *remove_bio_from_retry(struct r5conf *conf)
        return bi;
 }
 
-
 /*
  *  The "raid5_align_endio" should check if the read succeeded and if it
  *  did, call bio_endio on the original bio (having bio_put the new bio
@@ -4224,7 +4213,6 @@ static void raid5_align_endio(struct bio *bi, int error)
                return;
        }
 
-
        pr_debug("raid5_align_endio : io error...handing IO for a retry\n");
 
        add_bio_to_retry(raid_bi, conf);
@@ -4249,7 +4237,6 @@ static int bio_fits_rdev(struct bio *bi)
        return 1;
 }
 
-
 static int chunk_aligned_read(struct mddev *mddev, struct bio * raid_bio)
 {
        struct r5conf *conf = mddev->private;
@@ -4301,7 +4288,7 @@ static int chunk_aligned_read(struct mddev *mddev, struct bio * raid_bio)
                rcu_read_unlock();
                raid_bio->bi_next = (void*)rdev;
                align_bi->bi_bdev =  rdev->bdev;
-               align_bi->bi_flags &= ~(1 << BIO_SEG_VALID);
+               __clear_bit(BIO_SEG_VALID, &align_bi->bi_flags);
 
                if (!bio_fits_rdev(align_bi) ||
                    is_badblock(rdev, align_bi->bi_iter.bi_sector,
@@ -5446,7 +5433,6 @@ raid5_skip_copy = __ATTR(skip_copy, S_IRUGO | S_IWUSR,
                                        raid5_show_skip_copy,
                                        raid5_store_skip_copy);
 
-
 static ssize_t
 stripe_cache_active_show(struct mddev *mddev, char *page)
 {
@@ -5898,7 +5884,6 @@ static struct r5conf *setup_conf(struct mddev *mddev)
                return ERR_PTR(-ENOMEM);
 }
 
-
 static int only_parity(int raid_disk, int algo, int raid_disks, int max_degraded)
 {
        switch (algo) {
@@ -5911,7 +5896,7 @@ static int only_parity(int raid_disk, int algo, int raid_disks, int max_degraded
                        return 1;
                break;
        case ALGORITHM_PARITY_0_6:
-               if (raid_disk == 0 || 
+               if (raid_disk == 0 ||
                    raid_disk == raid_disks - 1)
                        return 1;
                break;
@@ -6165,7 +6150,6 @@ static int run(struct mddev *mddev)
                                                        "reshape");
        }
 
-
        /* Ok, everything is just fine now */
        if (mddev->to_remove == &raid5_attrs_group)
                mddev->to_remove = NULL;
@@ -6814,7 +6798,6 @@ static void raid5_quiesce(struct mddev *mddev, int state)
        }
 }
 
-
 static void *raid45_takeover_raid0(struct mddev *mddev, int level)
 {
        struct r0conf *raid0_conf = mddev->private;
@@ -6841,7 +6824,6 @@ static void *raid45_takeover_raid0(struct mddev *mddev, int level)
        return setup_conf(mddev);
 }
 
-
 static void *raid5_takeover_raid1(struct mddev *mddev)
 {
        int chunksect;
@@ -6902,7 +6884,6 @@ static void *raid5_takeover_raid6(struct mddev *mddev)
        return setup_conf(mddev);
 }
 
-
 static int raid5_check_reshape(struct mddev *mddev)
 {
        /* For a 2-drive array, the layout and chunk size can be changed
@@ -7051,7 +7032,6 @@ static void *raid6_takeover(struct mddev *mddev)
        return setup_conf(mddev);
 }
 
-
 static struct md_personality raid6_personality =
 {
        .name           = "raid6",