Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /usr/lib/python2.7/site-packages/tuned/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyc
�
+cc@s�ddlZddlmZddlTddlZddljZddlm	Z	ddl
Z
ddlZejj
�Zdejfd��YZdS(i����Ni(thotplug(t*(tcommandst
DiskPlugincBs9eZdZd�Zd�Zd�Zd�Zed��Zd�Z	d�Z
d�Zd	�Zd
�Z
ed��Zed��Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zedde�d��Ze d�e!d��Z"edde�d ��Z#e d�e!d!��Z$ed"de�d#��Z%e d"�e!d$��Z&d%�Z'd&�Z(ed'de�d(��Z)e d'�e!d)��Z*e+d*de�d+��Z,d,�Z-ed-de�d.��Z.e d-�e!d/��Z/RS(0s'
	Plugin for tuning options of disks.
	cOs�tt|�j||�ddddddddd	d
ddg|_d
dddddddddd	dg|_t|j�|_d|_d|_t	�|_
dS(Ni�i�i�i�i�i}iiiUiFi7iiii�i�i�i�i�i�i�iniZi<ig{�G�z�?(tsuperRt__init__t
_power_levelst_spindown_levelstlent_levelst_level_stepst_load_smallestRt_cmd(tselftargstkwargs((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyRs--		cCs�tt|�j�t|_t|_t�|_t�|_xp|j	j
d�D]\}|j|�rP|jj|j
�|jr�|j|j
�r�|jj|j
�q�qPqPWt�|_dS(Ntblock(RRt
_init_devicestTruet_devices_supportedt_use_hdparmtsett
_free_devicest_hdparm_apm_devicest_hardware_inventorytget_devicest_device_is_supportedtaddtsys_namet_is_hdparm_apm_supportedt_assigned_devices(R
tdevice((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyRs		cCs&g|D]}|jjd|�^qS(NR(Rt
get_device(R
tdevicestx((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_get_device_objects)scCs�|jjddd|gdtjgdt�\}}}|tjkrdtjd�t|_tS|r�tj	d|�tj
d||f�tSd	|kr�tj	d
|�tStS(Nthdparms-Cs/dev/%st	no_errorst
return_errs4hdparm command not found, ignoring for other devicess#Device '%s' not supported by hdparms(rc: %s, msg: '%s')tunknowns3Driver for device '%s' does not support apm command(RtexecuteterrnotENOENTRtlogtwarntFalseRtinfotdebug(R
Rtrctoutterr_msg((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyR,s
	cCsI|jdkoH|jjdd�dkoH|jdkpH|jjdkS(	Ntdiskt	removablet0tscsitvirtiotxentnvme(R6R7R8R9(tdevice_typet
attributestgettNonetparentt	subsystem(tclsR((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyR<scCs|jj|d|j�dS(NR(Rt	subscribet_hardware_events_callback(R
((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_hardware_events_initCscCs|jj|�dS(N(Rtunsubscribe(R
((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_hardware_events_cleanupFscCs;|j|�s|dkr7tt|�j||�ndS(Ntremove(RRRRB(R
teventR((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyRBIscCs?|jdk	r"|jj|�ntt|�j||�dS(N(t
_load_monitorR=t
add_deviceRRt_added_device_apply_tuning(R
tinstancetdevice_name((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyRJMscCs?|jdk	r"|jj|�ntt|�j||�dS(N(RHR=t
remove_deviceRRt_removed_device_unapply_tuning(R
RKRL((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyRNRscCs5itd6dd6dd6dd6dd6dd6dd6S(Ntdynamictelevatortapmtspindownt	readaheadtreadahead_multiplytscheduler_quantum(RR=(R@((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_get_config_optionsWscCs
ddgS(NRQRR((R@((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt#_get_config_options_used_by_dynamiccscCs�t|_d|_d|_|j|jd�r|t|_|jjd|j	�|_
i|_i|_i|_
i|_nt|_d|_
dS(NiROR3(Rt_has_static_tuningt_apm_errcntt_spindown_errcntt_option_booltoptionst_has_dynamic_tuningt_monitors_repositorytcreatetassigned_devicesRHt_device_idlet_statst_idlet_spindown_change_delayedR-R=(R
RK((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_instance_initjs									cCs2|jdk	r.|jj|j�d|_ndS(N(RHR=R^tdelete(R
RK((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_instance_cleanup}scCs�|rd}|j}nd}|j}|tjkr:dS|dkrOd}ne|tjkr�tjd|_|_tjd�dS|d7}|tjkr�tjd|�n|r�||_n	||_dS(NRRRQiisIhdparm command not found, ignoring future set_apm / set_spindown commandss5disabling set_%s command: too many consecutive errors(	RZRYtconststERROR_THRESHOLDR)R*R+R,R.(R
R0RRtstcnt((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_update_errcnt�s&		

cCsgtjd|�|jjdd|d|gdtjg�\}}|j|t�t|j	|<dS(Nschanging spindown to %dR$s-S%ds/dev/%sR%(
R+R/RR(R)R*RlRR-Rd(R
RKRtnew_spindown_levelR0R1((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_change_spindown�s5cCsG|jjddd|gdtjg�\}}d|koFd|kS(NR$s-Cs/dev/%sR%tstandbytsleeping(RR(R)R*(R
RR0R1((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_drive_spinning�s1cCs�||jkrdS|jj|�}|dkr5dS||jkrW|j||�n|j|||�|j||�|j|}|j|}|dd|j	kr�|d|j
kr�|d|j
kr�d}n?|ddkr|ddks
|ddkrd}nd}|dkr?|dc|7<|j|d}|j|d}t
jd|d�|jtjkr�|j|�r�|dkr�t
jd|�t|j|<q�|j|||�n|jtjkr�t
jd	|�|jjd
d|d|gd
tjg�\}	}
|j|	t�q�nC|j|r�|j|�r�|j|d}|j|||�nt
jd||d|df�t
jd||d|d|df�dS(Ntlevelitreadtwriteii����stuning level changed to %ds;delaying spindown change to %d, drive has already spun downschanging APM_level to %dR$s-B%ds/dev/%sR%s %s load: read %0.2f, write %0.2fs$%s idle: read %d, write %d, level %d(RRHtget_device_loadR=Rbt_init_stats_and_idlet
_update_statst_update_idleRcR	R
RRR+R/RZRhRiRqRRdRnRYRR(R)R*RlR-(R
RKRtloadtstatstidletlevel_changetnew_power_levelRmR0R1((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_instance_update_dynamic�sF

=	0	5"cCsjiddgd6ddgd6ddgd6|j|<idd6dd6dd	6|j|<t|j|<dS(
NiitnewtolditmaxRrRsRt(RbRcR-Rd(R
RKR((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyRv�s7"c
Cs|j|d|j|d<}||j|d<gt||�D]}|d|d^qA}||j|d<|j|d}gt||�D]}t|�^q�}	|	|j|d<t|d�t|	d�|j|d<t|d�t|	d�|j|d	<dS(
NRR�iitdiffR�RsiRt(RbtzipR�tfloat(
R
RKRtnew_loadtold_loadtnew_oldR�told_max_loadtpairtmax_load((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyRw�s .()cCs`xYddgD]K}|j|||jkrG|j||cd7<q
d|j||<q
WdS(NRsRtii(RbRRc(R
RKRt	operation((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyRx�scCs@||jkr#tjd|�ntt|�jtt�dS(Ns<There is no dynamic tuning available for device '%s' at time(RR+R.RRt_instance_apply_dynamicRR(R
RKR((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyR��scCsdS(N((R
RKR((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_instance_unapply_dynamic�ss/sys/block/cCs_d|krItjj||jdd�|�}tjj|�rI|Sntjj|||�S(Nt/t!(tostpathtjointreplacetexists(R
Rtsuffixtprefixtdev((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_sysfs_paths
$cCs|j|d�S(Nsqueue/scheduler(R�(R
R((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_elevator_filesRPt
per_devicecCs/|j|�}|s+|jj||�n|S(N(R�Rt
write_to_file(R
tvalueRtsimtsys_file((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt
_set_elevator
scCs1|j|�}|jj|jj|d|��S(Ntno_error(R�Rtget_active_optiont	read_file(R
Rtignore_missingR�((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt
_get_elevatorsRQcCs�||jkr7|s*tjd|�dSt|�Sn|jtjkr�|s�|jj	ddt|�d|gdt
jg�\}}|j|t
�nt|�SdSdS(Ns+apm option is not supported for device '%s'R$s-Bs/dev/R%(RR+R.R=tstrRYRhRiRR(R)R*RlR-(R
R�RR�R0R1((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_set_apms
:
cCs||jkr-|s)tjd|�ndSd}t}|jjddd|gdtjg�\}}|tjkr~dS|dkr�t	}nTt
jd|t
j�}|r�yt
|jd��}Wq�tk
r�t	}q�Xn|rtjd	|�n|S(
Ns+apm option is not supported for device '%s'R$s-Bs/dev/R%is
.*=\s*(\d+).*is2could not get current APM settings for device '%s'(RR+R.R=R-RR(R)R*RtretmatchtStinttgroupt
ValueErrorterror(R
RR�R�terrR0R1tm((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_get_apm(s(1	

RRcCs�||jkr7|s*tjd|�dSt|�Sn|jtjkr�|s�|jj	ddt|�d|gdt
jg�\}}|j|t
�nt|�SdSdS(Ns0spindown option is not supported for device '%s'R$s-Ss/dev/R%(RR+R.R=R�RZRhRiRR(R)R*RlR(R
R�RR�R0R1((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt
_set_spindown@s
:
cCs1||jkr-|s)tjd|�ndSdS(Ns0spindown option is not supported for device '%s'i�(RR+R.R=(R
RR�((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt
_get_spindownPs
cCs|j|d�S(Nsqueue/read_ahead_kb(R�(R
R((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_readahead_fileYscCs_t|�jdd�}t|d�}t|�dkr[|dddkr[|d:}n|S(NiiRji(R�tsplitR=R�R(R
R�tvaltv((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt	_parse_ra\s
&
RScCsB|j|�}|j|�}|s>|jj|d|�n|S(Ns%d(R�R�RR�(R
R�RR�R�R�((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_set_readaheadds
cCsM|j|�}|jj|d|�j�}t|�dkrCdSt|�S(NR�i(R�RR�tstripRR=R�(R
RR�R�R�((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_get_readaheadls
RTc	Cs�|r
dS|jddd|�}|r�|j|�}|dkrGdStt|�|�}|jj||�|j||t�nE|jj	|�}|dkr�dS|j||t�|jj
|�dS(Ntcommand_nameRTRL(R=t_storage_keyR�R�R�t_storageRR�R-R<tunset(	R
tenablingt
multiplierRtverifyR�tstorage_keyt
old_readaheadt
new_readahead((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_multiply_readaheadts"		cCs|j|d�S(Nsqueue/iosched/quantum(R�(R
R((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_scheduler_quantum_file�sRUcCs9|j|�}|s5|jj|dt|��n|S(Ns%d(R�RR�R�(R
R�RR�R�((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_set_scheduler_quantum�s cCsg|j|�}|jj|d|�j�}t|�dkr]|sYtjd|�ndSt|�S(NR�is>disk_scheduler_quantum option is not supported for device '%s'(	R�RR�R�RR+R.R=R�(R
RR�R�R�((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt_get_scheduler_quantum�s(0t__name__t
__module__t__doc__RRR#RtclassmethodRRCRERBRJRNRVRWReRgRlRnRqR~RvRwRxR�R�R�R�tcommand_setRR�tcommand_getR-R�R�R�R�R�R�R�R�R�tcommand_customR�R�R�R�(((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyRsZ	
														2															(R)tRt
decoratorst
tuned.logsttunedttuned.constsRhttuned.utils.commandsRR�R�tlogsR<R+tPluginR(((s=/usr/lib/python2.7/site-packages/tuned/plugins/plugin_disk.pyt<module>s


ZeroDay Forums Mini