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

libdm: Improve raid segment parameter handling.

This commit is contained in:
Heinz Mauelshagen 2015-09-23 15:25:46 +01:00 committed by Alasdair G Kergon
parent 192d9ad977
commit 96a6210198

View File

@ -2369,6 +2369,20 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *s
return 1; return 1;
} }
/* Is parameter non-zero? */
#define PARAM_IS_SET(p) (p) ? 1 : 0
/* Return number of bits assuming 4 * 64 bit size */
static int _get_params_count(uint64_t bits)
{
int r = 0;
r += 2 * hweight32(bits & 0xFFFFFFFF);
r += 2 * hweight32(bits >> 32);
return r;
}
static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major, static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
uint32_t minor, struct load_segment *seg, uint32_t minor, struct load_segment *seg,
@ -2382,25 +2396,11 @@ static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
if ((seg->flags & DM_NOSYNC) || (seg->flags & DM_FORCESYNC)) if ((seg->flags & DM_NOSYNC) || (seg->flags & DM_FORCESYNC))
param_count++; param_count++;
if (seg->region_size) param_count += 2 * (PARAM_IS_SET(seg->region_size) + PARAM_IS_SET(seg->writebehind) +
param_count += 2; PARAM_IS_SET(seg->min_recovery_rate) + PARAM_IS_SET(seg->max_recovery_rate));
if (seg->writebehind) param_count += _get_params_count(seg->rebuilds);
param_count += 2; param_count += _get_params_count(seg->writemostly);
if (seg->min_recovery_rate)
param_count += 2;
if (seg->max_recovery_rate)
param_count += 2;
/* rebuilds is 64-bit */
param_count += 2 * hweight32(seg->rebuilds & 0xFFFFFFFF);
param_count += 2 * hweight32(seg->rebuilds >> 32);
/* rebuilds is 64-bit */
param_count += 2 * hweight32(seg->writemostly & 0xFFFFFFFF);
param_count += 2 * hweight32(seg->writemostly >> 32);
if ((seg->type == SEG_RAID1) && seg->stripe_size) if ((seg->type == SEG_RAID1) && seg->stripe_size)
log_error("WARNING: Ignoring RAID1 stripe size"); log_error("WARNING: Ignoring RAID1 stripe size");