dev-mornfall-lvmcache - lvmcache: Split off lock cache into a separate unit.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=94d9562bea6d0fa5bc7e919cb34090ffe6b45fd9 Commit: 94d9562bea6d0fa5bc7e919cb34090ffe6b45fd9 Parent: 57795df3652211a0eb05ad924837006327dde02c Author: Petr Rockai <[email protected]> AuthorDate: Mon Feb 18 15:31:50 2013 +0100 Committer: Petr Rockai <[email protected]> CommitterDate: Wed Jun 5 12:37:36 2013 +0200
lvmcache: Split off lock cache into a separate unit.
--- include/.symlinks.in | 1 + lib/Makefile.in | 1 + lib/cache/lvmcache.c | 162 ++++------------------------------------------- lib/cache/lvmcache.h | 7 +-- lib/locking/lockcache.c | 156 +++++++++++++++++++++++++++++++++++++++++++++ lib/locking/lockcache.h | 13 ++++ lib/locking/locking.c | 12 +++- lib/metadata/metadata.c | 5 +- 8 files changed, 195 insertions(+), 162 deletions(-)
include/.symlinks.in +1 -0
@@ -32,6 +32,7 @@ @top_srcdir@/lib/format_text/text_import.h @top_srcdir@/lib/label/label.h @top_srcdir@/lib/locking/locking.h + at top_srcdir@/lib/locking/lockcache.h @top_srcdir@/lib/log/log.h @top_srcdir@/lib/log/lvm-logging.h @top_srcdir@/lib/metadata/lv.h
lib/Makefile.in +1 -0
@@ -81,6 +81,7 @@ SOURCES =\ locking/file_locking.c \ locking/locking.c \ locking/no_locking.c \ + locking/lockcache.c \ log/log.c \ metadata/lv.c \ metadata/lv_manip.c \
lib/cache/lvmcache.c +12 -150
248 lines not on this page · raw message
lib/cache/lvmcache.h +1 -6
@@ -60,10 +60,7 @@ int lvmcache_update_vgname_and_id(struct lvmcache_info *info, const char *vgname, const char *vgid, uint32_t vgstatus, const char *hostname);int lvmcache_update_vg (struct volume_group *vg,unsigned precommitted); - -void lvmcache_lock_vgname (const char *vgname,int read_only); -void lvmcache_unlock_vgname (const char *vgname); -int lvmcache_verify_lock_order (const char *vgname); +void lvmcache_update_lock_state (const char *vgname,int locked);/* Queries */ const struct format_type *lvmcache_fmt_from_vgname (struct cmd_context *cmd,const char *vgname,const char *vgid,unsigned revalidate_labels);
@@ -82,8 +79,6 @@ const char *lvmcache_pvid_from_devname(struct cmd_context *cmd, const char *dev_name);char *lvmcache_vgname_from_pvid (struct cmd_context *cmd,const char *pvid);const char *lvmcache_vgname_from_info (struct lvmcache_info *info); -int lvmcache_vgs_locked (void ); -int lvmcache_vgname_is_locked (const char *vgname);void lvmcache_seed_infos_from_lvmetad (struct cmd_context *cmd);
lib/locking/lockcache.c new file +156 -0
156 lines not on this page · raw message
lib/locking/lockcache.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef _LVM_LOCKCACHE_H +#define _LVM_LOCKCACHE_H + +#include "locking.h" + +int lockcache_vgname_is_locked (const char *vgname); +void lockcache_lock_vgname (const char *vgname,int read_only); +void lockcache_unlock_vgname (const char *vgname); +int lockcache_vgs_locked (void ); +int lockcache_verify_lock_order (const char *vgname); +void lockcache_destroy (void ); + +#endif
lib/locking/locking.c +8 -4
@@ -22,6 +22,7 @@#include "memlock.h" #include "defaults.h" #include "lvmcache.h" +#include "lockcache.h" #include <assert.h> #include <signal.h>
@@ -381,8 +382,10 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,if ((ret = _locking.lock_resource (cmd, resource, flags))) {if (lck_scope ==LCK_VG && !(flags &LCK_CACHE )) { -if (lck_type !=LCK_UNLOCK ) -lvmcache_lock_vgname (resource, lck_type ==LCK_READ ); +if (lck_type !=LCK_UNLOCK ) { +lockcache_lock_vgname (resource, lck_type ==LCK_READ ); +lvmcache_update_lock_state (resource,1 ); + }dev_reset_error_count (cmd); }
@@ -392,7 +395,8 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,/* If unlocking, always remove lock from lvmcache even if operation failed. */ if (lck_scope ==LCK_VG && !(flags &LCK_CACHE ) && lck_type ==LCK_UNLOCK ) { -lvmcache_unlock_vgname (resource); +lockcache_unlock_vgname (resource); +lvmcache_update_lock_state (resource,0 );if (!ret)_update_vg_lock_count (resource, flags); }
@@ -436,7 +440,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)/* VG locks alphabetical, ORPHAN lock last */ if ((lck_type !=LCK_UNLOCK ) && !(flags &LCK_CACHE ) && - !lvmcache_verify_lock_order (vol)) + !lockcache_verify_lock_order (vol)) return_0;/* Lock VG to change on-disk metadata. */
lib/metadata/metadata.c +3 -2
@@ -28,6 +28,7 @@#include "activate.h" #include "display.h" #include "locking.h" +#include "lockcache.h" #include "archiver.h" #include "defaults.h"
@@ -2669,7 +2670,7 @@ int vg_commit(struct volume_group *vg) {int cache_updated =0 ; -if (!lvmcache_vgname_is_locked (vg->name)) { +if (!lockcache_vgname_is_locked (vg->name)) {log_error (INTERNAL_ERROR "Attempt to write new VG metadata " "without locking %s" , vg->name);return cache_updated;
@@ -3990,7 +3991,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const chareturn NULL ; } - already_locked =lvmcache_vgname_is_locked (vg_name); + already_locked =lockcache_vgname_is_locked (vg_name);if (!already_locked && !(misc_flags &READ_WITHOUT_LOCK ) && !lock_vol (cmd, vg_name, lock_flags)) {