Ok so in fact the inconsistency is due to "parted" that will try to
probe devices iff the given block device return informations from
stat(), regardless if the block device is available or not.

Seems like the only trigger/criteria is the stat() return. Since the
loop device stat doesn't clear/reset once umounted/detacted, then parted
assume it can go ahead and probe it assuming it is a legit device.

----
# libparted/arch/linux.c
----
    618 static int
    619 _device_stat (PedDevice* dev, struct stat * dev_stat)
    620 {
    621         PED_ASSERT (dev != NULL);
    622         PED_ASSERT (!dev->external_mode);
    623 
    624         while (1) {
    625                 if (!stat (dev->path, dev_stat)) {
    626                         return 1;
    627                 } else {
    628                         if (ped_exception_throw (
    629                                 PED_EXCEPTION_ERROR,
    630                                 PED_EXCEPTION_RETRY_CANCEL,
    631                                 _("Could not stat device %s - %s."),
    632                                 dev->path,
    633                                 strerror (errno))
    634                                         != PED_EXCEPTION_RETRY)
    635                                 return 0;
    636                 }
    637         }
    638 }
----

Example:
----
# parted -s $(losetup -f) unit s print
Warning: Error fsyncing/closing /dev/loop18: Input/output error

# stat $(losetup -f)
  File: /dev/loop18
  Size: 0               Blocks: 0          IO Block: 4096   block special file
Device: 6h/6d   Inode: 509         Links: 1     Device type: 7,12
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (    6/    disk)
Access: 2019-12-25 13:05:15.543108777 -0500
Modify: 2019-12-25 13:05:15.543108777 -0500
Change: 2019-12-25 13:05:15.543108777 -0500
 Birth: -

# parted -s /dev/loop19 unit s print
Error: Could not stat device /dev/loop19 - No such file or directory.

# stat /dev/loop19
stat: cannot stat '/dev/loop19': No such file or directory
----

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1856871

Title:
  i/o error if next unused loop device is queried

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1856871/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to