[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#762199: zfsutils: zpool import finds nothing



Package: zfsutils
Version: 10.1~svn271683-1
Severity: grave
Tags: upstream patch

Hi,

With 10.1 and possibly earlier versions of zfsutils, zpool import
does not detect any pools.  Nor can it import them by name or GUID.

It is still possible to import a pool only by specifying a zpool.cache
file, if you have one.  But in case you don't, you could export a pool
and be unable to import it again, hence the severity.

ktrace revealed a openat64, stat64, close of each disk/partition
without trying to read a ZFS disklabel from it.  It seemed to be taking
an early exit from detection due to:

    if (statbuf.st_size < SPA_MINDEVSIZE) {
        (void) close(fd);

but these are not regular files, they are character devices with
st_size=0

I don't know if it affects upstream (or otherwise why not).  It was
introduced into 10-STABLE by r260339, MFC of r259168 and is still the
same way in HEAD.

The patch below has been tested to fix this with 10.1 kernel and
userland, although the surrounding #ifdef could be refactored now:

--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
@@ -1076,7 +1076,8 @@ zpool_open_func(void *arg)
                check_slices(rn->rn_avl, fd, rn->rn_name);
        }
 #else  /* !sun */
-       if (statbuf.st_size < SPA_MINDEVSIZE) {
+       if (S_ISREG(statbuf.st_mode) &&
+           statbuf.st_size < SPA_MINDEVSIZE) {
                (void) close(fd);
                return;
        }

-- System Information:
Debian Release: 7.6
  APT prefers proposed-updates
  APT policy: (500, 'proposed-updates'), (500, 'stable')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 9.0-2-amd64-xenhvm-ipsec
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash


Reply to: