Remove READ_REQUIRE_RESIZEABLE
cover Remove READ_REQUIRE_RESIZEABLE
The following patchset remove READ_REQUIRE_RESIZEABLE vg_read flag by moving the check inside specific library functions. At the time of vg_read(), we cannot know whether the user will want to resize or not. The check for this flag needs to be in the various functions that actually do the resizing of the VG.
Nightly tests passes and applies cleanly on:
commit 1ed598ada6fabade22c680ef57e3fbd9a608ea91
Author: Dave Wysochanski <[email protected]> Date: Fri Jul 10 21:19:37 2009 +0000
Remove unused code vg_lock_and_read() and related flags.
Author: Dave Wysochanski <[email protected]>
PATCH 1/4 Remove READ_REQUIRE_RESIZEABLE from vgextend by moving check inside vg_extend.
Move the check for the RESIZEABLE flag inside the vg_extend function. When we consolidated the vg locking, reading, and status flag checking, we tied the check for the RESIZEABLE flag to the vg_read() call. The problem with this is you cannot know what other APIs the application my or may not call after a vg_read() call. Thus the READ_REQUIRE_RESIZEABLE flag is not really ideal - ideally we should be checking for this flag on a specific operation, not inside the vg_read() call. This patch moves one check inside the library.
--- lib/metadata/metadata.c | 3 +++ tools/vgextend.c | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-)
lib/metadata/metadata.c +3 -0
@@ -439,6 +439,9 @@ int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)struct physical_volume *pv;struct cmd_context *cmd = vg->cmd; +if (_vg_bad_status_bits (vg,RESIZEABLE_VG )) +return 0 ; +if (!lock_vol (cmd,VG_ORPHANS ,LCK_VG_WRITE )) {log_error ("Can't get lock for orphan PVs" );return 0 ;
tools/vgextend.c +1 -2
@@ -37,8 +37,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) argv++;log_verbose ("Checking for volume group \"%s\"" , vg_name); - vg =vg_read_for_update (cmd, vg_name,NULL , -READ_REQUIRE_RESIZEABLE ); + vg =vg_read_for_update (cmd, vg_name,NULL ,0 );if (vg_read_error (vg)) {vg_release (vg);return ECMD_FAILED ;
Signature · 1 line
1.6.0.6
PATCH 2/4 Refactor vgsplit - move move_pvs_used_by_lv and move_pv inside library.
In the future we may export these functions or something like them in liblvm For now this helps in cleaning up the checks for RESIZEABLE since we can use the internal library function vg_bad_status_bits.
--- lib/metadata/metadata-exported.h | 5 +++ lib/metadata/metadata.c | 66 +++++++++++++++++++++++++++++++++++ tools/vgsplit.c | 70 +------------------------------------ 3 files changed, 73 insertions(+), 68 deletions(-)
lib/metadata/metadata-exported.h +5 -0
@@ -375,6 +375,11 @@ int scan_vgs_for_pvs(struct cmd_context *cmd);int pv_write (struct cmd_context *cmd,struct physical_volume *pv,struct dm_list *mdas,int64_t label_sector);int is_pv (pv_t *pv); +int move_pv (struct volume_group *vg_from,struct volume_group *vg_to, +const char *pv_name); +int move_pvs_used_by_lv (struct volume_group *vg_from, +struct volume_group *vg_to, +const char *lv_name);int is_orphan_vg (const char *vg_name);int is_orphan (const pv_t *pv); int vgs_are_compatible(struct cmd_context *cmd,
lib/metadata/metadata.c +66 -0
72 lines not on this page · raw message
tools/vgsplit.c +2 -68
86 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 3/4 Remove READ_REQUIRE_RESIZEABLE flag from vgsplit.
Remove READ_REQUIRE_RESIZEABLE flag from vgsplit similar to the removal from vgextend. Move the check inside the functions that actually move pvs from one vg structure to another. Should be no functional change.
--- lib/metadata/metadata.c | 10 ++++++++++ tools/vgsplit.c | 6 ++---- 2 files changed, 12 insertions(+), 4 deletions(-)
lib/metadata/metadata.c +10 -0
@@ -70,6 +70,8 @@ static struct physical_volume *_find_pv_in_vg_by_uuid(const struct volume_groupstatic vg_t *_vg_make_handle (struct cmd_context *cmd,struct volume_group *vg,uint32_t failure); +static uint32_t _vg_bad_status_bits (const struct volume_group *vg, +uint32_t status);unsigned long set_pe_align (struct physical_volume *pv,unsigned long data_alignment) {
@@ -287,6 +289,10 @@ int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,return 0 ; } +if (_vg_bad_status_bits (vg_from,RESIZEABLE_VG ) || +_vg_bad_status_bits (vg_to,RESIZEABLE_VG )) +return 0 ; +dm_list_move (&vg_to->pvs, &pvl->list); vg_from->pv_count--;
@@ -319,6 +325,10 @@ int move_pvs_used_by_lv(struct volume_group *vg_from,return 0 ; } +if (_vg_bad_status_bits (vg_from,RESIZEABLE_VG ) || +_vg_bad_status_bits (vg_to,RESIZEABLE_VG )) +return 0 ; + dm_list_iterate_items(lvseg, &lvl->lv->segments) { if (lvseg->log_lv) if (!move_pvs_used_by_lv(vg_from, vg_to,
tools/vgsplit.c +2 -4
@@ -248,8 +248,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)log_verbose ("Checking for volume group \"%s\"" , vg_name_from); - vg_from =vg_read_for_update (cmd, vg_name_from,NULL , -READ_REQUIRE_RESIZEABLE ); + vg_from =vg_read_for_update (cmd, vg_name_from,NULL ,0 );if (vg_read_error (vg_from)) {vg_release (vg_from);return ECMD_FAILED ;
@@ -283,8 +282,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)if (vg_read_error (vg_to) ==FAILED_EXIST ) { existing_vg =1 ;vg_release (vg_to); - vg_to =vg_read_for_update (cmd, vg_name_to,NULL , -READ_REQUIRE_RESIZEABLE ); + vg_to =vg_read_for_update (cmd, vg_name_to,NULL ,0 );if (vg_read_error (vg_to)) {vg_release (vg_to);
Signature · 1 line
1.6.0.6
PATCH 4/4 Remove READ_REQUIRE_RESIZEABLE flag from vg_read() interface - no users.
The checks for RESIZEABLE_VG should now be inside the various functions that have to do such operations.
--- lib/metadata/metadata-exported.h | 1 - lib/metadata/metadata.c | 3 --- 2 files changed, 0 insertions(+), 4 deletions(-)
lib/metadata/metadata-exported.h +0 -1
@@ -104,7 +104,6 @@ struct pv_segment;/* vg_read and vg_read_for_update flags */ #define READ_ALLOW_INCONSISTENT 0x00010000U#define READ_ALLOW_EXPORTED 0x00020000U -#define READ_REQUIRE_RESIZEABLE 0x00040000U/* A meta-flag, useful with toollib for_each_* functions. */ #define READ_FOR_UPDATE 0x00100000U
lib/metadata/metadata.c +0 -3
@@ -2994,9 +2994,6 @@ vg_t *vg_read(struct cmd_context *cmd, const char *vg_name,if (flags &READ_ALLOW_EXPORTED ) status &= ~EXPORTED_VG ; -if (flags &READ_REQUIRE_RESIZEABLE ) - status |=RESIZEABLE_VG ; -return _vg_lock_and_read (cmd, vg_name, vgid, lock_flags, status, flags); }
Signature · 1 line
1.6.0.6
cover Remove READ_REQUIRE_RESIZEABLE
In reply to Dave WysochanskiQuoted 2 lines · Dave Wysochanski
The following patchset remove
READ_REQUIRE_RESIZEABLEvg_readflag by moving the check inside specific library functions.
Ack.
Alasdair