c - fflush, fsync and sync vs memory layers -


i know there similar questions , gave them couldn't find explicit univocal answer question. investigating online these functions , relationship memory layers. in particular found beautiful article gave me insight memory layers

memory layers

it seems fflush() moves data application kernel filesystem buffer , it's ok, seems agree on point. thing left me puzzled in same article assumed write-back cache saying fsync() "the data saved stable storage layer" , after added "the storage may store data in write-back cache, fsync() still required files opened o_direct in order save data stable storage"

reading here , there seems truth fsync() , sync() let data enter storage device if 1 has caching layers moved here, not @ once permanently storage , data may lost if there power failure. unless have filesystem barriers enabled , "sync()/fsync() , other operations cause appropriate cache flush (ata) or synchronize cache (scsi) commands sent device" [from website answer]

questions:

  1. if data updated in kernel buffers , device has volatile cache layer in write-back mode true, said article, operations fsync() [and sync() suppose] synchronize data stable memory layer skipping volatile one? think happens write-through cache, not write-back one. read understood write-back cache on fsync() can send data device put them in volatile cache , enter permanent memory after

  2. i read fsync() works file descriptor , single file while sync() causes total deployment buffers applies every data updated. , page fsync() waits end of writing disk while sync() doesn't wait end of actual writing disk. there other differences connected memory data transfers between two?

thanks try help

"i don't have solution, admire problem."

from read references, there no standard. standard ends somewhere in kernel. kernel controls device driver , device driver (possibly supplied disk manufacturer) controls disk through api (device has small computer on board). manufacturer may have added capacitors/battery enough power flush device buffers in case of power failure, or may have not. device may provide sync function whether truely syncs (flushes) device buffers not known (device dependent). unless select , install device according specifications (and verify specs), never sure.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -