Hi Bart,

I always tell everyone that we shouldn't silence false positives but
just ignore them.  Obviously that's hard to do when it's GCC which
generates the warning.  I wish there were another way to silence this
warning.  The change you're proposing doesn't silence it in Smatch...

regards,
dan carpenter


tree:   git://internal_merge_and_test_tree devel-catchup-201802021118
head:   40247acd00cd56ee0a42826d2f746a639a41d35a
commit: b4918c33cd32756662eb82b46ac1112518570116 dm-raid: Suppress a compiler 
warning in parse_raid_params()
date:   11 days ago


git remote add linux-devel git://internal_merge_and_test_tree
git remote update linux-devel
git checkout b4918c33cd32756662eb82b46ac1112518570116
vim +1388 drivers/md/dm-raid.c

eb6491236 Jonathan Brassow   2012-10-11  1115  
eb6491236 Jonathan Brassow   2012-10-11  1116  /*
9d09e663d NeilBrown          2011-01-13  1117   * Possible arguments are...
9d09e663d NeilBrown          2011-01-13  1118   *       <chunk_size> 
[optional_args]
9d09e663d NeilBrown          2011-01-13  1119   *
327372797 Jonathan Brassow   2011-08-02  1120   * Argument definitions
327372797 Jonathan Brassow   2011-08-02  1121   *    <chunk_size>               
        The number of sectors per disk that
327372797 Jonathan Brassow   2011-08-02  1122   *                               
        will form the "stripe"
327372797 Jonathan Brassow   2011-08-02  1123   *    [[no]sync]                 
Force or prevent recovery of the
327372797 Jonathan Brassow   2011-08-02  1124   *                               
        entire array
9d09e663d NeilBrown          2011-01-13  1125   *    [rebuild <idx>]            
        Rebuild the drive indicated by the index
327372797 Jonathan Brassow   2011-08-02  1126   *    [daemon_sleep <ms>]        
        Time between bitmap daemon work to
327372797 Jonathan Brassow   2011-08-02  1127   *                               
        clear bits
9d09e663d NeilBrown          2011-01-13  1128   *    [min_recovery_rate 
<kB/sec/disk>]  Throttle RAID initialization
9d09e663d NeilBrown          2011-01-13  1129   *    [max_recovery_rate 
<kB/sec/disk>]  Throttle RAID initialization
46bed2b5c Jonathan Brassow   2011-08-02  1130   *    [write_mostly <idx>]       
        Indicate a write mostly drive via index
9d09e663d NeilBrown          2011-01-13  1131   *    [max_write_behind 
<sectors>]       See '-write-behind=' (man mdadm)
9d09e663d NeilBrown          2011-01-13  1132   *    [stripe_cache <sectors>]   
        Stripe cache size for higher RAIDs
c1084561b Jonathan Brassow   2011-08-02  1133   *    [region_size <sectors>]    
        Defines granularity of bitmap
63c32ed4a Heinz Mauelshagen  2016-11-30  1134   *    [journal_dev <dev>]        
        raid4/5/6 journaling deviice
63c32ed4a Heinz Mauelshagen  2016-11-30  1135   *                               
        (i.e. write hole closing log)
63f33b8dd Jonathan Brassow   2012-07-31  1136   *
63f33b8dd Jonathan Brassow   2012-07-31  1137   * RAID10-only options:
63f33b8dd Jonathan Brassow   2012-07-31  1138   *    [raid10_copies <# copies>] 
Number of copies.  (Default: 2)
fe5d2f4a1 Jonathan Brassow   2013-02-21  1139   *    [raid10_format 
<near|far|offset>] Layout algorithm.  (Default: near)
9d09e663d NeilBrown          2011-01-13  1140   */
92c83d79b Heinz Mauelshagen  2016-05-19  1141  static int 
parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
094f394df Heinz Mauelshagen  2016-07-19  1142                        unsigned 
int num_raid_params)
9d09e663d NeilBrown          2011-01-13  1143  {
9dbd1aa3a Heinz Mauelshagen  2016-06-13  1144   int value, raid10_format = 
ALGORITHM_RAID10_DEFAULT;
094f394df Heinz Mauelshagen  2016-07-19  1145   unsigned int raid10_copies = 2;
094f394df Heinz Mauelshagen  2016-07-19  1146   unsigned int i, write_mostly = 
0;
094f394df Heinz Mauelshagen  2016-07-19  1147   unsigned int region_size = 0;
542f90381 Mike Snitzer       2012-07-27  1148   sector_t max_io_len;
92c83d79b Heinz Mauelshagen  2016-05-19  1149   const char *arg, *key;
702108d19 Heinz Mauelshagen  2016-05-19  1150   struct raid_dev *rd;
33e53f068 Heinz Mauelshagen  2016-05-19  1151   struct raid_type *rt = 
rs->raid_type;
92c83d79b Heinz Mauelshagen  2016-05-19  1152  
92c83d79b Heinz Mauelshagen  2016-05-19  1153   arg = dm_shift_arg(as);
92c83d79b Heinz Mauelshagen  2016-05-19  1154   num_raid_params--; /* Account 
for chunk_size argument */
92c83d79b Heinz Mauelshagen  2016-05-19  1155  
9dbd1aa3a Heinz Mauelshagen  2016-06-13  1156   if (kstrtoint(arg, 10, &value) 
< 0) {
bd83a4c4f Mike Snitzer       2016-05-31  1157           rs->ti->error = "Bad 
numerical argument given for chunk_size";
bd83a4c4f Mike Snitzer       2016-05-31  1158           return -EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1159   }
9d09e663d NeilBrown          2011-01-13  1160  
9d09e663d NeilBrown          2011-01-13  1161   /*
9d09e663d NeilBrown          2011-01-13  1162    * First, parse the in-order 
required arguments
327372797 Jonathan Brassow   2011-08-02  1163    * "chunk_size" is the only 
argument of this type.
9d09e663d NeilBrown          2011-01-13  1164    */
33e53f068 Heinz Mauelshagen  2016-05-19  1165   if (rt_is_raid1(rt)) {
327372797 Jonathan Brassow   2011-08-02  1166           if (value)
327372797 Jonathan Brassow   2011-08-02  1167                   DMERR("Ignoring 
chunk size parameter for RAID 1");
327372797 Jonathan Brassow   2011-08-02  1168           value = 0;
bd83a4c4f Mike Snitzer       2016-05-31  1169   } else if 
(!is_power_of_2(value)) {
bd83a4c4f Mike Snitzer       2016-05-31  1170           rs->ti->error = "Chunk 
size must be a power of 2";
bd83a4c4f Mike Snitzer       2016-05-31  1171           return -EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1172   } else if (value < 8) {
bd83a4c4f Mike Snitzer       2016-05-31  1173           rs->ti->error = "Chunk 
size value is too small";
bd83a4c4f Mike Snitzer       2016-05-31  1174           return -EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1175   }
9d09e663d NeilBrown          2011-01-13  1176  
9d09e663d NeilBrown          2011-01-13  1177   rs->md.new_chunk_sectors = 
rs->md.chunk_sectors = value;
9d09e663d NeilBrown          2011-01-13  1178  
9d09e663d NeilBrown          2011-01-13  1179   /*
b12d437b7 Jonathan Brassow   2011-08-02  1180    * We set each individual 
device as In_sync with a completed
b12d437b7 Jonathan Brassow   2011-08-02  1181    * 'recovery_offset'.  If there 
has been a device failure or
b12d437b7 Jonathan Brassow   2011-08-02  1182    * replacement then one of the 
following cases applies:
b12d437b7 Jonathan Brassow   2011-08-02  1183    *
b12d437b7 Jonathan Brassow   2011-08-02  1184    *   1) User specifies 
'rebuild'.
b12d437b7 Jonathan Brassow   2011-08-02  1185    *      - Device is reset when 
param is read.
b12d437b7 Jonathan Brassow   2011-08-02  1186    *   2) A new device is 
supplied.
b12d437b7 Jonathan Brassow   2011-08-02  1187    *      - No matching 
superblock found, resets device.
b12d437b7 Jonathan Brassow   2011-08-02  1188    *   3) Device failure was 
transient and returns on reload.
b12d437b7 Jonathan Brassow   2011-08-02  1189    *      - Failure noticed, 
resets device for bitmap replay.
b12d437b7 Jonathan Brassow   2011-08-02  1190    *   4) Device hadn't completed 
recovery after previous failure.
b12d437b7 Jonathan Brassow   2011-08-02  1191    *      - Superblock is read 
and overrides recovery_offset.
b12d437b7 Jonathan Brassow   2011-08-02  1192    *
b12d437b7 Jonathan Brassow   2011-08-02  1193    * What is found in the 
superblocks of the devices is always
b12d437b7 Jonathan Brassow   2011-08-02  1194    * authoritative, unless 
'rebuild' or '[no]sync' was specified.
9d09e663d NeilBrown          2011-01-13  1195    */
ffeeac751 Heinz Mauelshagen  2016-06-30  1196   for (i = 0; i < rs->raid_disks; 
i++) {
9d09e663d NeilBrown          2011-01-13  1197           set_bit(In_sync, 
&rs->dev[i].rdev.flags);
b12d437b7 Jonathan Brassow   2011-08-02  1198           
rs->dev[i].rdev.recovery_offset = MaxSector;
b12d437b7 Jonathan Brassow   2011-08-02  1199   }
9d09e663d NeilBrown          2011-01-13  1200  
b12d437b7 Jonathan Brassow   2011-08-02  1201   /*
b12d437b7 Jonathan Brassow   2011-08-02  1202    * Second, parse the unordered 
optional arguments
b12d437b7 Jonathan Brassow   2011-08-02  1203    */
9d09e663d NeilBrown          2011-01-13  1204   for (i = 0; i < 
num_raid_params; i++) {
4763e543a Heinz Mauelshagen  2016-05-19  1205           key = dm_shift_arg(as);
bd83a4c4f Mike Snitzer       2016-05-31  1206           if (!key) {
bd83a4c4f Mike Snitzer       2016-05-31  1207                   rs->ti->error = 
"Not enough raid parameters given";
bd83a4c4f Mike Snitzer       2016-05-31  1208                   return -EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1209           }
92c83d79b Heinz Mauelshagen  2016-05-19  1210  
3fa6cf382 Mike Snitzer       2016-06-02  1211           if (!strcasecmp(key, 
dm_raid_arg_name_by_flag(CTR_FLAG_NOSYNC))) {
4286325b4 Mike Snitzer       2016-06-02  1212                   if 
(test_and_set_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1213                           
rs->ti->error = "Only one 'nosync' argument allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1214                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1215                   }
9d09e663d NeilBrown          2011-01-13  1216                   continue;
9d09e663d NeilBrown          2011-01-13  1217           }
3fa6cf382 Mike Snitzer       2016-06-02  1218           if (!strcasecmp(key, 
dm_raid_arg_name_by_flag(CTR_FLAG_SYNC))) {
4286325b4 Mike Snitzer       2016-06-02  1219                   if 
(test_and_set_bit(__CTR_FLAG_SYNC, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1220                           
rs->ti->error = "Only one 'sync' argument allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1221                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1222                   }
4763e543a Heinz Mauelshagen  2016-05-19  1223                   continue;
4763e543a Heinz Mauelshagen  2016-05-19  1224           }
3fa6cf382 Mike Snitzer       2016-06-02  1225           if (!strcasecmp(key, 
dm_raid_arg_name_by_flag(CTR_FLAG_RAID10_USE_NEAR_SETS))) {
4286325b4 Mike Snitzer       2016-06-02  1226                   if 
(test_and_set_bit(__CTR_FLAG_RAID10_USE_NEAR_SETS, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1227                           
rs->ti->error = "Only one 'raid10_use_new_sets' argument allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1228                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1229                   }
9d09e663d NeilBrown          2011-01-13  1230                   continue;
9d09e663d NeilBrown          2011-01-13  1231           }
9d09e663d NeilBrown          2011-01-13  1232  
92c83d79b Heinz Mauelshagen  2016-05-19  1233           arg = dm_shift_arg(as);
92c83d79b Heinz Mauelshagen  2016-05-19  1234           i++; /* Account for the 
argument pairs */
bd83a4c4f Mike Snitzer       2016-05-31  1235           if (!arg) {
bd83a4c4f Mike Snitzer       2016-05-31  1236                   rs->ti->error = 
"Wrong number of raid parameters given";
bd83a4c4f Mike Snitzer       2016-05-31  1237                   return -EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1238           }
63f33b8dd Jonathan Brassow   2012-07-31  1239  
702108d19 Heinz Mauelshagen  2016-05-19  1240           /*
702108d19 Heinz Mauelshagen  2016-05-19  1241            * Parameters that take 
a string value are checked here.
702108d19 Heinz Mauelshagen  2016-05-19  1242            */
63c32ed4a Heinz Mauelshagen  2016-11-30  1243           /* "raid10_format 
{near|offset|far} */
3fa6cf382 Mike Snitzer       2016-06-02  1244           if (!strcasecmp(key, 
dm_raid_arg_name_by_flag(CTR_FLAG_RAID10_FORMAT))) {
4286325b4 Mike Snitzer       2016-06-02  1245                   if 
(test_and_set_bit(__CTR_FLAG_RAID10_FORMAT, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1246                           
rs->ti->error = "Only one 'raid10_format' argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1247                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1248                   }
bd83a4c4f Mike Snitzer       2016-05-31  1249                   if 
(!rt_is_raid10(rt)) {
bd83a4c4f Mike Snitzer       2016-05-31  1250                           
rs->ti->error = "'raid10_format' is an invalid parameter for this RAID type";
bd83a4c4f Mike Snitzer       2016-05-31  1251                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1252                   }
33e53f068 Heinz Mauelshagen  2016-05-19  1253                   raid10_format = 
raid10_name_to_format(arg);
bd83a4c4f Mike Snitzer       2016-05-31  1254                   if 
(raid10_format < 0) {
bd83a4c4f Mike Snitzer       2016-05-31  1255                           
rs->ti->error = "Invalid 'raid10_format' value given";
bd83a4c4f Mike Snitzer       2016-05-31  1256                           return 
raid10_format;
bd83a4c4f Mike Snitzer       2016-05-31  1257                   }
63f33b8dd Jonathan Brassow   2012-07-31  1258                   continue;
63f33b8dd Jonathan Brassow   2012-07-31  1259           }
63f33b8dd Jonathan Brassow   2012-07-31  1260  
6e53636fe Heinz Mauelshagen  2017-03-22  1261           /* "journal_dev <dev>" 
*/
63c32ed4a Heinz Mauelshagen  2016-11-30  1262           if (!strcasecmp(key, 
dm_raid_arg_name_by_flag(CTR_FLAG_JOURNAL_DEV))) {
63c32ed4a Heinz Mauelshagen  2016-11-30  1263                   int r;
63c32ed4a Heinz Mauelshagen  2016-11-30  1264                   struct md_rdev 
*jdev;
63c32ed4a Heinz Mauelshagen  2016-11-30  1265  
63c32ed4a Heinz Mauelshagen  2016-11-30  1266                   if 
(test_and_set_bit(__CTR_FLAG_JOURNAL_DEV, &rs->ctr_flags)) {
63c32ed4a Heinz Mauelshagen  2016-11-30  1267                           
rs->ti->error = "Only one raid4/5/6 set journaling device allowed";
63c32ed4a Heinz Mauelshagen  2016-11-30  1268                           return 
-EINVAL;
63c32ed4a Heinz Mauelshagen  2016-11-30  1269                   }
63c32ed4a Heinz Mauelshagen  2016-11-30  1270                   if 
(!rt_is_raid456(rt)) {
63c32ed4a Heinz Mauelshagen  2016-11-30  1271                           
rs->ti->error = "'journal_dev' is an invalid parameter for this RAID type";
63c32ed4a Heinz Mauelshagen  2016-11-30  1272                           return 
-EINVAL;
63c32ed4a Heinz Mauelshagen  2016-11-30  1273                   }
63c32ed4a Heinz Mauelshagen  2016-11-30  1274                   r = 
dm_get_device(rs->ti, arg, dm_table_get_mode(rs->ti->table),
63c32ed4a Heinz Mauelshagen  2016-11-30  1275                                   
  &rs->journal_dev.dev);
63c32ed4a Heinz Mauelshagen  2016-11-30  1276                   if (r) {
63c32ed4a Heinz Mauelshagen  2016-11-30  1277                           
rs->ti->error = "raid4/5/6 journal device lookup failure";
63c32ed4a Heinz Mauelshagen  2016-11-30  1278                           return 
r;
63c32ed4a Heinz Mauelshagen  2016-11-30  1279                   }
63c32ed4a Heinz Mauelshagen  2016-11-30  1280                   jdev = 
&rs->journal_dev.rdev;
63c32ed4a Heinz Mauelshagen  2016-11-30  1281                   
md_rdev_init(jdev);
63c32ed4a Heinz Mauelshagen  2016-11-30  1282                   jdev->mddev = 
&rs->md;
63c32ed4a Heinz Mauelshagen  2016-11-30  1283                   jdev->bdev = 
rs->journal_dev.dev->bdev;
63c32ed4a Heinz Mauelshagen  2016-11-30  1284                   jdev->sectors = 
to_sector(i_size_read(jdev->bdev->bd_inode));
63c32ed4a Heinz Mauelshagen  2016-11-30  1285                   if 
(jdev->sectors < MIN_RAID456_JOURNAL_SPACE) {
63c32ed4a Heinz Mauelshagen  2016-11-30  1286                           
rs->ti->error = "No space for raid4/5/6 journal";
63c32ed4a Heinz Mauelshagen  2016-11-30  1287                           return 
-ENOSPC;
63c32ed4a Heinz Mauelshagen  2016-11-30  1288                   }
6e53636fe Heinz Mauelshagen  2017-03-22  1289                   
rs->journal_dev.mode = R5C_JOURNAL_MODE_WRITE_THROUGH;
63c32ed4a Heinz Mauelshagen  2016-11-30  1290                   
set_bit(Journal, &jdev->flags);
63c32ed4a Heinz Mauelshagen  2016-11-30  1291                   continue;
63c32ed4a Heinz Mauelshagen  2016-11-30  1292           }
63c32ed4a Heinz Mauelshagen  2016-11-30  1293  
6e53636fe Heinz Mauelshagen  2017-03-22  1294           /* "journal_mode 
<mode>" ("journal_dev" mandatory!) */
6e53636fe Heinz Mauelshagen  2017-03-22  1295           if (!strcasecmp(key, 
dm_raid_arg_name_by_flag(CTR_FLAG_JOURNAL_MODE))) {
6e53636fe Heinz Mauelshagen  2017-03-22  1296                   int r;
6e53636fe Heinz Mauelshagen  2017-03-22  1297  
6e53636fe Heinz Mauelshagen  2017-03-22  1298                   if 
(!test_bit(__CTR_FLAG_JOURNAL_DEV, &rs->ctr_flags)) {
6e53636fe Heinz Mauelshagen  2017-03-22  1299                           
rs->ti->error = "raid4/5/6 'journal_mode' is invalid without 'journal_dev'";
6e53636fe Heinz Mauelshagen  2017-03-22  1300                           return 
-EINVAL;
6e53636fe Heinz Mauelshagen  2017-03-22  1301                   }
6e53636fe Heinz Mauelshagen  2017-03-22  1302                   if 
(test_and_set_bit(__CTR_FLAG_JOURNAL_MODE, &rs->ctr_flags)) {
6e53636fe Heinz Mauelshagen  2017-03-22  1303                           
rs->ti->error = "Only one raid4/5/6 'journal_mode' argument allowed";
6e53636fe Heinz Mauelshagen  2017-03-22  1304                           return 
-EINVAL;
6e53636fe Heinz Mauelshagen  2017-03-22  1305                   }
6e53636fe Heinz Mauelshagen  2017-03-22  1306                   r = 
dm_raid_journal_mode_to_md(arg);
6e53636fe Heinz Mauelshagen  2017-03-22  1307                   if (r < 0) {
6e53636fe Heinz Mauelshagen  2017-03-22  1308                           
rs->ti->error = "Invalid 'journal_mode' argument";
6e53636fe Heinz Mauelshagen  2017-03-22  1309                           return 
r;
6e53636fe Heinz Mauelshagen  2017-03-22  1310                   }
6e53636fe Heinz Mauelshagen  2017-03-22  1311                   
rs->journal_dev.mode = r;
6e53636fe Heinz Mauelshagen  2017-03-22  1312                   continue;
6e53636fe Heinz Mauelshagen  2017-03-22  1313           }
6e53636fe Heinz Mauelshagen  2017-03-22  1314  
63c32ed4a Heinz Mauelshagen  2016-11-30  1315           /*
63c32ed4a Heinz Mauelshagen  2016-11-30  1316            * Parameters with 
number values from here on.
63c32ed4a Heinz Mauelshagen  2016-11-30  1317            */
9dbd1aa3a Heinz Mauelshagen  2016-06-13  1318           if (kstrtoint(arg, 10, 
&value) < 0) {
bd83a4c4f Mike Snitzer       2016-05-31  1319                   rs->ti->error = 
"Bad numerical argument given in raid params";
bd83a4c4f Mike Snitzer       2016-05-31  1320                   return -EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1321           }
702108d19 Heinz Mauelshagen  2016-05-19  1322  
3fa6cf382 Mike Snitzer       2016-06-02  1323           if (!strcasecmp(key, 
dm_raid_arg_name_by_flag(CTR_FLAG_REBUILD))) {
702108d19 Heinz Mauelshagen  2016-05-19  1324                   /*
702108d19 Heinz Mauelshagen  2016-05-19  1325                    * "rebuild" is 
being passed in by userspace to provide
702108d19 Heinz Mauelshagen  2016-05-19  1326                    * indexes of 
replaced devices and to set up additional
702108d19 Heinz Mauelshagen  2016-05-19  1327                    * devices on 
raid level takeover.
702108d19 Heinz Mauelshagen  2016-05-19  1328                    */
bb91a63fc Mike Snitzer       2016-06-02  1329                   if 
(!__within_range(value, 0, rs->raid_disks - 1)) {
bd83a4c4f Mike Snitzer       2016-05-31  1330                           
rs->ti->error = "Invalid rebuild index given";
bd83a4c4f Mike Snitzer       2016-05-31  1331                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1332                   }
702108d19 Heinz Mauelshagen  2016-05-19  1333  
bd83a4c4f Mike Snitzer       2016-05-31  1334                   if 
(test_and_set_bit(value, (void *) rs->rebuild_disks)) {
bd83a4c4f Mike Snitzer       2016-05-31  1335                           
rs->ti->error = "rebuild for this index already given";
bd83a4c4f Mike Snitzer       2016-05-31  1336                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1337                   }
ecbfb9f11 Heinz Mauelshagen  2016-05-19  1338  
702108d19 Heinz Mauelshagen  2016-05-19  1339                   rd = rs->dev + 
value;
702108d19 Heinz Mauelshagen  2016-05-19  1340                   
clear_bit(In_sync, &rd->rdev.flags);
702108d19 Heinz Mauelshagen  2016-05-19  1341                   
clear_bit(Faulty, &rd->rdev.flags);
702108d19 Heinz Mauelshagen  2016-05-19  1342                   
rd->rdev.recovery_offset = 0;
4286325b4 Mike Snitzer       2016-06-02  1343                   
set_bit(__CTR_FLAG_REBUILD, &rs->ctr_flags);
3fa6cf382 Mike Snitzer       2016-06-02  1344           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_WRITE_MOSTLY))) {
bd83a4c4f Mike Snitzer       2016-05-31  1345                   if 
(!rt_is_raid1(rt)) {
bd83a4c4f Mike Snitzer       2016-05-31  1346                           
rs->ti->error = "write_mostly option is only valid for RAID1";
bd83a4c4f Mike Snitzer       2016-05-31  1347                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1348                   }
702108d19 Heinz Mauelshagen  2016-05-19  1349  
bb91a63fc Mike Snitzer       2016-06-02  1350                   if 
(!__within_range(value, 0, rs->md.raid_disks - 1)) {
bd83a4c4f Mike Snitzer       2016-05-31  1351                           
rs->ti->error = "Invalid write_mostly index given";
bd83a4c4f Mike Snitzer       2016-05-31  1352                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1353                   }
9d09e663d NeilBrown          2011-01-13  1354  
5fa146b25 Heinz Mauelshagen  2016-06-15  1355                   write_mostly++;
46bed2b5c Jonathan Brassow   2011-08-02  1356                   
set_bit(WriteMostly, &rs->dev[value].rdev.flags);
4286325b4 Mike Snitzer       2016-06-02  1357                   
set_bit(__CTR_FLAG_WRITE_MOSTLY, &rs->ctr_flags);
3fa6cf382 Mike Snitzer       2016-06-02  1358           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_MAX_WRITE_BEHIND))) {
bd83a4c4f Mike Snitzer       2016-05-31  1359                   if 
(!rt_is_raid1(rt)) {
bd83a4c4f Mike Snitzer       2016-05-31  1360                           
rs->ti->error = "max_write_behind option is only valid for RAID1";
bd83a4c4f Mike Snitzer       2016-05-31  1361                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1362                   }
702108d19 Heinz Mauelshagen  2016-05-19  1363  
4286325b4 Mike Snitzer       2016-06-02  1364                   if 
(test_and_set_bit(__CTR_FLAG_MAX_WRITE_BEHIND, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1365                           
rs->ti->error = "Only one max_write_behind argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1366                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1367                   }
9d09e663d NeilBrown          2011-01-13  1368  
9d09e663d NeilBrown          2011-01-13  1369                   /*
9d09e663d NeilBrown          2011-01-13  1370                    * In 
device-mapper, we specify things in sectors, but
9d09e663d NeilBrown          2011-01-13  1371                    * MD records 
this value in kB
9d09e663d NeilBrown          2011-01-13  1372                    */
9d09e663d NeilBrown          2011-01-13  1373                   value /= 2;
bd83a4c4f Mike Snitzer       2016-05-31  1374                   if (value > 
COUNTER_MAX) {
bd83a4c4f Mike Snitzer       2016-05-31  1375                           
rs->ti->error = "Max write-behind limit out of range";
bd83a4c4f Mike Snitzer       2016-05-31  1376                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1377                   }
702108d19 Heinz Mauelshagen  2016-05-19  1378  
9d09e663d NeilBrown          2011-01-13  1379                   
rs->md.bitmap_info.max_write_behind = value;
3fa6cf382 Mike Snitzer       2016-06-02  1380           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_DAEMON_SLEEP))) {
b4918c33c Bart Van Assche    2018-01-26  1381                   static const 
long max_schedule_timeout =
b4918c33c Bart Van Assche    2018-01-26  1382                           
MAX_SCHEDULE_TIMEOUT;
b4918c33c Bart Van Assche    2018-01-26  1383  
4286325b4 Mike Snitzer       2016-06-02  1384                   if 
(test_and_set_bit(__CTR_FLAG_DAEMON_SLEEP, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1385                           
rs->ti->error = "Only one daemon_sleep argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1386                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1387                   }
b4918c33c Bart Van Assche    2018-01-26 @1388                   if (!value || 
value > max_schedule_timeout) {
bd83a4c4f Mike Snitzer       2016-05-31  1389                           
rs->ti->error = "daemon sleep period out of range";
bd83a4c4f Mike Snitzer       2016-05-31  1390                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1391                   }
9d09e663d NeilBrown          2011-01-13  1392                   
rs->md.bitmap_info.daemon_sleep = value;
3fa6cf382 Mike Snitzer       2016-06-02  1393           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_DATA_OFFSET))) {
4763e543a Heinz Mauelshagen  2016-05-19  1394                   /* Userspace 
passes new data_offset after having extended the the data image LV */
4286325b4 Mike Snitzer       2016-06-02  1395                   if 
(test_and_set_bit(__CTR_FLAG_DATA_OFFSET, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1396                           
rs->ti->error = "Only one data_offset argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1397                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1398                   }
4763e543a Heinz Mauelshagen  2016-05-19  1399                   /* Ensure 
sensible data offset */
75dd3b9ec Heinz Mauelshagen  2016-06-15  1400                   if (value < 0 ||
75dd3b9ec Heinz Mauelshagen  2016-06-15  1401                       (value && 
(value < MIN_FREE_RESHAPE_SPACE || value % to_sector(PAGE_SIZE)))) {
bd83a4c4f Mike Snitzer       2016-05-31  1402                           
rs->ti->error = "Bogus data_offset value";
bd83a4c4f Mike Snitzer       2016-05-31  1403                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1404                   }
4763e543a Heinz Mauelshagen  2016-05-19  1405                   rs->data_offset 
= value;
3fa6cf382 Mike Snitzer       2016-06-02  1406           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_DELTA_DISKS))) {
4763e543a Heinz Mauelshagen  2016-05-19  1407                   /* Define the 
+/-# of disks to add to/remove from the given raid set */
4286325b4 Mike Snitzer       2016-06-02  1408                   if 
(test_and_set_bit(__CTR_FLAG_DELTA_DISKS, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1409                           
rs->ti->error = "Only one delta_disks argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1410                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1411                   }
4763e543a Heinz Mauelshagen  2016-05-19  1412                   /* Ensure 
MAX_RAID_DEVICES and raid type minimal_devs! */
bb91a63fc Mike Snitzer       2016-06-02  1413                   if 
(!__within_range(abs(value), 1, MAX_RAID_DEVICES - rt->minimal_devs)) {
bd83a4c4f Mike Snitzer       2016-05-31  1414                           
rs->ti->error = "Too many delta_disk requested";
bd83a4c4f Mike Snitzer       2016-05-31  1415                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1416                   }
4763e543a Heinz Mauelshagen  2016-05-19  1417  
4763e543a Heinz Mauelshagen  2016-05-19  1418                   rs->delta_disks 
= value;
3fa6cf382 Mike Snitzer       2016-06-02  1419           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_STRIPE_CACHE))) {
4286325b4 Mike Snitzer       2016-06-02  1420                   if 
(test_and_set_bit(__CTR_FLAG_STRIPE_CACHE, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1421                           
rs->ti->error = "Only one stripe_cache argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1422                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1423                   }
bd83a4c4f Mike Snitzer       2016-05-31  1424  
bd83a4c4f Mike Snitzer       2016-05-31  1425                   if 
(!rt_is_raid456(rt)) {
bd83a4c4f Mike Snitzer       2016-05-31  1426                           
rs->ti->error = "Inappropriate argument: stripe_cache";
bd83a4c4f Mike Snitzer       2016-05-31  1427                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1428                   }
702108d19 Heinz Mauelshagen  2016-05-19  1429  
9dbd1aa3a Heinz Mauelshagen  2016-06-13  1430                   
rs->stripe_cache_entries = value;
3fa6cf382 Mike Snitzer       2016-06-02  1431           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_MIN_RECOVERY_RATE))) {
4286325b4 Mike Snitzer       2016-06-02  1432                   if 
(test_and_set_bit(__CTR_FLAG_MIN_RECOVERY_RATE, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1433                           
rs->ti->error = "Only one min_recovery_rate argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1434                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1435                   }
bd83a4c4f Mike Snitzer       2016-05-31  1436                   if (value > 
INT_MAX) {
bd83a4c4f Mike Snitzer       2016-05-31  1437                           
rs->ti->error = "min_recovery_rate out of range";
bd83a4c4f Mike Snitzer       2016-05-31  1438                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1439                   }
9d09e663d NeilBrown          2011-01-13  1440                   
rs->md.sync_speed_min = (int)value;
3fa6cf382 Mike Snitzer       2016-06-02  1441           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_MAX_RECOVERY_RATE))) {
f15f64d65 Heinz Mauelshagen  2016-07-27  1442                   if 
(test_and_set_bit(__CTR_FLAG_MAX_RECOVERY_RATE, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1443                           
rs->ti->error = "Only one max_recovery_rate argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1444                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1445                   }
bd83a4c4f Mike Snitzer       2016-05-31  1446                   if (value > 
INT_MAX) {
bd83a4c4f Mike Snitzer       2016-05-31  1447                           
rs->ti->error = "max_recovery_rate out of range";
bd83a4c4f Mike Snitzer       2016-05-31  1448                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1449                   }
9d09e663d NeilBrown          2011-01-13  1450                   
rs->md.sync_speed_max = (int)value;
3fa6cf382 Mike Snitzer       2016-06-02  1451           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_REGION_SIZE))) {
4286325b4 Mike Snitzer       2016-06-02  1452                   if 
(test_and_set_bit(__CTR_FLAG_REGION_SIZE, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1453                           
rs->ti->error = "Only one region_size argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1454                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1455                   }
702108d19 Heinz Mauelshagen  2016-05-19  1456  
c1084561b Jonathan Brassow   2011-08-02  1457                   region_size = 
value;
4257e085e Heinz Mauelshagen  2016-06-14  1458                   
rs->requested_bitmap_chunk_sectors = value;
3fa6cf382 Mike Snitzer       2016-06-02  1459           } else if 
(!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_RAID10_COPIES))) {
4286325b4 Mike Snitzer       2016-06-02  1460                   if 
(test_and_set_bit(__CTR_FLAG_RAID10_COPIES, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1461                           
rs->ti->error = "Only one raid10_copies argument pair allowed";
bd83a4c4f Mike Snitzer       2016-05-31  1462                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1463                   }
702108d19 Heinz Mauelshagen  2016-05-19  1464  
bb91a63fc Mike Snitzer       2016-06-02  1465                   if 
(!__within_range(value, 2, rs->md.raid_disks)) {
bd83a4c4f Mike Snitzer       2016-05-31  1466                           
rs->ti->error = "Bad value for 'raid10_copies'";
bd83a4c4f Mike Snitzer       2016-05-31  1467                           return 
-EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1468                   }
702108d19 Heinz Mauelshagen  2016-05-19  1469  
63f33b8dd Jonathan Brassow   2012-07-31  1470                   raid10_copies = 
value;
9d09e663d NeilBrown          2011-01-13  1471           } else {
9d09e663d NeilBrown          2011-01-13  1472                   DMERR("Unable 
to parse RAID parameter: %s", key);
bd83a4c4f Mike Snitzer       2016-05-31  1473                   rs->ti->error = 
"Unable to parse RAID parameter";
bd83a4c4f Mike Snitzer       2016-05-31  1474                   return -EINVAL;
9d09e663d NeilBrown          2011-01-13  1475           }
9d09e663d NeilBrown          2011-01-13  1476   }
9d09e663d NeilBrown          2011-01-13  1477  
0d851d14b Heinz Mauelshagen  2016-06-15  1478   if (test_bit(__CTR_FLAG_SYNC, 
&rs->ctr_flags) &&
0d851d14b Heinz Mauelshagen  2016-06-15  1479       test_bit(__CTR_FLAG_NOSYNC, 
&rs->ctr_flags)) {
0d851d14b Heinz Mauelshagen  2016-06-15  1480           rs->ti->error = "sync 
and nosync are mutually exclusive";
0d851d14b Heinz Mauelshagen  2016-06-15  1481           return -EINVAL;
0d851d14b Heinz Mauelshagen  2016-06-15  1482   }
0d851d14b Heinz Mauelshagen  2016-06-15  1483  
37f10be15 Heinz Mauelshagen  2016-06-24  1484   if 
(test_bit(__CTR_FLAG_REBUILD, &rs->ctr_flags) &&
37f10be15 Heinz Mauelshagen  2016-06-24  1485       (test_bit(__CTR_FLAG_SYNC, 
&rs->ctr_flags) ||
37f10be15 Heinz Mauelshagen  2016-06-24  1486        
test_bit(__CTR_FLAG_NOSYNC, &rs->ctr_flags))) {
37f10be15 Heinz Mauelshagen  2016-06-24  1487           rs->ti->error = 
"sync/nosync and rebuild are mutually exclusive";
37f10be15 Heinz Mauelshagen  2016-06-24  1488           return -EINVAL;
37f10be15 Heinz Mauelshagen  2016-06-24  1489   }
37f10be15 Heinz Mauelshagen  2016-06-24  1490  
5fa146b25 Heinz Mauelshagen  2016-06-15  1491   if (write_mostly >= 
rs->md.raid_disks) {
5fa146b25 Heinz Mauelshagen  2016-06-15  1492           rs->ti->error = "Can't 
set all raid1 devices to write_mostly";
5fa146b25 Heinz Mauelshagen  2016-06-15  1493           return -EINVAL;
5fa146b25 Heinz Mauelshagen  2016-06-15  1494   }
5fa146b25 Heinz Mauelshagen  2016-06-15  1495  
c1084561b Jonathan Brassow   2011-08-02  1496   if (validate_region_size(rs, 
region_size))
c1084561b Jonathan Brassow   2011-08-02  1497           return -EINVAL;
c1084561b Jonathan Brassow   2011-08-02  1498  
c1084561b Jonathan Brassow   2011-08-02  1499   if (rs->md.chunk_sectors)
542f90381 Mike Snitzer       2012-07-27  1500           max_io_len = 
rs->md.chunk_sectors;
c1084561b Jonathan Brassow   2011-08-02  1501   else
542f90381 Mike Snitzer       2012-07-27  1502           max_io_len = 
region_size;
c1084561b Jonathan Brassow   2011-08-02  1503  
542f90381 Mike Snitzer       2012-07-27  1504   if 
(dm_set_target_max_io_len(rs->ti, max_io_len))
542f90381 Mike Snitzer       2012-07-27  1505           return -EINVAL;
327372797 Jonathan Brassow   2011-08-02  1506  
33e53f068 Heinz Mauelshagen  2016-05-19  1507   if (rt_is_raid10(rt)) {
bd83a4c4f Mike Snitzer       2016-05-31  1508           if (raid10_copies > 
rs->md.raid_disks) {
bd83a4c4f Mike Snitzer       2016-05-31  1509                   rs->ti->error = 
"Not enough devices to satisfy specification";
bd83a4c4f Mike Snitzer       2016-05-31  1510                   return -EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1511           }
63f33b8dd Jonathan Brassow   2012-07-31  1512  
33e53f068 Heinz Mauelshagen  2016-05-19  1513           rs->md.new_layout = 
raid10_format_to_md_layout(rs, raid10_format, raid10_copies);
bd83a4c4f Mike Snitzer       2016-05-31  1514           if (rs->md.new_layout < 
0) {
bd83a4c4f Mike Snitzer       2016-05-31  1515                   rs->ti->error = 
"Error getting raid10 format";
bd83a4c4f Mike Snitzer       2016-05-31  1516                   return 
rs->md.new_layout;
bd83a4c4f Mike Snitzer       2016-05-31  1517           }
33e53f068 Heinz Mauelshagen  2016-05-19  1518  
33e53f068 Heinz Mauelshagen  2016-05-19  1519           rt = 
get_raid_type_by_ll(10, rs->md.new_layout);
bd83a4c4f Mike Snitzer       2016-05-31  1520           if (!rt) {
bd83a4c4f Mike Snitzer       2016-05-31  1521                   rs->ti->error = 
"Failed to recognize new raid10 layout";
bd83a4c4f Mike Snitzer       2016-05-31  1522                   return -EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1523           }
33e53f068 Heinz Mauelshagen  2016-05-19  1524  
33e53f068 Heinz Mauelshagen  2016-05-19  1525           if ((rt->algorithm == 
ALGORITHM_RAID10_DEFAULT ||
33e53f068 Heinz Mauelshagen  2016-05-19  1526                rt->algorithm == 
ALGORITHM_RAID10_NEAR) &&
4286325b4 Mike Snitzer       2016-06-02  1527               
test_bit(__CTR_FLAG_RAID10_USE_NEAR_SETS, &rs->ctr_flags)) {
bd83a4c4f Mike Snitzer       2016-05-31  1528                   rs->ti->error = 
"RAID10 format 'near' and 'raid10_use_near_sets' are incompatible";
bd83a4c4f Mike Snitzer       2016-05-31  1529                   return -EINVAL;
bd83a4c4f Mike Snitzer       2016-05-31  1530           }
bd83a4c4f Mike Snitzer       2016-05-31  1531   }
702108d19 Heinz Mauelshagen  2016-05-19  1532  
33e53f068 Heinz Mauelshagen  2016-05-19  1533   rs->raid10_copies = 
raid10_copies;
c039c332f Jonathan E Brassow 2012-07-27  1534  
9d09e663d NeilBrown          2011-01-13  1535   /* Assume there are no metadata 
devices until the drives are parsed */
9d09e663d NeilBrown          2011-01-13  1536   rs->md.persistent = 0;
9d09e663d NeilBrown          2011-01-13  1537   rs->md.external = 1;
9d09e663d NeilBrown          2011-01-13  1538  
f090279ea Heinz Mauelshagen  2016-05-19  1539   /* Check, if any invalid ctr 
arguments have been passed in for the raid level */
a30cbc0d1 Heinz Mauelshagen  2016-06-09  1540   return 
rs_check_for_valid_flags(rs);
9d09e663d NeilBrown          2011-01-13  1541  }
9d09e663d NeilBrown          2011-01-13  1542  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
_______________________________________________
kbuild mailing list
kbuild@lists.01.org
https://lists.01.org/mailman/listinfo/kbuild

Reply via email to