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

lvresize: fix regression when resizing with fs

When 'lvresize -r' is used to resize the volume, it's valid to
resize even to the same size of an LV, as the command then runs
fs-resize utility to eventually upsize the fs to the current
volume size.

Return code of such command then reflects the return value
of this fs-resize tool.

This fixes the regression introduced when the support
for option --fs was added (2.03.17).
This commit is contained in:
Zdenek Kabelac 2024-10-25 14:44:50 +02:00
parent 43ce78e5c6
commit 5a293968ec

View File

@ -6650,6 +6650,7 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
int is_active = 0; int is_active = 0;
int activated = 0; int activated = 0;
int activated_checksize = 0; int activated_checksize = 0;
int resize_fs = !strncmp(lp->fsopt, "resize", 6);
int status; int status;
int ret = 0; int ret = 0;
@ -6888,9 +6889,10 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
/* /*
* No resizing is needed. * No resizing is needed.
*/ */
if ((main_size_matches && meta_size_matches) || if (!resize_fs &&
(main_size_matches && !lv_meta) || ((main_size_matches && meta_size_matches) ||
(meta_size_matches && !lv_main)) { (main_size_matches && !lv_meta) ||
(meta_size_matches && !lv_main))) {
log_error("No size change."); log_error("No size change.");
return 0; return 0;
} }
@ -7103,11 +7105,18 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
goto end_main; goto end_main;
if (!_lv_resize_volume(lv_main, lp, lp->pvh)) if (!_lv_resize_volume(lv_main, lp, lp->pvh))
goto_out; goto_out;
if (!lp->size_changed) if (!lp->size_changed) {
goto_out; if (!resize_fs)
if (!lv_update_and_reload(lv_top)) goto_out;
goto_out; /* Even when the new volume size does NOT change, command still should resize
log_debug("Resized %s to %u extents.", display_lvname(lv_main), lp->extents); * 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: end_main: