1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

raid: remove log_*(), use DM_ARRAY_SIIZE() and avoid sz variable

This commit is contained in:
Heinz Mauelshagen 2024-11-08 19:45:58 +01:00
parent 680347d775
commit 94bfc8fc4f
3 changed files with 7 additions and 21 deletions

View File

@ -62,18 +62,13 @@ static uint32_t _hweight64(__le64 v)
static uint32_t _hweight_failed(struct dm_raid_superblock *sb)
{
size_t sz = _get_sb_size(sb);
uint32_t r = _hweight64(sb->failed_devices);
if (sz == sizeof(*sb)) {
int i = sizeof(sb->extended_failed_devices) / sizeof(*sb->extended_failed_devices);
if (_get_sb_size(sb) == sizeof(*sb)) {
int i = DM_ARRAY_SIZE(sb->extended_failed_devices);
while (i--) {
uint32_t hw = _hweight64(sb->extended_failed_devices[i]);
if (hw > r)
r = hw;
}
while (i--)
r = max(r, _hweight64(sb->extended_failed_devices[i]));
}
return r;
@ -81,16 +76,11 @@ static uint32_t _hweight_failed(struct dm_raid_superblock *sb)
static void _clear_failed_devices(struct dm_raid_superblock *sb)
{
size_t sz = _get_sb_size(sb);
sb->failed_devices = 0;
if (sz == sizeof(*sb)) {
int i = sizeof(sb->extended_failed_devices) / sizeof(*sb->extended_failed_devices);
while (i--)
sb->extended_failed_devices[i] = 0;
}
if (_get_sb_size(sb) == sizeof(*sb))
memset(sb->extended_failed_devices, 0, sizeof(sb->extended_failed_devices));
}
static int _count_or_clear_failed_devices(const char *dev_path, bool clear, uint32_t *nr_failed)
@ -123,10 +113,7 @@ static int _count_or_clear_failed_devices(const char *dev_path, bool clear, uint
}
if (nr_failed)
{
*nr_failed = _hweight_failed(sb);
log_print("%s[%u] nr_failed=%u", __func__, __LINE__, *nr_failed);
}
if (clear) {
r = (lseek(fd, 0, SEEK_SET) < 0) ? 0 : 1;

View File

@ -1481,7 +1481,7 @@ static int _lv_activate_lv(const struct logical_volume *lv, struct lv_activate_o
if (!lv_raid_count_failed_devices(lv, &failed_cnt))
return_0;
log_print("%s[%u] failed_cnt=%u parity_devs=%u", __func__, __LINE__, failed_cnt, raid_seg->segtype->parity_devs);
if (failed_cnt) {
if (failed_cnt > raid_seg->segtype->parity_devs) {
log_error("Can't activate as %s has %u failed device%s which is more than the allowed %u",

View File

@ -7335,7 +7335,6 @@ static int _raid_count_or_clear_failed_devices(const struct logical_volume *lv,
if (nr_failed_tmp > nr_failed)
nr_failed = nr_failed_tmp;
}
log_print("%s[%u] nr_failed=%u clear=%u", __func__, __LINE__, nr_failed, clear);
} else {
log_error("Missing meta areas on %s!", display_lvname(lv));