Skip to contentSkip to conversation

WebMin LVM module development

linux-lvm Michael Boman 4 participants 5 messages Dec 6, 2000 – Dec 7, 2000

lore
Share & tools
lore
#0 lore raw

Hi,

for the past week I've been working on a WebMin (http://www.webmin.com)
module for LVM.

I have a few questions I need to get answered as well as I seek people that is willing to try the LVM module out.

My questions are:
- How can I check what PV's are availble to use with a VG. I know the pvscan command, but it takes quite a long while to complete and I wonder if there is any shortcuts to find what PV's that is free to use with a VG.

- I have problem using MD as a PV of my VG, any hints what it can be? <output>

mike:/mnt# vgextend vg_test /dev/md0
vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte
vgextend -- ERROR: no physical volumes usable to extend volume group
"vg_test"
</output>

Seeking bug-hunters and feedback:
I'd like to offer the oppertunity for you guy's (and gal's) that are
living on the edge to try out my WebMin LVM module. It's not fully operational yet (Can only display VG's and assosiated info as well as create VG's), but I am hoping that a early beta release will provide me with enuff feedback to make this a good and useful module to WebMin.

The code is under GNU GPL License version 2 or later, and currently given out on a per-request basis. I nor the company I work for offers no garranty that it wont eat your data etc.. #include <std/disclaimer.txt> as per usual.

Jargon file for the uninformed:
MD = Multiple Devices, software raid.
PV = Physical Volume
PE = Physical Extent
LV = Logical Volume
VG = Volume Group

Best regards
Michael Boman

PS
Sorry for cross-posting here, but I wanted to make sure all relivant
parties got informed.
DS

Signature · 7 lines
"eLINUX  ---  Enabling the Net Economy on Linux"
----------------------------------------------------------
Michael Boman                   eLinux Pte Ltd
Technical Consultant            http://www.elinux.com.sg
[email protected]           Tel:    (65)  227 6180
                                Fax:    (65)  227 5808
----------------------------------------------------------

begin:vcard
n:Boman;Michael
tel;cell:+65 9855 1734
tel;fax:+65 227 5808
tel;work:+65 227 6180
x-mozilla-html:FALSE
url:http://www.elinux.com.sg
org:eLinux Pte Ltd;Technical Division
version:2.1
email;internet:[email protected]
title:Technical Consultant
adr;quoted-printable:;;3 Shenton Way=0D=0A#22-09 Shenton House;Singapore;;068805;Singapore x-mozilla-cpt:;0
fn:Michael Boman
end:vcard

#1 lore raw
Quoted 5 lines · Michael Boman

Hi,

for the past week I've been working on a WebMin (http://www.webmin.com)
module for LVM.

Quoted 8 lines

I have a few questions I need to get answered as well as I seek people that is willing to try the LVM module out.

My questions are:
- How can I check what PV's are availble to use with a VG. I know the pvscan command, but it takes quite a long while to complete and I wonder if there is any shortcuts to find what PV's that is free to use with a VG.

No. pvscan's purpose is to do that.
You probably saw the "-n" option to search for free PVs?

Quoted 8 lines

- I have problem using MD as a PV of my VG, any hints what it can be? <output>

mike:/mnt# vgextend vg_test /dev/md0
vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte
vgextend -- ERROR: no physical volumes usable to extend volume group
"vg_test"
</output>

That's a bug which in 0.9.
There's a fix in 0.8.1 which probaly didn't make it. 0.9.1 should fix this again.

Quoted 20 lines

Seeking bug-hunters and feedback:
I'd like to offer the oppertunity for you guy's (and gal's) that are
living on the edge to try out my WebMin LVM module. It's not fully operational yet (Can only display VG's and assosiated info as well as create VG's), but I am hoping that a early beta release will provide me with enuff feedback to make this a good and useful module to WebMin.

The code is under GNU GPL License version 2 or later, and currently given out on a per-request basis. I nor the company I work for offers no garranty that it wont eat your data etc.. #include <std/disclaimer.txt> as per usual.

Jargon file for the uninformed:
MD = Multiple Devices, software raid.
PV = Physical Volume
PE = Physical Extent
LV = Logical Volume
VG = Volume Group

Quoted 16 lines

Best regards
Michael Boman

PS
Sorry for cross-posting here, but I wanted to make sure all relivant
parties got informed.
DS

Signature · 7 lines
"eLINUX  ---  Enabling the Net Economy on Linux"
----------------------------------------------------------
Michael Boman                   eLinux Pte Ltd
Technical Consultant            http://www.elinux.com.sg
[email protected]           Tel:    (65)  227 6180
                                Fax:    (65)  227 5808
----------------------------------------------------------

Content-Description: Card for Michael Boman

Signature · 12 lines
Regards,
Heinz      -- The LVM guy --

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Heinz Mauelshagen                                 Sistina Software Inc.
Senior Consultant/Developer                       Bartningstr. 12
                                                  64289 Darmstadt
                                                  Germany
[email protected]                           +49 6151 7103 86
                                                       FAX 7103 96
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#2 lore raw
In reply to Michael Boman
Quoted 8 lines · Michael Boman

- I have problem using MD as a PV of my VG, any hints what it can be? <output>

mike:/mnt# vgextend vg_test /dev/md0
vgextend -- INFO: maximum logical volume size is 255.99 Gigabyte
vgextend -- ERROR: no physical volumes usable to extend volume group
"vg_test"
</output>

It's a known problem,
LVM 0.8final does not work
LVM 0.8.1 does work
LVM 0.9 does not again

Tomorrow is holiday in Milan, so i will try to give it a look

Regards,
L.

Signature · 2 lines
Luca Berra -- [email protected]
    Communication Media & Services S.r.l.
#3 lore raw
Quoted 1 line

Tomorrow is holiday in Milan, so i will try to give it a look

hey, what else would you want to do on your holiday :-)

Signature · 3 lines
 Steven Lembark                                   2930 W. Palmer St.
                                                 Chicago, IL  60647
 [email protected]                                   800-762-1582
#4 lore raw

[linux-lvm] lvm 0.9 + raid (Was: WebMin LVM module development)

In reply to Luca Berra
Quoted 3 lines · Luca Berra
Quoted 2 lines · Michael Boman

- I have problem using MD as a PV of my VG, any hints what it can be?

...

Quoted 1 line

Tomorrow is holiday in Milan, so i will try to give it a look

here it is, or so i hope...
i dinna give it thorough testing, but it seems to work for me

comments on the patch:
Makefile.in: just put a version number in the library,
so i can have different versions installed
pv_get_size.c: squashed an old bug that reappeared
vg_read_from_pv.c: it would have failed if pv_read said it was an MD, i also
catch LVM_EPV_READ_PV_EXPORTED, since this is done in other
places also
pv_read_uuidlist.c: same as above, this seems the right thing to me, but now
lvm 0.8 tools dont' work anymore on this vg, 0.8.1 seems to
work ok (?!?)
liblvm.h and vg_remove_dir_and_group_and_nodes.c: this is to work around a probable
kernel bug with lvm and devfs, if the dev/vgXX directory was removed
it was the impossible to fill it again with devices.
I also believe that the kernel should create the lvm devices with devfs but it doesn't.

Regards
L.

Signature · 2 lines
Luca Berra -- [email protected]
    Communication Media & Services S.r.l.
0.9/tools/lib/pv_get_size.c renamed from 0.9/tools/lib/pv_get_size.c.bluca.orig +5 -4
@@ -87,6 +87,7 @@
       goto pv_get_size_end;
    }
 
