The shrinking role of ETXTBSY
The shrinking role of ETXTBSY
Posted Aug 19, 2021 16:37 UTC (Thu) by mbunkus (subscriber, #87248)In reply to: The shrinking role of ETXTBSY by Sesse
Parent article: The shrinking role of ETXTBSY
Posted Aug 19, 2021 16:41 UTC (Thu)
by Sesse (subscriber, #53779)
[Link] (3 responses)
Posted Aug 19, 2021 17:38 UTC (Thu)
by mbunkus (subscriber, #87248)
[Link] (2 responses)
I'm talking about new_file being smaller than (old_file + free_before_copying) but being larger than free_before_copying. If you copy-to-temporary with atomic-rename you'll run out of space whereas directly opening the target file for writing will work.
Take this dummy 1MB file system with one 800KB file occupying it, trying to overwrite the 800KB file with a 400KB file:
[0 root@sweet-chili /home/mosu/tmp/mp] df .
rsync does the copy-to-temporary with atomic-rename, but it has always done so & is therefore fine. Of course it does have options to deal with low-space file systems the user can turn on, notably "--delete-before".
For cp it would be a huge change in semantics.
Posted Aug 20, 2021 17:49 UTC (Fri)
by smurf (subscriber, #17840)
[Link] (1 responses)
Posted Aug 20, 2021 18:19 UTC (Fri)
by mbunkus (subscriber, #87248)
[Link]
My main point was that such a change would change cp's semantics. I shouldn't have brought rsync up.
The shrinking role of ETXTBSY
The shrinking role of ETXTBSY
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 996 797 128 87% /home/mosu/tmp/mp
[0 root@sweet-chili /home/mosu/tmp/mp] ls -l
total 796
-rw-r--r-- 1 root root 800000 2021-08-19 19:30 800KB
[0 root@sweet-chili /home/mosu/tmp/mp] ls -l ../*KB
-rw-r--r-- 1 root root 400000 2021-08-19 19:30 ../400KB
-rw-r--r-- 1 root root 800000 2021-08-19 19:30 ../800KB
[0 root@sweet-chili /home/mosu/tmp/mp] cp ../400KB .
cp: error writing './400KB': No space left on device
[1 root@sweet-chili /home/mosu/tmp/mp] rm 400KB
[0 root@sweet-chili /home/mosu/tmp/mp] cp ../400KB 800KB
[0 root@sweet-chili /home/mosu/tmp/mp] ls -l
total 404
-rw-r--r-- 1 root root 400000 2021-08-19 19:33 800KB
[0 root@sweet-chili /home/mosu/tmp/mp]
The shrinking role of ETXTBSY
The shrinking role of ETXTBSY
