番茄系统家园 - 免费重装系统!简单装系统,人人都是装机大师!
当前位置:首页>Win7资讯 > csc cache win7

csc cache win7

来源:番茄系统家园浏览:时间:2021-07-18 20:32:38

csc cache win7

|-May-03|-May-03

网络文件系统的机制

,()ningthestateoftheI/ORequestPacket(IRP).TheIRP_NOCACHEbitintheFlagsfieldwilltellthefilesystem(and,ofcourse,thefilter)thatthefileI/Oinquestionisnottobecached.Normally,thisisthecluetothefilesystemdriverthatthisdatashouldnotbecached.

对于文件系统过滤驱动程序来说确定本地文件系统NTFS或者FAT的cache策略是相当容易的只要检查一下I/O请求包IRP的状态就可以了。如果发现IRP的flag域带有IRP_NOCACHE标志就说明文件系统不允许文件cache。

Networkfilesystemsareabitmorecomplexthanthis.WhiletheyalsousetheIRP_NOCACHEbit,theymayalsoneedtodisablecachingasaresultoftheirowninternalpolicy-perhapsdirectedbythestateoftheremotefileonthefiles

erver,aswellasotherclientsinthenetworkthatmightbeusingthefile.Therdbss.sys,whichimplementspartoftheminiredirectormodelallowstheredirector(forexamplemrxsmb.sys,whichisthedriverthatimplementsCIFSorLan

ManagerfunctionalityinWindows2000andmorerecent)tochangethecachingpolicyonaper-filebasis.Inthiscase,anormalIRP_MJ_READIRP,whichwouldnormallybecached,maybetreatedasnon-cached.

而网络文件系统在cache策略方面则有点复杂。虽然它们也使用IPR_NOCACHE标志它们也需要在它们的内部策略当中禁止使用文件cache这些内部的cache策略是由文件服务器上的远程文件的状态决定的而网络上其它的客户端都会使用这些文件。rdbss.sys驱动程序实现了被称为“miniredirector”模型的一部分功能它能够允许每一个重定向器redirector基于每一个文件来改变其缓冲策略。在这种情况下一个普通的IRP_MJ_READ类型的IRP可能被当作可被缓冲的也可以被当作非缓冲来处理。

Forafilterdriverthatismodifyingthedata,theusualtechniqueistolookforandoperateonnon-cachedI/Ooperations.ThiswillcapturebothpagingI/Ooperationsaswellasuserlevelnon-cachedI/Ooperations.However,ifthefilterwishestoalsofilteranyofthemini-redirectors(therearetwoshippedinWindowsXPforexample)itneedstolookatthefieldsoftheFileControlBlock(FCB).

对于一个正在修改文件读数据的过滤驱动程序来说例如对文件内容做透明加解密的驱动程序通常是通过检查和拦截非缓冲I/O请求来实现自己的功能。这样它们就会捕获分页I/O操作或者用户层的非缓冲I/O操作。但是如果过滤驱动程序如果也想拦截mini-redirector的话它就必须检查文件控制块FCB的相关域。

Formostfilesystems,theformatofthisstructureismostlyunderthecontrolofthefilesystem(exceptforthecommonheaderstructure)butformini-redirectorstheformatofthefilecontrolblockisdefinedbythemini-redirectormode

l.Seemrxfcb.hintheIFSKitforthefulldefinition.Thekeydatastructurehere(forafilter)istheMRX_FCB.TheFcbStatefieldwillindicateifthecurrentstateofthefileiscachedornon-cached.Ifthefileallowscachingthe

FCB_STATE_READCACHING_ENABLEDbitwillbeset.Otherwise,I/Otothegivenfilewillbetreatedasnon-cached.

对于大多数文件系统来说FCB结构的格式主要由文件系统来决定除了通用的头结构以外但是mini-redirector的FCB结构的格式由mini-redirector模式定义完整的FCB定义可以参考mrxfcb.h。对过滤驱动程序来说最关键的数据结构是MRX_FCB。该结构的FcbState域描述了该文件是否需要cache或者非cache。如果文件可以被cache则FCB_STATE_READCACHING_ENABLED标志将置位。否则对于指定的文件将被视为非cached。值得注意的是在WindowsServer2003IFSKit中这个标志的拼写已经发生了变化现在的拼写是FCB_STATE_READCACHING_ENABLED。

Note:IntheWindowsServer2003IFSKitthespellingofthisflaghasbeenchan

gedsothatitisnowFCB_STATE_READCACHING_ENABLED.

Whilethisallowsafiltertodeterminethecurrentstateofthefile,theredoesnotappeartobeanysimplewayforafiltertoensurethatthestateofthisfielddoesnotchangebetweenthetimethefilterchecksitandthetimethecal

