3 $sz>MountsPlugin._generate_mountpoint_topology..Zdisk1partlvmz[SWAP])disks device_name filesystemr)rr) rrZ communicate splitlineslen setdefaultsetadd_mountpoint_topology) clsZmountpoint_topologyZ current_diskr r columnsZ device_typeZdevice_removablerr mountpointr r r_generate_mountpoint_topologys, z*MountsPlugin._generate_mountpoint_topologycCs*|jd|_t|jj|_t|_dS)NT)r"Z_devices_supportedrrkeysZ _free_devicesZ_assigned_devices)selfr r r _init_devices;szMountsPlugin._init_devicescCsddiS)Ndisable_barriersr )r$r r r_get_config_optionsAsz MountsPlugin._get_config_optionscCsd|_d|_dS)NFT)Z_has_dynamic_tuningZ_has_static_tuning)r$instancer r r_instance_initGszMountsPlugin._instance_initcCsdS)Nr )r$r(r r r_instance_cleanupKszMountsPlugin._instance_cleanupcCs,tjd|}x|D]}tj|jSWdS)zV Get device cache type. This will work only for devices on SCSI kernel subsystem. z+/sys/block/%s/device/scsi_disk/*/cache_typeN)globcmdZ read_filestrip)r$deviceZsource_filenamesZsource_filenamer r r_get_device_cache_typeNs z#MountsPlugin._get_device_cache_typecCs.x(|j|dD]}|j|dkrdSqWdS)zr Checks if the device has 'write back' cache. If the cache type cannot be determined, asume some other cache. rz write backTF)rr/)r$r!r.r r r_mountpoint_has_writeback_cacheWsz,MountsPlugin._mountpoint_has_writeback_cachec CstdH}x@|D]4}|j}|dddkr.q|d|kr|d}PqWdSWdQRX|jd}xH|D]<}|jd\}} } |d ks|d kr| d krd S|d krfd SqfWd SdS)zP Checks if a given mountpoint is mounted with barriers enabled or disabled. z /proc/mountsr/rrN,=Z nobarrierZbarrier0FT)openr partition) r$r!Z mounts_filerr Z option_listoptionsZoptionnamesepvaluer r r_mountpoint_has_barriers`s"     z%MountsPlugin._mountpoint_has_barrierscCsd|dd|g}tj|dS)z Remounts partition. z/usr/bin/mountz-oz remount,%sN)r,Zexecute)r$r6r7Zremount_commandr r r_remount_partition}szMountsPlugin._remount_partitionr&T)Z per_devicec CsZ|jd|d}t|jdk}|p*|j|}|r |s:dSd}|j|djdsXd}nl| rn|j|rnd}nV|j|} | dkrd}n>| d kr|rtj t j |d Sd }n|rtj t j |d S|dk rtj d ||fdS|jj|| tj d ||j|dnJ|rdS|jj|} | dkr0dStj d||j|d|jj|dS)Nr&)Z command_namerforcerZextzfilesystem 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_keystrlowerZ _option_boolr startswithr0r;loginfoconstsZSTR_VERIFY_PROFILE_OKerrorZSTR_VERIFY_PROFILE_FAILZ_storagerr<getZunset) r$startr:r!ZverifyZignore_missingZ storage_keyr=Z reject_reasonoriginal_valuer r r_disable_barrierssN     zMountsPlugin._disable_barriersN)__name__ __module__ __qualname____doc__ classmethodr"r%r'r)r*r/r0r;r<Zcommand_customrHr r r rr s  $   r)Z tuned.constsrCrZ decorators subprocessrrZ tuned.logsZtunedZtuned.utils.commandsrr+ZlogsrErAr,ZPluginrr r r rs