master - lvmdbusd: Long running operations use own thread
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=72a943f720ba49...
Commit: 72a943f720ba49517592fd4040f58517a0b65852
Parent: fa444906bbe5eda22aa5823ef2f9e196b0c15602
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Nov 11 09:46:12 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Nov 17 11:35:16 2016 -0600
lvmdbusd: Long running operations use own thread
Anything that ends up using polld will be done in a unique thread
so that we don't hold off other operations from running concurrently.
---
daemons/lvmdbusd/background.py | 14 ++++++++++++++
daemons/lvmdbusd/fetch.py | 4 +++-
daemons/lvmdbusd/lv.py | 4 ++--
daemons/lvmdbusd/main.py | 4 ++--
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/daemons/lvmdbusd/background.py b/daemons/lvmdbusd/background.py
index f4cb539..19a2e6c 100644
--- a/daemons/lvmdbusd/background.py
+++ b/daemons/lvmdbusd/background.py
@@ -13,6 +13,7 @@ from .cmdhandler import options_to_cli_args
import dbus
from .utils import pv_range_append, pv_dest_ranges, log_error, log_debug
import os
+import threading
def pv_move_lv_cmd(move_options, lv_full_name,
@@ -126,3 +127,16 @@ def merge(interface_name, lv_uuid, lv_name, merge_options, job_state):
raise dbus.exceptions.DBusException(
interface_name,
'LV with uuid %s and name %s not present!' % (lv_uuid, lv_name))
+
+
+def _run_cmd(req):
+ log_debug(
+ "_run_cmd: Running method: %s with args %s" %
+ (str(req.method), str(req.arguments)))
+ req.run_cmd()
+ log_debug("_run_cmd: complete!")
+
+
+def cmd_runner(request):
+ t = threading.Thread(target=_run_cmd, args=(request,))
+ t.start()
diff --git a/daemons/lvmdbusd/fetch.py b/daemons/lvmdbusd/fetch.py
index 409b19d..78c3a4b 100644
--- a/daemons/lvmdbusd/fetch.py
+++ b/daemons/lvmdbusd/fetch.py
@@ -108,7 +108,9 @@ class StateUpdate(object):
except queue.Empty:
pass
- log_debug("Processing %d updates!" % len(queued_requests))
+ if len(queued_requests) > 1:
+ log_debug("Processing %d updates!" % len(queued_requests),
+ 'bg_black', 'fg_light_green')
# We have what we can, run the update with the needed options
for i in queued_requests:
diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py
index e130ae4..fd7aa1e 100644
--- a/daemons/lvmdbusd/lv.py
+++ b/daemons/lvmdbusd/lv.py
@@ -494,7 +494,7 @@ class Lv(LvCommon):
pv_dests_and_ranges, move_options, job_state), cb, cbe, False,
job_state)
- cfg.worker_q.put(r)
+ background.cmd_runner(r)
@staticmethod
def _snap_shot(lv_uuid, lv_name, name, optional_size,
@@ -916,4 +916,4 @@ class LvSnapShot(Lv):
(SNAPSHOT_INTERFACE, self.Uuid, self.lvm_id,
merge_options, job_state), cb, cbe, False,
job_state)
- cfg.worker_q.put(r)
+ background.cmd_runner(r)
diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py
index 6e782d2..4b9f94e 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -87,8 +87,6 @@ def main():
log_error("You cannot specify --lvmshell and --nojson")
sys.exit(1)
- cmdhandler.set_execution(cfg.args.use_lvm_shell)
-
# List of threads that we start up
thread_list = []
@@ -102,6 +100,8 @@ def main():
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
dbus.mainloop.glib.threads_init()
+ cmdhandler.set_execution(cfg.args.use_lvm_shell)
+
if use_session:
cfg.bus = dbus.SessionBus()
else:
6 years, 4 months
master - lvmdbusd: Use one thread to fetch state updates
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fa444906bbe5ed...
Commit: fa444906bbe5eda22aa5823ef2f9e196b0c15602
Parent: affe2cebf51169bff01fe20d9f4f1298bba9e1f9
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Nov 10 12:19:48 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Nov 17 11:35:16 2016 -0600
lvmdbusd: Use one thread to fetch state updates
In preparation to have more than one thread issuing commands to lvm
at the same time we need to serialize updates to the dbus state and
retrieving the global lvm state. To achieve this we have one thread
handling this with a thread safe queue taking and coalescing requests.
---
daemons/lvmdbusd/cfg.py | 1 +
daemons/lvmdbusd/fetch.py | 114 ++++++++++++++++++++++++++++++++++++++++-
daemons/lvmdbusd/main.py | 63 +++++-----------------
daemons/lvmdbusd/manager.py | 5 +-
daemons/lvmdbusd/refresh.py | 45 ----------------
daemons/lvmdbusd/udevwatch.py | 3 +-
6 files changed, 131 insertions(+), 100 deletions(-)
diff --git a/daemons/lvmdbusd/cfg.py b/daemons/lvmdbusd/cfg.py
index e5bd9e2..0612154 100644
--- a/daemons/lvmdbusd/cfg.py
+++ b/daemons/lvmdbusd/cfg.py
@@ -78,6 +78,7 @@ hidden_lv = itertools.count()
# Used to prevent circular imports...
load = None
+event = None
# Global cached state
db = None
diff --git a/daemons/lvmdbusd/fetch.py b/daemons/lvmdbusd/fetch.py
index 7626460..409b19d 100644
--- a/daemons/lvmdbusd/fetch.py
+++ b/daemons/lvmdbusd/fetch.py
@@ -11,7 +11,10 @@ from .pv import load_pvs
from .vg import load_vgs
from .lv import load_lvs
from . import cfg
-from .utils import MThreadRunner, log_debug
+from .utils import MThreadRunner, log_debug, log_error
+import threading
+import queue
+import traceback
def _main_thread_load(refresh=True, emit_signal=True):
@@ -45,3 +48,112 @@ def load(refresh=True, emit_signal=True, cache_refresh=True, log=True,
rc = _main_thread_load(refresh, emit_signal)
return rc
+
+
+# Even though lvm can handle multiple changes concurrently it really doesn't
+# make sense to make a 1-1 fetch of data for each change of lvm because when
+# we fetch the data once all previous changes are reflected.
+class StateUpdate(object):
+
+ class UpdateRequest(object):
+
+ def __init__(self, refresh, emit_signal, cache_refresh, log,
+ need_main_thread):
+ self.is_done = False
+ self.refresh = refresh
+ self.emit_signal = emit_signal
+ self.cache_refresh = cache_refresh
+ self.log = log
+ self.need_main_thread = need_main_thread
+ self.result = None
+ self.cond = threading.Condition(threading.Lock())
+
+ def done(self):
+ with self.cond:
+ if not self.is_done:
+ self.cond.wait()
+ return self.result
+
+ def set_result(self, result):
+ with self.cond:
+ self.result = result
+ self.is_done = True
+ self.cond.notify_all()
+
+ @staticmethod
+ def update_thread(obj):
+ while cfg.run.value != 0:
+ # noinspection PyBroadException
+ try:
+ queued_requests = []
+ refresh = True
+ emit_signal = True
+ cache_refresh = True
+ log = True
+ need_main_thread = True
+
+ with obj.lock:
+ wait = not obj.deferred
+ obj.deferred = False
+
+ if wait:
+ queued_requests.append(obj.queue.get(True, 2))
+
+ # Ok we have one or the deferred queue has some,
+ # check if any others
+ try:
+ while True:
+ queued_requests.append(obj.queue.get(False))
+
+ except queue.Empty:
+ pass
+
+ log_debug("Processing %d updates!" % len(queued_requests))
+
+ # We have what we can, run the update with the needed options
+ for i in queued_requests:
+ if not i.refresh:
+ refresh = False
+ if not i.emit_signal:
+ emit_signal = False
+ if not i.cache_refresh:
+ cache_refresh = False
+ if not i.log:
+ log = False
+ if not i.need_main_thread:
+ need_main_thread = False
+
+ num_changes = load(refresh, emit_signal, cache_refresh, log,
+ need_main_thread)
+ # Update is done, let everyone know!
+ for i in queued_requests:
+ i.set_result(num_changes)
+
+ except queue.Empty:
+ pass
+ except Exception:
+ st = traceback.format_exc()
+ log_error("update_thread exception: \n%s" % st)
+
+ def __init__(self):
+ self.lock = threading.RLock()
+ self.queue = queue.Queue()
+ self.deferred = False
+
+ # Do initial load
+ load(refresh=False, emit_signal=False, need_main_thread=False)
+
+ self.thread = threading.Thread(target=StateUpdate.update_thread,
+ args=(self,))
+
+ def load(self, refresh=True, emit_signal=True, cache_refresh=True,
+ log=True, need_main_thread=True):
+ # Place this request on the queue and wait for it to be completed
+ req = StateUpdate.UpdateRequest(refresh, emit_signal, cache_refresh,
+ log, need_main_thread)
+ self.queue.put(req)
+ return req.done()
+
+ def event(self):
+ with self.lock:
+ self.deferred = True
diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py
index 80a576a..6e782d2 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -20,7 +20,7 @@ import dbus.mainloop.glib
from . import lvmdb
# noinspection PyUnresolvedReferences
from gi.repository import GLib
-from .fetch import load
+from .fetch import StateUpdate
from .manager import Manager
import traceback
import queue
@@ -29,7 +29,6 @@ from .utils import log_debug, log_error
import argparse
import os
import sys
-from .refresh import handle_external_event, event_complete
class Lvm(objectmanager.ObjectManager):
@@ -37,54 +36,15 @@ class Lvm(objectmanager.ObjectManager):
super(Lvm, self).__init__(object_path, BASE_INTERFACE)
-def _discard_pending_refreshes():
- # We just handled a refresh, if we have any in the queue they can be
- # removed because by definition they are older than the refresh we just did.
- # As we limit the number of refreshes getting into the queue
- # we should only ever have one to remove.
- requests = []
- while not cfg.worker_q.empty():
- try:
- r = cfg.worker_q.get(block=False)
- if r.method != handle_external_event:
- requests.append(r)
- else:
- # Make sure we make this event complete even though it didn't
- # run, otherwise no other events will get processed
- event_complete()
- break
- except queue.Empty:
- break
-
- # Any requests we removed, but did not discard need to be re-queued
- for r in requests:
- cfg.worker_q.put(r)
-
-
def process_request():
while cfg.run.value != 0:
# noinspection PyBroadException
try:
req = cfg.worker_q.get(True, 5)
-
- start = cfg.db.num_refreshes
-
log_debug(
"Running method: %s with args %s" %
(str(req.method), str(req.arguments)))
req.run_cmd()
-
- end = cfg.db.num_refreshes
-
- num_refreshes = end - start
-
- if num_refreshes > 0:
- _discard_pending_refreshes()
-
- if num_refreshes > 1:
- log_debug(
- "Inspect method %s for too many refreshes" %
- (str(req.method)))
log_debug("Method complete ")
except queue.Empty:
pass
@@ -152,20 +112,25 @@ def main():
cfg.om = Lvm(BASE_OBJ_PATH)
cfg.om.register_object(Manager(MANAGER_OBJ_PATH))
- cfg.load = load
-
cfg.db = lvmdb.DataStore(cfg.args.use_json)
# Using a thread to process requests, we cannot hang the dbus library
# thread that is handling the dbus interface
thread_list.append(threading.Thread(target=process_request))
- cfg.load(refresh=False, emit_signal=False, need_main_thread=False)
+ # Have a single thread handling updating lvm and the dbus model so we don't
+ # have multiple threads doing this as the same time
+ updater = StateUpdate()
+ thread_list.append(updater.thread)
+
+ cfg.load = updater.load
+ cfg.event = updater.event
+
cfg.loop = GLib.MainLoop()
- for process in thread_list:
- process.damon = True
- process.start()
+ for thread in thread_list:
+ thread.damon = True
+ thread.start()
# Add udev watching
if cfg.args.use_udev:
@@ -187,8 +152,8 @@ def main():
cfg.loop.run()
udevwatch.remove()
- for process in thread_list:
- process.join()
+ for thread in thread_list:
+ thread.join()
except KeyboardInterrupt:
utils.handler(signal.SIGINT, None)
return 0
diff --git a/daemons/lvmdbusd/manager.py b/daemons/lvmdbusd/manager.py
index e81ee1f..821c625 100644
--- a/daemons/lvmdbusd/manager.py
+++ b/daemons/lvmdbusd/manager.py
@@ -14,9 +14,7 @@ from .cfg import MANAGER_INTERFACE
import dbus
from . import cfg
from . import cmdhandler
-from .fetch import load_pvs, load_vgs
from .request import RequestEntry
-from .refresh import event_add
from . import udevwatch
@@ -183,7 +181,8 @@ class Manager(AutomatedProperties):
"udev monitoring")
# We are dependent on external events now to stay current!
cfg.ee = True
- event_add((command,))
+ utils.log_debug("ExternalEvent %s" % command)
+ cfg.event()
return dbus.Int32(0)
@staticmethod
diff --git a/daemons/lvmdbusd/refresh.py b/daemons/lvmdbusd/refresh.py
deleted file mode 100644
index e29afd6..0000000
--- a/daemons/lvmdbusd/refresh.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (C) 2015-2016 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# Try and minimize the refreshes we do.
-
-import threading
-from .request import RequestEntry
-from . import cfg
-from . import utils
-
-_rlock = threading.RLock()
-_count = 0
-
-
-def handle_external_event(command):
- utils.log_debug("External event: '%s'" % command)
- event_complete()
- cfg.load()
-
-
-def event_add(params):
- global _rlock
- global _count
- with _rlock:
- if _count == 0:
- _count += 1
- r = RequestEntry(
- -1, handle_external_event,
- params, None, None, False)
- cfg.worker_q.put(r)
-
-
-def event_complete():
- global _rlock
- global _count
- with _rlock:
- if _count > 0:
- _count -= 1
- return _count
diff --git a/daemons/lvmdbusd/udevwatch.py b/daemons/lvmdbusd/udevwatch.py
index 6d56443..e2ac63a 100644
--- a/daemons/lvmdbusd/udevwatch.py
+++ b/daemons/lvmdbusd/udevwatch.py
@@ -9,7 +9,6 @@
import pyudev
import threading
-from .refresh import event_add
from . import cfg
observer = None
@@ -38,7 +37,7 @@ def filter_event(action, device):
refresh = True
if refresh:
- event_add(('udev',))
+ cfg.event()
def add():
6 years, 4 months
master - lvmdbus: Make bus name configurable
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=affe2cebf51169...
Commit: affe2cebf51169bff01fe20d9f4f1298bba9e1f9
Parent: 560229178cec9daff0c0f4fe16f59013d566f1d5
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Nov 4 13:26:31 2016 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Nov 17 11:35:16 2016 -0600
lvmdbus: Make bus name configurable
Add env LVM_DBUS_NAME to change what the bus name is.
---
daemons/lvmdbusd/cfg.py | 1 +
daemons/lvmdbusd/main.py | 4 ++--
test/dbus/lvmdbustest.py | 5 ++---
test/dbus/testlib.py | 34 ++++++++++++++++++----------------
4 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/daemons/lvmdbusd/cfg.py b/daemons/lvmdbusd/cfg.py
index 8965ec7..e5bd9e2 100644
--- a/daemons/lvmdbusd/cfg.py
+++ b/daemons/lvmdbusd/cfg.py
@@ -44,6 +44,7 @@ worker_q = queue.Queue()
# Main event loop
loop = None
+BUS_NAME = os.getenv('LVM_DBUS_NAME', 'com.redhat.lvmdbus1')
BASE_INTERFACE = 'com.redhat.lvmdbus1'
PV_INTERFACE = BASE_INTERFACE + '.Pv'
VG_INTERFACE = BASE_INTERFACE + '.Vg'
diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py
index 7d10bc3..80a576a 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -10,7 +10,7 @@
from . import cfg
from . import objectmanager
from . import utils
-from .cfg import BASE_INTERFACE, BASE_OBJ_PATH, MANAGER_OBJ_PATH
+from .cfg import BUS_NAME, BASE_INTERFACE, BASE_OBJ_PATH, MANAGER_OBJ_PATH
import threading
from . import cmdhandler
import time
@@ -148,7 +148,7 @@ def main():
cfg.bus = dbus.SystemBus()
# The base name variable needs to exist for things to work.
# noinspection PyUnusedLocal
- base_name = dbus.service.BusName(BASE_INTERFACE, cfg.bus)
+ base_name = dbus.service.BusName(BUS_NAME, cfg.bus)
cfg.om = Lvm(BASE_OBJ_PATH)
cfg.om.register_object(Manager(MANAGER_OBJ_PATH))
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 7e3a877..09f1b77 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -17,7 +17,6 @@ import unittest
import sys
import time
import pyudev
-import os
from testlib import *
g_tmo = 0
@@ -56,7 +55,7 @@ def get_objects():
CACHE_POOL_INT: [], CACHE_LV_INT: []}
manager = dbus.Interface(bus.get_object(
- BUSNAME, "/com/redhat/lvmdbus1"),
+ BUS_NAME, "/com/redhat/lvmdbus1"),
"org.freedesktop.DBus.ObjectManager")
objects = manager.GetManagedObjects()
@@ -71,7 +70,7 @@ def get_objects():
def set_execution(lvmshell):
lvm_manager = dbus.Interface(bus.get_object(
- BUSNAME, "/com/redhat/lvmdbus1/Manager"),
+ BUS_NAME, "/com/redhat/lvmdbus1/Manager"),
"com.redhat.lvmdbus1.Manager")
return lvm_manager.UseLvmShell(lvmshell)
diff --git a/test/dbus/testlib.py b/test/dbus/testlib.py
index d88ebbd..7f8456f 100644
--- a/test/dbus/testlib.py
+++ b/test/dbus/testlib.py
@@ -14,19 +14,21 @@ import functools
import xml.etree.ElementTree as Et
from collections import OrderedDict
import dbus
-
-BUSNAME = "com.redhat.lvmdbus1"
-MANAGER_INT = BUSNAME + '.Manager'
-MANAGER_OBJ = '/' + BUSNAME.replace('.', '/') + '/Manager'
-PV_INT = BUSNAME + ".Pv"
-VG_INT = BUSNAME + ".Vg"
-LV_INT = BUSNAME + ".Lv"
-THINPOOL_INT = BUSNAME + ".ThinPool"
-SNAPSHOT_INT = BUSNAME + ".Snapshot"
-LV_COMMON_INT = BUSNAME + ".LvCommon"
-JOB_INT = BUSNAME + ".Job"
-CACHE_POOL_INT = BUSNAME + ".CachePool"
-CACHE_LV_INT = BUSNAME + ".CachedLv"
+import os
+
+BUS_NAME = os.getenv('LVM_DBUS_NAME', 'com.redhat.lvmdbus1')
+BASE_INTERFACE = 'com.redhat.lvmdbus1'
+MANAGER_INT = BASE_INTERFACE + '.Manager'
+MANAGER_OBJ = '/' + BASE_INTERFACE.replace('.', '/') + '/Manager'
+PV_INT = BASE_INTERFACE + ".Pv"
+VG_INT = BASE_INTERFACE + ".Vg"
+LV_INT = BASE_INTERFACE + ".Lv"
+THINPOOL_INT = BASE_INTERFACE + ".ThinPool"
+SNAPSHOT_INT = BASE_INTERFACE + ".Snapshot"
+LV_COMMON_INT = BASE_INTERFACE + ".LvCommon"
+JOB_INT = BASE_INTERFACE + ".Job"
+CACHE_POOL_INT = BASE_INTERFACE + ".CachePool"
+CACHE_LV_INT = BASE_INTERFACE + ".CachedLv"
THINPOOL_LV_PATH = '/' + THINPOOL_INT.replace('.', '/')
@@ -162,7 +164,7 @@ class RemoteObject(object):
for i in range(0, 3):
try:
prop_fetch = dbus.Interface(self.bus.get_object(
- BUSNAME, self.object_path),
+ BUS_NAME, self.object_path),
'org.freedesktop.DBus.Properties')
props = prop_fetch.GetAll(self.interface)
break
@@ -186,7 +188,7 @@ class RemoteObject(object):
self.introspect = introspect
self.dbus_method = dbus.Interface(specified_bus.get_object(
- BUSNAME, self.object_path), self.interface)
+ BUS_NAME, self.object_path), self.interface)
self._set_props(properties)
@@ -222,7 +224,7 @@ class ClientProxy(object):
def __init__(self, specified_bus, object_path, interface=None, props=None):
i = dbus.Interface(specified_bus.get_object(
- BUSNAME, object_path), 'org.freedesktop.DBus.Introspectable')
+ BUS_NAME, object_path), 'org.freedesktop.DBus.Introspectable')
introspection_xml = i.Introspect()
6 years, 4 months
master - lvmdbustest.py: Remove raid4 use
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=560229178cec9d...
Commit: 560229178cec9daff0c0f4fe16f59013d566f1d5
Parent: 2a86f54b09312db58b662b1779557466a639567f
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Nov 4 13:16:24 2016 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Nov 17 11:35:16 2016 -0600
lvmdbustest.py: Remove raid4 use
Looks like this isn't support across versions. Need to add functionality
to service to return the supported segment types, so we only use the
supported ones.
---
test/dbus/lvmdbustest.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index e5b8243..7e3a877 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -496,7 +496,7 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create(pv_paths).Vg
self._test_lv_create(
- vg.LvCreateRaid, (lv_n(), 'raid4', mib(16), 2, 8, g_tmo, {}), vg)
+ vg.LvCreateRaid, (lv_n(), 'raid5', mib(16), 2, 8, g_tmo, {}), vg)
def _create_lv(self, thinpool=False, size=None, vg=None):
6 years, 4 months
master - libdm: separate dm_stats_populate() error cases
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2a86f54b09312d...
Commit: 2a86f54b09312db58b662b1779557466a639567f
Parent: 6de05cf5f5aa7c4125b20c11a13356b58ea2ff14
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Nov 17 11:39:43 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Nov 17 11:39:43 2016 +0000
libdm: separate dm_stats_populate() error cases
There are two possible errors in _dm_stats_populate_region():
* No region struct in dms->regions[region_id]
* Failure to parse data from @stats_print
These have very different causes: the first occurs where a client
program is populating one region at a time (region_id is a single
region identifier), and has not previously called dm_stats_list()
to dimension the region tables; this is an API usage error.
The second occurs when either we read unparseable data from the
kernel (kernel bug), or where various resource allocations fail.
Separate these two cases out and log separate messages for each
(allocation failures in the path already have their own distinct
message), since the "failed to parse.." message in the un-listed
handle case is confusing and misleading.
---
libdm/libdm-stats.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 55e2a42..ad3e624 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -2241,7 +2241,11 @@ static int _dm_stats_populate_region(struct dm_stats *dms, uint64_t region_id,
if (!_stats_bound(dms))
return_0;
- if (!region || !_stats_parse_region(dms, resp, region, region->timescale)) {
+ if (!region) {
+ log_error("Cannot populate empty handle before dm_stats_list().");
+ return 0;
+ }
+ if (!_stats_parse_region(dms, resp, region, region->timescale)) {
log_error("Could not parse @stats_print message response.");
return 0;
}
6 years, 4 months
master - raid: Remove fixed FIXME
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6de05cf5f5aa7c...
Commit: 6de05cf5f5aa7c4125b20c11a13356b58ea2ff14
Parent: cd0736a94554750e0077f390770212c68da8fa4e
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Nov 15 20:45:55 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Nov 15 20:45:55 2016 +0000
raid: Remove fixed FIXME
---
lib/metadata/raid_manip.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index b88ddcc..cf4cce1 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1055,7 +1055,6 @@ static int _extract_image_components(struct lv_segment *seg, uint32_t idx,
seg_type(seg, idx) = AREA_UNASSIGNED;
seg_metatype(seg, idx) = AREA_UNASSIGNED;
- /* FIXME Remove duplicated prefix? */
if (!(data_lv->name = _generate_raid_name(data_lv, "extracted", -1)))
return_0;
6 years, 4 months
master - dbus: also recognize error state for missing service that comes from original D-Bus
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cd0736a9455475...
Commit: cd0736a94554750e0077f390770212c68da8fa4e
Parent: 68d6d342f83f00784b53dda254d66875e134808d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Nov 15 10:09:11 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Nov 15 10:09:11 2016 +0100
dbus: also recognize error state for missing service that comes from original D-Bus
---
lib/notify/lvmnotify.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/notify/lvmnotify.c b/lib/notify/lvmnotify.c
index ac0ca73..1daee1e 100644
--- a/lib/notify/lvmnotify.c
+++ b/lib/notify/lvmnotify.c
@@ -15,7 +15,8 @@
#define LVM_DBUS_DESTINATION "com.redhat.lvmdbus1"
#define LVM_DBUS_PATH "/com/redhat/lvmdbus1/Manager"
#define LVM_DBUS_INTERFACE "com.redhat.lvmdbus1.Manager"
-#define SD_BUS_NO_SUCH_UNIT_ERROR "org.freedesktop.systemd1.NoSuchUnit"
+#define SD_BUS_SYSTEMD_NO_SUCH_UNIT_ERROR "org.freedesktop.systemd1.NoSuchUnit"
+#define SD_BUS_DBUS_SERVICE_UNKNOWN_ERROR "org.freedesktop.DBus.Error.ServiceUnknown"
#ifdef NOTIFYDBUS_SUPPORT
#include <systemd/sd-bus.h>
@@ -63,7 +64,8 @@ void lvmnotify_send(struct cmd_context *cmd)
cmd_name);
if (ret < 0) {
- if (sd_bus_error_has_name(&error, SD_BUS_NO_SUCH_UNIT_ERROR))
+ if (sd_bus_error_has_name(&error, SD_BUS_SYSTEMD_NO_SUCH_UNIT_ERROR) ||
+ sd_bus_error_has_name(&error, SD_BUS_DBUS_SERVICE_UNKNOWN_ERROR))
log_debug_dbus("%s: %s", _dbus_notification_failed_msg, error.message);
else
log_warn("WARNING: %s: %s", _dbus_notification_failed_msg, error.message);
6 years, 4 months
master - dbus: only log msg as debug if lvm2-lvmdbusd unit missing for D-Bus notification
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=68d6d342f83f00...
Commit: 68d6d342f83f00784b53dda254d66875e134808d
Parent: e7da8e7e1f27c2ee193a2dfc20819076c2bd19bf
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Nov 14 14:46:44 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Nov 14 14:53:19 2016 +0100
dbus: only log msg as debug if lvm2-lvmdbusd unit missing for D-Bus notification
Do not emit warning message but only log debug message if
lvm2-lvmdbusd.service unit is missing and at the same time
we have global/notify_dbus=1 (which is used by default if we
configured sources with "--enable-notify-dbus"). We don't want
hard dependency between LVM2 and lvmdbusd so it's enough to log
only debug message in this case.
---
WHATS_NEW | 1 +
lib/notify/lvmnotify.c | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 57c382f..7f8801a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.168 -
====================================
+ Only log msg as debug if lvm2-lvmdbusd unit missing for D-Bus notification.
Missing stripe filler now could be also 'zero'.
lvconvert --repair accepts --interval and --background option.
More efficiently prepare _rmeta devices when creating a new raid LV.
diff --git a/lib/notify/lvmnotify.c b/lib/notify/lvmnotify.c
index e9f8e29..ac0ca73 100644
--- a/lib/notify/lvmnotify.c
+++ b/lib/notify/lvmnotify.c
@@ -15,6 +15,7 @@
#define LVM_DBUS_DESTINATION "com.redhat.lvmdbus1"
#define LVM_DBUS_PATH "/com/redhat/lvmdbus1/Manager"
#define LVM_DBUS_INTERFACE "com.redhat.lvmdbus1.Manager"
+#define SD_BUS_NO_SUCH_UNIT_ERROR "org.freedesktop.systemd1.NoSuchUnit"
#ifdef NOTIFYDBUS_SUPPORT
#include <systemd/sd-bus.h>
@@ -26,6 +27,7 @@ int lvmnotify_is_supported(void)
void lvmnotify_send(struct cmd_context *cmd)
{
+ static const char _dbus_notification_failed_msg[] = "D-Bus notification failed";
sd_bus *bus = NULL;
sd_bus_message *m = NULL;
sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -61,7 +63,10 @@ void lvmnotify_send(struct cmd_context *cmd)
cmd_name);
if (ret < 0) {
- log_warn("WARNING: D-Bus notification failed: %s", error.message);
+ if (sd_bus_error_has_name(&error, SD_BUS_NO_SUCH_UNIT_ERROR))
+ log_debug_dbus("%s: %s", _dbus_notification_failed_msg, error.message);
+ else
+ log_warn("WARNING: %s: %s", _dbus_notification_failed_msg, error.message);
goto out;
}
6 years, 4 months
master - tests: fix checking for pvmove LV
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e7da8e7e1f27c2...
Commit: e7da8e7e1f27c2ee193a2dfc20819076c2bd19bf
Parent: a7691cdebb6333b8f35d6a5a1a7d18aad6536c23
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Nov 14 12:55:43 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Nov 14 12:55:43 2016 +0100
tests: fix checking for pvmove LV
Use consitently egrep.
TODO: make probably aux func
---
test/shell/pvmove-resume-2.sh | 2 +-
test/shell/pvmove-resume-multiseg.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/pvmove-resume-2.sh b/test/shell/pvmove-resume-2.sh
index 3baa6df..29fd2a8 100644
--- a/test/shell/pvmove-resume-2.sh
+++ b/test/shell/pvmove-resume-2.sh
@@ -76,7 +76,7 @@ test_pvmove_resume() {
aux enable_dev "$dev2"
i=0
- while get lv_field $vg name -a | grep "^pvmove"; do
+ while get lv_field $vg name -a | egrep "^\[?pvmove"; do
# wait for 30 secs at max
test $i -ge 300 && die "Pvmove is too slow or does not progress."
sleep .1
diff --git a/test/shell/pvmove-resume-multiseg.sh b/test/shell/pvmove-resume-multiseg.sh
index c22770f..a2fbf35 100644
--- a/test/shell/pvmove-resume-multiseg.sh
+++ b/test/shell/pvmove-resume-multiseg.sh
@@ -89,7 +89,7 @@ test_pvmove_resume() {
aux enable_dev "$dev5"
i=0
- while get lv_field $vg name -a | grep "^\[?pvmove"; do
+ while get lv_field $vg name -a | egrep "^\[?pvmove"; do
# wait for 30 secs at max
test $i -ge 300 && die "Pvmove is too slow or does not progress."
sleep .1
6 years, 4 months
master - cleanup: debug trace and indent change
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a7691cdebb6333...
Commit: a7691cdebb6333b8f35d6a5a1a7d18aad6536c23
Parent: 6db5b91231ce7ac84fafd4190bb3b4a079db1f49
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 8 16:20:51 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 11 16:58:20 2016 +0100
cleanup: debug trace and indent change
---
lib/activate/dev_manager.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index da66374..1a79c08 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2305,7 +2305,7 @@ static char *_add_error_or_zero_device(struct dev_manager *dm, struct dm_tree *d
if (!dm_tree_add_dev(dtree, info.major, info.minor)) {
log_error("Failed to add device (%" PRIu32 ":%" PRIu32") to dtree.",
info.major, info.minor);
- return_NULL;
+ return NULL;
}
}
@@ -2833,7 +2833,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
return_0;
- /* Even unused thin-pool still needs to get layered UUID -suffix */
+ /* Even unused thin-pool still needs to get layered UUID -suffix */
if (!layer && lv_is_new_thin_pool(lv))
layer = lv_layer(lv);
6 years, 4 months