LVM2/lib/metadata metadata-exported.h metadata.c
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski at sourceware.org 2009-06-09 14:29:11
Modified files:
lib/metadata : metadata-exported.h metadata.c
Log message:
Add vg_lock_newname() library function.
Various tools need to check for existence of a VG before doing something (vgsplit, vgrename, vgcreate). Currently we don't have an interface to check for existence, but the existence check is part of the vg_read* call(s). This patch is an attempt to pull out some of that functionality into a separate function, and hopefully simplify our vg_read interface, and move those patches along.
vg_lock_newname() is only concerned about checking whether a vg exists in the system. Unfortunately, we cannot just scan the system, but we must first obtain a lock. Since we are reserving a vgname, we take a WRITE lock on the vgname. Once obtained, we scan the system to ensure the name does not exist. The return codes and behavior is in the function header. You might think of this function as similar to an open() call with O_CREAT and O_EXCL flags (returns failure with -EEXIST if file already exists).
NOTE: I think including the word "lock" in the function name is important, as it clearly states the function obtains a lock and makes the code more readable, especially when it comes to cleanup / unlocking. The ultimate function name is somewhat open for debate though so later we may rename.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.224&r2=1.225
lib/metadata/metadata-exported.h +3 -0
@@ -127,6 +127,8 @@#define FAILED_RESIZEABLE 0x00000020U#define FAILED_CLUSTERED 0x00000040U#define FAILED_ALLOCATION 0x00000080U +#define FAILED_EXIST 0x00000100U +#define SUCCESS 0x00000000U/* Ordered list - see lv_manip.c */ typedef enum {
@@ -401,6 +403,7 @@const char *vgid, uint32_t lock_flags, uint32_t status_flags, uint32_t misc_flags); +uint32_t vg_lock_newname (struct cmd_context *cmd,const char *vgname);/* * Return a handle to VG metadata.
lib/metadata/metadata.c +46 -0
52 lines not on this page · raw message
Quoted 6 lines · wysochanski at sourceware.org
Various tools need to check for existence of a VG before doing something (vgsplit, vgrename, vgcreate). Currently we don't have an interface to check for existence, but the existence check is part of the vg_read* call(s). This patch is an attempt to pull out some of that functionality into a separate function, and hopefully simplify our
vg_readinterface, and move those patches along.
I must have missed the patches on lvm-devel? Anyway, the tool patches create conflicts with the vg_read patches that are pending for months. Could people *please* stop changing conflicting parts of the code (see also Milan's patch that changes the recovery code which conflicts with vg_read)? You can perfectly fine create patches on top of the vg_read changes if they obviously overlap...
Alternatively, we could of course discard the vg_read patches, but I haven't seen any NAKs yet...
(I guess you may consider this to be a NAK for the related commits, until the situation is resolved somehow...)
Signature · 6 lines
Peter Rockai | me()mornfall!net | prockai()redhat!com
http://blog.mornfall.net | http://web.mornfall.net
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
-- Blair P. Houghton on the subject of C program indentation