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

Factor out generate_log_name_format().

This commit is contained in:
Alasdair Kergon 2005-08-12 20:02:21 +00:00
parent bfd31e94d5
commit fb9d44daf1
4 changed files with 24 additions and 17 deletions

View File

@ -1,6 +1,6 @@
Version 2.01.15 -
=================================
Factor out adjusted_mirror_region_size().
Factor out adjusted_mirror_region_size() and generate_log_name_format().
Move compose_log_line() into mirror directory.
Factor out _get_library_path().
Don't kill idling clvmd threads.

View File

@ -579,27 +579,13 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
/* FIXME Calculate how many extents needed for the log */
len = strlen(lv_name) + 32;
if (!(log_name = alloca(len))) {
if (!(log_name = alloca(len)) ||
!(generate_log_name_format(vg, lv_name, log_name, len))) {
log_error("log_name allocation failed. "
"Remove new LV and retry.");
return 0;
}
if (lvm_snprintf(log_name, len, "%s_mlog", lv_name) < 0) {
log_error("log_name allocation failed. "
"Remove new LV and retry.");
return 0;
}
if (find_lv_in_vg(vg, log_name)) {
if (lvm_snprintf(log_name, len, "%s_mlog_%%d",
lv_name) < 0) {
log_error("log_name allocation failed. "
"Remove new LV and retry.");
return 0;
}
}
if (!(log_lv = lv_create_empty(vg->fid, log_name, NULL,
VISIBLE_LV | LVM_READ | LVM_WRITE,
lp->alloc, 0, vg))) {

View File

@ -1058,6 +1058,24 @@ int validate_vg_name(struct cmd_context *cmd, const char *vg_name)
return 1;
}
int generate_log_name_format(struct volume_group *vg, const char *lv_name,
char *buffer, size_t size)
{
if (lvm_snprintf(buffer, size, "%s_mlog", lv_name) < 0) {
stack;
return 0;
}
if (find_lv_in_vg(vg, buffer) &&
lvm_snprintf(buffer, size, "%s_mlog_%%d",
lv_name) < 0) {
stack;
return 0;
}
return 1;
}
/*
* Volumes may be zeroed to remove old application data.
*/

View File

@ -94,6 +94,9 @@ int apply_lvname_restrictions(const char *name);
int validate_vg_name(struct cmd_context *cmd, const char *vg_name);
int generate_log_name_format(struct volume_group *vg, const char *lv_name,
char *buffer, size_t size);
int zero_lv(struct cmd_context *cmd, struct logical_volume *lv);
#endif