Skip to contentSkip to conversation

A problem in LVM1 kernel code lvm.c::lvm_do_vg_create()

linux-lvm more.zeng 1 participant 2 messages Sep 25, 2006 – Sep 27, 2006

lore
Share & tools
lore

more.zeng

author
#0 lore raw

Dear LVM guys,

I find an issue in the LVM1 kernel code for function lvm.c::lvm_do_vg_create():

In the original code, the vg_count will be increased only when this function is executed successfully. But I think the vg_count should be increased after the variable vg[VG_CHR(minor)] is updated. Given the reason that after the variable vg[VG_CHR(minor)] is updated, for any failure case, lvm_do_vg_create() will always call lvm_do_vg_remove() that will decrease the vg_count. So the vg_count should be increased first before any call for lvm_do_vg_remove().

This issue did exist for our product for our LV sometimes will fail to start (corrupt snapshot). Please give me the confirmation that the above is really an issue and the following diff can resolve this issue (from the latest LVM1 CVS code), thanks.

Best regards,

More

Index: lvm.c

===================================================================

RCS file: /cvs/lvm/LVM/kernel/lvm.c,v

retrieving revision 1.81

diff -c -r1.81 lvm.c

*** lvm.c 5 Mar 2003 11:37:16 -0000 1.81

--- lvm.c 25 Sep 2006 09:57:26 -0000

***************

*** 1802,1807 ****

--- 1802,1809 ----

        vg[VG_CHR(minor)] = vg_ptr;

+ vg_count++;

+

        /* get the physical volume structures */

        vg_ptr->pv_act = vg_ptr->pv_cur = 0;

        for (p = 0; p < vg_ptr->pv_max; p++) {

***************

*** 1870,1877 ****

        vfree(snap_lv_ptr);

- vg_count++;

-

        MOD_INC_USE_COUNT;

--- 1872,1877 ----

author
#1 lore raw

Can anyone have a view of the following issue in the LVM1 kernel code? Very thanks for any comment.

Best regards,

More

_____

From: [email protected] [mailto:[email protected]] On Behalf Of more.zeng
Sent: 2006年9月25日 18:24
To: [email protected]
Subject: [linux-lvm] A problem in LVM1 kernel code lvm.c::lvm_do_vg_create()

Dear LVM guys,

I find an issue in the LVM1 kernel code for function lvm.c::lvm_do_vg_create():

In the original code, the vg_count will be increased only when this function is executed successfully. But I think the vg_count should be increased after the variable vg[VG_CHR(minor)] is updated. Given the reason that after the variable vg[VG_CHR(minor)] is updated, for any failure case, lvm_do_vg_create() will always call lvm_do_vg_remove() that will decrease the vg_count. So the vg_count should be increased first before any call for lvm_do_vg_remove().

This issue did exist for our product for our LV sometimes will fail to start (corrupt snapshot). Please give me the confirmation that the above is really an issue and the following diff can resolve this issue (from the latest LVM1 CVS code), thanks.

Best regards,

More

Index: lvm.c

===================================================================

RCS file: /cvs/lvm/LVM/kernel/lvm.c,v

retrieving revision 1.81

diff -c -r1.81 lvm.c

*** lvm.c 5 Mar 2003 11:37:16 -0000 1.81

--- lvm.c 25 Sep 2006 09:57:26 -0000

***************

*** 1802,1807 ****

--- 1802,1809 ----

        vg[VG_CHR(minor)] = vg_ptr;

+ vg_count++;

+

        /* get the physical volume structures */

        vg_ptr->pv_act = vg_ptr->pv_cur = 0;

        for (p = 0; p < vg_ptr->pv_max; p++) {

***************

*** 1870,1877 ****

        vfree(snap_lv_ptr);

- vg_count++;

-

        MOD_INC_USE_COUNT;

--- 1872,1877 ----