@@ -2106,10 +2106,9 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
2106
2106
continue ;
2107
2107
}
2108
2108
2109
- if (!mddev_is_dm (mddev ))
2110
- disk_stack_limits (mddev -> gendisk , rdev -> bdev ,
2111
- rdev -> data_offset << 9 );
2112
-
2109
+ err = mddev_stack_new_rdev (mddev , rdev );
2110
+ if (err )
2111
+ return err ;
2113
2112
p -> head_position = 0 ;
2114
2113
p -> recovery_disabled = mddev -> recovery_disabled - 1 ;
2115
2114
rdev -> raid_disk = mirror ;
@@ -2125,10 +2124,9 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
2125
2124
clear_bit (In_sync , & rdev -> flags );
2126
2125
set_bit (Replacement , & rdev -> flags );
2127
2126
rdev -> raid_disk = repl_slot ;
2128
- err = 0 ;
2129
- if (!mddev_is_dm (mddev ))
2130
- disk_stack_limits (mddev -> gendisk , rdev -> bdev ,
2131
- rdev -> data_offset << 9 );
2127
+ err = mddev_stack_new_rdev (mddev , rdev );
2128
+ if (err )
2129
+ return err ;
2132
2130
conf -> fullsync = 1 ;
2133
2131
WRITE_ONCE (p -> replacement , rdev );
2134
2132
}
@@ -3969,14 +3967,26 @@ static struct r10conf *setup_conf(struct mddev *mddev)
3969
3967
return ERR_PTR (err );
3970
3968
}
3971
3969
3972
- static void raid10_set_io_opt (struct r10conf * conf )
3970
+ static unsigned int raid10_nr_stripes (struct r10conf * conf )
3973
3971
{
3974
- int raid_disks = conf -> geo .raid_disks ;
3972
+ unsigned int raid_disks = conf -> geo .raid_disks ;
3973
+
3974
+ if (conf -> geo .raid_disks % conf -> geo .near_copies )
3975
+ return raid_disks ;
3976
+ return raid_disks / conf -> geo .near_copies ;
3977
+ }
3975
3978
3976
- if (!(conf -> geo .raid_disks % conf -> geo .near_copies ))
3977
- raid_disks /= conf -> geo .near_copies ;
3978
- blk_queue_io_opt (conf -> mddev -> queue , (conf -> mddev -> chunk_sectors << 9 ) *
3979
- raid_disks );
3979
+ static int raid10_set_queue_limits (struct mddev * mddev )
3980
+ {
3981
+ struct r10conf * conf = mddev -> private ;
3982
+ struct queue_limits lim ;
3983
+
3984
+ blk_set_stacking_limits (& lim );
3985
+ lim .max_write_zeroes_sectors = 0 ;
3986
+ lim .io_min = mddev -> chunk_sectors << 9 ;
3987
+ lim .io_opt = lim .io_min * raid10_nr_stripes (conf );
3988
+ mddev_stack_rdev_limits (mddev , & lim );
3989
+ return queue_limits_set (mddev -> queue , & lim );
3980
3990
}
3981
3991
3982
3992
static int raid10_run (struct mddev * mddev )
@@ -3988,6 +3998,7 @@ static int raid10_run(struct mddev *mddev)
3988
3998
sector_t size ;
3989
3999
sector_t min_offset_diff = 0 ;
3990
4000
int first = 1 ;
4001
+ int ret = - EIO ;
3991
4002
3992
4003
if (mddev -> private == NULL ) {
3993
4004
conf = setup_conf (mddev );
@@ -4014,12 +4025,6 @@ static int raid10_run(struct mddev *mddev)
4014
4025
}
4015
4026
}
4016
4027
4017
- if (!mddev_is_dm (conf -> mddev )) {
4018
- blk_queue_max_write_zeroes_sectors (mddev -> queue , 0 );
4019
- blk_queue_io_min (mddev -> queue , mddev -> chunk_sectors << 9 );
4020
- raid10_set_io_opt (conf );
4021
- }
4022
-
4023
4028
rdev_for_each (rdev , mddev ) {
4024
4029
long long diff ;
4025
4030
@@ -4048,14 +4053,16 @@ static int raid10_run(struct mddev *mddev)
4048
4053
if (first || diff < min_offset_diff )
4049
4054
min_offset_diff = diff ;
4050
4055
4051
- if (!mddev_is_dm (mddev ))
4052
- disk_stack_limits (mddev -> gendisk , rdev -> bdev ,
4053
- rdev -> data_offset << 9 );
4054
-
4055
4056
disk -> head_position = 0 ;
4056
4057
first = 0 ;
4057
4058
}
4058
4059
4060
+ if (!mddev_is_dm (conf -> mddev )) {
4061
+ ret = raid10_set_queue_limits (mddev );
4062
+ if (ret )
4063
+ goto out_free_conf ;
4064
+ }
4065
+
4059
4066
/* need to check that every block has at least one working mirror */
4060
4067
if (!enough (conf , -1 )) {
4061
4068
pr_err ("md/raid10:%s: not enough operational mirrors.\n" ,
@@ -4156,7 +4163,7 @@ static int raid10_run(struct mddev *mddev)
4156
4163
raid10_free_conf (conf );
4157
4164
mddev -> private = NULL ;
4158
4165
out :
4159
- return - EIO ;
4166
+ return ret ;
4160
4167
}
4161
4168
4162
4169
static void raid10_free (struct mddev * mddev , void * priv )
@@ -4933,8 +4940,7 @@ static void end_reshape(struct r10conf *conf)
4933
4940
conf -> reshape_safe = MaxSector ;
4934
4941
spin_unlock_irq (& conf -> device_lock );
4935
4942
4936
- if (!mddev_is_dm (conf -> mddev ))
4937
- raid10_set_io_opt (conf );
4943
+ mddev_update_io_opt (conf -> mddev , raid10_nr_stripes (conf ));
4938
4944
conf -> fullsync = 0 ;
4939
4945
}
4940
4946
0 commit comments