aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-07-26 21:00:36 -0400
committerNeilBrown <neilb@suse.de>2011-07-26 21:00:36 -0400
commitacfe726bdd0000a9be1b308b29fad1e9ae62178c (patch)
tree468713f2be848747723b89fe5afbf39cdfc375ef /drivers/md
parent474af965fe0005b334cabdb2904a7d712c21489b (diff)
md/raid5: finalise new merged handle_stripe.
handle_stripe5() and handle_stripe6() are now virtually identical. So discard one and rename the other to 'analyse_stripe()'. It always returns 0, so change it to 'void' and remove the 'done' variable in handle_stripe(). Signed-off-by: NeilBrown <neilb@suse.de> Reviewed-by: Namhyung Kim <namhyung@gmail.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid5.c115
1 files changed, 13 insertions, 102 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 63acc51e8406..b321d6c36594 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2898,100 +2898,27 @@ static void handle_stripe_expansion(raid5_conf_t *conf, struct stripe_head *sh)
2898 * 2898 *
2899 */ 2899 */
2900 2900
2901static int handle_stripe5(struct stripe_head *sh, struct stripe_head_state *s) 2901static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
2902{
2903 raid5_conf_t *conf = sh->raid_conf;
2904 int disks = sh->disks, i;
2905 struct r5dev *dev;
2906
2907 /* Now to look around and see what can be done */
2908 rcu_read_lock();
2909 spin_lock_irq(&conf->device_lock);
2910 for (i=disks; i--; ) {
2911 mdk_rdev_t *rdev;
2912
2913 dev = &sh->dev[i];
2914
2915 pr_debug("check %d: state 0x%lx toread %p read %p write %p "
2916 "written %p\n", i, dev->flags, dev->toread, dev->read,
2917 dev->towrite, dev->written);
2918
2919 /* maybe we can request a biofill operation
2920 *
2921 * new wantfill requests are only permitted while
2922 * ops_complete_biofill is guaranteed to be inactive
2923 */
2924 if (test_bit(R5_UPTODATE, &dev->flags) && dev->toread &&
2925 !test_bit(STRIPE_BIOFILL_RUN, &sh->state))
2926 set_bit(R5_Wantfill, &dev->flags);
2927
2928 /* now count some things */
2929 if (test_bit(R5_LOCKED, &dev->flags))
2930 s->locked++;
2931 if (test_bit(R5_UPTODATE, &dev->flags))
2932 s->uptodate++;
2933 if (test_bit(R5_Wantcompute, &dev->flags))
2934 s->compute++;
2935
2936 if (test_bit(R5_Wantfill, &dev->flags))
2937 s->to_fill++;
2938 else if (dev->toread)
2939 s->to_read++;
2940 if (dev->towrite) {
2941 s->to_write++;
2942 if (!test_bit(R5_OVERWRITE, &dev->flags))
2943 s->non_overwrite++;
2944 }
2945 if (dev->written)
2946 s->written++;
2947 rdev = rcu_dereference(conf->disks[i].rdev);
2948 if (s->blocked_rdev == NULL &&
2949 rdev && unlikely(test_bit(Blocked, &rdev->flags))) {
2950 s->blocked_rdev = rdev;
2951 atomic_inc(&rdev->nr_pending);
2952 }
2953 clear_bit(R5_Insync, &dev->flags);
2954 if (!rdev)
2955 /* Not in-sync */;
2956 else if (test_bit(In_sync, &rdev->flags))
2957 set_bit(R5_Insync, &dev->flags);
2958 else {
2959 /* could be in-sync depending on recovery/reshape status */
2960 if (sh->sector + STRIPE_SECTORS <= rdev->recovery_offset)
2961 set_bit(R5_Insync, &dev->flags);
2962 }
2963 if (!test_bit(R5_Insync, &dev->flags)) {
2964 /* The ReadError flag will just be confusing now */
2965 clear_bit(R5_ReadError, &dev->flags);
2966 clear_bit(R5_ReWrite, &dev->flags);
2967 }
2968 if (test_bit(R5_ReadError, &dev->flags))
2969 clear_bit(R5_Insync, &dev->flags);
2970 if (!test_bit(R5_Insync, &dev->flags)) {
2971 if (s->failed < 2)
2972 s->failed_num[s->failed] = i;
2973 s->failed++;
2974 }
2975 }
2976 spin_unlock_irq(&conf->device_lock);
2977 rcu_read_unlock();
2978
2979 return 0;
2980}
2981
2982static int handle_stripe6(struct stripe_head *sh, struct stripe_head_state *s)
2983{ 2902{
2984 raid5_conf_t *conf = sh->raid_conf; 2903 raid5_conf_t *conf = sh->raid_conf;
2985 int disks = sh->disks; 2904 int disks = sh->disks;
2986 struct r5dev *dev; 2905 struct r5dev *dev;
2987 int i; 2906 int i;
2988 2907
2989 /* Now to look around and see what can be done */ 2908 memset(s, 0, sizeof(*s));
2990 2909
2910 s->syncing = test_bit(STRIPE_SYNCING, &sh->state);
2911 s->expanding = test_bit(STRIPE_EXPAND_SOURCE, &sh->state);
2912 s->expanded = test_bit(STRIPE_EXPAND_READY, &sh->state);
2913 s->failed_num[0] = -1;
2914 s->failed_num[1] = -1;
2915
2916 /* Now to look around and see what can be done */
2991 rcu_read_lock(); 2917 rcu_read_lock();
2992 spin_lock_irq(&conf->device_lock); 2918 spin_lock_irq(&conf->device_lock);
2993 for (i=disks; i--; ) { 2919 for (i=disks; i--; ) {
2994 mdk_rdev_t *rdev; 2920 mdk_rdev_t *rdev;
2921
2995 dev = &sh->dev[i]; 2922 dev = &sh->dev[i];
2996 2923
2997 pr_debug("check %d: state 0x%lx read %p write %p written %p\n", 2924 pr_debug("check %d: state 0x%lx read %p write %p written %p\n",
@@ -3015,9 +2942,9 @@ static int handle_stripe6(struct stripe_head *sh, struct stripe_head_state *s)
3015 BUG_ON(s->compute > 2); 2942 BUG_ON(s->compute > 2);
3016 } 2943 }
3017 2944
3018 if (test_bit(R5_Wantfill, &dev->flags)) { 2945 if (test_bit(R5_Wantfill, &dev->flags))
3019 s->to_fill++; 2946 s->to_fill++;
3020 } else if (dev->toread) 2947 else if (dev->toread)
3021 s->to_read++; 2948 s->to_read++;
3022 if (dev->towrite) { 2949 if (dev->towrite) {
3023 s->to_write++; 2950 s->to_write++;
@@ -3057,14 +2984,11 @@ static int handle_stripe6(struct stripe_head *sh, struct stripe_head_state *s)
3057 } 2984 }
3058 spin_unlock_irq(&conf->device_lock); 2985 spin_unlock_irq(&conf->device_lock);
3059 rcu_read_unlock(); 2986 rcu_read_unlock();
3060
3061 return 0;
3062} 2987}
3063 2988
3064static void handle_stripe(struct stripe_head *sh) 2989static void handle_stripe(struct stripe_head *sh)
3065{ 2990{
3066 struct stripe_head_state s; 2991 struct stripe_head_state s;
3067 int done;
3068 raid5_conf_t *conf = sh->raid_conf; 2992 raid5_conf_t *conf = sh->raid_conf;
3069 int i; 2993 int i;
3070 int prexor; 2994 int prexor;
@@ -3090,21 +3014,8 @@ static void handle_stripe(struct stripe_head *sh)
3090 (unsigned long long)sh->sector, sh->state, 3014 (unsigned long long)sh->sector, sh->state,
3091 atomic_read(&sh->count), sh->pd_idx, sh->qd_idx, 3015 atomic_read(&sh->count), sh->pd_idx, sh->qd_idx,
3092 sh->check_state, sh->reconstruct_state); 3016 sh->check_state, sh->reconstruct_state);
3093 memset(&s, 0, sizeof(s));
3094
3095 s.syncing = test_bit(STRIPE_SYNCING, &sh->state);
3096 s.expanding = test_bit(STRIPE_EXPAND_SOURCE, &sh->state);
3097 s.expanded = test_bit(STRIPE_EXPAND_READY, &sh->state);
3098 s.failed_num[0] = -1;
3099 s.failed_num[1] = -1;
3100
3101 if (conf->level == 6)
3102 done = handle_stripe6(sh, &s);
3103 else
3104 done = handle_stripe5(sh, &s);
3105 3017
3106 if (done) 3018 analyse_stripe(sh, &s);
3107 goto finish;
3108 3019
3109 if (unlikely(s.blocked_rdev)) { 3020 if (unlikely(s.blocked_rdev)) {
3110 if (s.syncing || s.expanding || s.expanded || 3021 if (s.syncing || s.expanding || s.expanded ||