5

I'm trying fully understand the sync command operations in linux OS.

After reading: https://en.wikipedia.org/wiki/Sync_(Unix) https://lwn.net/Articles/457667/

I understood that sync command responsible for flushing data all the way from application's buffers to permanent storage.

  1. how linux tracks it's permanent storage devices and their suitable writing requests? (inside /dev we have many device files not all of them represnt permanent storage devices) where can I see each device's awaiting writing requests?

  2. does sync (specifically sync command) scans all system's devices for writing requests and performs all of them? does it maintain some efficient list?

  3. how virtual file systems related to sync command? does sync command scans each filesystem? if so why?

  4. is there any literature regarding this command and its "backstage" operations?

Paulo Tomé
  • 3,782
hutcruchi
  • 329
  • One small correction: sync doesn't touch applications' buffers, only kernel buffers. – Andy Dalton Nov 26 '19 at 15:07
  • this Q is related: https://unix.stackexchange.com/questions/545917/has-sync-been-proved-to-be-necessary-when-writing-to-a-block-device-with-dd (gives a practical side to the Q) –  Nov 27 '19 at 16:25
  • Your question is massively interesting, but it is very broad: each point would require a thoroughful answer and, together, they could be too much. Why don't you consider splitting the question? – BowPark Nov 29 '19 at 11:44

1 Answers1

4

This manpage might clarify things a bit.

What I read between the lines is that every filesystem implementation has to provide a sync-method.

So the sync command just calls the Kernel, which in turn calls all sync-methods - propably for all mounted filesystems.

Perhaps you can find better explanations of what is happening there when looking into the kernel-code for sync.

Nils
  • 18,492