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

lvmlockd: zero extended lvmlock LV

After the internal lvmlock LV (holding sanlock leases) is
extended to hold more leases, it needs to be zeroed.
sanlock expects to see either zeroed blocks or blocks
initialized with leases.
This commit is contained in:
David Teigland 2017-08-15 11:53:21 -05:00
parent 43305ae8da
commit df5c296426

View File

@ -365,6 +365,9 @@ static int _remove_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg)
static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg, int extend_mb)
{
struct device *dev;
char path[PATH_MAX];
uint64_t old_size_bytes, new_size_bytes;
struct logical_volume *lv = vg->sanlock_lv;
struct lvresize_params lp = {
.sign = SIGN_NONE,
@ -374,12 +377,49 @@ static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg,
.force = 1,
};
old_size_bytes = lv->size * SECTOR_SIZE;
if (!lv_resize(lv, &lp, &vg->pvs)) {
log_error("Extend LV %s to size %s failed.",
log_error("Extend sanlock LV %s to size %s failed.",
display_lvname(lv), display_size(cmd, lp.size));
return 0;
}
new_size_bytes = lv->size * SECTOR_SIZE;
if (dm_snprintf(path, sizeof(path), "%s/mapper/%s-%s", lv->vg->cmd->dev_dir,
lv->vg->name, lv->name) < 0) {
log_error("Extend sanlock LV %s name too long - extended size not zeroed.",
display_lvname(lv));
return 0;
}
log_debug("Extend sanlock LV zeroing blocks from offset " FMTu64 " bytes len %u bytes",
old_size_bytes, (uint32_t)(new_size_bytes - old_size_bytes));
log_print("Zeroing %u MiB on extended internal lvmlock LV...", extend_mb);
if (!(dev = dev_cache_get(path, NULL))) {
log_error("Extend sanlock LV %s cannot find device.", display_lvname(lv));
return 0;
}
if (!dev_open_quiet(dev)) {
log_error("Extend sanlock LV %s cannot open device.", display_lvname(lv));
return 0;
}
if (!dev_set(dev, old_size_bytes, new_size_bytes - old_size_bytes, 0)) {
log_error("Extend sanlock LV %s cannot zero device.", display_lvname(lv));
dev_close_immediate(dev);
return 0;
}
dev_flush(dev);
if (!dev_close_immediate(dev))
stack;
return 1;
}