[bug report] dm zoned: metadata version 2

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

 



Hello Hannes Reinecke,

The patch 70978208ec91: "dm zoned: metadata version 2" from May 11,
2020, leads to the following static checker warning:

	drivers/md/dm-zoned-target.c:1047 dmz_iterate_devices()
	warn: was expecting a 64 bit value instead of '~(zone_nr_sectors - 1)'

drivers/md/dm-zoned-target.c
  1039  static int dmz_iterate_devices(struct dm_target *ti,
  1040                                 iterate_devices_callout_fn fn, void *data)
  1041  {
  1042          struct dmz_target *dmz = ti->private;
  1043          unsigned int zone_nr_sectors = dmz_zone_nr_sectors(dmz->metadata);
  1044          sector_t capacity;
  1045          int r;
  1046  
  1047          capacity = dmz->dev[0].capacity & ~(zone_nr_sectors - 1);

sector_t is a u64 and zone_nr_sectors is a u32.  It means that the high
32 bits are always cleared.  Making zone_nr_sectors a sector_t, u64 or
even an int would fix this problem.

  1048          r = fn(ti, dmz->ddev[0], 0, capacity, data);
  1049          if (!r && dmz->ddev[1]) {
  1050                  capacity = dmz->dev[1].capacity & ~(zone_nr_sectors - 1);
  1051                  r = fn(ti, dmz->ddev[1], 0, capacity, data);
  1052          }
  1053          return r;
  1054  }

regards,
dan carpenter

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux