kpartx / device-mapper errors on small disk

Bug #1271205 reported by Dirk Mueller
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

This was originally opened as a cirros bug, but seems generic to kpartx or device-mapper. I suspect device-mapper.

Independent of cirros, recreate is like this:
 $ sudo modprobe nbd
 $ rm -f my.img
 $ truncate --size $((16065*5*512)) my.img
 $ echo "16065,," | sfdisk -uS my.img
 $ fdisk -l my.img
   ...

 $ sudo qemu-nbd --connect /dev/nbd7 "$PWD/my.img"
 $ sudo kpartx -av /dev/nbd7
 $ sudo kpartx -av /dev/nbd7
  device-mapper: resume ioctl on nbd7p1 failed: Invalid argument
  create/reload failed on nbd7p1
  add map nbd7p1 (0:0): 0 64260 linear /dev/nbd7 16065
 $ dmesg | tail
 [1281945.659640] nbd7: p1 size 64260 extends beyond EOD, truncated
 [1281964.528483] device-mapper: table: 252:0: nbd7 too small for target: start=16065, len=64260, dev_size=80324

wrt cirros, the reproduce looks like this:
$ wget http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img

$ sudo qemu-nbd -c /dev/nbd7 cirros-0.3.2-x86_64-disk.img
$ sudo kpartx -av /dev/nbd7

gives:

device-mapper: resume ioctl on nbd7p1 failed: Invalid argument
create/reload failed on nbd7p1
add map nbd7p1 (0:0): 0 64260 linear /dev/nbd7 16065

dmesg adds:

[80163.572187] bio: create slab <bio-1> at 1
[80163.572258] device-mapper: table: 253:0: nbd7 too small for target: start=16065, len=64260, dev_size=80324

using fdisk on /dev/nbd7 gives

Command (m for help): v
Partitions 1: cylinder 5 greater than maximum 4
Remaining 16063 unallocated 512-byte sectors

Revision history for this message
Scott Moser (smoser) wrote :

Is this still an issue?

qemu-img convert -O raw cirros-0.3.2-x86_64-disk.img out.img

$ fdisk -l out.img

Disk out.img: 41 MB, 41126400 bytes
255 heads, 63 sectors/track, 5 cylinders, total 80325 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

  Device Boot Start End Blocks Id System
out.img1 * 16065 80324 32130 83 Linux

that doesn't complain about anything, and the math of 80324*512 (+512) == 41126400

Changed in cirros:
importance: Undecided → Medium
status: New → Incomplete
Revision history for this message
Dirk Mueller (dmllr) wrote :

I've updated the description and reproducer with 0.3.2, which still triggers the issue for me.

Changed in cirros:
status: Incomplete → New
description: updated
Revision history for this message
Scott Moser (smoser) wrote :

thanks for the info, i'll look again. but it sure looks valid to me.

Can you reproduce the issue on the raw ? (ie, convert it to raw and then try it ?).

If it doesn't reproduce on raw, it'd seem like a nbd issue.

Revision history for this message
Scott Moser (smoser) wrote :

$ wget http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img
$ sudo modprobe nbd
$ sudo qemu-nbd --connect /dev/nbd7 "$PWD/cirros-0.3.2-x86_64-disk.img"
$ uname -r
3.16.0-9-generic

$ dpkg-query --show kpartx
kpartx 0.4.9-3ubuntu9

$ dmesg | tail
[1247602.113116] lxcbr0: port 13(vethBSQRAS) entered disabled state
[1247602.116137] device vethBSQRAS left promiscuous mode
[1247602.116147] lxcbr0: port 13(vethBSQRAS) entered disabled state
[1247662.461112] lxcbr0: port 1(veth6DN6SA) entered disabled state
[1247662.464157] device veth6DN6SA left promiscuous mode
[1247662.464166] lxcbr0: port 1(veth6DN6SA) entered disabled state
[1277842.416330] nbd: registered device at major 43
[1277842.523136] device-mapper: multipath: version 1.7.0 loaded
[1278264.061112] nbd7: p1
[1278264.061152] nbd7: p1 size 64260 extends beyond EOD, truncated

$ sudo kpartx -v -a -l /dev/nbd7
nbd7p1 : 0 64260 /dev/nbd7 16065

$ sudo kpartx -v -a /dev/nbd7
device-mapper: resume ioctl on nbd7p1 failed: Invalid argument
create/reload failed on nbd7p1
add map nbd7p1 (0:0): 0 64260 linear /dev/nbd7 16065

$ dmesg
...
[1278264.061112] nbd7: p1
[1278264.061152] nbd7: p1 size 64260 extends beyond EOD, truncated
[1278539.540515] device-mapper: table: 252:0: nbd7 too small for target: start=16065, len=64260, dev_size=80324

$ sudo fdisk -uS -l /dev/nbd7

Disk /dev/nbd7: 39.2 MiB, 41125888 bytes, 80324 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device Boot Start End Sectors Size Id Type
/dev/nbd7p1 * 16065 80324 64260 31.4M 83 Linux

$ echo $((512*80324))
41125888

$ sudo qemu-nbd --disconnect /dev/nbd7

Also note that the 'End' sector (80324) is the same as listed in size.

So it certainly seems like the partition table is ok. Additionally, the image is fine to boot in kvm. try just booting with:
  qemu-system-x86_64 -device virtio-net-pci,netdev=net00 -netdev type=user,id=net00 -curses
(it will time out on the lack of metadata service, but thats fine).

Really, this is a bug in either the device mapper (linux) or nbd. But i'd think device mapper.
 (just try booting with 'qemu-system-x86_64 -curses').

all that said, cirros probably should start at 2048 rather than 16065. I opened that as bug 1367830.

description: updated
Changed in cirros:
status: New → Confirmed
Scott Moser (smoser)
summary: - can't kpartx qcow2 cirros 0.3.1
+ kpartx / device-mapper errors on small disk
description: updated
Scott Moser (smoser)
description: updated
no longer affects: cirros
Changed in linux (Ubuntu):
status: New → Confirmed
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.