@@ -155,7 +155,7 @@ static int raid6_idx_to_slot(int idx, struct stripe_head *sh,
155155 return slot ;
156156}
157157
158- static void print_raid5_conf (struct r5conf * conf );
158+ static void print_raid5_conf (struct r5conf * conf );
159159
160160static int stripe_operations_active (struct stripe_head * sh )
161161{
@@ -5899,6 +5899,39 @@ static int add_all_stripe_bios(struct r5conf *conf,
58995899 return ret ;
59005900}
59015901
5902+ enum reshape_loc {
5903+ LOC_NO_RESHAPE ,
5904+ LOC_AHEAD_OF_RESHAPE ,
5905+ LOC_INSIDE_RESHAPE ,
5906+ LOC_BEHIND_RESHAPE ,
5907+ };
5908+
5909+ static enum reshape_loc get_reshape_loc (struct mddev * mddev ,
5910+ struct r5conf * conf , sector_t logical_sector )
5911+ {
5912+ sector_t reshape_progress , reshape_safe ;
5913+ /*
5914+ * Spinlock is needed as reshape_progress may be
5915+ * 64bit on a 32bit platform, and so it might be
5916+ * possible to see a half-updated value
5917+ * Of course reshape_progress could change after
5918+ * the lock is dropped, so once we get a reference
5919+ * to the stripe that we think it is, we will have
5920+ * to check again.
5921+ */
5922+ spin_lock_irq (& conf -> device_lock );
5923+ reshape_progress = conf -> reshape_progress ;
5924+ reshape_safe = conf -> reshape_safe ;
5925+ spin_unlock_irq (& conf -> device_lock );
5926+ if (reshape_progress == MaxSector )
5927+ return LOC_NO_RESHAPE ;
5928+ if (ahead_of_reshape (mddev , logical_sector , reshape_progress ))
5929+ return LOC_AHEAD_OF_RESHAPE ;
5930+ if (ahead_of_reshape (mddev , logical_sector , reshape_safe ))
5931+ return LOC_INSIDE_RESHAPE ;
5932+ return LOC_BEHIND_RESHAPE ;
5933+ }
5934+
59025935static enum stripe_result make_stripe_request (struct mddev * mddev ,
59035936 struct r5conf * conf , struct stripe_request_ctx * ctx ,
59045937 sector_t logical_sector , struct bio * bi )
@@ -5913,28 +5946,14 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
59135946 seq = read_seqcount_begin (& conf -> gen_lock );
59145947
59155948 if (unlikely (conf -> reshape_progress != MaxSector )) {
5916- /*
5917- * Spinlock is needed as reshape_progress may be
5918- * 64bit on a 32bit platform, and so it might be
5919- * possible to see a half-updated value
5920- * Of course reshape_progress could change after
5921- * the lock is dropped, so once we get a reference
5922- * to the stripe that we think it is, we will have
5923- * to check again.
5924- */
5925- spin_lock_irq (& conf -> device_lock );
5926- if (ahead_of_reshape (mddev , logical_sector ,
5927- conf -> reshape_progress )) {
5928- previous = 1 ;
5929- } else {
5930- if (ahead_of_reshape (mddev , logical_sector ,
5931- conf -> reshape_safe )) {
5932- spin_unlock_irq (& conf -> device_lock );
5933- ret = STRIPE_SCHEDULE_AND_RETRY ;
5934- goto out ;
5935- }
5949+ enum reshape_loc loc = get_reshape_loc (mddev , conf ,
5950+ logical_sector );
5951+ if (loc == LOC_INSIDE_RESHAPE ) {
5952+ ret = STRIPE_SCHEDULE_AND_RETRY ;
5953+ goto out ;
59365954 }
5937- spin_unlock_irq (& conf -> device_lock );
5955+ if (loc == LOC_AHEAD_OF_RESHAPE )
5956+ previous = 1 ;
59385957 }
59395958
59405959 new_sector = raid5_compute_sector (conf , logical_sector , previous ,
@@ -6112,8 +6131,7 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
61126131 /* Bail out if conflicts with reshape and REQ_NOWAIT is set */
61136132 if ((bi -> bi_opf & REQ_NOWAIT ) &&
61146133 (conf -> reshape_progress != MaxSector ) &&
6115- !ahead_of_reshape (mddev , logical_sector , conf -> reshape_progress ) &&
6116- ahead_of_reshape (mddev , logical_sector , conf -> reshape_safe )) {
6134+ get_reshape_loc (mddev , conf , logical_sector ) == LOC_INSIDE_RESHAPE ) {
61176135 bio_wouldblock_error (bi );
61186136 if (rw == WRITE )
61196137 md_write_end (mddev );
@@ -7568,11 +7586,11 @@ static struct r5conf *setup_conf(struct mddev *mddev)
75687586 if (test_bit (Replacement , & rdev -> flags )) {
75697587 if (disk -> replacement )
75707588 goto abort ;
7571- RCU_INIT_POINTER ( disk -> replacement , rdev ) ;
7589+ disk -> replacement = rdev ;
75727590 } else {
75737591 if (disk -> rdev )
75747592 goto abort ;
7575- RCU_INIT_POINTER ( disk -> rdev , rdev ) ;
7593+ disk -> rdev = rdev ;
75767594 }
75777595
75787596 if (test_bit (In_sync , & rdev -> flags )) {
@@ -8054,7 +8072,7 @@ static void raid5_status(struct seq_file *seq, struct mddev *mddev)
80548072 seq_printf (seq , "]" );
80558073}
80568074
8057- static void print_raid5_conf (struct r5conf * conf )
8075+ static void print_raid5_conf (struct r5conf * conf )
80588076{
80598077 struct md_rdev * rdev ;
80608078 int i ;
@@ -8068,15 +8086,13 @@ static void print_raid5_conf (struct r5conf *conf)
80688086 conf -> raid_disks ,
80698087 conf -> raid_disks - conf -> mddev -> degraded );
80708088
8071- rcu_read_lock ();
80728089 for (i = 0 ; i < conf -> raid_disks ; i ++ ) {
8073- rdev = rcu_dereference ( conf -> disks [i ].rdev ) ;
8090+ rdev = conf -> disks [i ].rdev ;
80748091 if (rdev )
80758092 pr_debug (" disk %d, o:%d, dev:%pg\n" ,
80768093 i , !test_bit (Faulty , & rdev -> flags ),
80778094 rdev -> bdev );
80788095 }
8079- rcu_read_unlock ();
80808096}
80818097
80828098static int raid5_spare_active (struct mddev * mddev )
0 commit comments