+   memset ( disk_dev_name, 0, sizeof ( disk_dev_name));
    if ( ( cache_entry = lvm_dir_cache_find ( dev_name)) != NULL) {
       if ( lvm_check_partitioned_dev ( cache_entry->st_rdev) == TRUE) {
          st_rdev = cache_entry->st_rdev -
@@ -96,14 +97,14 @@
             if ( dir_cache[i].st_rdev == st_rdev)
                break;
          }
-      }
+         strncpy ( disk_dev_name, dir_cache[i].dev_name, sizeof ( disk_dev_name) - 1);
+      } else {
+         strncpy ( disk_dev_name, dev_name, sizeof ( disk_dev_name) - 1);
+	  }
    } else {
       ret = -LVM_EPV_GET_SIZE_LVM_DIR_CACHE;
       goto pv_get_size_end;
    }
-
-   memset ( disk_dev_name, 0, sizeof ( disk_dev_name));
-   strncpy ( disk_dev_name, dir_cache[i].dev_name, sizeof ( disk_dev_name) - 1);
 
    first = 1;
    if ( ( pv_handle = open ( disk_dev_name, O_RDONLY)) == -1) {
0.9/tools/lib/Makefile.in renamed from 0.9/tools/lib/Makefile.in.bluca.orig +12 -6
@@ -32,9 +32,11 @@
 include ../tools_and_lib.make.tmpl
 
 ARCHIVE = liblvm.a
+SOV = liblvm.so.0.9.0
+SOM = liblvm.so.0.9
 SO = liblvm.so
 
-ALL_RM = $(ALL_OBJECTS) $(ARCHIVE) $(SO)
+ALL_RM = $(ALL_OBJECTS) $(ARCHIVE) $(SO) $(SOM) $(SOV)
 
 all_this: $(ARCHIVE) $(SO) Makefile
 	@echo ""
@@ -43,15 +45,17 @@
 
 install_this:
 	@echo "*** Installing $(ARCHIVE) and $(SO) in ${prefix}/lib ***"
-	@rm -f ${libdir}/${SO} ${libdir}/$(ARCHIVE);
+	@rm -f ${libdir}/${SO} ${libdir}/${SOV} ${libdir}/${SOM} ${libdir}/$(ARCHIVE);
 	@INSTALL@ -d ${libdir}
-	@INSTALL@ $(ARCHIVE) $(SO) ${libdir}
+	@INSTALL@ $(ARCHIVE) $(SOV) ${libdir}
 	chmod 444 ${libdir}/$(ARCHIVE)
-	chmod 555 ${libdir}/$(SO)
+	chmod 555 ${libdir}/$(SOV)
+	ln -s $(SOV) ${libdir}/${SO}
+	ln -s $(SOV) ${libdir}/${SOM}
 
 remove_this:
 	@echo "*** Removing $(ARCHIVE) and $(SO) in ${prefix}/lib ***"
-	@rm -f ${libdir}/${SO} ${libdir}/$(ARCHIVE);
+	@rm -f ${libdir}/${SO} ${libdir}/${SOV} ${libdir}/${SOM} ${libdir}/$(ARCHIVE);
 
 $(ALL_SOURCES):	liblvm.h $(OTHER_DEP)
 
@@ -64,7 +68,9 @@
 	ranlib $@
 
 $(SO):	$(ALL_OBJECTS)
-	ld -shared -o $(SO) $(ALL_OBJECTS)
+	gcc -shared -Wl,-soname,$(SOM) -o $(SOV) $(ALL_OBJECTS)
+	ln -sf $(SOV) $(SOM)
+	ln -sf $(SOV) $(SO)
 
 clean_this:
 	rm -f $(ALL_RM)
0.9/tools/lib/vg_read_from_pv.c renamed from 0.9/tools/lib/vg_read_from_pv.c.bluca.orig +4 -1
@@ -45,7 +45,9 @@
       goto vg_read_from_pv_end;
    }
 
