to...@tuxteam.de (12022-07-10): > But then, always doing sync twice looks like a very mild measure, and > far cheaper than seeing a therapist. Especially given that the second > sync will typically be very quick. If it's working, I'd go with that :) > > Since writing to USBs for me mostly involves copying whole images > (with exception of my backup, which is an rsync: there I do use > sync, but just once), I do use sync much less these days after > having discovered dd's oflag=sync.
On Linux, a process that writes to a device that is not currently mounted and therefore has no page cache will go into D state when closing the associated file descriptor. You can check for with this kind of command: strace -ftttT sh -c "( dd if=/dev/urandom bs=1M count=0 seek=32000; cat /tmp/file ) > /dev/disk/by-label/CIGAES_R64" where /tmp/file was obtained with the opposite dd command: [pid 3708814] 1657561091.466910 write(1, "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"..., 131072) = 131072 <0.000233> [pid 3708814] 1657561091.467280 read(3, "", 131072) = 0 <0.000106> [pid 3708814] 1657561091.467527 munmap(0x7f14a2f0e000, 139264) = 0 <0.000062> [pid 3708814] 1657561091.467658 close(3) = 0 <0.000018> [pid 3708814] 1657561091.467755 close(1) = 0 <161.011040> [pid 3708814] 1657561252.478904 close(2) = 0 <0.000019> [pid 3708814] 1657561252.479045 exit_group(0) = ? [pid 3708814] 1657561252.479252 +++ exited with 0 +++ 1657561252.479286 <... wait4 resumed>[{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 3708814 <288.273781> 1657561252.479345 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3708814, si_uid=1000, si_status=0, si_utime=1, si_stime=168} --- 1657561252.479383 rt_sigreturn({mask=[]}) = 3708814 <0.000011> 1657561252.479433 wait4(-1, 0x7ffee8b3cc5c, WNOHANG, NULL) = -1 ECHILD (No child processes) <0.000011> 1657561252.479510 exit_group(0) = ? 1657561252.479624 +++ exited with 0 +++ Notice the time taken by the close(1). If you naively run strace on cat itself, then you do not see anything, because then strace itself is holding a copy of the file descriptor, and it is strace that will go into D state. I do not know where this behavior is documented, but I suspect it is somewhere. Regards, -- Nicolas George
signature.asc
Description: PGP signature