ó ±2öYc@s˜ddljZddlZddlTddlmZmZddlZddl m Z ddl Z ej j ƒZe ƒZdejfd„ƒYZdS(iÿÿÿÿN(t*(tPopentPIPE(tcommandst MountsPlugincBs†eZdZed„ƒZd„Zed„ƒZd„Zd„Zd„Z d„Z d„Z d „Z e d d eƒd „ƒZRS( s. Plugin for tuning options of mount-points. c Csoi}d}tdddgdtdtdtƒjƒ\}}x td„|jƒƒD]}t|ƒdkrvqXn|d \}}}t|ƒdkr¥|dnd} t|ƒd krÇ|d nd} |d krå|}qXn|d ksX|dkrqXn| dksX| dkr!qXn|j| it ƒd6|d6| d6ƒ|| dj |ƒqXW||_ dS(sÁ 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. tlsblks-rnosTYPE,RM,KNAME,FSTYPE,MOUNTPOINTtstdouttstderrt close_fdscSs |jƒS(N(tsplit(tline((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pytsiitdiskt1tparttlvms[SWAP]tdiskst device_namet filesystemN(RR( tNoneRRtTruet communicatetmapt splitlinestlent setdefaulttsettaddt_mountpoint_topology( tclstmountpoint_topologyt current_diskRRtcolumnst device_typetdevice_removableRRt mountpoint((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt_generate_mountpoint_topologys&3"" (cCs;|jƒt|_t|jjƒƒ|_tƒ|_dS(N(R$Rt_devices_supportedRRtkeyst _free_devicest_assigned_devices(tself((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt _init_devices2s  cCs idd6S(Ntdisable_barriers(R(R)((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt_get_config_options8scCst|_t|_dS(N(tFalset_has_dynamic_tuningRt_has_static_tuning(R)tinstance((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt_instance_init>s cCsdS(N((R)R0((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt_instance_cleanupBscCs8tjd|ƒ}x|D]}tj|ƒjƒSWdS(sV Get device cache type. This will work only for devices on SCSI kernel subsystem. s+/sys/block/%s/device/scsi_disk/*/cache_typeN(tglobtcmdt read_filetstripR(R)tdevicetsource_filenamestsource_filename((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt_get_device_cache_typeEs cCs9x2|j|dD]}|j|ƒdkrtSqWtS(sr Checks if the device has 'write back' cache. If the cache type cannot be determined, asume some other cache. Rs write back(RR:RR-(R)R#R7((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt_mountpoint_has_writeback_cacheNsc Csætdƒ`}xV|D]J}|jƒ}|dddkrBqn|d|kr|d}PqqWdSWdQX|jdƒ}xb|D]V}|jdƒ\}} } |d ksÆ|d krÊ| d krÊtS|d kr„tSq„WtSdS( sP Checks if a given mountpoint is mounted with barriers enabled or disabled. s /proc/mountsit/iiNt,t=t nobarriertbarriert0(topenR Rt partitionR-R( R)R#t mounts_fileR R t option_listtoptionstoptiontnametseptvalue((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt_mountpoint_has_barriersWs"     $ cCs'd|dd|g}tj|ƒdS(s Remounts partition. s/usr/bin/mounts-os remount,%sN(R4texecute(R)RCRFtremount_command((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt_remount_partitiontsR+t per_devicec CsË|jd|ƒ}t|ƒjƒdk}|p<|j|ƒ}|rj|sOdSd}|j|djdƒsxd}n”| r—|j|ƒr—d}nu|j|ƒ} | dkr»d}nQ| t krî|råt j t j |ƒtSd}n|r t jt j|ƒt S|dk r3t j d ||fƒdS|jj|| ƒt j d |ƒ|j|d ƒn]|rtdS|jj|ƒ} | dkr–dSt j d |ƒ|j|d ƒ|jj|ƒdS(NR+tforceRtextsfilesystem not supportedsdevice uses write back cachesunknown current settingsbarriers already disableds#not disabling barriers on '%s' (%s)sdisabling barriers on '%s's barrier=0senabling barriers on '%s's barrier=1(t _storage_keytstrtlowert _option_boolRRt startswithR;RKR-tlogtinfotconststSTR_VERIFY_PROFILE_OKRterrortSTR_VERIFY_PROFILE_FAILt_storageRRNtgettunset( R)tstartRJR#tverifytignore_missingt storage_keyRPt reject_reasontoriginal_value((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyt_disable_barriers{sJ        (t__name__t __module__t__doc__t classmethodR$R*R,R1R2R:R;RKRNtcommand_customRRf(((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyR s!     (t tuned.constsRYtbaset decoratorst subprocessRRt tuned.logsttunedttuned.utils.commandsRR3tlogsR^RWR4tPluginR(((s?/usr/lib/python2.7/site-packages/tuned/plugins/plugin_mounts.pyts