clvmd: try to refresh device cache on the first failure
PATCH 1/1 clvmd: try to refresh device cache on the first failure
Sometimes, the device cache in clvmd could be out of date. "clvmd -R" is invented for this issue. However, to run "clvmd -R" manually is not convenient, because it's hard to predict when device change would happen.
This patch gives another try after refreshing the device cache. In normal, it doesn't cause any side-effect. In case of the issue above, it's worth a retry.
--- daemons/clvmd/lvm-functions.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
daemons/clvmd/lvm-functions.c +10 -1
@@ -507,11 +507,14 @@ const char *do_lock_query(char *resource)int do_lock_lv (unsigned char command,unsigned char lock_flags,char *resource) {int status =0 ; +int do_refresh =0 ;DEBUGLOG ("do_lock_lv: resource '%s', cmd = %s, flags = %s, critical_section = %d\n" , resource,decode_locking_cmd (command),decode_flags (lock_flags),critical_section ()); -if (!cmd->initialized.config ||config_files_changed (cmd)) { +again: +if (!cmd->initialized.config ||config_files_changed (cmd) + || do_refresh) {/* Reinitialise various settings inc. logging, filters */ if (do_refresh_cache ()) {log_error ("Updated config file invalid. Aborting." );
@@ -577,6 +580,12 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)init_test (0 );pthread_mutex_unlock (&lvm_lock); +/* Try again in case device cache is stale */ +if (status ==EIO && !do_refresh) { + do_refresh =1 ; + goto again; + } +DEBUGLOG ("Command return is %d, critical_section is %d\n" , status,critical_section ());return status; }
Signature · 1 line
2.10.2
PATCH 1/1 clvmd: try to refresh device cache on the first failure
Dne 24.5.2017 v 10:45 Eric Ren napsal(a):
Quoted 5 lines
Sometimes, the device cache in clvmd could be out of date. "clvmd -R" is invented for this issue. However, to run "clvmd -R" manually is not convenient, because it's hard to predict when device change would happen.
Hi
Looking at the patch header - it doesn't really look like solution for clustered problem clvmd cannot be resolve out-of-sync trouble of your cluster
- it'd be likely masking serious problems elsewhere.
So could you please start with regular trouble report first - i.e. what do you mean by 'sometimes' ???
Regard
Zdene
PATCH 1/1 clvmd: try to refresh device cache on the first failure
Hi!
Quoted 7 lines · Zdenek Kabelac
Dne 24.5.2017 v 10:45 Eric Ren napsal(a):
Quoted 5 lines
Sometimes, the device cache in clvmd could be out of date. "clvmd -R" is invented for this issue. However, to run "clvmd -R" manually is not convenient, because it's hard to predict when device change would happen.
Quoted 5 lines
Hi
Looking at the patch header - it doesn't really look like solution for clustered problem clvmd cannot be resolve out-of-sync trouble of your cluster - it'd be likely masking serious problems elsewhere.
Sorry, I should send this one as RFC instead:-)
Quoted 3 lines
So could you please start with regular trouble report first - i.e. what do you mean by 'sometimes' ???
This issue was first reported here:
https://www.redhat.com/archives/lvm-devel/2017-May/msg00058.html
I also record one way how to reproduce:
https://asciinema.org/a/c62ica4ptxe94nw2s593yto4i
By "sometimes", I meant the time when the device cache in clvmd is not updated.
It turns out I'm wrong in understanding the root cause of this problem, after discussion with Alasdair on IRC.
After I set "obtain_device_list_from_udev = 0" in lvm.conf, the locking error disappeared, which means udev
DB is not sync with device changes - MD device, isscsi device according to my test.
"
[root at centos1 loopdevs]# vgchange -ay testvg
Error locking on node 1: Volume group for uuid not found:
wYiWFAj64kucp3e7lgC5m9xtDGFNfwA82tsvS3TzuhXiiLWMknlNpBw1yf5YfVjr
0 logical volume(s) in volume group "testvg" now active
[root at centos1 loopdevs]# vi /etc/lvm/lvm.conf
[root at centos1 loopdevs]# vgchange -ay testvg
1 logical volume(s) in volume group "testvg" now active
"
So, I was working on the wrong direction. Thanks for your guys' help!
Regards,
Eric
Quoted 10 lines
Regard
Zdene
Signature · 3 lines
lvm-devel mailing list lvm-devel at redhat.com https://www.redhat.com/mailman/listinfo/lvm-devel
PATCH 1/1 clvmd: try to refresh device cache on the first failure
Hi Zdenek,
Quoted 23 lines · Eric Ren
Hi!
Quoted 5 lines · Zdenek Kabelac
Hi
Looking at the patch header - it doesn't really look like solution for clustered problem clvmd cannot be resolve out-of-sync trouble of your cluster - it'd be likely masking serious problems elsewhere.
Sorry, I should send this one as RFC instead:-)
Quoted 3 lines
So could you please start with regular trouble report first - i.e. what do you mean by 'sometimes' ???
This issue was first reported here:
https://www.redhat.com/archives/lvm-devel/2017-May/msg00058.htmlI also record one way how to reproduce:
https://asciinema.org/a/c62ica4ptxe94nw2s593yto4iBy "sometimes", I meant the time when the device cache in clvmd is not updated.
Quoted 6 lines
It turns out I'm wrong in understanding the root cause of this problem, after discussion with Alasdair on IRC.
After I set "obtain_device_list_from_udev= 0" in lvm.conf, the locking error disappeared, which means udev
DB is not sync with device changes - MD device, isscsi device according to my test.
I was cheated by setting "obtain_device_list_from_udev = 0", because in daemons/clvmd/lvm-functions.c :do_lock_lv()
{
if (!cmd->initialized.config || config_files_changed(cmd)) /*
lvm.conf is changed when I firstly set obtain_device_list_from_udev */
do_refresh_cache(); /* refresh device cache and metadata */
}I attached a patch trying to fix this issue. Yes, this patch looks not neat. But, as of now, it's the best one I can think of. Welcome review and feedback from you:-P
Regards,
Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-pvscan-device-cache-in-clvmd-is-not-refreshed-as-nee.patch
Type: text/x-patch
Size: 3234 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20170531/46a3478e/attachment.bin>
PATCH 1/1 clvmd: try to refresh device cache on the first failure
Dne 31.5.2017 v 07:37 Eric Ren napsal(a):
Quoted 42 lines
Hi Zdenek,
Quoted 20 lines · Eric Ren
Hi!
Quoted 5 lines · Zdenek Kabelac
Hi
Looking at the patch header - it doesn't really look like solution for clustered problem clvmd cannot be resolve out-of-sync trouble of your cluster - it'd be likely masking serious problems elsewhere.
Sorry, I should send this one as RFC instead:-)
Quoted 3 lines
So could you please start with regular trouble report first - i.e. what do you mean by 'sometimes' ???
This issue was first reported here:
https://www.redhat.com/archives/lvm-devel/2017-May/msg00058.htmlI also record one way how to reproduce:
https://asciinema.org/a/c62ica4ptxe94nw2s593yto4iQuoted 8 lines
By "sometimes", I meant the time when the device cache in clvmd is not updated.
It turns out I'm wrong in understanding the root cause of this problem, after discussion with Alasdair on IRC.
After I set "obtain_device_list_from_udev= 0" in lvm.conf, the locking error disappeared, which means udev
DB is not sync with device changes - MD device, isscsi device according to my test.I was cheated by setting "
obtain_device_list_from_udev= 0", because indaemons/clvmd/lvm-functions.c:do_lock_lv(){ if (!cmd->initialized.config || config_files_changed(cmd)) /* lvm.conf is changed when I firstly set obtain_device_list_from_udev */ do_refresh_cache(); /* refresh device cache and metadata */ }
Quoted 3 lines
I attached a patch trying to fix this issue. Yes, this patch looks not neat. But, as of now, it's the best one I can think of.
Welcome review and feedback from you:-P
Hi Eric
Your solution is still likely not a valid fix for your problem.
Targeted 'standard' case on modern udev-based system is - user is running lvm2 with valid udevDB, thus 'obtain_device_list_from_udev = 1' works.
It's very bad idea to 'bypass' udev and run on system with udev and not having udevDB state reflecting reality of your system.
So looking at RHEL6 'doc' for clmvd:
When you normally add 'device' on system when obtain is 0 (i.e. old RHEL6 case with 'not so good udev') - admin is supposed to manually run 'vgscan'. The reason here is very simple - older system had some troubles with 'udev' DB validity - and the most 'fair' solution is to let admin decide when he really needs update the state. Doing so behind his back autonomously might significantly reduce performance of clvmd caching - since with frequent udev watch rule clvmd would be scanning permanently.
So back to your case - I'm not sure why do you still focusing on hacking clvmd where your main effort should be put into having 'udev' usable.
Once you get 'udev' working properly - you can start to use obtain.. == 1.
Then you run your: 'mdadm --assemble...'
Then likely 'udevadm settle' (as unfortunately mdadm is NOT cooperating with udev - so to be sure you md0 is known in udevDB it's ATM upto admin to wait to be sure - complains about this should go to mdadm 'playground :)).
Then you run 'vgchange -ay' - and clvmd should read devs from udev and see
it and activate it.
So where in the above steps you see/have a problem?
Clvmd really can't be used to hack around bugs in other subsystems - it will simply not work too well..
Regards
Zdenek
PATCH 1/1 clvmd: try to refresh device cache on the first failure
Hi Zdenek,
Quoted 68 lines · Zdenek Kabelac
Dne 31.5.2017 v 07:37 Eric Ren napsal(a):
Quoted 41 lines
Hi Zdenek,
Quoted 20 lines · Eric Ren
Hi!
Quoted 5 lines · Zdenek Kabelac
Hi
Looking at the patch header - it doesn't really look like solution for clustered problem clvmd cannot be resolve out-of-sync trouble of your cluster - it'd be likely masking serious problems elsewhere.
Sorry, I should send this one as RFC instead:-)
Quoted 3 lines
So could you please start with regular trouble report first - i.e. what do you mean by 'sometimes' ???
This issue was first reported here:
https://www.redhat.com/archives/lvm-devel/2017-May/msg00058.htmlI also record one way how to reproduce:
https://asciinema.org/a/c62ica4ptxe94nw2s593yto4iQuoted 7 lines
By "sometimes", I meant the time when the device cache in clvmd is not updated.
It turns out I'm wrong in understanding the root cause of this problem, after discussion with Alasdair on IRC.
After I set "obtain_device_list_from_udev= 0" in lvm.conf, the locking error disappeared, which means udev
DB is not sync with device changes - MD device, isscsi device according to my test.I was cheated by setting "
obtain_device_list_from_udev= 0", because indaemons/clvmd/lvm-functions.c:do_lock_lv(){ if (!cmd->initialized.config || config_files_changed(cmd)) /* lvm.conf is changed when I firstly set obtain_device_list_from_udev */ do_refresh_cache(); /* refresh device cache and metadata */ }Quoted 3 lines
I attached a patch trying to fix this issue. Yes, this patch looks not neat. But, as of now, it's the best one I can think of.
Welcome review and feedback from you:-PHi Eric
Your solution is still likely not a valid fix for your problem.
Targeted 'standard' case on modern udev-based system is - user is running lvm2 with valid udevDB, thus '
obtain_device_list_from_udev= 1' works.It's very bad idea to 'bypass' udev and run on system with udev and not having udevDB state reflecting reality of your system.
So looking at RHEL6 'doc' for clmvd:
When you normally add 'device' on system when obtain is 0 (i.e. old RHEL6 case with 'not so good udev') - admin is supposed to manually run 'vgscan'. The reason here is very simple - older system had some troubles with 'udev' DB validity - and the most 'fair' solution is to let admin decide when he really needs update the state. Doing so behind his back autonomously might significantly reduce performance of clvmd caching - since with frequent udev watch rule clvmd would be scanning permanently.
Quoted 2 lines
So back to your case - I'm not sure why do you still focusing on hacking clvmd where your main effort should be put into having 'udev' usable.
Thanks for your information:-P
Unfortunately, I still failed to tell the problem clearly. Since this problem can be reproduced easily, I debugged it step by step using
gdb, and read most of code paths relative to this problem. It's indeed a problem that "device cache" in clvmd is not updated as needed.
Let me break down:
1. what's "device cache" in clvmd?
In lib/device/dev-cache.c:
static struct {
....
struct btree *devices; ....
} _cache;
2. How to keep the "device cache" update in clvmd? do_refresh_cache()
lvmcache_label_scan()
dev_iter_create()
dev_cache_full_scan()
_full_scan()
_dev_cache_index_devs()
_dev_cache_iterate_devs_fro_index() /* with udev */3. When to refresh "device cache" in clvmd?
In daemons/clvmd/lvm-functions.c:do_lock_vg()
do_refresh_cache() /* P_#global causes a full cache refresh */
4. What is the problem?
clvmd missed a chance to update its device cache when a MD device is assembled, because 'pvscan' triggered by udev rules exits
too early to call lock_vol(..., VG_GLOBAL, ...).
Hope I make this issue understood this time. But, I have to admit that this fix in pvscan tool looks nasty:-/
Regards,
Eric
Quoted 24 lines
Once you get 'udev' working properly - you can start to use obtain.. == 1.
Then you run your: 'mdadm --assemble...'
Then likely 'udevadm settle' (as unfortunately mdadm is NOT cooperating with udev - so to be sure you md0 is known in udevDB it's ATM upto admin to wait to be sure - complains about this should go to mdadm 'playground :)).Then you run 'vgchange -ay' - and clvmd should read devs from udev and see it and
activate it.So where in the above steps you see/have a problem?
Clvmd really can't be used to hack around bugs in other subsystems - it will simply not work too well..Regards
Zdenek
Signature · 3 lines
lvm-devel mailing list lvm-devel at redhat.com https://www.redhat.com/mailman/listinfo/lvm-devel
PATCH 1/1 clvmd: try to refresh device cache on the first failure
Dne 31.5.2017 v 13:26 Eric Ren napsal(a):
Quoted 77 lines
Hi Zdenek,
Quoted 71 lines · Zdenek Kabelac
Dne 31.5.2017 v 07:37 Eric Ren napsal(a):
Quoted 43 lines
Hi Zdenek,
Quoted 23 lines · Eric Ren
Hi!
Quoted 5 lines · Zdenek Kabelac
Hi
Looking at the patch header - it doesn't really look like solution for clustered problem clvmd cannot be resolve out-of-sync trouble of your cluster - it'd be likely masking serious problems elsewhere.
Sorry, I should send this one as RFC instead:-)
Quoted 3 lines
So could you please start with regular trouble report first - i.e. what do you mean by 'sometimes' ???
This issue was first reported here:
https://www.redhat.com/archives/lvm-devel/2017-May/msg00058.htmlI also record one way how to reproduce:
https://asciinema.org/a/c62ica4ptxe94nw2s593yto4iBy "sometimes", I meant the time when the device cache in clvmd is not updated.
Quoted 6 lines
It turns out I'm wrong in understanding the root cause of this problem, after discussion with Alasdair on IRC.
After I set "obtain_device_list_from_udev= 0" in lvm.conf, the locking error disappeared, which means udev
DB is not sync with device changes - MD device, isscsi device according to my test.I was cheated by setting "
obtain_device_list_from_udev= 0", because indaemons/clvmd/lvm-functions.c:do_lock_lv(){ if (!cmd->initialized.config || config_files_changed(cmd)) /* lvm.conf is changed when I firstly set obtain_device_list_from_udev */ do_refresh_cache(); /* refresh device cache and metadata */ }Quoted 3 lines
I attached a patch trying to fix this issue. Yes, this patch looks not neat. But, as of now, it's the best one I can think of. Welcome review and feedback from you:-P
Hi Eric
Your solution is still likely not a valid fix for your problem.
Targeted 'standard' case on modern udev-based system is - user is running lvm2 with valid udevDB, thus '
obtain_device_list_from_udev= 1' works.It's very bad idea to 'bypass' udev and run on system with udev and not having udevDB state reflecting reality of your system.
So looking at RHEL6 'doc' for clmvd:
When you normally add 'device' on system when obtain is 0 (i.e. old RHEL6 case with 'not so good udev') - admin is supposed to manually run 'vgscan'. The reason here is very simple - older system had some troubles with 'udev' DB validity - and the most 'fair' solution is to let admin decide when he really needs update the state. Doing so behind his back autonomously might significantly reduce performance of clvmd caching - since with frequent udev watch rule clvmd would be scanning permanently.
Quoted 2 lines
So back to your case - I'm not sure why do you still focusing on hacking clvmd where your main effort should be put into having 'udev' usable.
Quoted 6 lines
Thanks for your information:-P
Unfortunately, I still failed to tell the problem clearly. Since this problem can be reproduced easily, I debugged it step by step using
gdb, and read most of code paths relative to this problem. It's indeed a problem that "device cache" in clvmd is not updated as needed.
And as was already mentioned - this is a documented and the only supported logic in clvmd.
If user runs WITHOUT obtain_device_list_from_udev == 1 (i.e. command does scan and manually discover device and maintains .cache file) it's admin responsibility to refresh device cache when ANY new device appears.
It's seen counterproductive to NOT use udev and yet want udev to update .cache.
So the only issue we care here is - user has obtain == 1 and yet clvmd does
NOT work correctly - doing any code analysis is premature here...
Quoted 4 lines
4. What is the problem?
clvmd missed a chance to update its device cache when a MD device is assembled, because 'pvscan' triggered by udev rules exits too early to calllock_vol(..., VG_GLOBAL, ...).
pvscan in UDEV rules is ONLY for 'lvmetad' nothing else and certainly not for clvmd.
Quoted 3 lines
Hope I make this issue understood this time. But, I have to admit that this fix in pvscan tool looks nasty:-/
So if you still see reproducible problem feel free to regular community bugzilla at:
https://bugzilla.redhat.com/enter_bug.cgi?product=LVM%20and%20device-mapper
Regards
Zdenek
PATCH 1/1 clvmd: try to refresh device cache on the first failure
Hi!
Quoted 10 lines · Zdenek Kabelac
[...snip...]
Quoted 6 lines
Thanks for your information:-P
Unfortunately, I still failed to tell the problem clearly. Since this problem can be reproduced easily, I debugged it step by step using
gdb, and read most of code paths relative to this problem. It's indeed a problem that "device cache" in clvmd is not updated as needed.And as was already mentioned - this is a documented and the only supported logic in clvmd.
Quoted 8 lines
If user runs WITHOUT
obtain_device_list_from_udev== 1 (i.e. command does scan and manually discover device and maintains .cache file) it's admin responsibility to refresh device cache when ANY new device appears.It's seen counterproductive to NOT use udev and yet want udev to update .cache.
So the only issue we care here is - user has obtain == 1 and yet clvmd does NOT work
correctly - doing any code analysis is premature here...
This problem can be reproduced no matter 'obtain_device_list_from_udev == 1' or 'obtain_xx == 0'.
The reason why I mention 'obtain...' here is, several days ago on IRC, when I tried 'obtain... == 0' following your
instructions, the problem *disappeared*, so I thought, yes, udev has something wrong! But, as mentioned previously,
I was cheated because do_refresh_cache() will be called if lvm.conf is *changed*.
Quoted 7 lines
Quoted 5 lines
4. What is the problem?
clvmd missed a chance to update its device cache when a MD device is assembled, because 'pvscan' triggered by udev rules exits
too early to calllock_vol(..., VG_GLOBAL, ...).pvscan in UDEV rules is ONLY for 'lvmetad' nothing else and certainly not for clvmd.
Yeah, this is the problem. So, do_refresh_cache() won't be called when underlying device changes.
Quoted 9 lines
Quoted 4 lines
Hope I make this issue understood this time. But, I have to admit that this fix in pvscan tool looks nasty:-/
So if you still see reproducible problem feel free to regular community bugzilla at:
https://bugzilla.redhat.com/enter_bug.cgi?product=LVM%20and%20device-mapper
Thanks, will do.
Regards,
Eric
Quoted 11 lines
Regards
Zdenek
Signature · 3 lines
lvm-devel mailing list lvm-devel at redhat.com https://www.redhat.com/mailman/listinfo/lvm-devel