Hello, On Mon, 12 Apr 2021, Carlos E. R. wrote:
It is just a fact, it can not.
Situation.
The system is running the process "texpire", which is part of leafnode package, an nntp proxy server. texpire simply looks at every posts and deletes those that are old according to certain rules. This is very intensive on the disk, looking at 1.2 million files. It runs for half an hour.
If during that process I issue a "sync", it does not succeed till texpire ends. It can not be killed.
You have to kill texpire, as that's continuously creating new stuff to be synced. And you can consider 'sync' to be halfdead already (just not yet done reporting back (or not usually, other than exiting with status 0)), as it's basically just issuing a 'sync', 'syncfs', 'fsync' or fdatasync' syscall (see the manpages in section 2) and reporting back. The source for sync is rather straightforward and a measly 5537 bytes in coreutils version 8.32. ==== comments by me after //DNH: ==== [..] int main (int argc, char **argv) { [..] if (! args_specified || (arg_file_system && ! HAVE_SYNCFS)) mode = MODE_SYNC; else if (arg_file_system) mode = MODE_FILE_SYSTEM; //DNH: will call syncfs(2) if available else if (! arg_data) mode = MODE_FILE; //DNH: will call fsync(2) else mode = MODE_DATA; //DNH: will call fdatasync(2) if (mode == MODE_SYNC) sync (); //DNH: well, duh ;) [..] return ok ? EXIT_SUCCESS : EXIT_FAILURE; } ==== So, default is to just call 'sync(2)', unless you call 'sync(1)' with options or arguments in which case it branches to a function and calls fsync(2) or fdatasync(2) or syncfs(2) depeding on 'mode'. And: ==== man 2 sync ==== sync() causes all pending modifications to filesystem metadata and cached file data to be written to the underlying filesystems. ==== Anyway: all those functions (sync, fsync, fdatasync, syncfs) are syscalls and, as they're writing to storage, in uninterruptible sleep-state ('D' in ps/top etc.), and thus not "killable" from userland. And if sync(1) is "in" the call to these functions, you can not kill it as well until that function returns control to the sync(1) process. So, your only option is to kill anything that still causes more stuff to be synced and wait. Or shut the machine off hard[1] via sysrq+b, sysrq+o, the reset- or powerbutton ... HTH, -dnh [1] as the kernel is already syncing ... -- Sigmonster was here!