
On 14/04/2021 07.46, David Haller wrote:
Hello,
On Wed, 14 Apr 2021, Carlos E. R. wrote: [*yawn* uhm *yawn* me tired]
As "lazytime" current implementation delays write for 24 hours (or up to), I wonder if I can "sync" just a partition.
More precisely: you can sync just one filesystem ;)
$ sync --help -f, --file-system sync the file systems that contain the files
Yeah, I had the distinct recollection™ of "sync" not accepting parameters, so I did not even think of looking at the man page. Funny memory. Although this man page is new, feb 2018. You can even ask to sync a file.
cue the manpages of the aforementioned syscalls ;)
So: sync -f /var/spool/news/message.id
Works even on a /var/spool/news/ as bind-mounted reiserfs-image from a chroot with a sync(1) that knows '-f' while the sync(1) of the host does not yet know the option, but the running kernel has the matching syscall 'syncfs(2)' :) I.e.:
root@${on_host]# mount -o loop /foo/news_reiserfs.img /var/spool/news root@${on_host]# mount --bind /var/spool/news/ ${mnt_chroot}/var/spool/news [.. chroot ${mnt_chroot} ..] root@${in_chroot}# strace sync -f /var/spool/news/message.id [..] open("/var/spool/news/message.id", O_RDONLY|O_NONBLOCK) = 3 [..] syncfs(3) = 0 close(3) = 0 [..]
Mind: the 'syncfs(3)' here means: call syncfs(2) with the argument of the integer '3', which happend to be returned by the preceding 'open(2)' syscall and is the "fd" or "file descriptor" argument of the function[0].
Yes, I have seen that methodology on trace dumps :-) [...] Heh, you mention traces below.
I already gave you pointers to where to find the real work done by 'syncfs(2)'.
Yes, thanks, I have material to read.
-dnh
[0] int FD; FD = open("foo", ...); syncfs(FD); close(FD);
in strace, the return values comes after the '=' so, the strace rewritten:
open("/var/spool/news/message.id", O_RDONLY|O_NONBLOCK) = FD syncfs(FD) = OK close(FD) = OK
-- Cheers / Saludos, Carlos E. R. (from 15.2 x86_64 at Telcontar)