https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209508

            Bug ID: 209508
           Summary: zfs import assertion failed in avl_add()
           Product: Base System
           Version: 10.3-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: natm...@shaw.ca

Created attachment 170292
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=170292&action=edit
Proposed patch to libzfs_import.c

SUMMARY:

Starting with 10.3-RELEASE, running "zpool import" or "zpool import name"
crashes with:

Assertion failed: (avl_find() succeeded inside avl_add()), file
/usr/src/cddl/lib/libavl/../../../sys/cddl/contrib/opensolaris/common/avl/avl.c,
line 649.

Previously when running 10.2-RELEASE this did not happen.



ENVIRONMENT:

This system is running 10.3-RELEASE in a Xen domU.  There are 4 disks attached
at boot time, ada0-3.  These have GPT partitions, the largest of which is added
to a zfs pool.

I also have two removable disks at that I add to the domU at runtime from the
host, but the problem above occurs with just ada0-3 present ("zfs import" leads
to the assertion failed instead of showing no pools), so I don't believe the
removable disks are related.  However, adding and removing the disks is the
reason that I'm using zpool import.



ANALYSIS:

I believe the problem is in
cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c

Around line 1225, it appears that the code is listing all of the geom providers
and adding them to the slice_cache avl tree.

Placing some printfs in that code, I can see that it is trying to add ada0*
twice:

...
Adding geom to avl ada0p1
Adding geom to avl ada0p2
Adding geom to avl ada0p3
Already have geom in avl ada0p1
Already have geom in avl ada0p2
Already have geom in avl ada0p3
...
Adding geom to avl ada0
Already have geom in avl ada0
...


In svn, it looks like the assertion was added in base r287703 that prevents
adding duplicate entries to the avl.

I then modified libzfs_import.c to call avl_find() before trying to call
avl_add:

avl_index_t where;
if (avl_find(&slice_cache, slice, &where) == NULL) {
 avl_add(&slice_cache, slice);
}

(and the same lower down around line 1260)

This allows the "zfs import" to list any available pools, and "zfs import name"
to import the pool successfully.

I'm new to FreeBSD so I'm not sure if this the correct solution but it works in
my case.  A patch is attached.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"

Reply via email to