-   if ( pv_read ( pv_name, &pv_this_ptr, NULL) == 0) {
+   if ( ( ret = pv_read ( pv_name, &pv_this_ptr, NULL)) == 0 ||
+	   ret == -LVM_EPV_READ_MD_DEVICE ||
+	   ret == -LVM_EPV_READ_PV_EXPORTED) {
       /* read the VG info */
       if ( ( pv_handle = open ( pv_name, O_RDONLY)) == -1)
          ret = -LVM_EVG_READ_OPEN;
@@ -53,6 +55,7 @@
                 pv_this_ptr->vg_on_disk.base) ret = -LVM_EVG_READ_LSEEK;
       else if ( read ( pv_handle, &vg_this, sizeof ( vg_this)) != \
                 sizeof ( vg_this)) ret = -LVM_EVG_READ_READ;
+      else ret = 0;
       if ( pv_handle != -1) close ( pv_handle);
    
       if ( ret == 0) {
0.9/tools/lib/liblvm.h renamed from 0.9/tools/lib/liblvm.h.bluca.orig +1 -0
@@ -108,6 +108,7 @@
 #define	LVMTAB_DIR              "/etc/lvmtab.d"	/* storage dir VG data */
 #define	LVMTAB_MINSIZE   ( sizeof ( vg_t) + sizeof ( lv_t) + sizeof ( pv_t))
 #define	LVM_DEV                 "/dev/lvm"
+#define	DEVFS_DEV               ".devfsd"
 #define	VG_BACKUP_DIR           "/etc/lvmconf"
 #define	DISK_NAME_LEN		8
 #define	LV_MIN_NAME_LEN		5
0.9/tools/lib/pv_read_uuidlist.c renamed from 0.9/tools/lib/pv_read_uuidlist.c.bluca.orig +4 -1
@@ -61,7 +61,9 @@
         pv_uuidlist == NULL) {
       ret = -LVM_EPARAM;
    } else {
-      if ( ( ret = pv_read ( pv_name, &pv_this_ptr, NULL)) == 0) {
+      if ( ( ret = pv_read ( pv_name, &pv_this_ptr, NULL)) == 0 ||
+              ret == -LVM_EPV_READ_MD_DEVICE ||
+              ret == -LVM_EPV_READ_PV_EXPORTED) {
          if ( ( pv_handle = open ( pv_name, O_RDONLY)) == -1)
             ret = -LVM_EPV_READ_UUIDLIST_OPEN;
          else if ( lseek ( pv_handle,
@@ -89,6 +91,7 @@
                         memset ( ptr, 0, NAME_LEN);
                      }
                   }
+		  ret = 0;
                }
                for ( i = 0; i < ABS_MAX_PV - 1; i++) {
                   ptr = this_pv_uuidlist + i * NAME_LEN;
0.9/tools/lib/vg_remove_dir_and_group_and_nodes.c renamed from 0.9/tools/lib/vg_remove_dir_and_group_and_nodes.c.bluca.orig +5 -2
@@ -43,11 +43,14 @@
    debug_enter ( "vg_remove_dir_and_group_and_nodes -- CALLED\n");
 #endif
 
-   if ( vg_name != NULL && vg_check_name ( vg_name) == 0) {
+   if ( vg_name == NULL || vg_check_name ( vg_name) < 0) ret = -LVM_EPARAM;
+   /* should be a warning, but i would have to catch it */
+   else if ( access ( LVM_DIR_PREFIX "/" DEVFS_DEV, F_OK) == 0 ) ret = 0;
+   else {
       /* remove the volume group directory */
       sprintf ( buffer, LVM_DIR_PREFIX "%s%c", vg_name, 0);
       ret = lvm_remove_recursive ( buffer);
-   } else ret = -LVM_EPARAM;
+   }
 
 #ifdef DEBUG
    debug_leave ( "vg_remove_dir_and_group_and_nodes -- LEAVING with ret: %d\n",