master - Remove locking for non-vgs
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ebd147ff244abd7d308ffb3ea8a2121b5f4bc7a3 Commit: ebd147ff244abd7d308ffb3ea8a2121b5f4bc7a3 Parent: 4ce9579099a08e4d3cb0c0805517d3352b487b86 Author: David Teigland <[email protected]> AuthorDate: Fri Jun 8 14:34:50 2018 -0500 Committer: David Teigland <[email protected]> CommitterDate: Fri Jun 8 14:34:50 2018 -0500
Remove locking for non-vgs
Locks for VGs are the only thing that locking.[ch] now handles, so references to other variations can be removed.
--- lib/locking/file_locking.c | 39 ++++++++++++++------------------------- lib/locking/locking.c | 26 +++++--------------------- lib/locking/locking.h | 41 ++++++----------------------------------- 3 files changed, 25 insertions(+), 81 deletions(-)
lib/locking/file_locking.c +14 -25
@@ -45,31 +45,20 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource, {char lockfile[PATH_MAX ]; -switch (flags &LCK_SCOPE_MASK ) { -case LCK_VG : -if (is_orphan_vg (resource) ||is_global_vg (resource)) { -if (dm_snprintf (lockfile,sizeof (lockfile), -"%s/P_%s" , _lock_dir, resource +1 ) <0 ) { -log_error ("Too long locking filename %s/P_%s." , - _lock_dir, resource +1 ); -return 0 ; - } - }else -if (dm_snprintf (lockfile,sizeof (lockfile), -"%s/V_%s" , _lock_dir, resource) <0 ) { -log_error ("Too long locking filename %s/V_%s." , - _lock_dir, resource); -return 0 ; - } - -if (!lock_file (lockfile, flags)) - return_0; -break ; -default : -log_error ("Unrecognised lock scope: %d" , - flags &LCK_SCOPE_MASK ); -return 0 ; - } +if (is_orphan_vg (resource) ||is_global_vg (resource)) { +if (dm_snprintf (lockfile,sizeof (lockfile), +"%s/P_%s" , _lock_dir, resource +1 ) <0 ) { +log_error ("Too long locking filename %s/P_%s." , _lock_dir, resource +1 ); +return 0 ; + } + }else +if (dm_snprintf (lockfile,sizeof (lockfile),"%s/V_%s" , _lock_dir, resource) <0 ) { +log_error ("Too long locking filename %s/V_%s." , _lock_dir, resource); +return 0 ; + } + +if (!lock_file (lockfile, flags)) + return_0;return 1 ; }
lib/locking/locking.c +5 -21
@@ -69,8 +69,7 @@ void reset_locking(void)static void _update_vg_lock_count (const char *resource,uint32_t flags) {/* Ignore locks not associated with updating VG metadata */ -if ((flags &LCK_SCOPE_MASK ) !=LCK_VG || - !strcmp (resource,VG_GLOBAL )) +if (!strcmp (resource,VG_GLOBAL ))return ;if ((flags &LCK_TYPE_MASK ) ==LCK_UNLOCK )
@@ -179,7 +178,6 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const str { char resource[258] __attribute__((aligned(8)));uint32_t lck_type = flags &LCK_TYPE_MASK ; -uint32_t lck_scope = flags &LCK_SCOPE_MASK ;if (!_blocking_supported) flags |=LCK_NONBLOCK ;
@@ -206,7 +204,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const strif (lck_type !=LCK_WRITE ) goto out_hold; -if (cmd->is_activating && (lck_scope ==LCK_VG ) &&strcmp (vol,VG_GLOBAL )) +if (cmd->is_activating &&strcmp (vol,VG_GLOBAL )) goto out_hold; goto out_fail;
@@ -229,7 +227,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const str* refuse write lock requests. */ if (cmd->metadata_read_only) { -if ((lck_type ==LCK_WRITE ) && (lck_scope ==LCK_VG ) &&strcmp (vol,VG_GLOBAL )) { +if ((lck_type ==LCK_WRITE ) &&strcmp (vol,VG_GLOBAL )) {log_error ("Operation prohibited while global/metadata_read_only is set." ); goto out_fail; }
@@ -240,29 +238,15 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const strif (!_lock_vol (cmd, resource, flags)) goto out_fail; -/* -* FIXME: I don't think we need this any more. -* If a real lock was acquired -* perform an immediate unlock unless LCK_HOLD was requested. -*/ - -if ((lck_type ==LCK_UNLOCK ) || (flags &LCK_HOLD )) - goto out_hold; - -if (!_lock_vol (cmd, resource, (flags & ~LCK_TYPE_MASK ) |LCK_UNLOCK )) - return_0; -return 1 ; - - out_hold:/* * FIXME: other parts of the code want to check if a VG is * locked by looking in lvmcache. They shouldn't need to * do that, and we should be able to remove this. */ -if ((lck_scope ==LCK_VG ) && (lck_type !=LCK_UNLOCK )) +if (lck_type !=LCK_UNLOCK )lvmcache_lock_vgname (resource, lck_type ==LCK_READ ); -else if ((lck_scope ==LCK_VG ) && (lck_type ==LCK_UNLOCK )) +else if (lck_type ==LCK_UNLOCK )lvmcache_unlock_vgname (resource);/* FIXME: we shouldn't need to keep track of this either. */
lib/locking/locking.h +6 -35
69 lines not on this page · raw message