Theoretically write into the buffer cache , take some time to wait until the buffer is full update or write to disk it. Why do I write later , some problems are not directly read it ? Look at this place APUE others do a test , fsync after read are invalid , how I do not fsync, read all OK, to kneel ah. . .
no O_ * SYNC and other signs .
Linux version 3.10.12-100.fc18.x86_64 (mockbuild @ bkernel02) (gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) ( GCC)) # 1 SMP Mon Sep 16 13:05:36 UTC 2013
------ Solution ------------- -------------------------------
POSIX requires that a read (2) which can be proved to occur after a
write () has returned returns the new data. Note that not all
filesystems are POSIX conforming.
landlord said the phenomenon should be completely non-existent , write as long as the return value indicates that the kernel has been written , then read that you can read . As the kernel when data is written to disk , it is pdflush another matter .
------ For reference only -------------------------------------- -
is not to say that as long as the kernel is written with or without a permanent media can be read into it ? That 's usually when fsync use it ?
------ For reference only -------------------------------------- -
carefully checked the next , APUE second version is the Linux 2.4 kernel , and just after the 2.4 , Linux kernel buffer cache merged into the page cache , if there is a separate buffer cache and the page cache , write the write data in the buffer cache when , read can read it ?
------ For reference only -------------------------------------- -
sync is written to disk , is not written into the buffer , I think this concept there is nothing strange issue.
write back had already demonstrated a write buffer , read must be able to read , can not read that the system would not be able to use it.
------ For reference only -------------------------------------- -
fact , linux 2.4 kernel before , buffer cache and the page cache is not together, reading and writing are not directly synchronized.
passage inside information in many English also mentioned . I now know whether the write synchronization and disk read and write is not related , but a relationship and buffer synchronization , but now using the page dirty write back, to avoid this problem. I think not because POSIX requires it that all linux system will conform to this . Indeed wiki which said , linux is "Mostly POSIX-compliant" rather than "Fully POSIX-compliant".
没有评论:
发表评论