lisactuallyprocessedbythefilesystem.Thus,itispossiblethatthefilestatemightchangetodisallowcachingafterthischeckismade.Similarly,ifthecheckisdoneaftertheI/Ohasbeenprocessed,itispossiblethefilestat

emightchangetoindicatethatcachingisnowallowedonceagain.SamplecodeforthiscanbeseenintheIFSKit(seesmbmrx/wnet/sys/openclos.c)todemonstrateonepotentialimplementationmodel.

通过检查FCB结构的FcbStatus域的状态允许过滤驱动程序检查当前文件的状态但是却没有什么有效而简单的方法确保过滤驱动程序检查时的状态与文件系统真正处理这个文件之间该文件状态保持不变。因此这样的情况很可能发生文件过滤驱动程序检查文件状态时文件是允许cache的但是真正处理的时候变为不允许cache了。相反的情况也同样会出现。详细的示例请看IFS的例子代码smbmrx/wnet/sys/openclos.c。

Topreventthestatefromchanging,thecallermustacquiretheFCBresource;inordertoavoiddeadlockswhilecallingtheredirector,itmustbeownedexclusive(usingtheERESOURCEintheFCBitself).Again,todothisrequiesrelyingu

pontheimplementationandpublishedinterfaceavailableintheIFSKit.

为了防止这种状态的变化调用者必须获取FCB的资源。为了避免调用redirector其间出现死锁现象调用者必须排他的拥有FCB资源。

Note:thissynchronizationisonlyneededforuserlevelcachedrequests,sincepagingI/Ooruserlevelnon-cachedrequestswillalreadynotbecachedasamatterofcourse.ThisisimportantbecausethislockcannotbesafelyacquiredwhenprocessingpagingI/O-thiswouldviolatetheexistinglockhierarchyandintroducethepossibilityofdeadlocks.

EventuallyIfiguredoutthiswasbecausenetworkredirectorsliketosetaninternalflagcalledSRVOPEN_FLAG_DONTUSE_WRITE_CACHEINGwhenafileisopenedforwrite-only,whichcausestheredirectortosendallwritesacrossthenetworkassoonasitgetsthem,bypasstheNTcache.Thismeansanylayeredfilterwillseetheordinarywriterequest,butneveracorrespondingpaging-I/Orequest.Togetaroundthis,myfilternowhastoforciblyturneverywrite-onlynetworkfileopenintoaread/writeopen.

当一个文件以只写write-only方式打开时网络重定向器会设置一个内部标志SRVOPEN_FLAG_DONTUSE_WRITE_CACHEING这将导致重定向器发送所有的写请求到网络文件服务器上绕过了NTcache机制。这意味着所有的分层过滤驱动程序只能看到普通的写请求但是不会看到任何对应的分页I/O请求。为了能够过滤网络文件的读写分页请求我的过滤驱动程序不得不强迫将所有的以只写write-only方式打开网络文件变为读写方式打开。

下面是如何将write-only打开的文件转换为读写打开的文件的方式

ThereasonwhyImrantinginpublicisthatseemsthatIcanneverknowa-prioriwhetherIwillseeareadorwriterequestasbothpagingandnon-pagingI/O,oroneortheother,foragivenfilesystem.Instead,Imustscsc cache win7pecialcasemycodeforeachfilesystemandpraythatIvecoveredeveryscenariothatcanresultinmynothandlingaread/writeor

handlingittwice.TheonlyalternativeIcancomeupwithistoforceALLreads/writestoafilteredfiletobenon-cached,withthecorrespondingperformancepenalties.Isthereanelegantwayoutofthismess?

IthinkIsentamessageaboutthisbefore.ThelongandtheshortofitisthatyouCANNOTforcetheredirectortocachewritesforfilesthatareopenwrite-only.Youmustinsteadtweakthefilepermissionstoconvertawrite-onlyopenofanetworkfileintoaread/writeopen.Usecodelikethefollowingtodoso:

if((0(desiredAccess(FILE_EXECUTE|FILE_READ_DATA)))(0!(desiredAccess(FILE_WRITE_DATA|

FILE_APPEND_DATA))))

{

pIrpSp-Parameters.Create.SecurityContext-DesiredAccess|FILE_READ_DATA;

}

下面解释了为什么write-only类型的文件不能执行cache

writeonlyhandleinredirectordoesntcache

--------------------------------------------------------------------------------

Igotbittenbythisafewmonthsago,sohereismytakeonthesituation...

ThisisbecausetheNTcacheneedsreadaccesstothefileinordertowork.Thecacheworksonpage-sizedchunks.Ifyouopenafileandwrite1byteatlocation0,andcachingisenabled,theNTcachewillpage-inthememorypagerepresentingthefirst4096bytesofthefile,whichrequiresittoissueapagingI/Oreadforthefirst4096bytes.Thenitwillpasteinyournewbyteandmarkthepagedirty,whichcausesthepagetobewrittenoutlaterbythelazywriter.

