Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-24 Thread David Wright
On Thu 22 Aug 2024 at 20:31:24 (-0700), Mike Castle wrote: > On Thu, Aug 22, 2024 at 4:31 PM David Wright wrote: ↑↑↑ odd time to pick > > Irrespective of the time taken, that could trigger the OOM killer, > > couldn't it. Very risky, unless you're using two swaps as

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-23 Thread Thorsten Glaser
Pierre-Elliott Bécue dixit: >> 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? Encryptio

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-23 Thread Pierre-Elliott Bécue
Hey, Thorsten Glaser wrote on 21/08/2024 at 01:34:32+0200: > (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 > # > crtpv LABEL=fo

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-22 Thread Mike Castle
On Thu, Aug 22, 2024 at 4:31 PM David Wright wrote: > Irrespective of the time taken, that could trigger the OOM killer, > couldn't it. Very risky, unless you're using two swaps as mentioned. I was actually surprised to see this happen in a test right now. I *thought* that swapoff() would fail i

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-22 Thread Thorsten Glaser
Mike Castle dixit: >Exactly. In my experience, running swapoff(8) _will_ take a long time >if the swap area has a lot of content. Yes. >It will block until everything is moved out. Unfortunately not. It will block until *almost* everything is moved out. I think what we’re seeing is that the re

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-22 Thread Mike Castle
On Thu, Aug 22, 2024 at 11:45 AM David Wright wrote: > I'm not convinced. Finding out what needs copying back and locating > somewhere to put it is AIUI a slow process. What's much faster is > when processes themselves demand something be paged back in from > swap. I think there are "tricks" avai

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-22 Thread David Wright
On Thu 22 Aug 2024 at 21:34:45 (+0200), to...@tuxteam.de wrote: > On Thu, Aug 22, 2024 at 01:45:06PM -0500, David Wright wrote: > > On Thu 22 Aug 2024 at 17:21:04 (+), Thorsten Glaser wrote: > > > Mike Castle dixit: > > [...] > > > > >I suspect that the race is that, when the the swapoff() sy

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-22 Thread tomas
On Thu, Aug 22, 2024 at 01:45:06PM -0500, David Wright wrote: > On Thu 22 Aug 2024 at 17:21:04 (+), 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 tha

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-22 Thread David Wright
On Thu 22 Aug 2024 at 17:21:04 (+), Thorsten Glaser wrote: > Mike Castle dixit: > > >Does cryptdisks have the ability to display what is in use at the > >moment? Maybe polling that before executing the stop? > > That’s what I would like to ask and why I sent this eMail. Is cryptdisks_stop f

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-22 Thread Thorsten Glaser
Mike Castle dixit: >Does cryptdisks have the ability to display what is in use at the >moment? Maybe polling that before executing the stop? That’s what I would like to ask and why I sent this eMail. >I suspect that the race is that, when the the swapoff() syscall >returns, the kernel has indee

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-22 Thread Mike Castle
On Thu, Aug 22, 2024 at 5:45 AM Stefan Monnier wrote: > How 'bout checking the success of `cryptdisks_stop`? 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 re

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-22 Thread Stefan Monnier
> Not the right condition though… it’s absent there but still in use. > I am looking for the right thing to check… How 'bout checking the success of `cryptdisks_stop`? Stefan

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-21 Thread Thorsten Glaser
(Please Cc me on replies.) Franco Martelli dixit: > 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… bye

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-21 Thread Franco Martelli
On 21/08/24 at 01:34, Thorsten Glaser wrote: (Please d̲o̲ Cc me on replies, I don’t subscribe to this list. Thanks!) 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

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-21 Thread Stefan Monnier
> 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 ke

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-21 Thread Alain D D Williams
On Wed, Aug 21, 2024 at 07:38:29AM -0400, Greg Wooledge wrote: > Even if that's true, running them all in the same command as Roberto > shows would not give you any benefit. In early Unix sync *did* return immediately after scheduling a buffer flush. > You'd need to physically *type* the command

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-21 Thread Alain D D Williams
On Wed, Aug 21, 2024 at 08:39:37AM +0200, Erwan David wrote: > On Wed, Aug 21, 2024 at 02:18:44AM CEST, Greg Wooledge > 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 kno

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-21 Thread Roberto C . Sánchez
On Tue, Aug 20, 2024 at 08:18:44PM -0400, Greg Wooledge wrote: > 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 rememb

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-21 Thread Greg Wooledge
On Wed, Aug 21, 2024 at 08:39:37 +0200, Erwan David wrote: > On Wed, Aug 21, 2024 at 02:18:44AM CEST, Greg Wooledge > 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

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-20 Thread Erwan David
On Wed, Aug 21, 2024 at 02:18:44AM CEST, Greg Wooledge 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 remembe

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-20 Thread Greg Wooledge
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.

Re: wait until swapoff is *actually* finished (it returns too early)?

2024-08-20 Thread Roberto C . Sánchez
On Tue, Aug 20, 2024 at 11:34:32PM +, Thorsten Glaser wrote: > > 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

wait until swapoff is *actually* finished (it returns too early)?

2024-08-20 Thread Thorsten Glaser
(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 # crtpv LABEL=fooclvm nonediscard,luks,initramfs cswp1 /dev/vg-f