VULN_CHECK_I913V6 GiCddlZddlmZddlddlZddlmZddlm Z ddl Z ddl Z ejjZGddejZy)N)hotplug)*)commandscXeZdZdZfdZfdZdZdZedZ dZ dZ fd Z fd Z fd Zed Zed ZdZdZfdZdZdZdZdZdZdZdZfdZdZd2dZdZedddZ e!dd3d Z"ed!dd"Z#e!d!d3d#Z$ed$dd%Z%e!d$d3d&Z&d'Z'd(Z(ed)dd*Z)e!d)d3d+Z*e+d,dd-Z,d.Z-ed/dd0Z.e!d/d3d1Z/xZ0S)4 DiskPlugina. Plug-in for tuning various block device options. This plug-in can also dynamically change the advanced power management and spindown timeout setting for a drive according to the current drive utilization. The dynamic tuning is controlled by the [option]`dynamic` and the global [option]`dynamic_tuning` option in `tuned-main.conf`. The disk plug-in operates on all supported block devices unless a comma separated list of [option]`devices` is passed to it. .Operate only on the `sda` block device ==== ---- [disk] devices=sda ---- ==== The [option]`elevator` option sets the Linux I/O scheduler. .Use the bfq I/O scheduler on the `xvda` block device ==== ---- [disk] device=xvda elevator=bfq ---- ==== The [option]`scheduler_quantum` option only applies to the CFQ I/O scheduler. It defines the number of I/O requests that CFQ sends to one device at one time, essentially limiting queue depth. The default value is 8 requests. The device being used may support greater queue depth, but increasing the value of quantum will also increase latency, especially for large sequential write work loads. The [option]`apm` option sets the Advanced Power Management feature on drives that support it. It corresponds to using the `-B` option of the `hdparm` utility. The [option]`spindown` option puts the drive into idle (low-power) mode, and also sets the standby (spindown) timeout for the drive. It corresponds to using `-S` option of the `hdparm` utility. .Use a medium-agressive power management with spindown ==== ---- [disk] apm=128 spindown=6 ---- ==== The [option]`readahead` option controls how much extra data the operating system reads from disk when performing sequential I/O operations. Increasing the `readahead` value might improve performance in application environments where sequential reading of large files takes place. The default unit for readahead is KiB. This can be adjusted to sectors by specifying the suffix 's'. If the suffix is specified, there must be at least one space between the number and suffix (for example, `readahead=8192 s`). .Set the `readahead` to 4MB unless already set to a higher value ==== ---- [disk] readahead=>4096 ---- ==== The disk readahead value can be multiplied by the constant specified by the [option]`readahead_multiply` option. ctt| |i|gd|_gd|_t |j|_d|_d|_t|_ y)N) }iUF7) rnZr<g{Gz?) superr__init__ _power_levels_spindown_levelslen_levels _level_steps_load_smallestr_cmd)selfargskwargs __class__s >/usr/lib/python3.12/site-packages/tuned/plugins/plugin_disk.pyr"zDiskPlugin.__init__UsR D"D3F3N$Q$T''($,$$j$)cNtt| d|_d|_t |_t|_|jjdD]9}|j|s|j j|j;t |_y)NTblock)r!r _init_devices_devices_supported _use_hdparmset _free_devicesdict_hdparm_apm_device_support_hardware_inventory get_devices_device_is_supportedaddsys_name_assigned_devices)r*devicer-s r.r2zDiskPlugin._init_devices_s D') $$u$$(F$!((44W=f '6??+>5$r/c`|Dcgc]}|jjd| c}Scc}wNr1)r9 get_device)r*devicesxs r._get_device_objectszDiskPlugin._get_device_objectsjs-CJ K7a$ " " - -gq 97 KK Ks#+c*|jsy||jvr|j|S|jjddd|zgtj gd\}}}|tj k(rt jdd|_y|rDt jd|zt jd |d |d d|j|<yd |vr(t jd |zd|j|<yd|j|<y)NFhdparm-C/dev/%sT) no_errors return_errz4hdparm command not found, ignoring for other devicesz#Device '%s' not supported by hdparmz(rc: z, msg: 'z')unknownz3Driver for device '%s' does not support apm command) r4r8r)executeerrnoENOENTlogwarninginfodebug)r*r?rcouterr_msgs r._is_hdparm_apm_supportedz#DiskPlugin._is_hdparm_apm_supportedms    t...  ) )& 11yy(((D)f:L)M4)12sGELL=;;EF4  88 1F :;99b' 23-24""6* C88 AF JK-24""6* ,0$!!&) r/c|jdk(xrI|jjdddk(xr(|jduxs|jjdvS)Ndisk removable0)scsivirtioxennvmemmc) device_type attributesgetparent subsystem)clsr?s r.r;zDiskPlugin._device_is_supportedsb    &  d+t3  MMT ]]!r/cR|jj|d|jyrA)r9 subscribe_hardware_events_callbackr*s r._hardware_events_initz DiskPlugin._hardware_events_inits $$T7D4R4RSr/c:|jj|yN)r9 unsubscriberjs r._hardware_events_cleanupz#DiskPlugin._hardware_events_cleanups&&t,r/c\|j|s|dk(rtt|||yy)Nremove)r;r!rri)r*eventr?r-s r.riz$DiskPlugin._hardware_events_callbacks. v&%8*;T4UFC+)) .&%-w1X XY)) 2fd6lDQXM[_`g[h5i ijr/cddgzddgzddgzd|j|<dddd|j|<d|j|<y)N rr)newoldmax)rrrF)rrrr*rxr?s r.rzDiskPlugin._init_stats_and_idlesN%'1#XbA3hrQCxQ(//&&'Q@(...3(##F+r/c,|j|dx|j|d<}||j|d<t||Dcgc] }|d|dz }}||j|d<|j|d}t||Dcgc] }t|} }| |j|d<t|dt| dz |j|d<t|dt| dz |j|d <ycc}wcc}w) Nrrrrdiffrrr)rziprfloat) r*rxr?new_loadold_loadnew_oldr old_max_loadpairmax_loads r.rzDiskPlugin._update_stats#s".6oof.Ee.LL(//&% 8#+(//&% 25Xx1H I1Hg'!*wqz !1H$ I$((//&&!(/,$' d$; <$;Dc$i$;( <#+(//&% &+47^eHQK6H%H(//&&!%*47^eHQK6H%H(//&'" J =s D  DcdD]N}|j|||jkr|j||xxdz cc<=d|j||<Py)N)rrrr)rr(r)r*rxr? operations r.rzDiskPlugin._update_idle4sT$ioofi(4+>+>> NN69%*%()HNN69% %r/c|j|stjd|zytt|||y)Nzdisk_scheduler_quantum option is not supported for device '%s')r'r)rrr%rPrRrrs r._get_scheduler_quantumz!DiskPlugin._get_scheduler_quantumsb  ) )& 1( ))  h  @ F F H%Z1_ HH MPV VW  Ur/)z /sys/block/)F)1__name__ __module__ __qualname____doc__r"r2rErW classmethodr;rkrorirvr|rrrrrrrrrrrrrrrr command_setr command_getrrrrr r rrrcommand_customr%r'r)r+ __classcell__)r-s@r.rr sFP !L.T-DL P    P! )04 80kd4 I"*E.5jT*+j]] e% & e.jT* + j  9  kd+  ,  k%$7$8$(;!d34!"#r/r)rNr decorators tuned.logstuned tuned.constsrtuned.utils.commandsrrrlogsrcrPPluginrrr/r.r=s? )  jjnn``r/