[Rpm-maint] [rpm-software-management/rpm] Add macro to force fsync() on close() (#187)

Jeff Johnson notifications at github.com
Sun Apr 9 20:50:44 UTC 2017


OK, here is one way to install a file without leaving the file in the cache.

The simplest explanation is to show the --rpmiodebug log (interspersed with some debugging):

*** Fopen ufdio path /usr/share/doc/hello-2.0/README;58ea9807 fmode w+.ufdio
*** ufdOpen(/usr/share/doc/hello-2.0/README;58ea9807,0x242,0666)
==> Fileno(0x1c2c260) rc 31 	| ufdio 31 fp (nil)
*** Fdopen(0x1c2c260,w+.ufdio) 	| ufdio 31 fp (nil)
==> Fdopen(0x1c2c260,"w+.ufdio") returns fd 0x1c2c260 	| ufdio 31 fp (nil)
==>	Fopen("/usr/share/doc/hello-2.0/README;58ea9807",242,0666) 	| ufdio 31 fp (nil)
==> Ferror(0x1c2c260) rc 0 	| ufdio 31 fp (nil)
==> Fileno(0x1c2c260) rc 31 	| ufdio 31 fp (nil)
==>	Fread(0x1c2fff0,0x7ffd4dedc7d0,39) rc 39 	| gzdio 0x1c29f20 fp 30 | fdio -1 fp (nil)
==>	Fwrite(0x1c2c260,0x7ffd4dedc7d0,39) rc 39 	| ufdio 31 fp (nil)
==> Ferror(0x1c2c260) rc 0 	| ufdio 31 fp (nil)
***	fdatasync(31)
*** fbefore: 1
***	posix_fadvise(31, 0, 0, 0x4)
***	fsync(31)
*** fafter: 0
ufdio:       1 writes,       39 total bytes in 0.000013 secs
`

Basically there are 3 pieces to an RPM install implementation that does not blow out the system cache.

1) After Fwrite(), a Flush() followed by fdatasync(2) is needed.

After writing all the bytes, one page is cached (see mincore(2), the "fbefore: 1" line).

2) posix_fadvise(POSIX_MADV_DONTNEED) is called to hint that the file need not remain in cache.
3) fsync is called to write the file metadata to disk.

After syncing all the bytes, no pages are cached (the "fafter: 0" line).

This is basically what rsync-fadvise is doing here: [https://github.com/MageSlayer/rsync-fadvise](url)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/187#issuecomment-292812018
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20170409/41f2eaaa/attachment-0001.html>


More information about the Rpm-maint mailing list