On Mon, Dec 2, 2013 at 6:57 PM, Jorgen Lundman <[email protected]> wrote:

>
> I will panic if I create a DMU_OST_ZVOL but not DMU_OST_ZFS. Tracking the
> sources for "zct_props" we have the following situation;
>
>
> static int
> zfs_ioc_create(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
> {
>         zfs_creat_t zct;
>
> ....
>         (void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
> ....
>         zct.zct_props = nvprops;
> ....
>     if (type == DMU_OST_ZVOL) {
> ....
>     } else if (type == DMU_OST_ZFS) {
>         VERIFY(nvlist_alloc(&zct.zct_zplprops,
>                             NV_UNIQUE_NAME, KM_SLEEP) == 0);
>         error = zfs_fill_zplprops(fsname, nvprops,
>                                   zct.zct_zplprops, &is_insensitive);
>     }
>
> ....
>
>     nvlist_free(zct.zct_zplprops);
>
>
> So if we have type DMU_OST_ZFS, we call nvlist_alloc, and zfs_fill_zplprops
> to copy the properties over.
> When it is type DMU_OST_ZVOL, zct.zct_zplprops is still pointing to
> "nvprops" from the innvl "props".
>

No, zct_zplprops is uninitialized in that case.  zct_props still points to
the looked-up nvlist, which we do not free.

There is one critical difference between the code you quoted and what's in
illumos:

  zfs_creat_t zct = { 0 };

By zeroing out zct, we ensure that zct_zplprops is NULL for the
DMU_OST_ZVOL case.  nvlist_free(NULL) is a no-op.

--matt



>
> When creating a volume, I panic in "nvlist_free(zct.zct_zplprops);",
> possibly as the memory functions are more strict, or I do something else
> wrong. (20%/80% there)


> But I am curious, which is correct. Should "nvprops" not be released, and
> calling nvlist_free() on it is wrong (and why would I be the first to
> notice that)
>
> Or, should it be freed, and all platforms leaks memory when type is
> DMU_OST_ZVOL, as only the new zplprops is released, not the original
> "nvprops".
>
> Lund
>
> --
> Jorgen Lundman       | <[email protected]>
> Unix Administrator   | +81 (0)3 -5456-2687 ext 1017 (work)
> Shibuya-ku, Tokyo    | +81 (0)90-5578-8500          (cell)
> Japan                | +81 (0)3 -3375-1767          (home)
> _______________________________________________
> developer mailing list
> [email protected]
> http://lists.open-zfs.org/mailman/listinfo/developer
>
_______________________________________________
developer mailing list
[email protected]
http://lists.open-zfs.org/mailman/listinfo/developer

Reply via email to