-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Sat, Oct 14, 2017 at 05:42:39AM +0100, Andrew Clausen wrote:
> Hi all,
> 
> On 14 October 2017 at 01:20, Wojtek Porczyk <w...@invisiblethingslab.com>
> wrote:
> 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA256
> >
> > On Sat, Oct 14, 2017 at 02:06:43AM +0200, Wojtek Porczyk wrote:
> > > On Sat, Oct 14, 2017 at 01:40:45AM +0200, Marek Marczykowski-Górecki
> > wrote:
> > > > On Sat, Oct 14, 2017 at 01:21:58AM +0200, Wojtek Porczyk wrote:
> > > > > On Sat, Oct 14, 2017 at 01:20:13AM +0200, Marek Marczykowski-Górecki
> > wrote:
> > > > > > You can't reload partition table while it is used (something from
> > there
> > > > > > is mounted). At least Linux doesn't support it.
> > > > >
> > > > > Just tested with loop device, fdisk, and ext4. Looks like it works.
> > Unless it
> > > > > works only with loop?
> > > >
> > > > No, it doesn't work, at least not directly:
> > > >
> >
> > (snip)
> >
> > > >     The kernel still uses the old table. The new table will be used at
> > the next reboot or after you run partprobe(8) or kpartx(8).
> > > >
> > > > I wonder on what conditions partprobe would work. And how would mounted
> > > > filesystem react for it.
> > >
> > > I'm calling bullshit on that. Coredump follows:
> >
> > (...)
> >
> > > [root@qubes-dev tmp]# partprobe /dev/loop0
> > > [root@qubes-dev tmp]# echo $?
> > > 0
> >
> > (...)
> >
> > Look at strace of blockdev --rereadpt and partprobe. The difference is that
> > blockdev (and I assume fdisk also, since both are from util-linux) fires
> > ioctl(fd, BLKRRPART), but partprobe (from GNU parted) does something funny
> > to
> > /sys, which I didn't try to understand, but seems to work.
> >
> > My guess is that this is a missing feature in kernel, which parted works
> > around.
> >
> 
> I am a Qubes user, and coincidentally, the original author of partprobe
> (and parted).  I haven't looked at partprobe/parted since 2005.  The code
> has changed a lot since then, but let me do my best...
> 
> The BLKRRPART ioctl is no good because it can't accommodate busy block
> devices at all, i.e. resizing partition 1 when partition 2 on the same disk
> is mounted.
> 
> Instead, Parted primarily uses the BLKPG family of ioctl to inform the
> kernel of partition table changes.  (It also has "new" support for the
> device mapper -- but that's probably not relevant here.)  You can read
> about the BLKPG ioctl in /usr/include/linux/blkpg.h.  Since 2012, the linux
> kernel supports a new BLKPG feature to do online partition resizing, i.e.
> telling the kernel to modify a mounted partition.  I think this is what is
> being used here.
> 
> The relevant Parted code is in the function linux_disk_commit(), which
> calls _disk_sync_part_table() and _blkpg_resize_partition() inside
> http://git.savannah.gnu.org/cgit/parted.git/tree/libparted/arch/linux.c
> 
> If the BLKPG ioctl fails, then partprobe/parted will throw an exception and
> tell you about it.

Thank you for your insight. I pasted the above to
https://github.com/QubesOS/qubes-issues/issues/3173#issuecomment-336635237.

> Wojtek: what part of your shell transcript was unexpected?  It looked like
> everything worked to me.

Yes, it did. The "bullshit" comment was in reply to Marek's statement about
supposed inability to reread partition table while any partition is mounted.
Well, as you point out, it can't be reloaded using BLKRRPART ioctl, which is
used by fdisk. Marek didn't use the partprobe, and he just took the error
message from fdisk at face value and concluded that we need to reboot.


- -- 
pozdrawiam / best regards       _.-._
Wojtek Porczyk               .-^'   '^-.
Invisible Things Lab         |'-.-^-.-'|
                             |  |   |  |
 I do not fear computers,    |  '-.-'  |
 I fear lack of them.        '-._ :  ,-'
    -- Isaac Asimov             `^-^-_>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIbBAEBCAAGBQJZ4hJ6AAoJEL9r2TIQOiNRK+cP8QFb36PkY3+hmdlostS1Nqa2
QE1men8VxZmniwMtpUl9XRdWWYZpgsZy3OZ7M+WXncWQGzQNBk+3UIcJUC4chYS7
hR9rTLQpkV5g7fZmP8QCQukgG5SfJFhAcsBvl00WK+b7g46fIeaikWoQ2AgwZuTa
ZNnZLyJPOOp4W/93HxEkeQapgoe/arL+4R0F3SRnPloGI1bac8wHZUpPa5Y69hTO
+evN7Ibkt4VWkRlQm/rjKn6cF070B+VwThvxEvIbQtXc8dMnIifhxoGwjwYCWiWv
q7Tws0Fgqcjr/EaRGrj/pUtPPIJkIiqKg+w6p7mNUyZSm0Ro8eXm5Z4ywJCZjJ55
vC5Z8Nl/zOOcCOIDl2u8rqA5nKR9qN4B7+IgyR6dXzYgqvvRZaNBR/FVQeu5ETMC
VtuI6XgaRNeEC6EVRym+p4wh9ARIiw84QgJF0MJ8GgTXBHvNU10WroQTC68bCJNJ
gSEVHW8jNR5ccUAqvBDfgXcAx7iMEpfeJISXWd7uBYDgKZ1GxjHIJSG3LKWf+uZo
rLwU9IojN6+fu7akreyUEp+BQKAtJYZM29E3jJxAQRKkAPB0nQuIiaXx4K6uNbXZ
7oZLan4Ucnj6O0YI5Jm0RG40rXjLCDrEBaUL3xBf08g48x6kOtGw7rzE+PXHPSvl
g/Hgj6mlAQT1bgjxvE8=
=LFw9
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-devel+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-devel@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-devel/20171014133451.GG21553%40invisiblethingslab.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to