Date: Mon, 21 Oct 2024 03:52:58 -0600 From: Warner Losh <imp@bsdimp.com> To: Stephane Rochoy <stephane.rochoy@stormshield.eu> Cc: freebsd-hackers@freebsd.org Subject: Re: swapon vs GEOM labels Message-ID: <CANCZdfrk0tn68a0N89odyke%2BDDxgFqZOj41fsE=-7ehb2V8w0A@mail.gmail.com> In-Reply-To: <86ttd5rdze.fsf@cthulhu.stephaner.labo.int> References: <86ttd5rdze.fsf@cthulhu.stephaner.labo.int>
next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000cfe45d0624f99e61 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Oct 21, 2024 at 3:40=E2=80=AFAM Stephane Rochoy < stephane.rochoy@stormshield.eu> wrote: > Hi Hackers, > > I'm playing with glabel(8) and swapon(8) but found a behavior that > is somewhat puzzling. > > I boot main (b88df1e893c4) with an USB memstick plugged. The > memstick is da0 and hold a freebsd-swap partition, da0p1. This > partition was given the `swap` label using `glabel label` (i.e., > an automatic label, stored somewhere into da0p1, AFAIK). > > # glabel status > Name Status Components > label/swap N/A da0p1 > > Then I give the whole device the `usbmemstick` label using `glabel > create` (i.e., a manual label, not stored anywhere). > > # glabel create usbmemstick da0 > # glabel status > Name Status Components > label/swap N/A da0p1 > label/usbmemstick N/A da0 > > What puzzle me is what happen when I enable swap: > > # sysctl vm.nswapdev > vm.nswapdev: 0 > # swapctl -l > Device: 1024-blocks Used: > # dumpon -l > /dev/null > # swapon /dev/label/usbmemstickp1 > # glabel status > Name Status Components > label/usbmemstick N/A da0 > # swapoff /dev/label/usbmemstickp1 > # glabel status > Name Status Components > label/usbmemstick N/A da0 > label/swap N/A label/usbmemstickp1 > > While swap is enabled, the `swap` label is no longer available. It > comes back when swap is disabled. > > Note that I also tried to enable swap using the automatic label > (i.e., `swap`). In such a case this is the `usbmemstick` label > that vanish. And the label is even not restored on `swapoff`. > > Is it the expected behavior? Am I doing something wrong? > This both makes sense to me, and seems wrong to me. When things are nested like this, it kinda makes sense that label/usbmemstickp1 shows up. geom doesn't enumerate everything and this seems to be a bit of an artifact. I'd expect both label/usbmemstickp1 and label/swap to be there. geom does odd things with devices that are open to keep others from opening them, and this may just be an artifact of this kinda weird behavior. Warner --000000000000cfe45d0624f99e61 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">= <div dir=3D"ltr" class=3D"gmail_attr">On Mon, Oct 21, 2024 at 3:40=E2=80=AF= AM Stephane Rochoy <<a href=3D"mailto:stephane.rochoy@stormshield.eu">st= ephane.rochoy@stormshield.eu</a>> wrote:<br></div><blockquote class=3D"g= mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204= ,204,204);padding-left:1ex">Hi Hackers,<br> <br> I'm playing with glabel(8) and swapon(8) but found a behavior that<br> is somewhat puzzling.<br> <br> I boot main (b88df1e893c4) with an USB memstick plugged. The<br> memstick is da0 and hold a freebsd-swap partition, da0p1. This<br> partition was given the `swap` label using `glabel label` (i.e.,<br> an automatic label, stored somewhere into da0p1, AFAIK).<br> <br> =C2=A0 # glabel status<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Name=C2=A0 Status=C2=A0 Components<br> =C2=A0 label/swap=C2=A0 =C2=A0 =C2=A0N/A=C2=A0 da0p1<br> <br> Then I give the whole device the `usbmemstick` label using `glabel<br> create` (i.e., a manual label, not stored anywhere).<br> <br> =C2=A0 # glabel create usbmemstick da0<br> =C2=A0 # glabel status<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Name=C2=A0 Status=C2=A0 Co= mponents<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 label/swap=C2=A0 =C2=A0 =C2=A0N/A=C2=A0 da0p1<b= r> =C2=A0 label/usbmemstick=C2=A0 =C2=A0 N/A=C2=A0 da0<br> <br> What puzzle me is what happen when I enable swap:<br> <br> =C2=A0 # sysctl vm.nswapdev<br> =C2=A0 vm.nswapdev: 0<br> =C2=A0 # swapctl -l<br> =C2=A0 Device:=C2=A0 =C2=A0 =C2=A0 1024-blocks=C2=A0 =C2=A0 =C2=A0Used:<br> =C2=A0 # dumpon -l<br> =C2=A0 /dev/null<br> =C2=A0 # swapon /dev/label/usbmemstickp1<br> =C2=A0 # glabel status<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Name=C2=A0 Status=C2=A0 Co= mponents<br> =C2=A0 label/usbmemstick=C2=A0 =C2=A0 N/A=C2=A0 da0<br> =C2=A0 # swapoff /dev/label/usbmemstickp1<br> =C2=A0 # glabel status<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Name=C2=A0 Status=C2=A0 Co= mponents<br> =C2=A0 label/usbmemstick=C2=A0 =C2=A0 N/A=C2=A0 da0<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 label/swap=C2=A0 =C2=A0 =C2=A0N/A=C2=A0 label/u= sbmemstickp1<br> <br> While swap is enabled, the `swap` label is no longer available. It<br> comes back when swap is disabled.<br> <br> Note that I also tried to enable swap using the automatic label<br> (i.e., `swap`). In such a case this is the `usbmemstick` label<br> that vanish. And the label is even not restored on `swapoff`.<br> <br> Is it the expected behavior? Am I doing something wrong?<br></blockquote><d= iv><br></div><div>This both makes sense to me, and seems wrong to me.=C2=A0= When</div><div>things are nested like this, it kinda makes sense that labe= l/usbmemstickp1</div><div>shows up. geom doesn't enumerate everything a= nd this seems to be a bit</div><div>of an artifact. I'd expect both lab= el/usbmemstickp1 and label/swap to be there.</div><div>geom does odd things= with devices that are open to keep others from opening</div><div>them, and= this may just be an artifact of this kinda weird behavior.</div><div><br><= /div><div>Warner</div></div></div> --000000000000cfe45d0624f99e61--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfrk0tn68a0N89odyke%2BDDxgFqZOj41fsE=-7ehb2V8w0A>