@@ -155,7 +155,7 @@ static int raid6_idx_to_slot(int idx, struct stripe_head *sh,
155
155
return slot ;
156
156
}
157
157
158
- static void print_raid5_conf (struct r5conf * conf );
158
+ static void print_raid5_conf (struct r5conf * conf );
159
159
160
160
static int stripe_operations_active (struct stripe_head * sh )
161
161
{
@@ -5899,6 +5899,39 @@ static int add_all_stripe_bios(struct r5conf *conf,
5899
5899
return ret ;
5900
5900
}
5901
5901
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
+
5902
5935
static enum stripe_result make_stripe_request (struct mddev * mddev ,
5903
5936
struct r5conf * conf , struct stripe_request_ctx * ctx ,
5904
5937
sector_t logical_sector , struct bio * bi )
@@ -5913,28 +5946,14 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
5913
5946
seq = read_seqcount_begin (& conf -> gen_lock );
5914
5947
5915
5948
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 ;
5936
5954
}
5937
- spin_unlock_irq (& conf -> device_lock );
5955
+ if (loc == LOC_AHEAD_OF_RESHAPE )
5956
+ previous = 1 ;
5938
5957
}
5939
5958
5940
5959
new_sector = raid5_compute_sector (conf , logical_sector , previous ,
@@ -6112,8 +6131,7 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
6112
6131
/* Bail out if conflicts with reshape and REQ_NOWAIT is set */
6113
6132
if ((bi -> bi_opf & REQ_NOWAIT ) &&
6114
6133
(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 ) {
6117
6135
bio_wouldblock_error (bi );
6118
6136
if (rw == WRITE )
6119
6137
md_write_end (mddev );
@@ -7568,11 +7586,11 @@ static struct r5conf *setup_conf(struct mddev *mddev)
7568
7586
if (test_bit (Replacement , & rdev -> flags )) {
7569
7587
if (disk -> replacement )
7570
7588
goto abort ;
7571
- RCU_INIT_POINTER ( disk -> replacement , rdev ) ;
7589
+ disk -> replacement = rdev ;
7572
7590
} else {
7573
7591
if (disk -> rdev )
7574
7592
goto abort ;
7575
- RCU_INIT_POINTER ( disk -> rdev , rdev ) ;
7593
+ disk -> rdev = rdev ;
7576
7594
}
7577
7595
7578
7596
if (test_bit (In_sync , & rdev -> flags )) {
@@ -8054,7 +8072,7 @@ static void raid5_status(struct seq_file *seq, struct mddev *mddev)
8054
8072
seq_printf (seq , "]" );
8055
8073
}
8056
8074
8057
- static void print_raid5_conf (struct r5conf * conf )
8075
+ static void print_raid5_conf (struct r5conf * conf )
8058
8076
{
8059
8077
struct md_rdev * rdev ;
8060
8078
int i ;
@@ -8068,15 +8086,13 @@ static void print_raid5_conf (struct r5conf *conf)
8068
8086
conf -> raid_disks ,
8069
8087
conf -> raid_disks - conf -> mddev -> degraded );
8070
8088
8071
- rcu_read_lock ();
8072
8089
for (i = 0 ; i < conf -> raid_disks ; i ++ ) {
8073
- rdev = rcu_dereference ( conf -> disks [i ].rdev ) ;
8090
+ rdev = conf -> disks [i ].rdev ;
8074
8091
if (rdev )
8075
8092
pr_debug (" disk %d, o:%d, dev:%pg\n" ,
8076
8093
i , !test_bit (Faulty , & rdev -> flags ),
8077
8094
rdev -> bdev );
8078
8095
}
8079
- rcu_read_unlock ();
8080
8096
}
8081
8097
8082
8098
static int raid5_spare_active (struct mddev * mddev )
0 commit comments