Forlocalfiles,pagingI/Oisallowedtobypassallsecuritychecks(sinceonlytrustedkernelcomponentscanissuepagingI/Orequests),sothatpagingreadsareallowedonallopensforallfiles.Fornetworkfiles,thereisnoreasontheremotePCshouldtrustyourPCandgrantitreadaccessifyouonlyhavewrite-accesstothefile.ThereforetheNTcachecannotbeusedonwrite-onlyremotefiles.

相关阅读

  • 求thinkpad s3 24g固态硬盘装win7教程
  • 安装了固thinkpad固态硬盘win7态硬盘ssd的thinkpad X250加装固态硬盘教程
  • csc cache win7
  • 推荐系统

    • 雨林木风 winxp下载 纯净版 永久激活 winxp ghost系统 sp3 系统下载

      雨林木风 winxp下载 纯净版 永久激活 winxp ghost系统 sp3 系统下载64位
      系统大小:0MB系统类型:WinXP

      雨林木风在系统方面技术积累雄厚深耕多年,打造了国内重装系统行业知名品牌,雨林木风WindowsXP其系统口碑得到许多人认可,积累了广大的用户群体,是一款稳定流畅的系统,雨林木风 winxp下载 纯净版 永久激活 winxp ghost系统 sp3 系统下载,有需要的朋友速度下载吧。

      系统等级:
      进入下载 >
    • 萝卜家园win7纯净版 ghost系统下载 x64 联想电脑专用

      萝卜家园win7纯净版 ghost系统下载 x64 联想电脑专用64位
      系统大小:0MB系统类型:Win7

      萝卜家园win7纯净版是款非常纯净的win7系统,此版本优化更新了大量的驱动,帮助用户们进行舒适的使用,更加的适合家庭办公的使用,方便用户,有需要的用户们快来下载安装吧。

      系统等级:
      进入下载 >
    • 雨林木风xp系统 xp系统纯净版 winXP ghost xp sp3 纯净版系统下载

      雨林木风xp系统 xp系统纯净版 winXP ghost xp sp3 纯净版系统下载64位
      系统大小:1.01GB系统类型:WinXP

      雨林木风xp系统 xp系统纯净版 winXP ghost xp sp3 纯净版系统下载,雨林木风WinXP系统技术积累雄厚深耕多年,采用了新的系统功能和硬件驱动,可以更好的发挥系统的性能,优化了系统、驱动对硬件的加速,加固了系统安全策略,运行环境安全可靠稳定。

      系统等级:
      进入下载 >
    • 萝卜家园win10企业版 免激活密钥 激活工具 V2023 X64位系统下载

      萝卜家园win10企业版 免激活密钥 激活工具 V2023 X64位系统下载64位
      系统大小:0MB系统类型:Win10

      萝卜家园在系统方面技术积累雄厚深耕多年,打造了国内重装系统行业的萝卜家园品牌,(win10企业版,win10 ghost,win10镜像),萝卜家园win10企业版 免激活密钥 激活工具 ghost镜像 X64位系统下载,其系统口碑得到许多人认可,积累了广大的用户群体,萝卜家园win10纯净版是一款稳定流畅的系统,一直以来都以用户为中心,是由萝卜家园win10团队推出的萝卜家园

      系统等级:
      进入下载 >
    • 萝卜家园windows10游戏版 win10游戏专业版 V2023 X64位系统下载

      萝卜家园windows10游戏版 win10游戏专业版 V2023 X64位系统下载64位
      系统大小:0MB系统类型:Win10

      萝卜家园windows10游戏版 win10游戏专业版 ghost X64位 系统下载,萝卜家园在系统方面技术积累雄厚深耕多年,打造了国内重装系统行业的萝卜家园品牌,其系统口碑得到许多人认可,积累了广大的用户群体,萝卜家园win10纯净版是一款稳定流畅的系统,一直以来都以用户为中心,是由萝卜家园win10团队推出的萝卜家园win10国内镜像版,基于国内用户的习惯,做

      系统等级:
      进入下载 >
    • windows11下载 萝卜家园win11专业版 X64位 V2023官网下载

      windows11下载 萝卜家园win11专业版 X64位 V2023官网下载64位
      系统大小:0MB系统类型:Win11

      萝卜家园在系统方面技术积累雄厚深耕多年,windows11下载 萝卜家园win11专业版 X64位 官网正式版可以更好的发挥系统的性能,优化了系统、驱动对硬件的加速,使得软件在WINDOWS11系统中运行得更加流畅,加固了系统安全策略,WINDOWS11系统在家用办公上跑分表现都是非常优秀,完美的兼容各种硬件和软件,运行环境安全可靠稳定。

      系统等级:
      进入下载 >