Change in vdsm[master]: mount: Add mounts monitor
Nir Soffer has restored this change. Change subject: mount: Add mounts monitor .. Restored -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: restore Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Allon Mureinik Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Jenkins CI RO Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks ___ vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org
Change in vdsm[master]: mount: Add mounts monitor
gerrit-hooks has posted comments on this change. Change subject: mount: Add mounts monitor .. Patch Set 4: * Update tracker: IGNORE, no Bug-Url found -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Allon Mureinik Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Jenkins CI RO Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org
Change in vdsm[master]: mount: Add mounts monitor
Jenkins CI RO has abandoned this change. Change subject: mount: Add mounts monitor .. Abandoned Abandoned due to no activity - please restore if still relevant -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: abandon Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Allon Mureinik Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Jenkins CI RO Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks ___ vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org
Change in vdsm[master]: mount: Add mounts monitor
Nir Soffer has posted comments on this change. Change subject: mount: Add mounts monitor .. Patch Set 4: (2 comments) This is experimental infrastructure, if we will decide to use it, I will integrate it in a following patch. https://gerrit.ovirt.org/#/c/56516/4/lib/vdsm/storage/mount.py File lib/vdsm/storage/mount.py: Line 342: monitor.wait() Line 343: Line 344: """ Line 345: Line 346: log = logging.getLogger("storage.Mount.Monitor") > Shouldn't it be "storage.Monitor"? This name belongs to storage/monitor.py Line 347: Line 348: def __init__(self, callback): Line 349: self._was_changed = callback Line 350: self._mountsfd = -1 Line 391: raise Line 392: Line 393: def wait(self, timeout=None): Line 394: """ Line 395: Wait until the monitor stops. Return True if the monitor has stooped > s/stooped/stopped Thanks, will fix. Line 396: and False if the timeout expired. Line 397: """ Line 398: self._thread.join(timeout) Line 399: return not self._thread.is_alive() -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Allon Mureinik Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: Yes ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: mount: Add mounts monitor
Idan Shaby has posted comments on this change. Change subject: mount: Add mounts monitor .. Patch Set 4: (2 comments) Have you used this Monitor somewhere? It seems that it's a dead code for now. https://gerrit.ovirt.org/#/c/56516/4/lib/vdsm/storage/mount.py File lib/vdsm/storage/mount.py: PS4, Line 346: "storage.Mount.Monitor" Shouldn't it be "storage.Monitor"? PS4, Line 395: stooped s/stooped/stopped -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Allon Mureinik Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: Yes ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: mount: Add mounts monitor
Nir Soffer has posted comments on this change. Change subject: mount: Add mounts monitor .. Patch Set 4: One issue with this patch - current caching is not needed and is removed in https://gerrit.ovirt.org/56517, so I'm not sure we need to monitor mounts changes. This can replace the udevadm hack used to detect completion of a loop device umount, but waiting for mount changes is not enough, since you want to wait for specific device, and this waits only for some mount change. We can wait for specific device using pyudev.Monitor. So this can be useful only if we want to replace mounts polling with mounts events - read current mounts each time we receive an event, and serve mounts results from the cached version. I need to do profiling to see if checking mount status is still an issue with many file based storage domains. -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Allon Mureinik Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: mount: Add mounts monitor
gerrit-hooks has posted comments on this change. Change subject: mount: Add mounts monitor .. Patch Set 4: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Allon Mureinik Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: mount: Add mounts monitor
Nir Soffer has posted comments on this change. Change subject: mount: Add mounts monitor .. Patch Set 3: Verified+1 Verified using the tests (when running as root). -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Allon Mureinik Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: mount: Add mounts monitor
gerrit-hooks has posted comments on this change. Change subject: mount: Add mounts monitor .. Patch Set 3: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Allon Mureinik Gerrit-Reviewer: Dan Kenigsberg Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: mount: Add mounts monitor
Nir Soffer has uploaded a new change for review. Change subject: mount: Add mounts monitor .. mount: Add mounts monitor Since kernel version 2.6.15, /proc/mounts is pollable: after opening the file for reading, a change in this file (i.e., a filesystem mount or unmount) causes poll(2) to mark the file as having an error condition. This patch adds mount.Monitor for detecting mount changes. The monitor runs in a background thread and invoke a callback each time mounts change. In the next patches we will use the monitor for the mounts cache and for waiting until mount and unmount commands finished instead of the current udevadm hack. Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Signed-off-by: Nir Soffer --- M lib/vdsm/storage/mount.py M tests/mountTests.py 2 files changed, 225 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/56516/2 diff --git a/lib/vdsm/storage/mount.py b/lib/vdsm/storage/mount.py index 2fd7237..71fa966 100644 --- a/lib/vdsm/storage/mount.py +++ b/lib/vdsm/storage/mount.py @@ -24,6 +24,7 @@ import logging import os import re +import select import stat import threading @@ -32,9 +33,12 @@ from vdsm import cmdutils from vdsm import commands +from vdsm import concurrent from vdsm import constants from vdsm import supervdsm from vdsm import utils +from vdsm.infra import filecontrol +from vdsm.infra import eventfd # Common vfs types @@ -315,3 +319,140 @@ return raise MountError(rc, ";".join((out, err))) + + +class Monitor(object): +""" +Monitor mounts changes for current process. + +Since kernel version 2.6.15, /proc/mounts is pollable: after opening the +file for reading, a change in this file (i.e., a filesystem mount or +unmount) causes poll(2) to mark the file as having an error condition. + +Usage: + +def was_changed(): +print "mounts change detected" + +monitor = mounts.Monitor(was_changed) +monitor.start() +... +monitor.stop() +... +monitor.wait() + +""" + +log = logging.getLogger("storage.Mount.Monitor") + +def __init__(self, callback): +self._was_changed = callback +self._wakeupfd = eventfd.EventFD(eventfd.EFD_CLOEXEC | + eventfd.EFD_NONBLOCK) +try: +self._mountsfd = os.open("/proc/mounts", os.O_RDONLY) +except: +try: +self._wakeupfd.close() +except Exception as e: +self.log.exception("Unable to close wakeup fd: %s", e) +raise +filecontrol.set_close_on_exec(self._mountsfd) +self._thread = concurrent.thread(self._run) +self._stopped = False + +def start(self): +""" +Start the monitor. +""" +self.log.info("Start monitoring mounts") +self._thread.start() + +def stop(self): +""" +Stop the monitor. + +To wait until the monitor stop, use wait(). +""" +self.log.info("Stop monitoring mounts") +self._stopped = True +while True: +try: +return self._wakeupfd.write(1) +except OSError as e: +if e.errno == errno.EINTR: +continue +if e.errno == errno.EAGAIN: +# If the eventfd is not writable, it should be readable, +# and poll will return soon. +return +if e.errno == errno.EBADF: +return +raise + +def wait(self, timeout=None): +""" +Wait until the monitor stops. Return True if the monitor has stooped +and False if the timeout expired. +""" +self._thread.join(timeout) +return not self._thread.is_alive() + +def _run(self): +self.log.debug("Mounts monitor started") +poller = select.poll() +poller.register(self._mountsfd, select.POLLPRI) +poller.register(self._wakeupfd, select.POLLIN) +try: +while not self._stopped: +try: +events = poller.poll() +except EnvironmentError as e: +if e.errno != errno.EINTR: +raise +continue +for fd, event in events: +if fd is self._mountsfd: +self._handle_mounts(event) +elif fd is self._wakeupfd.fileno(): +self._handle_wakeup(event) +else: +raise AssertionError("Unexpected fd recevied from " + "poll (fd=%d, event=%d)" + % (fd, event)) +finally: +poller.unregister(s
Change in vdsm[master]: mount: Add mounts monitor
gerrit-hooks has posted comments on this change. Change subject: mount: Add mounts monitor .. Patch Set 2: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: mount: Add mounts monitor
gerrit-hooks has posted comments on this change. Change subject: mount: Add mounts monitor .. Patch Set 1: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/56516 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I25ad36ebfde12d2e3250e893de98bba66f160623 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches