mirror of
git://sourceware.org/git/lvm2.git
synced 2024-10-26 08:55:06 +03:00
Compare commits
22 Commits
89f904c13f
...
c7cc527610
Author | SHA1 | Date | |
---|---|---|---|
|
c7cc527610 | ||
|
95bfcd8118 | ||
|
708435d187 | ||
|
034b6a262c | ||
|
143545a08c | ||
|
c8a8c7286f | ||
|
5a293968ec | ||
|
43ce78e5c6 | ||
|
aa0200c3ff | ||
|
40010e3eb8 | ||
|
ebc5c0cb1d | ||
|
0fbcb3b308 | ||
|
5ec8f744d0 | ||
|
ea4daeb28e | ||
|
1363a5ffb2 | ||
|
5a3375f958 | ||
|
edfa4955d8 | ||
|
a5e3f0e6dd | ||
|
f61572eef2 | ||
|
87f68f443c | ||
|
7d48c1f6e3 | ||
|
188dd3c357 |
@ -1,5 +1,6 @@
|
||||
Version 2.03.28 -
|
||||
==================
|
||||
Restore fs resize call for lvresize -r on the same size LV (2.03.17).
|
||||
Correct off-by-one devicesfile backup counting.
|
||||
Replace use of dm_hash with radix_tree for lv names and uuids.
|
||||
Refactor vg_validate with uniq_insert and better use of CPU caches.
|
||||
|
@ -631,7 +631,7 @@ static inline int lm_is_running_sanlock(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t lv_size_bytes);
|
||||
static inline int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t lv_size_bytes)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -1418,7 +1418,8 @@ static struct dm_config_value *_clone_config_value(struct dm_pool *mem,
|
||||
|
||||
if (v->type == DM_CFG_STRING) {
|
||||
if (!(new_cv = _create_str_value(mem, v->v.str, strlen(v->v.str)))) {
|
||||
|
||||
log_error("Failed to clone string config value.");
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (!(new_cv = _create_value(mem))) {
|
||||
|
@ -1325,23 +1325,26 @@ int dm_devs_cache_update(void)
|
||||
if (_cache.dm_devs) {
|
||||
/* Compare existing cached list with a new one.
|
||||
* When there is any mismatch, just rebuild whole cache */
|
||||
l = dm_list_first(dm_devs_new);
|
||||
dm_list_iterate_items(dm_dev, _cache.dm_devs) {
|
||||
dm_dev_new = dm_list_item(l, struct dm_active_device);
|
||||
if ((dm_dev->devno != dm_dev_new->devno) ||
|
||||
strcmp(dm_dev->uuid, dm_dev_new->uuid)) {
|
||||
log_debug_cache("Mismatching UUID or devno found %s %lu %s %lu",
|
||||
dm_dev->uuid, dm_dev->devno,
|
||||
dm_dev_new->uuid, dm_dev_new->devno);
|
||||
cache_changed = 1;
|
||||
break;
|
||||
if ((l = dm_list_first(dm_devs_new))) {
|
||||
dm_list_iterate_items(dm_dev, _cache.dm_devs) {
|
||||
dm_dev_new = dm_list_item(l, struct dm_active_device);
|
||||
if ((dm_dev->devno != dm_dev_new->devno) ||
|
||||
strcmp(dm_dev->uuid, dm_dev_new->uuid)) {
|
||||
log_debug_cache("Mismatching UUID or devno found %s %u:%u %s %u:%u.",
|
||||
dm_dev->uuid, MAJOR(dm_dev->devno), MINOR(dm_dev->devno),
|
||||
dm_dev_new->uuid, MAJOR(dm_dev_new->devno), MINOR(dm_dev_new->devno));
|
||||
cache_changed = 1;
|
||||
break;
|
||||
}
|
||||
if (!(l = dm_list_next(dm_devs_new, l))) {
|
||||
if (dm_list_next(_cache.dm_devs, &dm_dev->list))
|
||||
cache_changed = 1; /* old cached list still with entries */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(l = dm_list_next(dm_devs_new, l))) {
|
||||
if (dm_list_next(_cache.dm_devs, &dm_dev->list))
|
||||
cache_changed = 1; /* old cached list still with entries */
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
cache_changed = 1;
|
||||
|
||||
if (!cache_changed) {
|
||||
log_debug_cache("Preserving DM cache.");
|
||||
dm_device_list_destroy(&dm_devs_new);
|
||||
|
@ -611,7 +611,7 @@ static int _has_gpt_partition_table(struct device *dev)
|
||||
sz_entry = le32_to_cpu(gpt_header.sz_part_entry);
|
||||
|
||||
for (i = 0; i < nr_entries; i++) {
|
||||
if (!dev_read_bytes(dev, entries_start + i * sz_entry,
|
||||
if (!dev_read_bytes(dev, entries_start + (uint64_t)i * sz_entry,
|
||||
sizeof(gpt_part_entry), &gpt_part_entry))
|
||||
return_0;
|
||||
|
||||
@ -1005,8 +1005,8 @@ int fs_get_blkid(const char *pathname, struct fs_info *fsi)
|
||||
fsi->fs_last_byte = fssize;
|
||||
|
||||
/*
|
||||
* For swap, there's no FSLASTBLOCK reported by blkid. We do have FSSIZE reported though.
|
||||
* The last block is then calculated as:
|
||||
* For swap, FSLASTBLOCK is reported by blkid since v2.41 so use that directly.
|
||||
* Otherwise, we do have FSSIZE reported since v2.39. Then. then last block is calculated as:
|
||||
* FSSIZE (== size of the usable swap area) + FSBLOCKSIZE (== size of the swap header)
|
||||
*/
|
||||
if (!strcmp(fsi->fstype, "swap"))
|
||||
|
@ -1359,7 +1359,7 @@ static void devices_file_backup(struct cmd_context *cmd, char *fc, char *fb, tim
|
||||
{
|
||||
struct dirent *de;
|
||||
struct dirent **namelist = NULL;
|
||||
DIR *dir;
|
||||
DIR *dir = NULL;
|
||||
FILE *fp = NULL;
|
||||
struct tm *tm;
|
||||
char dirpath[PATH_MAX];
|
||||
@ -1512,7 +1512,7 @@ out:
|
||||
if (fp && fclose(fp))
|
||||
stack;
|
||||
|
||||
if (closedir(dir))
|
||||
if (dir && closedir(dir))
|
||||
log_sys_debug("closedir", dirpath);
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ static int _get_pv_idx(const struct formatter *f, const struct physical_volume *
|
||||
|
||||
if (!pv || !radix_tree_lookup(f->pv_idx, &pv, sizeof(pv), &idx)) {
|
||||
log_error(INTERNAL_ERROR "PV name for %s missing in metadata export radix tree.",
|
||||
pv_dev_name(pv));
|
||||
(pv) ? pv_dev_name(pv) : "");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1581,7 +1581,7 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
|
||||
return_0;
|
||||
}
|
||||
|
||||
if (seg_is_thin_pool(seg)) {
|
||||
if (seg_is_thin_pool(seg) && seg_lv(seg, 0)) {
|
||||
/* For some segtypes the size may differ between the segment size and its layered LV
|
||||
* i.e. thin-pool and tdata.
|
||||
*
|
||||
@ -1834,6 +1834,11 @@ int historical_glv_remove(struct generic_logical_volume *glv)
|
||||
*/
|
||||
int lv_remove(struct logical_volume *lv)
|
||||
{
|
||||
if (!lv) {
|
||||
log_error(INTERNAL_ERROR "Cannot remove undefined LV.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lv_is_historical(lv))
|
||||
return historical_glv_remove(lv->this_glv);
|
||||
|
||||
@ -6645,6 +6650,7 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
int is_active = 0;
|
||||
int activated = 0;
|
||||
int activated_checksize = 0;
|
||||
int resize_fs = !strncmp(lp->fsopt, "resize", 6);
|
||||
int status;
|
||||
int ret = 0;
|
||||
|
||||
@ -6883,9 +6889,10 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
/*
|
||||
* No resizing is needed.
|
||||
*/
|
||||
if ((main_size_matches && meta_size_matches) ||
|
||||
(main_size_matches && !lv_meta) ||
|
||||
(meta_size_matches && !lv_main)) {
|
||||
if (!resize_fs &&
|
||||
((main_size_matches && meta_size_matches) ||
|
||||
(main_size_matches && !lv_meta) ||
|
||||
(meta_size_matches && !lv_main))) {
|
||||
log_error("No size change.");
|
||||
return 0;
|
||||
}
|
||||
@ -7098,11 +7105,18 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
goto end_main;
|
||||
if (!_lv_resize_volume(lv_main, lp, lp->pvh))
|
||||
goto_out;
|
||||
if (!lp->size_changed)
|
||||
goto_out;
|
||||
if (!lv_update_and_reload(lv_top))
|
||||
goto_out;
|
||||
log_debug("Resized %s to %u extents.", display_lvname(lv_main), lp->extents);
|
||||
if (!lp->size_changed) {
|
||||
if (!resize_fs)
|
||||
goto_out;
|
||||
/* Even when the new volume size does NOT change, command still should resize
|
||||
* the filesystem, we still run filesystem resize tool to eventually
|
||||
* match the volume size. Return code of command then reflects the result
|
||||
* of such operation thus it's valid to 'lvresize -f -Lsamesize vg/lv' */
|
||||
} else {
|
||||
if (!lv_update_and_reload(lv_top))
|
||||
goto_out;
|
||||
log_debug("Resized %s to %u extents.", display_lvname(lv_main), lp->extents);
|
||||
}
|
||||
|
||||
end_main:
|
||||
|
||||
|
@ -632,7 +632,7 @@ int check_lv_segments_complete_vg(struct logical_volume *lv)
|
||||
}
|
||||
|
||||
if (seg_is_mirrored(seg) && !seg_is_raid(seg) &&
|
||||
seg_type(seg, s) == AREA_LV &&
|
||||
seg_type(seg, s) == AREA_LV && seg_lv(seg, s) &&
|
||||
seg_lv(seg, s)->le_count != seg->area_len) {
|
||||
log_error("LV %s: mirrored LV segment %u has "
|
||||
"wrong size %u (should be %u).",
|
||||
|
@ -1671,6 +1671,11 @@ struct logical_volume *find_lv_in_vg_by_lvid(const struct volume_group *vg,
|
||||
struct logical_volume *find_lv(const struct volume_group *vg,
|
||||
const char *lv_name)
|
||||
{
|
||||
if (!vg->lv_names) {
|
||||
struct lv_list *lvl = find_lv_in_vg(vg, lv_name);
|
||||
return lvl ? lvl->lv : NULL;
|
||||
}
|
||||
|
||||
return radix_tree_lookup_ptr(vg->lv_names, lv_name, strlen(lv_name));
|
||||
}
|
||||
|
||||
@ -3023,11 +3028,14 @@ int vg_write(struct volume_group *vg)
|
||||
|
||||
/* Write to each copy of the metadata area */
|
||||
dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) {
|
||||
mda_dev = mda_get_device(mda);
|
||||
|
||||
if (mda->status & MDA_FAILED)
|
||||
continue;
|
||||
|
||||
if (!(mda_dev = mda_get_device(mda))) {
|
||||
log_warn("WARNING: mda without device.");
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* When the scan and vg_read find old metadata in an mda, they
|
||||
* leave the info struct in lvmcache, and leave the mda in
|
||||
|
@ -993,7 +993,11 @@ static int _remove_mirror_images(struct logical_volume *lv,
|
||||
|
||||
/* Mirror with only 1 area is 'in sync'. */
|
||||
if (new_area_count == 1 && is_temporary_mirror_layer(lv)) {
|
||||
detached_log_lv = detach_mirror_log(mirrored_seg);
|
||||
if (!(detached_log_lv = detach_mirror_log(mirrored_seg))) {
|
||||
log_error("Cannot detach mirror log from %s..",
|
||||
display_lvname(mirrored_seg->lv));
|
||||
return 0;
|
||||
}
|
||||
if (!_init_mirror_log(lv->vg->cmd,
|
||||
(struct logical_volume*)lv_lock_holder(mirrored_seg->lv),
|
||||
detached_log_lv,
|
||||
|
@ -6105,9 +6105,13 @@ static int _log_prohibited_option(const struct lv_segment *seg_from,
|
||||
if (seg_from->segtype == new_segtype)
|
||||
log_error("%s not allowed when converting %s LV %s.",
|
||||
opt_str, lvseg_name(seg_from), display_lvname(seg_from->lv));
|
||||
else
|
||||
else if (new_segtype)
|
||||
log_error("%s not allowed for LV %s when converting from %s to %s.",
|
||||
opt_str, display_lvname(seg_from->lv), lvseg_name(seg_from), new_segtype->name);
|
||||
else {
|
||||
log_error(INTERNAL_ERROR "New segtype is not defined.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -104,16 +104,15 @@ static void _daemon_close_descriptor(int fd, unsigned suppress_warnings,
|
||||
* Note: when 'from_fd' is set to -1, unused 'custom_fds' must use same value!
|
||||
*
|
||||
* command: print command name with warning message
|
||||
* suppress_warning: whether to print warning messages
|
||||
* suppress_warnings: whether to print warning messages
|
||||
* above_fd: close all descriptors above this descriptor
|
||||
* custom_fds: preserve descriptors from this set of descriptors
|
||||
*/
|
||||
static int daemon_close_stray_fds(const char *command, int suppress_warning,
|
||||
static int daemon_close_stray_fds(const char *command, int suppress_warnings,
|
||||
int from_fd, const struct custom_fds *custom_fds)
|
||||
{
|
||||
struct rlimit rlim;
|
||||
int fd;
|
||||
unsigned suppress_warnings = 0;
|
||||
pid_t ppid = getppid();
|
||||
char parent_cmdline[64];
|
||||
static const char _fd_dir[] = DEFAULT_PROC_DIR "/self/fd";
|
||||
|
@ -141,6 +141,7 @@ static int _is_open_in_pid(pid_t pid, const char *path)
|
||||
char link_buf[PATH_MAX];
|
||||
DIR *pid_d = NULL;
|
||||
ssize_t len;
|
||||
int df;
|
||||
|
||||
if (pid == getpid())
|
||||
return 0;
|
||||
@ -169,7 +170,8 @@ static int _is_open_in_pid(pid_t pid, const char *path)
|
||||
while ((pid_dp = readdir(pid_d)) != NULL) {
|
||||
if (pid_dp->d_name[0] == '.')
|
||||
continue;
|
||||
if ((len = readlinkat(dirfd(pid_d), pid_dp->d_name, link_buf,
|
||||
if (((df = dirfd(pid_d)) < 0) ||
|
||||
(len = readlinkat(df, pid_dp->d_name, link_buf,
|
||||
(sizeof(link_buf) - 1))) < 0) {
|
||||
log_error("readlink failed for " DEFAULT_PROC_DIR
|
||||
"/%d/fd/.", pid);
|
||||
|
@ -406,7 +406,7 @@ static int _parse_file(struct dm_task *dmt, const char *file)
|
||||
buffer_size = LINE_SIZE;
|
||||
if (!(buffer = malloc(buffer_size))) {
|
||||
log_error("Failed to malloc line buffer.");
|
||||
return 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (fgets(buffer, (int) buffer_size, fp))
|
||||
@ -419,12 +419,11 @@ static int _parse_file(struct dm_task *dmt, const char *file)
|
||||
r = 1;
|
||||
|
||||
out:
|
||||
memset(buffer, 0, buffer_size);
|
||||
#ifndef HAVE_GETLINE
|
||||
free(buffer);
|
||||
#else
|
||||
free(buffer);
|
||||
#endif
|
||||
if (buffer) {
|
||||
memset(buffer, 0, buffer_size);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
if (file && fclose(fp))
|
||||
log_sys_debug("fclose", file);
|
||||
|
||||
|
@ -1418,7 +1418,8 @@ static struct dm_config_value *_clone_config_value(struct dm_pool *mem,
|
||||
|
||||
if (v->type == DM_CFG_STRING) {
|
||||
if (!(new_cv = _create_str_value(mem, v->v.str, strlen(v->v.str)))) {
|
||||
|
||||
log_error("Failed to clone string config value.");
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (!(new_cv = _create_value(mem))) {
|
||||
|
@ -922,6 +922,8 @@ blocks in the array and check for discrepancies
|
||||
(mismatches between mirrors or incorrect parity values).
|
||||
\fBcheck\fP will count but not correct discrepancies.
|
||||
\fBrepair\fP will correct discrepancies.
|
||||
Mind that these synchronization actions are transient and have to be restarted
|
||||
after a system failure/reboot or a configuration change to the RaidLV.
|
||||
See \fBlvs\fP(8) for reporting discrepancies found or repaired.
|
||||
.
|
||||
.HP
|
||||
|
@ -137,11 +137,24 @@ mount "$DM_DEV_DIR/$vg/$lv" "$mount_dir"
|
||||
# so exit 0 test here, if the feature is not present
|
||||
blkid -p "$DM_DEV_DIR/$vg/$lv" | grep FSLASTBLOCK || exit 0
|
||||
|
||||
# existence of FSLASTBLOCK gives assumption on having 'new enough' blkid
|
||||
FSSIZE="$(blkid -p -o udev --match-tag FSSIZE "$DM_DEV_DIR/$vg/$lv")"
|
||||
FSSIZE=${FSSIZE/*=}
|
||||
# lvextend, ext4, active, mounted,
|
||||
df --output=size "$mount_dir" |tee df1
|
||||
lvextend -L+5M $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "25.00m"
|
||||
# here the filesystem should be resize to match 25M and must not fail
|
||||
lvextend -r -L25M $vg/$lv
|
||||
NEW_FSSIZE="$(blkid -p -o udev --match-tag FSSIZE "$DM_DEV_DIR/$vg/$lv")"
|
||||
NEW_FSSIZE=${NEW_FSSIZE/*=}
|
||||
test "$NEW_FSSIZE" -gt "$FSSIZE" ||
|
||||
die "Filesystem should be extended"
|
||||
|
||||
# lvextend, ext4, active, mounted, no --fs setting is same as --fs ignore
|
||||
df --output=size "$mount_dir" |tee df1
|
||||
dd if=/dev/zero of="$mount_dir/zeros1" bs=1M count=8 oflag=direct
|
||||
lvextend -L+10M $vg/$lv
|
||||
lvextend -L+5M $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "30.00m"
|
||||
# with no --fs used, the fs size should be the same
|
||||
df --output=size "$mount_dir" |tee df2
|
||||
@ -661,21 +674,24 @@ lvremove -f $vg
|
||||
lvcreate -n $lv -L 16M $vg
|
||||
mkswap /dev/$vg/$lv
|
||||
|
||||
# lvreduce not allowed if LV size < swap size
|
||||
not lvreduce --fs checksize -L8m $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "16.00m"
|
||||
# FSSIZE reported since util-linux/blkid v2.39 and later only
|
||||
blkid -p "$DM_DEV_DIR/$vg/$lv" | grep FSSIZE && {
|
||||
# lvreduce not allowed if LV size < swap size
|
||||
not lvreduce --fs checksize -L8m $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "16.00m"
|
||||
|
||||
# lvreduce not allowed if LV size < swap size,
|
||||
# even with --fs resize, this is not supported
|
||||
not lvreduce --fs resize $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "16.00m"
|
||||
# lvreduce not allowed if LV size < swap size,
|
||||
# even with --fs resize, this is not supported
|
||||
not lvreduce --fs resize $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "16.00m"
|
||||
|
||||
# lvextend allowed if LV size > swap size
|
||||
lvextend -L32m $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "32.00m"
|
||||
# lvextend allowed if LV size > swap size
|
||||
lvextend -L32m $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "32.00m"
|
||||
|
||||
# lvreduce allowed if LV size == swap size
|
||||
lvreduce -L16m $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "16.00m"
|
||||
# lvreduce allowed if LV size == swap size
|
||||
lvreduce -L16m $vg/$lv
|
||||
check lv_field $vg/$lv lv_size "16.00m"
|
||||
}
|
||||
|
||||
vgremove -ff $vg
|
||||
|
@ -864,6 +864,8 @@ arg(syncaction_ARG, '\0', "syncaction", syncaction_VAL, 0, 0,
|
||||
"(mismatches between mirrors or incorrect parity values).\n"
|
||||
"\\fBcheck\\fP will count but not correct discrepancies.\n"
|
||||
"\\fBrepair\\fP will correct discrepancies.\n"
|
||||
"Mind that these synchronization actions are transient and have to be restarted\n"
|
||||
"after a system failure/reboot or a configuration change to the RaidLV.\n"
|
||||
"See \\fBlvs\\fP(8) for reporting discrepancies found or repaired.\n")
|
||||
|
||||
arg(sysinit_ARG, '\0', "sysinit", 0, 0, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user