Just adding a “sleep” is no proper fix anyway, so the question
is, how to wait in a shell script until the swap device is
*really* swapoff’d when the syscall returns too early, and
(someone from the Linux kernel maintainers reading this?) should
I report the latter as a bug against the kernel?
sync && sync && sync && swapoff
I couldn't tell why I have sync 3 times, but I know that it's how I've
called swapoff since as far back as I can remember.
On Tue, Aug 20, 2024 at 20:04:11 -0400, Roberto C. Sánchez wrote:
sync && sync && sync && swapoff
I couldn't tell why I have sync 3 times, but I know that it's how I've called swapoff since as far back as I can remember.
Cargo cult. It was never useful to the best of my knowledge.
On Wed, Aug 21, 2024 at 02:18:44AM CEST, Greg Wooledge <greg@wooledge.org> said:
On Tue, Aug 20, 2024 at 20:04:11 -0400, Roberto C. Snchez wrote:
sync && sync && sync && swapoff
I couldn't tell why I have sync 3 times, but I know that it's how I've called swapoff since as far back as I can remember.
Cargo cult. It was never useful to the best of my knowledge.
Once upon a time, the sync command would return before the actual
syscall where completed. Doing 3 times sync gave you a very high
probability that the first one indeed completed all its writes.
But it was already false in SunOS 4 (~1990)
On Tue, Aug 20, 2024 at 20:04:11 -0400, Roberto C. Snchez wrote:
sync && sync && sync && swapoff
I couldn't tell why I have sync 3 times, but I know that it's how I've called swapoff since as far back as I can remember.
Cargo cult. It was never useful to the best of my knowledge.
On Wed, Aug 21, 2024 at 02:18:44AM CEST, Greg Wooledge <greg@wooledge.org> said:
On Tue, Aug 20, 2024 at 20:04:11 -0400, Roberto C. Sánchez wrote:
sync && sync && sync && swapoff
I couldn't tell why I have sync 3 times, but I know that it's how I've called swapoff since as far back as I can remember.
Cargo cult. It was never useful to the best of my knowledge.
Once upon a time, the sync command would return before the actual
syscall where completed. Doing 3 times sync gave you a very high
probability that the first one indeed completed all its writes.
Even if that's true, running them all in the same command as Roberto
shows would not give you any benefit.
You'd need to physically *type* the command and press Enter three times
to get any "protection". And even then, it's really just the extra
time that it takes to type those commands out.
You'd get the same "protection" by simply waiting 10 seconds (or whatever's appropriate) after running sync once.
Just adding a “sleep” is no proper fix anyway, so the question
is, how to wait in a shell script until the swap device is
*really* swapoff’d when the syscall returns too early, and
(someone from the Linux kernel maintainers reading this?) should
I report the latter as a bug against the kernel?
interrupt it when a condition is satisfied, e.g.:
while true
do
/usr/bin/grep lv-swp1 /proc/swaps >/dev/null 2>&1
Not the right condition though… it’s absent there but still in use.
I am looking for the right thing to check…
Does cryptdisks have the ability to display what is in use at the
moment? Maybe polling that before executing the stop?
I suspect that the race is that, when the the swapoff() syscall
returns, the kernel has indeed moved all of the content off, so that
part is fine... but it has not yet released whatever kind of resources
is has on the backing store (akin to an open file handle).
You could then control the timeout by looping no more than N times,
then failing a bit more gracefully than it is now.
On Thu 22 Aug 2024 at 17:21:04 (+0000), Thorsten Glaser wrote:
Mike Castle dixit:
I suspect that the race is that, when the the swapoff() syscall
returns, the kernel has indeed moved all of the content off, so that
part is fine... but it has not yet released whatever kind of resources
is has on the backing store (akin to an open file handle).
My guess as well.
I'm not convinced. Finding out what needs copying back and locating
somewhere to put it is AIUI a slow process.
(Please d̲o̲ Cc me on replies, I don’t subscribe to this list. Thanks!)
Hi,
this is a bit curious problem:
I have a setup with swap devices on dmcrypt:
$ cat /etc/crypttab
# <target name> <source device> <key file> <options>
crtpv LABEL=fooclvm none discard,luks,initramfs
cswp1 /dev/vg-foo/lv-swp1 /dev/random discard,cipher=aes-xts-plain64,size=256,plain,swap
cswp2 /dev/vg-foo/lv-swp2 /dev/random discard,cipher=aes-xts-plain64,size=256,plain,swap
In a cronjob, I basically do swapoff && cryptdisks_stop && \
cryptdisks_start && swapon for both swaps individually to throw away
the old encryption key regularily (but not too frequently).
In a cronjob, I basically do swapoff && cryptdisks_stop && \
cryptdisks_start && swapon for both swaps individually to throw away
the old encryption key regularily (but not too frequently).
Ooc, what do you expect to actually gain from this setup?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 02:43:19 |
Calls: | 10,387 |
Calls today: | 2 |
Files: | 14,061 |
Messages: | 6,416,755 |