Dear list,

I met a problem that looks like systemd-udevd will make a new scsi disk 
partition (like /dev/sdb1)
disappear in a few time. This problem makes libvirt cannot lstat the new scsi 
disk for a period.
(you can check this link https://bugzilla.redhat.com/show_bug.cgi?id=1264719).
And we wrote a script to verify this problem and finally find if we stop 
systemd-udevd, this will not happen.

Could you please give me some help and tell me what systemd-udevd does to a new 
scsi disk partition
making scsi disk partition disappear in a few time? Thanks in advance for your 
reply.

And the attachment is the script we have used to check if that scsi device will 
disappear.

BR,
Luyao
#!/usr/bin/env python
"""
Verify bug https://bugzilla.redhat.com/show_bug.cgi?id=1264719
"""
import glob
import os
import subprocess
import threading
import time
import numpy


def prepare_disk():
    """
    Prepare a SCSI disk for debug
    """
    subprocess.call(['rmmod', 'scsi_debug'])
    pre_disks = glob.glob('/dev/sd?')
    subprocess.call(['modprobe', 'scsi_debug'])
    new_disks = set(glob.glob('/dev/sd?')) - set(pre_disks)
    if len(new_disks) > 1:
        raise Exception('Multiple new SCSI disks found: %s' % new_disks)
    elif len(new_disks) == 0:
        raise Exception("No new SCSI disks found after 'modprobe scsi_debug'")
    new_disk = list(new_disks)[0]

    subprocess.call(['parted', '-s', new_disk, 'mklabel', 'msdos'])
    subprocess.call(['parted', '-s', new_disk, 'mkpart', 'primary', 'ext4',
                     '8192s', '100%'], stderr=subprocess.STDOUT)
    subprocess.call(['sync'])
    time.sleep(1)

    return new_disk


def monitor_partition(disk, status):
    """
    Start a process to monitor change of partitions on given disk.
    """
    part = disk + '1'
    exists = True
    while status['running']:
        if os.path.exists(part) != exists:
            exists = not exists
            status['changes'] += 1
            now = time.time()
            if exists:
                status['durations'].append(now - status['lastchange'])
            status['lastchange'] = now


def run():
    """
    Main run function
    """
    count = 0
    results = {}
    status = {'running': True, 'changes': 0, 'durations': [], 'lastchange': 0}
    disk = prepare_disk()
    t_mon = threading.Thread(target=monitor_partition, args=(disk, status))
    t_mon.start()
    time.sleep(1)
    try:
        while True:
            prepare_disk()
            count += 1

            if count % 10 == 0:
                print "Iteration %8d: part changed %d times" % (
                    count, status['changes'])
                print "\tStats of blackout:"
                print "\t\tMean:%s" % numpy.mean(status['durations'])
                print "\t\tDeviation:%s" % numpy.std(status['durations'])
                for result, result_count in results.items():
                    result_str = '\n'.join(result[1:]).strip()
                    if result_str:
                        result_str = result_str.splitlines()[-1]
                    print "\t%5.2f%%: %s" % (
                        float(result_count) * 100 / count, result_str)
    finally:
        status['running'] = False


if __name__ == '__main__':
    run()
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to