util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francis Moreau <francis.moro@gmail.com>
To: "Dale R. Worley" <worley@alum.mit.edu>
Cc: util-linux@vger.kernel.org
Subject: Re: Weird behaviour with lsblk and freshly created loop device
Date: Tue, 02 Sep 2014 08:54:27 +0200	[thread overview]
Message-ID: <540569A3.8090904@gmail.com> (raw)
In-Reply-To: <201409011941.s81JfCZf004329@hobgoblin.ariadne.com>

On 09/01/2014 09:41 PM, Dale R. Worley wrote:
>> From: Francis Moreau <francis.moro@gmail.com>
> 
>> Right after associating a loop device with a disk image file, I'm using
>> lsblk to retrieve some info about the partitions.
>>
>> If I'm doing this as root:
>>
>>   $ losetup /dev/loop0 /tmp/installer-disks/disk0.img && lsblk -n --raw
>> --paths -o NAME,PARTTYPE /dev/loop0 && losetup -d /dev/loop0
>>
>> then the output is missing the parttypes:
>>
>>   /dev/loop0
>>   /dev/loop0p1
>>   /dev/loop0p2
>>
>> However adding a sleep or 'udevadm settle' after setting the loop device
>> the parttypes are correctly showed:
> 
> It looks like the process of determining the partitions is
> asynchronous, and is not assured of being completed when losetup
> returns.

Still lsblk lists the partitions.

I'm not sure how lsblk works. It seems that it relies on udev to get
certain information, parttype is an example but doesn't for listing
partitions of  block devices.

That seems to make the whole process racy.

If this is correct, I'm wondering why lsblk relies on udev to retrieve
block device metadata. Can't it find them out directly from the kernel ?

> 
> What happens when you add -P to losetup?  The manual page (for Fedora
> 19) says "force kernel to scan partition table on newly created loop
> device", which suggests that the partition scan will be completed by
> the time losetup returns.

Adding -P doesn't help. Actually the kernel correctly detected the
partitions embedded in the loop device. But udev hasn't handled the
associeted events yet when lsblk is called.

Thanks

      reply	other threads:[~2014-09-02  6:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-01 15:39 Weird behaviour with lsblk and freshly created loop device Francis Moreau
2014-09-01 15:40 ` Francis Moreau
2014-09-01 17:56 ` Karel Zak
2014-09-02  7:03   ` Francis Moreau
2014-09-02  7:30     ` Karel Zak
2014-09-02 16:45       ` Francis Moreau
2014-09-05  7:45         ` Karel Zak
2014-09-05  8:13           ` Francis Moreau
2014-09-01 19:41 ` Dale R. Worley
2014-09-02  6:54   ` Francis Moreau [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=540569A3.8090904@gmail.com \
    --to=francis.moro@gmail.com \
    --cc=util-linux@vger.kernel.org \
    --cc=worley@alum.mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).