什么是USEC_INITIALIZED属性?

时间:2019-01-10 05:47:23

标签: linux-device-driver udev block-device

我得到udevadm info -q property -n /dev/sda

的以下输出
DEVLINKS=/dev/disk/by-path/pci-0000:00:1f.2-ata-1 /dev/disk/by-id/wwn-0x5000c500a90b2880 /dev/disk/by-id/ata-ST500LM021-1KJ152_W62GX4GF
DEVNAME=/dev/sda
DEVPATH=/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
DEVTYPE=disk
ID_ATA=1
ID_ATA_DOWNLOAD_MICROCODE=1
ID_ATA_FEATURE_SET_APM=1
ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=128
ID_ATA_FEATURE_SET_APM_ENABLED=1
ID_ATA_FEATURE_SET_HPA=1
ID_ATA_FEATURE_SET_HPA_ENABLED=1
ID_ATA_FEATURE_SET_PM=1
ID_ATA_FEATURE_SET_PM_ENABLED=1
ID_ATA_FEATURE_SET_PUIS=1
ID_ATA_FEATURE_SET_PUIS_ENABLED=0
ID_ATA_FEATURE_SET_SECURITY=1
ID_ATA_FEATURE_SET_SECURITY_ENABLED=0
ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=78
ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=78
ID_ATA_FEATURE_SET_SMART=1
ID_ATA_FEATURE_SET_SMART_ENABLED=1
ID_ATA_ROTATION_RATE_RPM=7200
ID_ATA_SATA=1
ID_ATA_SATA_SIGNAL_RATE_GEN1=1
ID_ATA_SATA_SIGNAL_RATE_GEN2=1
ID_ATA_WRITE_CACHE=1
ID_ATA_WRITE_CACHE_ENABLED=1
ID_BUS=ata
ID_MODEL=ST500LM021-1KJ152
ID_MODEL_ENC=ST500LM021-1KJ152\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
ID_PART_TABLE_TYPE=gpt
ID_PART_TABLE_UUID=f8f58152-5c2e-4c72-9b1a-8bdde0e1c8ee
ID_PATH=pci-0000:00:1f.2-ata-1
ID_PATH_TAG=pci-0000_00_1f_2-ata-1
ID_REVISION=0005SDM1
ID_SERIAL=ST500LM021-1KJ152_W62GX4GF
ID_SERIAL_SHORT=W62GX4GF
ID_TYPE=disk
ID_WWN=0x5000c500a90b2880
ID_WWN_WITH_EXTENSION=0x5000c500a90b2880
MAJOR=8
MINOR=0
SUBSYSTEM=block
TAGS=:systemd:
USEC_INITIALIZED=2694098

输出最后一行中的USEC_INITIALIZED属性是什么。

是从连接设备到设备实际初始化之间的时间。

如果是初始化时间,内核将如何知道何时初始化设备,因为针对不同类型的设备(例如,块设备,相机等)将以不同的方式进行操作。

1 个答案:

答案 0 :(得分:1)

USEC_INITIALIZED设置为在udevd中注册设备时单调增加的系统时钟的值。该时钟的保证是它永远不会倒退。它通常在启动时从0开始。这是来自systemd/src/libsystemd/sd-device/device-private.c的函数:

int device_ensure_usec_initialized(sd_device *device, sd_device *device_old) {
        usec_t when;

        assert(device);

        if (device_old && device_old->usec_initialized > 0)
                when = device_old->usec_initialized;
        else
                when = now(CLOCK_MONOTONIC);

        return device_set_usec_initialized(device, when);
}