master - dev-io: open device read-only to obtain readahead value
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c8591b2ac7c99ea43e7f94f3dfb183019c2fed6e Commit: c8591b2ac7c99ea43e7f94f3dfb183019c2fed6e Parent: 6fc4c99b2fc745b0167520f9395e9e2e39c162e8 Author: Peter Rajnoha <[email protected]> AuthorDate: Mon Jun 25 11:34:21 2012 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Mon Jun 25 11:55:37 2012 +0200
dev-io: open device read-only to obtain readahead value
There's no need to have the device open RW while obtaining the readahead value. The RW open used before caused the CHANGE udev event to be generated if the WATCH udev rule was set for the underlying device (and that is normally the case both for non-dm and dm devices by default).
This did not cause any problems before since we were not interested in *underlying* devices. However, with upcoming changes (autoactivation), we're watching for events on underlying devices marked as PVs and such a spurious event could cause the autoactivation code to be triggered. So when trying to deactivate the volume, we could end up with immediate activation just after that because of the CHANGE event originated in the WATCH udev rule since the underlying device was open RW during the deactivation process.
Though maybe a better solution would be to completely filter such spurious events out of the autoactivation process somehow, it's still useful if there are as least spurious events generated as possible in the system itself.
--- WHATS_NEW | 1 + lib/device/dev-io.c | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.97 - =============================== + Open device read-only to obtain readahead value. Fix lvconvert error path NULL pointer dereference. Check for create_instance() fail in pvscan_lvmetad_single(). Use 64bit math for reserved memory and stack.
lib/device/dev-io.c +1 -1
@@ -282,7 +282,7 @@ static int _dev_read_ahead_dev(struct device *dev, uint32_t *read_ahead)return 1 ; } -if (!dev_open (dev)) +if (!dev_open_readonly (dev)) return_0;if (ioctl (dev->fd,BLKRAGET , &read_ahead_long) <0 ) {
Dne 25.6.2012 11:56, Peter Rajnoha napsal(a):
Quoted 16 lines
dev-io: open device read-only to obtain readahead value
There's no need to have the device open RW while obtaining the readahead value. The RW open used before caused the CHANGE udev event to be generated if the WATCH udev rule was set for the underlying device (and that is normally the case both for non-dm and dm devices by default).
This did not cause any problems before since we were not interested in *underlying* devices. However, with upcoming changes (autoactivation), we're watching for events on underlying devices marked as PVs and such a spurious event could cause the autoactivation code to be triggered. So when trying to deactivate the volume, we could end up with immediate activation just after that because of the CHANGE event originated in the WATCH udev rule since the underlying device was open RW during the deactivation process.
Quoted 3 lines
Though maybe a better solution would be to completely filter such spurious events out of the autoactivation process somehow, it's still useful if there are as least spurious events generated as possible in the system itself.
Which should be further fixed to use sysfs improved libdm method.
Zdenek
Quoted 6 lines · Zdenek Kabelac
Dne 25.6.2012 11:56, Peter Rajnoha napsal(a):
Quoted 3 lines
dev-io: open device read-only to obtain readahead value
Which should be further fixed to use sysfs improved libdm method.
Indeed. Though the libdm fn needs refactoring then to take all block devs, not just DM ones as current dm_task_get_read_ahead is bound to a "DM task"... a new fn would be required in libdm to do that as a matter of fact.
Peter