Bug#737140: Assumes zpool member devices reside directly in /dev

Andras Korn korn-debbugs at elan.rulez.org
Thu Jan 30 15:35:56 UTC 2014


Package: grub-pc
Version: 2.02~beta2-6
Severity: normal
Tags: upstream

Hi,

"grub-probe --target=device /" calls "zpool status" to determine what
devices a zpool consists of.

Unfortunately zpool status only prints "nicknames" for devices, for example:

# zpool status
  pool: sealynx
 state: ONLINE
   see: http://zfsonlinux.org/msg/ZFS-8000-EY
  scan: none requested
config:

        NAME                                                STATE     READ WRITE CKSUM
        sealynx                                             ONLINE       0     0     0
          mirror-0                                          ONLINE       0     0     0
            scsi-SATA_Hitachi_HUA7220_JPW9P0N007TZ5D-part3  ONLINE       0     0     0
            scsi-SATA_Hitachi_HUA7220_JPW9P0N00AZ49D-part3  ONLINE       0     0     0
        logs
          mirror-1                                          ONLINE       0     0     0
            scsi-SATA_SAMSUNG_MZ7WD12S16KNEAD700746-part3   ONLINE       0     0     0
            scsi-SATA_SAMSUNG_MZ7WD12S16KNEAD700747-part3   ONLINE       0     0     0
        cache
          scsi-SATA_SAMSUNG_MZ7WD12S16KNEAD700746-part4     ONLINE       0     0     0
          scsi-SATA_SAMSUNG_MZ7WD12S16KNEAD700747-part4     ONLINE       0     0     0

In this case, the pool was assembled using device names from
/dev/disks/by-id, but grub-probe assumes they are under /dev and fails:

grub-probe: error: failed to get canonical path of `/dev/scsi-SATA_Hitachi_HUA7220_JPW9P0N007TZ5D-part3'.

Additionally, for non-online devices, the output of zpool status is likely
completely useless to grub-probe. I'm not sure if you're already filtering
those out, but if not, you should.

I suppose something like the following could be used to obtain the
"canonical" device names:

zpool status $poolname \
	| sed -n '/^[[:space:]]*NAME[[:space:]]*STATE[[:space:]]/,${
		/ ONLINE /s/^[[:space:]]*//;
		s/[[:space:]]*ONLINE[[:space:]]*[0-9]*[[:space:]]*[0-9]*[[:space:]]*[0-9]*[[:space:]]*$//p
	}' \
	| while read candidate; do
		devlink="$(find /dev -name "$candidate" | head -n 1)"
		if [[ -e "$devlink" ]]; then
			[[ -b "$(readlink -f "$devlink")" ]] && readlink -f "$devlink"
		fi
	done

This still has problems (for example, it assumes that the first match in
/dev for any of the names printed by zpool status will be either the
relevant block device or a symlink to it), but I'm not sure it's possible or
necessary to do much better.

Ideally, zpool should be patched so that it can print device paths, not just
device names.

Andras

-- 
                Both of his feet are firmly planted in the air.



More information about the Pkg-grub-devel mailing list