관리-도구
편집 파일: plugin_mounts.cpython-39.opt-1.pyc
a ����,�g�����������������������@���sr���d�dl�mZ�ddlmZ�ddlT�d�dlmZmZ�d�dlZ d�dl mZ�d�dlZe j ���Ze��ZG�dd��dej�ZdS�) �����N����)�base)�*)�Popen�PIPE)�commandsc�������������������@���st���e�Zd�ZdZedd���Zdd��Zedd���Zdd ��Zd d��Z dd ��Z dd��Zdd��Zdd��Z eddd�dd���ZdS�)�MountsPlugina=�� Enables or disables barriers for mounts according to the value of the boolean option [option]`disable_barriers`. The option additionally allows the special value `force`, which disables barriers even on mountpoints with write back caches. NOTE: Only extended file systems (ext) are supported by this plug-in. c�����������������C���s����i�}d}t�g�d�ttddd����\}}dd��|���D��D�]�}t|�dk�rJq8|dd��\}}}t|�dkrp|d�nd} t|�dkr�|d�nd} |d kr�|}q8|d ks8|dvr�q8| du�s8| dkr�q8|�| t��|| d ���|| �d��|��q8||�_dS�)z� Gets the information about disks, partitions and mountpoints. Stores information about used filesystem and creates a list of all underlying devices (in case of LVM) for each mountpoint. N)Zlsblkz-rnozTYPE,RM,KNAME,FSTYPE,MOUNTPOINTT)�stdout�stderrZ close_fdsZuniversal_newlinesc�����������������S���s���g�|�]}|�����qS���)�split)�.0�liner���r����?/usr/lib/python3.9/site-packages/tuned/plugins/plugin_mounts.py� <listcomp>#��������z>MountsPlugin._generate_mountpoint_topology.<locals>.<listcomp>��������Zdisk�1)�partZlvmz[SWAP])�disks�device_name� filesystemr���) r���r���Zcommunicate� splitlines�len� setdefault�set�add�_mountpoint_topology)�clsZmountpoint_topologyZcurrent_diskr ���r ����columnsZdevice_typeZdevice_removabler���r���� mountpointr���r���r����_generate_mountpoint_topology���s,�����z*MountsPlugin._generate_mountpoint_topologyc�����������������C���s*���|������d|�_t|�j����|�_t��|�_d�S�)NT)r"���Z_devices_supportedr���r����keysZ _free_devicesZ_assigned_devices��selfr���r���r���� _init_devices:���s����zMountsPlugin._init_devicesc�����������������C���s���dd�iS�)N�disable_barriersr���r$���r���r���r����_get_config_options@���s�����z MountsPlugin._get_config_optionsc�����������������C���s���d|_�d|_d�S�)NFT)Z_has_dynamic_tuningZ_has_static_tuning�r%����instancer���r���r����_instance_initF���s����zMountsPlugin._instance_initc�����������������C���s���d�S�)Nr���r)���r���r���r����_instance_cleanupJ���s����zMountsPlugin._instance_cleanupc�����������������C���s,���t���d|��}|D�]}t�|������S�dS�)zV Get device cache type. This will work only for devices on SCSI kernel subsystem. z+/sys/block/%s/device/scsi_disk/*/cache_typeN)�glob�cmdZ read_file�strip)r%����deviceZsource_filenamesZsource_filenamer���r���r����_get_device_cache_typeM���s����z#MountsPlugin._get_device_cache_typec�����������������C���s,���|�j�|�d�D�]}|��|�dkr�dS�qdS�)zr Checks if the device has 'write back' cache. If the cache type cannot be determined, asume some other cache. r���z write backTF)r���r1���)r%���r!���r0���r���r���r����_mountpoint_has_writeback_cacheV���s����z,MountsPlugin._mountpoint_has_writeback_cachec�����������������C���s����t�d��\}|D�]6}|���}|d�d�dkr,q|d�|kr|d�}�qVqW�d����dS�W�d����n1�sj0����Y��|�d�}|D�]@}|�d�\}} } |d ks�|d kr�| dkr��dS�|d kr��d S�q�d S�)zP Checks if a given mountpoint is mounted with barriers enabled or disabled. z/proc/mountsr����/r���r���N�,�=Z nobarrierZbarrier�0FT)�openr���� partition)r%���r!���Zmounts_filer���r ���Zoption_list�options�option�name�sep�valuer���r���r����_mountpoint_has_barriers_���s"���� . z%MountsPlugin._mountpoint_has_barriersc�����������������C���s���d|dd|�g}t��|��dS�)z Remounts partition. z/usr/bin/mountz-oz remount,%sN)r.���Zexecute)r%���r8���r9���Zremount_commandr���r���r����_remount_partition|���s����zMountsPlugin._remount_partitionr'���T)Z per_devicec�����������������C���sX��|�j�d|d�}t|����dk}|p*|��|�}|�r |s:d�S�d�} |�j|�d��d�sXd} nj|sl|��|�rld} nV|��|�} | d�u�r�d} n>| d kr�|r�t� t j|���d S�d} n|r�t�t j |���d S�| d�ur�t� d|| f���d�S�|�j�|| ��t� d |���|��|d��nJ|�rd�S�|�j�|�} | d�u��r.d�S�t� d|���|��|d��|�j�|��d�S�)Nr'���)Zcommand_namer����forcer����extzfilesystem not supportedzdevice uses write back cachezunknown current settingFTzbarriers already disabledz#not disabling barriers on '%s' (%s)zdisabling barriers on '%s'z barrier=0zenabling barriers on '%s'z barrier=1)Z_storage_key�str�lowerZ_option_boolr���� startswithr2���r>����log�info�constsZSTR_VERIFY_PROFILE_OK�errorZSTR_VERIFY_PROFILE_FAILZ_storager���r?����getZunset)r%����startr=���r!���ZverifyZignore_missingr*���Zstorage_keyr@���Z reject_reason�original_valuer���r���r����_disable_barriers����sP����� zMountsPlugin._disable_barriersN)�__name__� __module__�__qualname__�__doc__�classmethodr"���r&���r(���r+���r,���r1���r2���r>���r?���Zcommand_customrL���r���r���r���r���r������s��� # r���)Ztuned.constsrG�����r���Z decorators� subprocessr���r���Z tuned.logsZtunedZtuned.utils.commandsr���r-���ZlogsrI���rE���r.���ZPluginr���r���r���r���r����<module>���s���