[bug report] scsi: smartpqi: Add support for RAID5 and RAID6 writes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Don Brace,

The patch 6702d2c40f31: "scsi: smartpqi: Add support for RAID5 and
RAID6 writes" from Mar 11, 2021, leads to the following static
checker warning:

	drivers/scsi/smartpqi/smartpqi_init.c:2664 pqi_calc_aio_r5_or_r6()
	warn: previously used 'rmd->blocks_per_row' as divisor (see line 2622)

drivers/scsi/smartpqi/smartpqi_init.c
  2607          rmd->r5or6_last_row_offset = do_div(tmpdiv, rmd->stripesize);
  2608          tmpdiv = rmd->r5or6_last_row_offset;
  2609          rmd->r5or6_last_row_offset = do_div(tmpdiv, rmd->blocks_per_row);
  2610          tmpdiv = rmd->r5or6_first_row_offset;
  2611          do_div(tmpdiv, rmd->strip_size);
  2612          rmd->first_column = rmd->r5or6_first_column = tmpdiv;
  2613          tmpdiv = rmd->r5or6_last_row_offset;
  2614          do_div(tmpdiv, rmd->strip_size);
  2615          rmd->r5or6_last_column = tmpdiv;
  2616  #else
  2617          rmd->first_row_offset = rmd->r5or6_first_row_offset =
  2618                  (u32)((rmd->first_block % rmd->stripesize) %
  2619                  rmd->blocks_per_row);
  2620  
  2621          rmd->r5or6_last_row_offset =
  2622                  (u32)((rmd->last_block % rmd->stripesize) %
  2623                  rmd->blocks_per_row);
                        ^^^^^^^^^^^^^^^^^^^
If ->blocks_per_row is zero then we are toasted long before the ...

  2624  
  2625          rmd->first_column =
  2626                  rmd->r5or6_first_row_offset / rmd->strip_size;
  2627          rmd->r5or6_first_column = rmd->first_column;
  2628          rmd->r5or6_last_column = rmd->r5or6_last_row_offset / rmd->strip_size;
  2629  #endif
  2630          if (rmd->r5or6_first_column != rmd->r5or6_last_column)
  2631                  return PQI_RAID_BYPASS_INELIGIBLE;
  2632  
  2633          /* Request is eligible. */
  2634          rmd->map_row =
  2635                  ((u32)(rmd->first_row >> raid_map->parity_rotation_shift)) %
  2636                  get_unaligned_le16(&raid_map->row_cnt);
  2637  
  2638          rmd->map_index = (rmd->first_group *
  2639                  (get_unaligned_le16(&raid_map->row_cnt) *
  2640                  rmd->total_disks_per_row)) +
  2641                  (rmd->map_row * rmd->total_disks_per_row) + rmd->first_column;
  2642  
  2643          if (rmd->is_write) {
  2644                  u32 index;
  2645  
  2646                  /*
  2647                   * p_parity_it_nexus and q_parity_it_nexus are pointers to the
  2648                   * parity entries inside the device's raid_map.
  2649                   *
  2650                   * A device's RAID map is bounded by: number of RAID disks squared.
  2651                   *
  2652                   * The devices RAID map size is checked during device
  2653                   * initialization.
  2654                   */
  2655                  index = DIV_ROUND_UP(rmd->map_index + 1, rmd->total_disks_per_row);
  2656                  index *= rmd->total_disks_per_row;
  2657                  index -= get_unaligned_le16(&raid_map->metadata_disks_per_row);
  2658  
  2659                  rmd->p_parity_it_nexus = raid_map->disk_data[index].aio_handle;
  2660                  if (rmd->raid_level == SA_RAID_6) {
  2661                          rmd->q_parity_it_nexus = raid_map->disk_data[index + 1].aio_handle;
  2662                          rmd->xor_mult = raid_map->disk_data[rmd->map_index].xor_mult[1];
  2663                  }
  2664                  if (rmd->blocks_per_row == 0)
                            ^^^^^^^^^^^^^^^^^^^^^^^^
... check on this line.

  2665                          return PQI_RAID_BYPASS_INELIGIBLE;
  2666  #if BITS_PER_LONG == 32
  2667                  tmpdiv = rmd->first_block;
  2668                  do_div(tmpdiv, rmd->blocks_per_row);
  2669                  rmd->row = tmpdiv;
  2670  #else
  2671                  rmd->row = rmd->first_block / rmd->blocks_per_row;
  2672  #endif
  2673          }
  2674  
  2675          return 0;
  2676  }

regards,
dan carpenter



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux