LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2009-09-02 21:34:11
Modified files:
. : WHATS_NEW lib/cache : lvmcache.c lvmcache.h lib/locking : locking.c locking.h
Log message:
Enforce an alphabetical lock ordering for vgname locks.
Add a new constraint that vgname locks must be obtained in alphabetical order. At this point, we have test coverage for the 3 commands affected - vgsplit, vgmerge, and vgrename. Tests have been updated to cover these commands. Going forward any command or library call that must obtain more than one vgname lock must do so in alphabetical order. Future patches will update lvm2app to enforce this ordering.
Author: Dave Wysochanski <[email protected]>
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1252&r2=1.1253
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.50&r2=1.51
WHATS_NEW +2 -0
@@ -1,5 +1,7 @@ Version 2.02.52 - ================================= + Enforce an alphabetical lock ordering for vgname locks. + Refactor vgsplit, vgmerge, and vgrename to obey vgname ordering rules. Implement write lock prioritisation for file locking and make it default. Fix clogd build direcory. Drop unrequired clogd Makefile.
lib/cache/lvmcache.c +40 -1
53 lines not on this page · raw message
lib/cache/lvmcache.h +1 -0
@@ -84,6 +84,7 @@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);/* Queries */ const struct format_type *fmt_from_vgname (const char *vgname,const char *vgid);
lib/locking/locking.c +6 -0
@@ -387,6 +387,12 @@if (!_blocking_supported ||vgs_locked ()) flags |=LCK_NONBLOCK ; +if (vol[0 ] !='#' && + ((flags &LCK_TYPE_MASK ) !=LCK_UNLOCK ) && + (!(flags &LCK_CACHE )) && + !lvmcache_verify_lock_order (vol)) +return 0 ; +/* Lock VG to change on-disk metadata. */ /* If LVM1 driver knows about the VG, it can't be accessed. */ if (!check_lvm1_vg_inactive (cmd, vol))
lib/locking/locking.h +2 -0
@@ -34,6 +34,8 @@* Use VG_GLOBAL as a global lock and to wipe the internal cache. * char *vol holds volume group name. * Set the LCK_CACHE flag to invalidate 'vol' in the internal cache. +* If more than one lock needs to be held simultaneously, they must be +* acquired in alphabetical order of 'vol' (to avoid deadlocks). * * LCK_LV: * Lock/unlock an individual logical volume