util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francis Moreau <francis.moro@gmail.com>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: Re: Weird behaviour with lsblk and freshly created loop device
Date: Tue, 02 Sep 2014 09:03:45 +0200	[thread overview]
Message-ID: <54056BD1.1080205@gmail.com> (raw)
In-Reply-To: <20140901175609.GA21325@x2.net.home>

On 09/01/2014 07:56 PM, Karel Zak wrote:
> On Mon, Sep 01, 2014 at 05:39:48PM +0200, Francis Moreau wrote:
>> Hello,
>>
>> 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:
>>
>>    $ losetup /dev/loop0 /tmp/installer-disks/disk0.img && udevadm settle
>> && lsblk -n --raw --paths -o NAME,PARTTYPE /dev/loop0 && losetup -d
>> /dev/loop0
>>   /dev/loop0
>>   /dev/loop0p1 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
>>   /dev/loop0p2 4f68bce3-e8cd-4db1-96e7-fbcaf984b709
>>
>> Could anybody tell me if that's expected ?
> 
>  Sure, lsblk reads the information from udev db.
> 
>  You can compile --without-udev, the it will use libblkid only.
>  
>  Maybe  we can add something like "lsblk --no-udev" to bypass udev 
>  without recompilation, but is it really necessary? 

It seems that lsblk uses udev to get some block device metadata and asks
some others to the kernel. If so, it makes the whole process racy
because udev might not have handled the events sent by the kernel yet.

I'm not sure why udev is used by default in the first place, what are
the benefits ? Using libblkid, at least by default seems the right thing
to do.

Otherwise maybe lsblk should do the equivalent of 'udevadm settle' to
handle correctly freshly created devices ?

Thanks.

  reply	other threads:[~2014-09-02  7:03 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 [this message]
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

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=54056BD1.1080205@gmail.com \
    --to=francis.moro@gmail.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /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).