Skip to content

Commit

Permalink
add 'udevadm trigger' wrapper and call after device add rockstor#1606
Browse files Browse the repository at this point in the history
This was found to be required to ensure lsblk and udev info
was successfully updated after a btrfs device add command.
The failed state of stale info was only rarely observed but
was reproduced a number of times using both whole and
partition pool members.
  • Loading branch information
phillxnet committed Jan 9, 2017
1 parent 6a71ae8 commit 0358560
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rockstor/storageadmin/views/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from fs.btrfs import (add_pool, pool_usage, resize_pool, umount_root,
btrfs_uuid, mount_root, start_balance, usage_bound,
remove_share)
from system.osi import remount
from system.osi import remount, trigger_udev_update
from storageadmin.util import handle_exception
from django.conf import settings
import rest_framework_custom as rfc
Expand Down Expand Up @@ -369,7 +369,8 @@ def put(self, request, pname, command):
for d_o in disks:
d_o.pool = pool
d_o.save()

# Now we ensure udev info is updated via system wide trigger
trigger_udev_update()
elif (command == 'remove'):
if (new_raid != pool.raid):
e_msg = ('Raid configuration cannot be changed while '
Expand Down
12 changes: 12 additions & 0 deletions src/rockstor/system/osi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1691,3 +1691,15 @@ def hostid():
return puuid
except:
return '%s-%s' % (run_command([HOSTID])[0][0], str(uuid.uuid4()))


def trigger_udev_update():
"""
In some instances udev info can be out of date after some btrfs opperations.
To cause a system wide update of all udev info, and the output of lsblk,
we can execute:
udevadm trigger
This function is a simple wrapper to call the above command via run_command
:return: o, e, rc as returned by run_command
"""
return run_command([UDEVADM, 'trigger'])

0 comments on commit 0358560

Please sign in to comment.